Merge "Go back to previous state when hitting back from discovery bounce" into ub-launcher3-edmonton

This commit is contained in:
TreeHugger Robot 2018-05-21 23:11:56 +00:00 committed by Android (Google) Code Review
commit 52cb0a73a4
4 changed files with 15 additions and 4 deletions

View File

@ -123,9 +123,11 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch
protected abstract boolean isOfType(@FloatingViewType int type); protected abstract boolean isOfType(@FloatingViewType int type);
public void onBackPressed() { /** @return Whether the back is consumed. If false, Launcher will handle the back as well. */
public boolean onBackPressed() {
logActionCommand(Action.Command.BACK); logActionCommand(Action.Command.BACK);
close(true); close(true);
return true;
} }
@Override @Override

View File

@ -1599,8 +1599,8 @@ public class Launcher extends BaseDraggingActivity
// by using if-else statements. // by using if-else statements.
UserEventDispatcher ued = getUserEventDispatcher(); UserEventDispatcher ued = getUserEventDispatcher();
AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this); AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this);
if (topView != null) { if (topView != null && topView.onBackPressed()) {
topView.onBackPressed(); // Handled by the floating view.
} else if (!isInState(NORMAL)) { } else if (!isInState(NORMAL)) {
LauncherState lastState = mStateManager.getLastState(); LauncherState lastState = mStateManager.getLastState();
ued.logActionCommand(Action.Command.BACK, mStateManager.getState().containerType, ued.logActionCommand(Action.Command.BACK, mStateManager.getState().containerType,

View File

@ -83,6 +83,14 @@ public class DiscoveryBounce extends AbstractFloatingView {
} }
} }
@Override
public boolean onBackPressed() {
super.onBackPressed();
// Go back to the previous state (from a user's perspective this floating view isn't
// something to go back from).
return false;
}
@Override @Override
public boolean onControllerInterceptTouchEvent(MotionEvent ev) { public boolean onControllerInterceptTouchEvent(MotionEvent ev) {
handleClose(false); handleClose(false);

View File

@ -1437,12 +1437,13 @@ public class Folder extends AbstractFloatingView implements DragSource,
} }
@Override @Override
public void onBackPressed() { public boolean onBackPressed() {
if (isEditingName()) { if (isEditingName()) {
mFolderName.dispatchBackKey(); mFolderName.dispatchBackKey();
} else { } else {
super.onBackPressed(); super.onBackPressed();
} }
return true;
} }
@Override @Override