Camera content descriptions and allow camera capture in talk back.
This commit is contained in:
parent
af8042c5f4
commit
5a614faee1
10 changed files with 101 additions and 55 deletions
|
@ -6,12 +6,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
<org.thoughtcrime.securesms.mediasend.CameraButtonView
|
||||
android:id="@+id/camera_capture_button"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:background="@drawable/ic_camera_shutter"
|
||||
android:contentDescription="@string/CameraXFragment_capture_description"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
@ -25,6 +26,7 @@
|
|||
android:src="@drawable/ic_switch_camera_32"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/CameraXFragment_change_camera_description"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
|
@ -35,6 +37,7 @@
|
|||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginBottom="42dp"
|
||||
android:contentDescription="@string/CameraXFragment_open_gallery_description"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintBottom_toTopOf="@id/camera_capture_button"
|
||||
app:layout_constraintStart_toStartOf="@id/camera_capture_button"
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<Button
|
||||
<org.thoughtcrime.securesms.mediasend.CameraButtonView
|
||||
android:id="@+id/camera_capture_button"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:background="@drawable/ic_camera_shutter"
|
||||
android:contentDescription="@string/CameraXFragment_capture_description"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
@ -25,6 +26,7 @@
|
|||
android:src="@drawable/ic_switch_camera_32"
|
||||
android:scaleType="fitCenter"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/CameraXFragment_change_camera_description"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -35,6 +37,7 @@
|
|||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:contentDescription="@string/CameraXFragment_open_gallery_description"
|
||||
android:scaleType="centerCrop"
|
||||
app:layout_constraintTop_toTopOf="@id/camera_capture_button"
|
||||
app:layout_constraintBottom_toBottomOf="@id/camera_capture_button"
|
||||
|
|
|
@ -75,6 +75,7 @@
|
|||
android:layout_gravity="bottom|end"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="88dp"
|
||||
android:contentDescription="@string/conversation_list_fragment__open_camera_description"
|
||||
android:src="@drawable/ic_camera_filled_24"
|
||||
android:tint="?conversation_list_camera_icon_tint"
|
||||
android:focusable="true"
|
||||
|
|
|
@ -142,6 +142,7 @@
|
|||
android:layout_gravity="bottom|end"
|
||||
android:padding="6dp"
|
||||
android:background="@drawable/media_continue_button_background"
|
||||
android:contentDescription="@string/MediaSendActivity_select_recipients_description"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/ic_continue_24"
|
||||
tools:visibility="visible"/>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:title=""
|
||||
android:title="@string/CameraContacts__menu_search"
|
||||
android:id="@+id/menu_search"
|
||||
android:icon="@drawable/ic_search_white_24dp"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:title=""
|
||||
android:title="@string/MediaPickerActivity__menu_open_camera"
|
||||
android:id="@+id/mediapicker_menu_camera"
|
||||
android:visible="true"
|
||||
android:icon="@drawable/ic_camera_alt_white_24dp"
|
||||
|
|
|
@ -92,6 +92,11 @@
|
|||
<!-- CameraActivity -->
|
||||
<string name="CameraActivity_image_save_failure">Failed to save image.</string>
|
||||
|
||||
<!-- CameraXFragment -->
|
||||
<string name="CameraXFragment_capture_description">Capture</string>
|
||||
<string name="CameraXFragment_change_camera_description">Change camera</string>
|
||||
<string name="CameraXFragment_open_gallery_description">Open gallery</string>
|
||||
|
||||
<!-- CameraContacts -->
|
||||
<string name="CameraContacts_recent_contacts">Recent contacts</string>
|
||||
<string name="CameraContacts_signal_contacts">Signal contacts</string>
|
||||
|
@ -102,6 +107,7 @@
|
|||
<string name="CameraContacts_you_can_only_use_the_camera_button">You can only use the camera button to send photos to Signal contacts. </string>
|
||||
<string name="CameraContacts_cant_find_who_youre_looking_for">Can\'t find who you\'re looking for?</string>
|
||||
<string name="CameraContacts_invite_a_contact_to_join_signal">Invite a contact to join Signal</string>
|
||||
<string name="CameraContacts__menu_search">Search</string>
|
||||
|
||||
<!-- ClearProfileActivity -->
|
||||
<string name="ClearProfileActivity_remove">Remove</string>
|
||||
|
@ -484,6 +490,7 @@
|
|||
|
||||
<!-- MediaPickerActivity -->
|
||||
<string name="MediaPickerActivity_send_to">Send to %s</string>
|
||||
<string name="MediaPickerActivity__menu_open_camera">Open camera</string>
|
||||
|
||||
<!-- MediaPickerItemFragment -->
|
||||
<string name="MediaPickerItemFragment_tap_to_select">Tap to select</string>
|
||||
|
@ -501,6 +508,7 @@
|
|||
<item quantity="one">You can\'t share more than %d item.</item>
|
||||
<item quantity="other">You can\'t share more than %d items.</item>
|
||||
</plurals>
|
||||
<string name="MediaSendActivity_select_recipients_description">Select recipients</string>
|
||||
|
||||
<!-- MediaRepository -->
|
||||
<string name="MediaRepository_all_media">All media</string>
|
||||
|
@ -1423,6 +1431,7 @@
|
|||
|
||||
<!-- conversation_list_fragment -->
|
||||
<string name="conversation_list_fragment__fab_content_description">New conversation</string>
|
||||
<string name="conversation_list_fragment__open_camera_description">Open Camera</string>
|
||||
<string name="conversation_list_fragment__give_your_inbox_something_to_write_home_about_get_started_by_messaging_a_friend">Give your inbox something to write home about. Get started by messaging a friend.</string>
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.thoughtcrime.securesms.mediasend;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Matrix;
|
||||
|
@ -10,9 +9,6 @@ import android.graphics.PointF;
|
|||
import android.graphics.SurfaceTexture;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.Display;
|
||||
import android.view.GestureDetector;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -22,14 +18,17 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProviders;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.MultiTransformation;
|
||||
import com.bumptech.glide.load.Transformation;
|
||||
|
@ -61,7 +60,7 @@ public class Camera1Fragment extends Fragment implements CameraFragment,
|
|||
private TextureView cameraPreview;
|
||||
private ViewGroup controlsContainer;
|
||||
private ImageButton flipButton;
|
||||
private Button captureButton;
|
||||
private View captureButton;
|
||||
private Camera1Controller camera;
|
||||
private Controller controller;
|
||||
private OrderEnforcer<Stage> orderEnforcer;
|
||||
|
@ -218,7 +217,6 @@ public class Camera1Fragment extends Fragment implements CameraFragment,
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private void initControls() {
|
||||
flipButton = requireView().findViewById(R.id.camera_flip_button);
|
||||
captureButton = requireView().findViewById(R.id.camera_capture_button);
|
||||
|
@ -226,26 +224,9 @@ public class Camera1Fragment extends Fragment implements CameraFragment,
|
|||
View galleryButton = requireView().findViewById(R.id.camera_gallery_button);
|
||||
View countButton = requireView().findViewById(R.id.camera_count_button);
|
||||
|
||||
captureButton.setOnTouchListener((v, event) -> {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
Animation shrinkAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.camera_capture_button_shrink);
|
||||
shrinkAnimation.setFillAfter(true);
|
||||
shrinkAnimation.setFillEnabled(true);
|
||||
captureButton.startAnimation(shrinkAnimation);
|
||||
onCaptureClicked();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
case MotionEvent.ACTION_OUTSIDE:
|
||||
Animation growAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.camera_capture_button_grow);
|
||||
growAnimation.setFillAfter(true);
|
||||
growAnimation.setFillEnabled(true);
|
||||
captureButton.startAnimation(growAnimation);
|
||||
captureButton.setEnabled(false);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
captureButton.setOnClickListener(v -> {
|
||||
captureButton.setEnabled(false);
|
||||
onCaptureClicked();
|
||||
});
|
||||
|
||||
orderEnforcer.run(Stage.CAMERA_PROPERTIES_AVAILABLE, () -> {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
package org.thoughtcrime.securesms.mediasend;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
|
||||
import androidx.appcompat.widget.AppCompatButton;
|
||||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
|
||||
public final class CameraButtonView extends AppCompatButton {
|
||||
|
||||
private Animation shrinkAnimation;
|
||||
private Animation growAnimation;
|
||||
|
||||
public CameraButtonView(Context context) {
|
||||
super(context);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public CameraButtonView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public CameraButtonView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context);
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
shrinkAnimation = AnimationUtils.loadAnimation(context, R.anim.camera_capture_button_shrink);
|
||||
growAnimation = AnimationUtils.loadAnimation(context, R.anim.camera_capture_button_grow);
|
||||
|
||||
shrinkAnimation.setFillAfter(true);
|
||||
shrinkAnimation.setFillEnabled(true);
|
||||
|
||||
growAnimation.setFillAfter(true);
|
||||
growAnimation.setFillEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
if (isEnabled()) {
|
||||
startAnimation(shrinkAnimation);
|
||||
performClick();
|
||||
}
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
startAnimation(growAnimation);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performClick() {
|
||||
return super.performClick();
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
|
@ -166,26 +165,10 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||
View galleryButton = requireView().findViewById(R.id.camera_gallery_button);
|
||||
View countButton = requireView().findViewById(R.id.camera_count_button);
|
||||
|
||||
captureButton.setOnTouchListener((v, event) -> {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
Animation shrinkAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.camera_capture_button_shrink);
|
||||
shrinkAnimation.setFillAfter(true);
|
||||
shrinkAnimation.setFillEnabled(true);
|
||||
captureButton.startAnimation(shrinkAnimation);
|
||||
onCaptureClicked();
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
case MotionEvent.ACTION_OUTSIDE:
|
||||
Animation growAnimation = AnimationUtils.loadAnimation(getContext(), R.anim.camera_capture_button_grow);
|
||||
growAnimation.setFillAfter(true);
|
||||
growAnimation.setFillEnabled(true);
|
||||
captureButton.startAnimation(growAnimation);
|
||||
captureButton.setEnabled(false);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
captureButton.setOnClickListener(v -> {
|
||||
captureButton.setEnabled(false);
|
||||
flipButton.setEnabled(false);
|
||||
onCaptureClicked();
|
||||
});
|
||||
|
||||
if (camera.hasCameraWithLensFacing(CameraX.LensFacing.FRONT) && camera.hasCameraWithLensFacing(CameraX.LensFacing.BACK)) {
|
||||
|
@ -203,14 +186,15 @@ public class CameraXFragment extends Fragment implements CameraFragment {
|
|||
GestureDetector gestureDetector = new GestureDetector(requireContext(), new GestureDetector.SimpleOnGestureListener() {
|
||||
@Override
|
||||
public boolean onDoubleTap(MotionEvent e) {
|
||||
flipButton.performClick();
|
||||
if (flipButton.isEnabled()) {
|
||||
flipButton.performClick();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
camera.setOnTouchListener((v, event) -> gestureDetector.onTouchEvent(event));
|
||||
|
||||
|
||||
} else {
|
||||
flipButton.setVisibility(View.GONE);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue