summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2014-09-24 16:20:37 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-09-24 16:20:37 +0000
commita2cbb297748038e20d43869c480eb8e120a815cc (patch)
treeb89cee6f585668fc67ea521c793025f1266510e0 /policy
parent7fec638e356371badd9c33fc94524b8e0de01b03 (diff)
parent0012660efd45ac25eda148881d693601bf79aff0 (diff)
downloadframeworks_base-a2cbb297748038e20d43869c480eb8e120a815cc.zip
frameworks_base-a2cbb297748038e20d43869c480eb8e120a815cc.tar.gz
frameworks_base-a2cbb297748038e20d43869c480eb8e120a815cc.tar.bz2
am 5a662bca: am b667c05d: am e4465aea: am f40f4af6: Merge "Add announcement of global actions dialog" into lmp-dev
* commit '5a662bcac6c47dbea80b3cbef350d7dc6b922d11': Add announcement of global actions dialog
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java41
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;