From a120b8e304f1541529f26ef5af13f8bb5ac655f6 Mon Sep 17 00:00:00 2001 From: Adam Copp Date: Tue, 12 Nov 2013 16:26:04 +0000 Subject: [PATCH] Hooks for subclasses to react to home presses. This provides the nessecary hooks for GEL so that it can prevent scrolling to the home screen when a search is open, instead choosing to dismiss the search. Bug: 11128544 Change-Id: I3c1b67bc271c1342db4a0abac364f2923bdeba3a --- src/com/android/launcher3/Launcher.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index d52ef9f7e4..84173b01b8 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1698,7 +1698,7 @@ public class Launcher extends Activity // In all these cases, only animate if we're already on home mWorkspace.exitWidgetResizeMode(); if (alreadyOnHome && mState == State.WORKSPACE && !mWorkspace.isTouchActive() && - openFolder == null) { + openFolder == null && shouldMoveToDefaultScreenOnHomeIntent()) { mWorkspace.moveToDefaultScreen(true); } @@ -1724,6 +1724,8 @@ public class Launcher extends Activity if (mAppsCustomizeTabHost != null) { mAppsCustomizeTabHost.reset(); } + + onHomeIntent(); } if (DEBUG_RESUME_TIME) { @@ -1731,6 +1733,21 @@ public class Launcher extends Activity } } + /** + * Override point for subclasses to prevent movement to the default screen when the home + * button is pressed. Used (for example) in GEL, to prevent movement during a search. + */ + protected boolean shouldMoveToDefaultScreenOnHomeIntent() { + return true; + } + + /** + * Override point for subclasses to provide custom behaviour for when a home intent is fired. + */ + protected void onHomeIntent() { + // Do nothing + } + @Override public void onRestoreInstanceState(Bundle state) { super.onRestoreInstanceState(state);