mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 17:48:33 +00:00
Call answer button listens to accessibility changes.
This commit is contained in:
parent
a58f564d1e
commit
900371bb30
@ -26,7 +26,7 @@ import org.thoughtcrime.securesms.logging.Log;
|
|||||||
import org.thoughtcrime.securesms.util.ServiceUtil;
|
import org.thoughtcrime.securesms.util.ServiceUtil;
|
||||||
import org.thoughtcrime.securesms.util.ViewUtil;
|
import org.thoughtcrime.securesms.util.ViewUtil;
|
||||||
|
|
||||||
public final class WebRtcAnswerDeclineButton extends LinearLayout {
|
public final class WebRtcAnswerDeclineButton extends LinearLayout implements AccessibilityManager.TouchExplorationStateChangeListener {
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final String TAG = Log.tag(WebRtcAnswerDeclineButton.class);
|
private static final String TAG = Log.tag(WebRtcAnswerDeclineButton.class);
|
||||||
@ -45,6 +45,8 @@ public final class WebRtcAnswerDeclineButton extends LinearLayout {
|
|||||||
|
|
||||||
private AnswerDeclineListener listener;
|
private AnswerDeclineListener listener;
|
||||||
@Nullable private DragToAnswer dragToAnswerListener;
|
@Nullable private DragToAnswer dragToAnswerListener;
|
||||||
|
private AccessibilityManager accessibilityManager;
|
||||||
|
private boolean ringAnimation;
|
||||||
|
|
||||||
public WebRtcAnswerDeclineButton(Context context) {
|
public WebRtcAnswerDeclineButton(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
@ -65,15 +67,29 @@ public final class WebRtcAnswerDeclineButton extends LinearLayout {
|
|||||||
setOrientation(LinearLayout.VERTICAL);
|
setOrientation(LinearLayout.VERTICAL);
|
||||||
setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||||
|
|
||||||
AccessibilityManager accessibilityManager = ServiceUtil.getAccessibilityManager(getContext());
|
accessibilityManager = ServiceUtil.getAccessibilityManager(getContext());
|
||||||
boolean isExploreByTouchEnabled = accessibilityManager.isTouchExplorationEnabled();
|
|
||||||
|
|
||||||
if (isExploreByTouchEnabled) {
|
createView(accessibilityManager.isTouchExplorationEnabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
accessibilityManager.addTouchExplorationStateChangeListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDetachedFromWindow() {
|
||||||
|
accessibilityManager.removeTouchExplorationStateChangeListener(this);
|
||||||
|
super.onDetachedFromWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createView(boolean isTouchExplorationEnabled) {
|
||||||
|
if (isTouchExplorationEnabled) {
|
||||||
inflate(getContext(), R.layout.webrtc_answer_decline_button_accessible, this);
|
inflate(getContext(), R.layout.webrtc_answer_decline_button_accessible, this);
|
||||||
|
|
||||||
findViewById(R.id.answer).setOnClickListener((view) -> listener.onAnswered());
|
findViewById(R.id.answer).setOnClickListener((view) -> listener.onAnswered());
|
||||||
findViewById(R.id.reject).setOnClickListener((view) -> listener.onDeclined());
|
findViewById(R.id.reject).setOnClickListener((view) -> listener.onDeclined());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
inflate(getContext(), R.layout.webrtc_answer_decline_button, this);
|
inflate(getContext(), R.layout.webrtc_answer_decline_button, this);
|
||||||
|
|
||||||
@ -82,6 +98,10 @@ public final class WebRtcAnswerDeclineButton extends LinearLayout {
|
|||||||
dragToAnswerListener = new DragToAnswer(answer, this);
|
dragToAnswerListener = new DragToAnswer(answer, this);
|
||||||
|
|
||||||
answer.setOnTouchListener(dragToAnswerListener);
|
answer.setOnTouchListener(dragToAnswerListener);
|
||||||
|
|
||||||
|
if (ringAnimation) {
|
||||||
|
startRingingAnimation();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,17 +110,25 @@ public final class WebRtcAnswerDeclineButton extends LinearLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void startRingingAnimation() {
|
public void startRingingAnimation() {
|
||||||
|
ringAnimation = true;
|
||||||
if (dragToAnswerListener != null) {
|
if (dragToAnswerListener != null) {
|
||||||
dragToAnswerListener.startRingingAnimation();
|
dragToAnswerListener.startRingingAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopRingingAnimation() {
|
public void stopRingingAnimation() {
|
||||||
|
ringAnimation = false;
|
||||||
if (dragToAnswerListener != null) {
|
if (dragToAnswerListener != null) {
|
||||||
dragToAnswerListener.stopRingingAnimation();
|
dragToAnswerListener.stopRingingAnimation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTouchExplorationStateChanged(boolean enabled) {
|
||||||
|
removeAllViews();
|
||||||
|
createView(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
private class DragToAnswer implements View.OnTouchListener {
|
private class DragToAnswer implements View.OnTouchListener {
|
||||||
|
|
||||||
private final TextView swipeUpText;
|
private final TextView swipeUpText;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user