diff options
| author | 2015-10-20 01:18:09 +0000 | |
|---|---|---|
| committer | 2015-10-20 01:18:09 +0000 | |
| commit | c8b59474d2d80fc6a22c8e507e18b0c8d853ff1e (patch) | |
| tree | 12b32db6a071a379f631844f91caf0d14f93bafb | |
| parent | be1226b9399db634c6366c9f2c5883ad50545d01 (diff) | |
| parent | 0fdcc6617769d8198012a92527c6aff2ced4831f (diff) | |
Merge "Reload content description of KeyButtonView" into mnc-dr-dev am: 9a345f31f2 am: 574b5f71e8 am: 011f9eb1fc
am: 0fdcc66177
* commit '0fdcc6617769d8198012a92527c6aff2ced4831f':
Reload content description of KeyButtonView
| -rw-r--r-- | packages/SystemUI/res/values/attrs.xml | 1 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index c070a0e2bf9b..955efb501cc8 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -20,6 +20,7 @@ <attr name="keyCode" format="integer" /> <!-- does this button generate longpress / repeat events? --> <attr name="keyRepeat" format="boolean" /> + <attr name="android:contentDescription" /> </declare-styleable> <declare-styleable name="ToggleSlider"> <attr name="text" format="string" /> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java index 4c99792265fc..4d268ceda4db 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/KeyButtonView.java @@ -18,12 +18,14 @@ package com.android.systemui.statusbar.policy; import android.app.ActivityManager; import android.content.Context; +import android.content.res.Configuration; import android.content.res.TypedArray; import android.hardware.input.InputManager; import android.media.AudioManager; import android.os.Bundle; import android.os.SystemClock; import android.util.AttributeSet; +import android.util.TypedValue; import android.view.HapticFeedbackConstants; import android.view.InputDevice; import android.view.KeyCharacterMap; @@ -43,6 +45,7 @@ import static android.view.accessibility.AccessibilityNodeInfo.ACTION_LONG_CLICK public class KeyButtonView extends ImageView { + private int mContentDescriptionRes; private long mDownTime; private int mCode; private int mTouchSlop; @@ -79,8 +82,14 @@ public class KeyButtonView extends ImageView { mSupportsLongpress = a.getBoolean(R.styleable.KeyButtonView_keyRepeat, true); + TypedValue value = new TypedValue(); + if (a.getValue(R.styleable.KeyButtonView_android_contentDescription, value)) { + mContentDescriptionRes = value.resourceId; + } + a.recycle(); + setClickable(true); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); @@ -88,6 +97,15 @@ public class KeyButtonView extends ImageView { } @Override + protected void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + + if (mContentDescriptionRes != 0) { + setContentDescription(mContext.getString(mContentDescriptionRes)); + } + } + + @Override public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (mCode != 0) { |