diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2010-10-05 15:55:39 -0700 |
---|---|---|
committer | Svetoslav Ganov <svetoslavganov@google.com> | 2010-10-05 15:55:39 -0700 |
commit | cd2613ab7b0f4f967c1d0388e1267ad01db787a8 (patch) | |
tree | e97aa358e5afd3f7843da0f0bcd2d03a5f448af5 /core/java | |
parent | 10bc36522592179622a0fa7b7f6fffba5907fbf5 (diff) | |
download | frameworks_base-cd2613ab7b0f4f967c1d0388e1267ad01db787a8.zip frameworks_base-cd2613ab7b0f4f967c1d0388e1267ad01db787a8.tar.gz frameworks_base-cd2613ab7b0f4f967c1d0388e1267ad01db787a8.tar.bz2 |
2763342 Toasts do not fire accessibility events
Change-Id: I11f2ca9a0875d3d00eb78fd53b882f8ac5c21a4d
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/widget/Toast.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/widget/Toast.java b/core/java/android/widget/Toast.java index df957ac..29ca49a 100644 --- a/core/java/android/widget/Toast.java +++ b/core/java/android/widget/Toast.java @@ -30,6 +30,8 @@ import android.view.LayoutInflater; import android.view.View; import android.view.WindowManager; import android.view.WindowManagerImpl; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; /** * A toast is a view containing a quick little message for the user. The toast class @@ -281,6 +283,21 @@ public class Toast { tv.setText(s); } + private void trySendAccessibilityEvent() { + AccessibilityManager accessibilityManager = AccessibilityManager.getInstance(mContext); + if (!accessibilityManager.isEnabled()) { + return; + } + // treat toasts as notifications since they are used to + // announce a transient piece of information to the user + AccessibilityEvent event = AccessibilityEvent.obtain( + AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED); + event.setClassName(getClass().getName()); + event.setPackageName(mContext.getPackageName()); + mView.dispatchPopulateAccessibilityEvent(event); + accessibilityManager.sendAccessibilityEvent(event); + } + // ======================================================================================= // All the gunk below is the interaction with the Notification Service, which handles // the proper ordering of these system-wide. @@ -371,6 +388,7 @@ public class Toast { } if (localLOGV) Log.v(TAG, "ADD! " + mView + " in " + this); mWM.addView(mView, mParams); + trySendAccessibilityEvent(); } } |