diff options
author | Tony Wickham <twickham@google.com> | 2018-05-21 13:13:58 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2018-05-21 16:01:49 -0700 |
commit | 52c1b66f46eb4764825f87d4be07c62cd650935c (patch) | |
tree | 67b91f059d2232d935c94e9543cf271afe036a41 /src | |
parent | 1b74bd652cb4fa8e09590d8aeaaf8a7ff0f92888 (diff) |
Go back to previous state when hitting back from discovery bounce
Normally when you hit back, we just close the floating view if there
is one. This makes less sense for DiscoveryBounce, since it doesn't
feel like a different state even though it's technically a floating
view. So in that case, don't consume the back press; let launcher
handle it to go to the previous state.
Bug: 80075741
Change-Id: I7270b61be70509cb2101400a12929478a5d082aa
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/AbstractFloatingView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/DiscoveryBounce.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 3 |
4 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/launcher3/AbstractFloatingView.java b/src/com/android/launcher3/AbstractFloatingView.java index 5a1c1580ad..b112a8cdfb 100644 --- a/src/com/android/launcher3/AbstractFloatingView.java +++ b/src/com/android/launcher3/AbstractFloatingView.java @@ -121,9 +121,11 @@ public abstract class AbstractFloatingView extends LinearLayout implements Touch 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); close(true); + return true; } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index e851499be6..32539cdecb 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1583,8 +1583,8 @@ public class Launcher extends BaseDraggingActivity // by using if-else statements. UserEventDispatcher ued = getUserEventDispatcher(); AbstractFloatingView topView = AbstractFloatingView.getTopOpenView(this); - if (topView != null) { - topView.onBackPressed(); + if (topView != null && topView.onBackPressed()) { + // Handled by the floating view. } else if (!isInState(NORMAL)) { LauncherState lastState = mStateManager.getLastState(); ued.logActionCommand(Action.Command.BACK, mStateManager.getState().containerType, diff --git a/src/com/android/launcher3/allapps/DiscoveryBounce.java b/src/com/android/launcher3/allapps/DiscoveryBounce.java index deaf8d3c1d..e1cd06a8b9 100644 --- a/src/com/android/launcher3/allapps/DiscoveryBounce.java +++ b/src/com/android/launcher3/allapps/DiscoveryBounce.java @@ -84,6 +84,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 public boolean onControllerInterceptTouchEvent(MotionEvent ev) { handleClose(false); return false; diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index b49952f154..6b13da70cb 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -1437,12 +1437,13 @@ public class Folder extends AbstractFloatingView implements DragSource, } @Override - public void onBackPressed() { + public boolean onBackPressed() { if (isEditingName()) { mFolderName.dispatchBackKey(); } else { super.onBackPressed(); } + return true; } @Override |