Fix keyboard focus for opening folder.
Previous patch Ia4ccc59ca27e560e470122d1b2c6c1eccb4caf9a was
reverted due to a weird behavior around folder name editing
with virtual keyboard.
Also, requestFocus() on doneEditingFolderName() did nothing
because the folder itself didn't get the focus at that point.
This CL addresses these issues:
- no change on the descendant focusability. Folder itself is
focusable before its descendants.
- customize Folder.focusSearch(), so once the folder is focused,
further focus cycle moves among its descendants.
- Folder requests its focus when it appears. Without this,
the first arrow-key after opening a folder by touch moves
the focus to the folder itself, which looks like nothing happened.
Bug: 22562679
Change-Id: I04375bd4cb69d463b9a95bebafa9c60142e95daa
diff --git a/src/com/android/launcher3/Folder.java b/src/com/android/launcher3/Folder.java
index afb5fd8..53fab11 100644
--- a/src/com/android/launcher3/Folder.java
+++ b/src/com/android/launcher3/Folder.java
@@ -36,6 +36,7 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.ActionMode;
+import android.view.FocusFinder;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
@@ -358,11 +359,26 @@
}
@Override
+ protected void onAttachedToWindow() {
+ // requestFocus() causes the focus onto the folder itself, which doesn't cause visual
+ // effect but the next arrow key can start the keyboard focus inside of the folder, not
+ // the folder itself.
+ requestFocus();
+ super.onAttachedToWindow();
+ }
+
+ @Override
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
// When the folder gets focus, we don't want to announce the list of items.
return true;
}
+ @Override
+ public View focusSearch(int direction) {
+ // When the folder is focused, further focus search should be within the folder contents.
+ return FocusFinder.getInstance().findNextFocus(this, null, direction);
+ }
+
/**
* @return the FolderInfo object associated with this folder
*/