summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/FocusHelper.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-03-05 11:33:33 -0800
committerSunny Goyal <sunnygoyal@google.com>2015-03-09 14:21:43 -0700
commit290800b5b7d575fd709f244f54a5fa5b63b58876 (patch)
tree6713f6dfc221f322d49942308044d8553479876c /src/com/android/launcher3/FocusHelper.java
parentd5bf4ab5f75bbfd28162d8a45043cc5801fbfcc5 (diff)
downloadandroid_packages_apps_Trebuchet-290800b5b7d575fd709f244f54a5fa5b63b58876.tar.gz
android_packages_apps_Trebuchet-290800b5b7d575fd709f244f54a5fa5b63b58876.tar.bz2
android_packages_apps_Trebuchet-290800b5b7d575fd709f244f54a5fa5b63b58876.zip
Adding a scrollable folder content implementation
> Size is restricted to 3x3 for now > Drag-drop across page s not implemented yet > A-Z sorting is not implemented yet Change-Id: I84328caa6ad910d1edeeac6f3a7fb61b7292ea7e
Diffstat (limited to 'src/com/android/launcher3/FocusHelper.java')
-rw-r--r--src/com/android/launcher3/FocusHelper.java45
1 files changed, 37 insertions, 8 deletions
diff --git a/src/com/android/launcher3/FocusHelper.java b/src/com/android/launcher3/FocusHelper.java
index 737f6cca7..b090a7c3f 100644
--- a/src/com/android/launcher3/FocusHelper.java
+++ b/src/com/android/launcher3/FocusHelper.java
@@ -23,6 +23,7 @@ import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ViewGroup;
+import com.android.launcher3.FocusHelper.PagedViewKeyListener;
import com.android.launcher3.util.FocusLogic;
/**
@@ -65,9 +66,32 @@ public class FocusHelper {
//
/**
+ * A keyboard listener for scrollable folders
+ */
+ public static class PagedFolderKeyEventListener extends PagedViewKeyListener {
+
+ private final Folder mFolder;
+
+ public PagedFolderKeyEventListener(Folder folder) {
+ mFolder = folder;
+ }
+
+ @Override
+ public void handleNoopKey(int keyCode, View v) {
+ if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
+ mFolder.mFolderName.requestFocus();
+ playSoundEffect(keyCode, v);
+ }
+ }
+ }
+
+ /**
* Handles key events in the all apps screen.
*/
- static boolean handleAppsCustomizeKeyEvent(View v, int keyCode, KeyEvent e) {
+ public static class PagedViewKeyListener implements View.OnKeyListener {
+
+ @Override
+ public boolean onKey(View v, int keyCode, KeyEvent e) {
boolean consume = FocusLogic.shouldConsume(keyCode);
if (e.getAction() == KeyEvent.ACTION_UP) {
return consume;
@@ -87,15 +111,14 @@ public class FocusHelper {
parentLayout = (ViewGroup) itemContainer.getParent();
countX = ((CellLayout) parentLayout).getCountX();
countY = ((CellLayout) parentLayout).getCountY();
- } else if (v.getParent() instanceof ViewGroup) {
- //TODO(hyunyoungs): figure out when this needs to be called.
- itemContainer = parentLayout = (ViewGroup) v.getParent();
- countX = ((PagedViewGridLayout) parentLayout).getCellCountX();
- countY = ((PagedViewGridLayout) parentLayout).getCellCountY();
} else {
- throw new IllegalStateException(
- "Parent of the focused item inside all apps screen is not a supported type.");
+ if (LauncherAppState.isDogfoodBuild()) {
+ throw new IllegalStateException("Parent of the focused item is not supported.");
+ } else {
+ return false;
+ }
}
+
final int iconIndex = itemContainer.indexOfChild(v);
final PagedView container = (PagedView) parentLayout.getParent();
final int pageIndex = container.indexToPage(container.indexOfChild(parentLayout));
@@ -109,6 +132,7 @@ public class FocusHelper {
int newIconIndex = FocusLogic.handleKeyEvent(keyCode, countX, countY, matrix,
iconIndex, pageIndex, pageCount);
if (newIconIndex == FocusLogic.NOOP) {
+ handleNoopKey(keyCode, v);
return consume;
}
switch (newIconIndex) {
@@ -163,10 +187,15 @@ public class FocusHelper {
if (child != null) {
child.requestFocus();
playSoundEffect(keyCode, v);
+ } else {
+ handleNoopKey(keyCode, v);
}
return consume;
}
+ public void handleNoopKey(int keyCode, View v) { }
+ }
+
/**
* Handles key events in the workspace hot seat (bottom of the screen).
* <p>Currently we don't special case for the phone UI in different orientations, even though