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
This commit is contained in:
Sunny Goyal
2015-03-05 11:33:33 -08:00
parent d5bf4ab5f7
commit 290800b5b7
9 changed files with 742 additions and 37 deletions

View File

@@ -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;
/**
@@ -64,10 +65,33 @@ public class FocusHelper {
// Key code handling methods.
//
/**
* 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