diff options
Diffstat (limited to 'policy')
-rw-r--r-- | policy/src/com/android/internal/policy/impl/GlobalActions.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index 7b41391..dfcdaa0 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -68,6 +68,7 @@ import android.view.WindowManager; import android.view.WindowManagerGlobal; import android.view.WindowManagerInternal; import android.view.WindowManagerPolicy.WindowManagerFuncs; +import android.view.accessibility.AccessibilityEvent; import android.widget.AdapterView; import android.widget.BaseAdapter; import android.widget.ImageView; @@ -625,6 +626,12 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac * What each item in the global actions dialog must be able to support. */ private interface Action { + /** + * @return Text that will be announced when dialog is created. null + * for none. + */ + CharSequence getLabelForAccessibility(Context context); + View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater); void onPress(); @@ -692,6 +699,14 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac abstract public void onPress(); + public CharSequence getLabelForAccessibility(Context context) { + if (mMessage != null) { + return mMessage; + } else { + return context.getString(mMessageResId); + } + } + public View create( Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = inflater.inflate(R.layout.global_actions_item, parent, false); @@ -781,6 +796,11 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } + @Override + public CharSequence getLabelForAccessibility(Context context) { + return context.getString(mMessageResId); + } + public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { willCreate(); @@ -897,6 +917,11 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac return index; } + @Override + public CharSequence getLabelForAccessibility(Context context) { + return null; + } + public View create(Context context, View convertView, ViewGroup parent, LayoutInflater inflater) { View v = inflater.inflate(R.layout.global_actions_silent_mode, parent, false); @@ -1045,6 +1070,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac private final Context mContext; private final int mWindowTouchSlop; private final AlertController mAlert; + private final MyAdapter mAdapter; private EnableAccessibilityController mEnableAccessibilityController; @@ -1055,6 +1081,7 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac super(context, getDialogTheme(context)); mContext = context; mAlert = new AlertController(mContext, this, getWindow()); + mAdapter = (MyAdapter) params.mAdapter; mWindowTouchSlop = ViewConfiguration.get(context).getScaledWindowTouchSlop(); params.apply(mAlert); } @@ -1149,6 +1176,20 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac } @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { + for (int i = 0; i < mAdapter.getCount(); ++i) { + CharSequence label = + mAdapter.getItem(i).getLabelForAccessibility(getContext()); + if (label != null) { + event.getText().add(label); + } + } + } + return super.dispatchPopulateAccessibilityEvent(event); + } + + @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (mAlert.onKeyDown(keyCode, event)) { return true; |