From 2a422f719b70f6c292b954fb24f324b7f4ac1858 Mon Sep 17 00:00:00 2001 From: yueg Date: Wed, 24 Jan 2018 15:20:10 -0800 Subject: Bubble v2 a11y. - Set checkable for bubble buttons so the check status of non checkable button (back to call, end call) is not read. - Add support for bottom action buttons. Test: manual PiperOrigin-RevId: 183150371 Change-Id: Ifae9c912ec923e8d2cda3146413138bd2eb94b47 --- java/com/android/incallui/NewReturnToCallController.java | 3 +++ java/com/android/newbubble/BottomActionViewController.java | 9 +++++++++ java/com/android/newbubble/NewBubble.java | 2 +- java/com/android/newbubble/NewBubbleInfo.java | 8 ++++---- java/com/android/newbubble/NewCheckableButton.java | 12 +++++++++--- java/com/android/newbubble/res/layout/bottom_action_base.xml | 9 ++++++--- java/com/android/newbubble/res/values/strings.xml | 2 ++ 7 files changed, 34 insertions(+), 11 deletions(-) diff --git a/java/com/android/incallui/NewReturnToCallController.java b/java/com/android/incallui/NewReturnToCallController.java index b8798b1b9..4c3c2a2eb 100644 --- a/java/com/android/incallui/NewReturnToCallController.java +++ b/java/com/android/incallui/NewReturnToCallController.java @@ -238,6 +238,7 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au .setIconDrawable(context.getDrawable(R.drawable.quantum_ic_exit_to_app_vd_theme_24)) .setIntent(fullScreen) .setName(context.getText(R.string.bubble_return_to_call)) + .setCheckable(false) .build()); // Mute/unmute actions.add( @@ -252,6 +253,7 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au Action.builder() .setIconDrawable(context.getDrawable(speakerButtonInfo.icon)) .setName(context.getText(speakerButtonInfo.label)) + .setCheckable(speakerButtonInfo.checkable) .setChecked(speakerButtonInfo.isChecked) .setIntent(speakerButtonInfo.checkable ? toggleSpeaker : showSpeakerSelect) .build()); @@ -261,6 +263,7 @@ public class NewReturnToCallController implements InCallUiListener, Listener, Au .setIconDrawable(context.getDrawable(R.drawable.quantum_ic_call_end_vd_theme_24)) .setIntent(endCall) .setName(context.getText(R.string.incall_label_end_call)) + .setCheckable(false) .build()); return actions; } diff --git a/java/com/android/newbubble/BottomActionViewController.java b/java/com/android/newbubble/BottomActionViewController.java index 04e0e5fe7..b480ac986 100644 --- a/java/com/android/newbubble/BottomActionViewController.java +++ b/java/com/android/newbubble/BottomActionViewController.java @@ -23,6 +23,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; +import android.view.accessibility.AccessibilityEvent; import android.view.animation.LinearInterpolator; /** Controller for showing and hiding bubble bottom action view. */ @@ -157,10 +158,14 @@ final class BottomActionViewController { // Scale unhighlight target back to 1x if (!shouldHighlightDismiss && dismissHighlighted) { + // A11y + dismissView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); // Unhighlight dismiss dismissView.animate().scaleX(1f).scaleY(1f).setDuration(HIGHLIGHT_TARGET_DURATION).start(); dismissHighlighted = false; } else if (!shouldHighlightEndCall && endCallHighlighted) { + // A11y + endCallView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); // Unhighlight end call endCallView.animate().scaleX(1f).scaleY(1f).setDuration(HIGHLIGHT_TARGET_DURATION).start(); endCallHighlighted = false; @@ -168,6 +173,8 @@ final class BottomActionViewController { // Scale highlight target larger if (shouldHighlightDismiss && !dismissHighlighted) { + // A11y + dismissView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); // Highlight dismiss dismissView.setPivotY(dismissView.getHeight() / 2 + textOffsetSize); dismissView @@ -184,6 +191,8 @@ final class BottomActionViewController { .start(); dismissHighlighted = true; } else if (shouldHighlightEndCall && !endCallHighlighted) { + // A11y + endCallView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); // Highlight end call endCallView.setPivotY(dismissView.getHeight() / 2 + textOffsetSize); endCallView diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java index 8b188ba33..2e98ad17b 100644 --- a/java/com/android/newbubble/NewBubble.java +++ b/java/com/android/newbubble/NewBubble.java @@ -722,7 +722,7 @@ public class NewBubble { button.setCompoundDrawablesWithIntrinsicBounds(action.getIconDrawable(), null, null, null); } button.setChecked(action.isChecked()); - button.setEnabled(action.isEnabled()); + button.setCheckable(action.isCheckable()); button.setText(action.getName()); button.setContentDescription(action.getName()); button.setOnClickListener(v -> doAction(action)); diff --git a/java/com/android/newbubble/NewBubbleInfo.java b/java/com/android/newbubble/NewBubbleInfo.java index ec26a3143..cc7ac7c6f 100644 --- a/java/com/android/newbubble/NewBubbleInfo.java +++ b/java/com/android/newbubble/NewBubbleInfo.java @@ -86,19 +86,19 @@ public abstract class NewBubbleInfo { @NonNull public abstract PendingIntent getIntent(); - public abstract boolean isEnabled(); + public abstract boolean isCheckable(); public abstract boolean isChecked(); public static Builder builder() { - return new AutoValue_NewBubbleInfo_Action.Builder().setEnabled(true).setChecked(false); + return new AutoValue_NewBubbleInfo_Action.Builder().setCheckable(true).setChecked(false); } public static Builder from(@NonNull Action action) { return builder() .setIntent(action.getIntent()) .setChecked(action.isChecked()) - .setEnabled(action.isEnabled()) + .setCheckable(action.isCheckable()) .setName(action.getName()) .setIconDrawable(action.getIconDrawable()); } @@ -113,7 +113,7 @@ public abstract class NewBubbleInfo { public abstract Builder setIntent(@NonNull PendingIntent intent); - public abstract Builder setEnabled(boolean enabled); + public abstract Builder setCheckable(boolean enabled); public abstract Builder setChecked(boolean checked); diff --git a/java/com/android/newbubble/NewCheckableButton.java b/java/com/android/newbubble/NewCheckableButton.java index 15858d39e..fda0ddc6e 100644 --- a/java/com/android/newbubble/NewCheckableButton.java +++ b/java/com/android/newbubble/NewCheckableButton.java @@ -45,22 +45,28 @@ public class NewCheckableButton extends AppCompatButton implements Checkable { public NewCheckableButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); + } + public void setCheckable(boolean checkable) { ViewCompat.setAccessibilityDelegate( this, new AccessibilityDelegateCompat() { @Override public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) { super.onInitializeAccessibilityEvent(host, event); - event.setChecked(isChecked()); + if (checkable) { + event.setChecked(isChecked()); + } } @Override public void onInitializeAccessibilityNodeInfo( View host, AccessibilityNodeInfoCompat info) { super.onInitializeAccessibilityNodeInfo(host, info); - info.setCheckable(true); - info.setChecked(isChecked()); + info.setCheckable(checkable); + if (checkable) { + info.setChecked(isChecked()); + } } }); } diff --git a/java/com/android/newbubble/res/layout/bottom_action_base.xml b/java/com/android/newbubble/res/layout/bottom_action_base.xml index 8f7ba753e..b4d7c891e 100644 --- a/java/com/android/newbubble/res/layout/bottom_action_base.xml +++ b/java/com/android/newbubble/res/layout/bottom_action_base.xml @@ -20,7 +20,8 @@ android:weightSum="2" android:orientation="horizontal" android:gravity="center" - android:background="@drawable/bottom_action_scrim"> + android:background="@drawable/bottom_action_scrim" + android:contentDescription="@string/a11y_bubble_bottom_action_description"> + android:gravity="center" + android:contentDescription="@string/bubble_bottom_action_hide"> + android:gravity="center" + android:contentDescription="@string/bubble_bottom_action_end_call"> Dialer bubble + + Bottom action buttons Expand call action menu -- cgit v1.2.3