mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 11:18:21 +00:00
Fixing arrow navigation in task carousel
Bug: 80155387 Change-Id: Icbdca2e8ad2a0e7e7dfbc8493942787d9fa58a62
This commit is contained in:
@@ -930,11 +930,16 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
set.play(anim);
|
||||
}
|
||||
|
||||
private void snapToPageRelative(int delta) {
|
||||
private boolean snapToPageRelative(int delta, boolean cycle) {
|
||||
if (getPageCount() == 0) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
snapToPage((getNextPage() + getPageCount() + delta) % getPageCount());
|
||||
final int newPageUnbound = getNextPage() + delta;
|
||||
if (!cycle && (newPageUnbound < 0 || newPageUnbound >= getChildCount())) {
|
||||
return false;
|
||||
}
|
||||
snapToPage((newPageUnbound + getPageCount()) % getPageCount());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -970,21 +975,12 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
switch (event.getKeyCode()) {
|
||||
case KeyEvent.KEYCODE_TAB:
|
||||
if (!event.isAltPressed() &&
|
||||
getNextPage() ==
|
||||
(event.isShiftPressed() ? 0 : getChildCount() - 1)) {
|
||||
// If not Alt-Tab navigation, don't loop forever in the carousel and leave
|
||||
// it once we reached the end.
|
||||
return false;
|
||||
}
|
||||
snapToPageRelative(event.isShiftPressed() ? -1 : 1);
|
||||
return true;
|
||||
return snapToPageRelative(event.isShiftPressed() ? -1 : 1,
|
||||
event.isAltPressed() /* cycle */);
|
||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
||||
snapToPageRelative(mIsRtl ? -1 : 1);
|
||||
return true;
|
||||
return snapToPageRelative(mIsRtl ? -1 : 1, false /* cycle */);
|
||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||
snapToPageRelative(mIsRtl ? 1 : -1);
|
||||
return true;
|
||||
return snapToPageRelative(mIsRtl ? 1 : -1, false /* cycle */);
|
||||
case KeyEvent.KEYCODE_DEL:
|
||||
case KeyEvent.KEYCODE_FORWARD_DEL:
|
||||
dismissTask((TaskView) getChildAt(getNextPage()), true /*animateTaskView*/,
|
||||
@@ -1012,16 +1008,14 @@ public abstract class RecentsView<T extends BaseActivity> extends PagedView impl
|
||||
setCurrentPage(0);
|
||||
break;
|
||||
case FOCUS_BACKWARD:
|
||||
case FOCUS_RIGHT:
|
||||
case FOCUS_LEFT:
|
||||
setCurrentPage(getChildCount() - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void snapToTaskAfterNext() {
|
||||
snapToPageRelative(1);
|
||||
}
|
||||
|
||||
public float getContentAlpha() {
|
||||
return mContentAlpha;
|
||||
}
|
||||
|
||||
@@ -70,6 +70,14 @@ public class RecentsViewContainer extends InsettableFrameLayout {
|
||||
|
||||
mRecentsView.setClearAllButton(mClearAllButton);
|
||||
mClearAllButton.setRecentsView(mRecentsView);
|
||||
|
||||
if (mRecentsView.isRtl()) {
|
||||
mClearAllButton.setNextFocusRightId(mRecentsView.getId());
|
||||
mRecentsView.setNextFocusLeftId(mClearAllButton.getId());
|
||||
} else {
|
||||
mClearAllButton.setNextFocusLeftId(mRecentsView.getId());
|
||||
mRecentsView.setNextFocusRightId(mClearAllButton.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user