diff options
author | John Spurlock <jspurlock@google.com> | 2015-05-05 14:50:43 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2015-05-05 14:53:13 -0400 |
commit | 5adeabc61d41f89af7f9e01e9f07136618547b9b (patch) | |
tree | d13f079a870fe1b7568b941ee71b50ee58c3a6fe /packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java | |
parent | ad2399f3be4861d0f5acf072460d98fafc951c57 (diff) | |
download | frameworks_base-5adeabc61d41f89af7f9e01e9f07136618547b9b.zip frameworks_base-5adeabc61d41f89af7f9e01e9f07136618547b9b.tar.gz frameworks_base-5adeabc61d41f89af7f9e01e9f07136618547b9b.tar.bz2 |
Volume A11y: Prevent auto-dismiss when feedback enabled.
- Prevent the volume dialog from timing out when feedback is enabled.
- Use the a11y events as an additional user activity signal.
- Add content descriptions for the dialog icon buttons.
Bug: 20172022
Change-Id: Id5cd29d9cee27fded2fc8a029913cfcc2b68c152
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java | 76 |
1 files changed, 72 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java index 9434036..7115897 100644 --- a/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java +++ b/packages/SystemUI/src/com/android/systemui/volume/VolumeDialog.java @@ -16,6 +16,9 @@ package com.android.systemui.volume; +import static android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_ALL_MASK; + +import android.accessibilityservice.AccessibilityServiceInfo; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; @@ -32,6 +35,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.AudioSystem; +import android.os.Debug; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -43,6 +47,8 @@ import android.util.SparseBooleanArray; import android.view.Gravity; import android.view.MotionEvent; import android.view.View; +import android.view.View.AccessibilityDelegate; +import android.view.View.OnAttachStateChangeListener; import android.view.View.OnClickListener; import android.view.View.OnLayoutChangeListener; import android.view.View.OnTouchListener; @@ -50,6 +56,9 @@ import android.view.ViewGroup; import android.view.ViewGroup.MarginLayoutParams; import android.view.Window; import android.view.WindowManager; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; +import android.view.accessibility.AccessibilityManager.AccessibilityStateChangeListener; import android.view.animation.DecelerateInterpolator; import android.widget.ImageButton; import android.widget.LinearLayout; @@ -97,6 +106,7 @@ public class VolumeDialog { private final ZenFooter mZenFooter; private final LayoutTransition mLayoutTransition; private final Object mSafetyWarningLock = new Object(); + private final Accessibility mAccessibility = new Accessibility(); private boolean mShowing; private boolean mExpanded; @@ -174,6 +184,8 @@ public class VolumeDialog { mZenFooter = (ZenFooter) mDialog.findViewById(R.id.volume_zen_footer); mZenFooter.init(zenModeController); + mAccessibility.init(); + controller.addCallback(mControllerCallbackH, mHandler); controller.getState(); } @@ -409,10 +421,13 @@ public class VolumeDialog { protected void rescheduleTimeoutH() { mHandler.removeMessages(H.DISMISS); - final int timeout = computeTimeoutH(); - if (D.BUG) Log.d(TAG, "rescheduleTimeout " + timeout); - mHandler.sendMessageDelayed(mHandler - .obtainMessage(H.DISMISS, Events.DISMISS_REASON_TIMEOUT, 0), timeout); + int timeout = -1; + if (!mAccessibility.mFeedbackEnabled) { + timeout = computeTimeoutH(); + mHandler.sendMessageDelayed(mHandler + .obtainMessage(H.DISMISS, Events.DISMISS_REASON_TIMEOUT, 0), timeout); + } + if (D.BUG) Log.d(TAG, "rescheduleTimeout " + timeout + " " + Debug.getCaller()); mController.userActivity(); } @@ -475,6 +490,8 @@ public class VolumeDialog { if (res == mExpandButtonRes) return; mExpandButtonRes = res; mExpandButton.setImageResource(res); + mExpandButton.setContentDescription(mContext.getString(mExpanded ? + R.string.accessibility_volume_collapse : R.string.accessibility_volume_expand)); } private boolean isVisibleH(VolumeRow row, boolean isActive) { @@ -632,6 +649,7 @@ public class VolumeDialog { : (iconRes == R.drawable.ic_volume_media_bt || iconRes == row.iconRes) ? Events.ICON_STATE_UNMUTE : Events.ICON_STATE_UNKNOWN; + row.icon.setContentDescription(ss.name); // update slider updateVolumeRowSliderH(row, zenMuted); @@ -931,6 +949,56 @@ public class VolumeDialog { } } + private final class Accessibility { + private AccessibilityManager mMgr; + private boolean mFeedbackEnabled; + + public void init() { + mMgr = (AccessibilityManager) mContext.getSystemService(Context.ACCESSIBILITY_SERVICE); + mDialogView.addOnAttachStateChangeListener(new OnAttachStateChangeListener() { + @Override + public void onViewDetachedFromWindow(View v) { + // noop + } + + @Override + public void onViewAttachedToWindow(View v) { + updateFeedbackEnabled(); + } + }); + mDialogView.setAccessibilityDelegate(new AccessibilityDelegate() { + @Override + public boolean onRequestSendAccessibilityEvent(ViewGroup host, View child, + AccessibilityEvent event) { + rescheduleTimeoutH(); + return super.onRequestSendAccessibilityEvent(host, child, event); + } + }); + mMgr.addAccessibilityStateChangeListener(new AccessibilityStateChangeListener() { + @Override + public void onAccessibilityStateChanged(boolean enabled) { + updateFeedbackEnabled(); + } + }); + updateFeedbackEnabled(); + } + + private void updateFeedbackEnabled() { + mFeedbackEnabled = computeFeedbackEnabled(); + } + + private boolean computeFeedbackEnabled() { + final List<AccessibilityServiceInfo> services = + mMgr.getEnabledAccessibilityServiceList(FEEDBACK_ALL_MASK); + for (AccessibilityServiceInfo asi : services) { + if ((asi.feedbackType & FEEDBACK_ALL_MASK) != 0) { + return true; + } + } + return false; + } + } + private static class VolumeRow { private View view; private View space; |