diff options
author | Adam Cohen <adamcohen@google.com> | 2011-10-25 21:38:29 -0700 |
---|---|---|
committer | Adam Cohen <adamcohen@google.com> | 2011-10-26 14:08:19 -0700 |
commit | 3371da0159cc54ff8ae1b1b26effb96445f208d5 (patch) | |
tree | aac9f398c475f14c802370e827c44973fd9cc21e /src/com/android/launcher2/Folder.java | |
parent | f060868dd6ca8fb2f199fefd5cbb19a75ac2c108 (diff) | |
download | android_packages_apps_Trebuchet-3371da0159cc54ff8ae1b1b26effb96445f208d5.tar.gz android_packages_apps_Trebuchet-3371da0159cc54ff8ae1b1b26effb96445f208d5.tar.bz2 android_packages_apps_Trebuchet-3371da0159cc54ff8ae1b1b26effb96445f208d5.zip |
Initial changes to make folders accessible
Change-Id: Id8c9cbc0ef200967c3b966fbccfdfde184d4211c
Diffstat (limited to 'src/com/android/launcher2/Folder.java')
-rw-r--r-- | src/com/android/launcher2/Folder.java | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/com/android/launcher2/Folder.java b/src/com/android/launcher2/Folder.java index 019ac7000..33b5de17c 100644 --- a/src/com/android/launcher2/Folder.java +++ b/src/com/android/launcher2/Folder.java @@ -37,6 +37,8 @@ import android.view.Menu; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; import android.view.inputmethod.EditorInfo; @@ -95,7 +97,6 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList private Alarm mReorderAlarm = new Alarm(); private Alarm mOnExitAlarm = new Alarm(); private int mFolderNameHeight; - private Rect mHitRect = new Rect(); private Rect mTempRect = new Rect(); private boolean mDragInProgress = false; private boolean mDeleteFolderOnDropCompleted = false; @@ -240,9 +241,14 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderName.setHint(sHintText); // Convert to a string here to ensure that no other state associated with the text field // gets saved. - mInfo.setTitle(mFolderName.getText().toString()); + String newTitle = mFolderName.getText().toString(); + mInfo.setTitle(newTitle); LauncherModel.updateItemInDatabase(mLauncher, mInfo); + if (commit) { + sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, + String.format(mContext.getString(R.string.folder_renamed), newTitle)); + } // In order to clear the focus from the text field, we set the focus on ourself. This // ensures that every time the field is clicked, focus is gained, giving reliable behavior. requestFocus(); @@ -283,6 +289,12 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList mFolderIcon = icon; } + @Override + public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { + // When the folder gets focus, we don't want to announce the list of items. + return true; + } + /** * @return the FolderInfo object associated with this folder */ @@ -398,6 +410,9 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { + sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, + String.format(mContext.getString(R.string.folder_opened), + mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override @@ -415,6 +430,15 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList oa.start(); } + private void sendCustomAccessibilityEvent(int type, String text) { + if (AccessibilityManager.getInstance(mContext).isEnabled()) { + AccessibilityEvent event = AccessibilityEvent.obtain(type); + onInitializeAccessibilityEvent(event); + event.getText().add(text); + AccessibilityManager.getInstance(mContext).sendAccessibilityEvent(event); + } + } + private void setFocusOnFirstChild() { View firstChild = mContent.getChildAt(0, 0); if (firstChild != null) { @@ -460,6 +484,8 @@ public class Folder extends LinearLayout implements DragSource, View.OnClickList } @Override public void onAnimationStart(Animator animation) { + sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, + mContext.getString(R.string.folder_closed)); mState = STATE_ANIMATING; } }); |