mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 01:46:49 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user