diff options
Diffstat (limited to 'java/com/android')
-rw-r--r-- | java/com/android/newbubble/NewBubble.java | 34 | ||||
-rw-r--r-- | java/com/android/newbubble/res/layout/new_bubble_base.xml | 1 | ||||
-rw-r--r-- | java/com/android/newbubble/res/values/strings.xml | 27 |
3 files changed, 62 insertions, 0 deletions
diff --git a/java/com/android/newbubble/NewBubble.java b/java/com/android/newbubble/NewBubble.java index 23c4411cf..34a9585c1 100644 --- a/java/com/android/newbubble/NewBubble.java +++ b/java/com/android/newbubble/NewBubble.java @@ -47,11 +47,14 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.View.AccessibilityDelegate; import android.view.ViewGroup; import android.view.ViewPropertyAnimator; import android.view.ViewTreeObserver.OnPreDrawListener; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; +import android.view.accessibility.AccessibilityNodeInfo; +import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; import android.view.animation.AnticipateInterpolator; import android.view.animation.OvershootInterpolator; import android.widget.ImageView; @@ -228,6 +231,8 @@ public class NewBubble { if (isUserAction) { logBasicOrCallImpression(DialerImpression.Type.BUBBLE_PRIMARY_BUTTON_EXPAND); } + setPrimaryButtonAccessibilityAction( + context.getString(R.string.a11y_bubble_primary_button_collapse_action)); viewHolder.setDrawerVisibility(View.INVISIBLE); View expandedView = viewHolder.getExpandedView(); expandedView @@ -310,6 +315,8 @@ public class NewBubble { if (isUserAction && collapseEndAction == CollapseEnd.NOTHING) { logBasicOrCallImpression(DialerImpression.Type.BUBBLE_COLLAPSE_BY_USER); } + setPrimaryButtonAccessibilityAction( + context.getString(R.string.a11y_bubble_primary_button_expand_action)); // Animate expanded view to move from its position to above primary button and hide collapseAnimation = expandedView @@ -448,6 +455,9 @@ public class NewBubble { viewHolder.setChildClickable(true); visibility = Visibility.ENTERING; + setPrimaryButtonAccessibilityAction( + context.getString(R.string.a11y_bubble_primary_button_expand_action)); + // Show bubble animation: scale the whole bubble to 1, and change avatar+icon's alpha to 1 ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(viewHolder.getPrimaryButton(), "scaleX", 1); @@ -726,6 +736,11 @@ public class NewBubble { exitAnimatorSet.addListener( new AnimatorListenerAdapter() { @Override + public void onAnimationStart(Animator animation) { + viewHolder.getPrimaryButton().setAccessibilityDelegate(null); + } + + @Override public void onAnimationEnd(Animator animation) { afterHiding.run(); } @@ -793,6 +808,7 @@ public class NewBubble { button.setChecked(action.isChecked()); button.setEnabled(action.isEnabled()); button.setText(action.getName()); + button.setContentDescription(action.getName()); button.setOnClickListener(v -> doAction(action)); } @@ -822,6 +838,8 @@ public class NewBubble { viewHolder .getPrimaryIcon() .setTranslationX(isDrawingFromRight() ? -primaryIconMoveDistance : 0); + setPrimaryButtonAccessibilityAction( + context.getString(R.string.a11y_bubble_primary_button_expand_action)); update(); @@ -883,6 +901,22 @@ public class NewBubble { } } + private void setPrimaryButtonAccessibilityAction(String description) { + viewHolder + .getPrimaryButton() + .setAccessibilityDelegate( + new AccessibilityDelegate() { + @Override + public void onInitializeAccessibilityNodeInfo(View v, AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(v, info); + + AccessibilityAction clickAction = + new AccessibilityAction(AccessibilityNodeInfo.ACTION_CLICK, description); + info.addAction(clickAction); + } + }); + } + @VisibleForTesting class ViewHolder { diff --git a/java/com/android/newbubble/res/layout/new_bubble_base.xml b/java/com/android/newbubble/res/layout/new_bubble_base.xml index 8d4771631..216dce0d2 100644 --- a/java/com/android/newbubble/res/layout/new_bubble_base.xml +++ b/java/com/android/newbubble/res/layout/new_bubble_base.xml @@ -38,6 +38,7 @@ android:layout_marginEnd="@dimen/bubble_shadow_padding_size_horizontal" android:layout_marginTop="@dimen/bubble_shadow_padding_size_vertical" android:layout_marginBottom="@dimen/bubble_shadow_padding_size_vertical" + android:contentDescription="@string/a11y_bubble_description" android:background="@drawable/bubble_shape_circle" android:measureAllChildren="false" android:elevation="@dimen/bubble_elevation" diff --git a/java/com/android/newbubble/res/values/strings.xml b/java/com/android/newbubble/res/values/strings.xml new file mode 100644 index 000000000..5b82b181f --- /dev/null +++ b/java/com/android/newbubble/res/values/strings.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ Copyright (C) 2017 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License + --> + +<resources> + <!-- A string for Talkback to read when accessibility user touch bubble. --> + <string name="a11y_bubble_description">Dialer bubble</string> + <!-- A string to describe available action for accessibility user. It will be read as "Actions: + double tap to expand call action menu". --> + <string name="a11y_bubble_primary_button_expand_action">Expand call action menu</string> + <!-- A string to describe available action for accessibility user. It will be read as "Actions: + double tap to collapse call action menu". --> + <string name="a11y_bubble_primary_button_collapse_action">Collapse call action menu</string> +</resources>
\ No newline at end of file |