From 0c5f6f6dc6c5e6948ff5683fa8ed38ed956f457c Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Fri, 27 Jun 2014 16:56:22 -0700 Subject: Fix GEL integration for RTL mode. In RTL mode, the Google Now activity starts to the right, so to return to Trebuchet, the left edge must be swiped. Change-Id: Ib8869570307b6186e7e9ea19520ed21418a175fb --- .../android/launcher3/GelIntegrationHelper.java | 6 +++-- src/com/android/launcher3/Launcher.java | 30 +++++++++++++++++++++- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/GelIntegrationHelper.java b/src/com/android/launcher3/GelIntegrationHelper.java index 6dd9c0e32..f43e7e6a0 100644 --- a/src/com/android/launcher3/GelIntegrationHelper.java +++ b/src/com/android/launcher3/GelIntegrationHelper.java @@ -22,6 +22,7 @@ public class GelIntegrationHelper { private static final String GEL_PACKAGE_NAME = "com.google.android.googlequicksearchbox"; private static final int EDGE_GESTURE_SERVICE_RIGHT_EDGE = 4; + private static final int EDGE_GESTURE_SERVICE_LEFT_EDGE = 1; private static final int EDGE_GESTURE_SERVICE_NO_EDGE = -1; private EdgeGestureManager.EdgeGestureActivationListener mEdgeGestureActivationListener = null; @@ -42,7 +43,7 @@ public class GelIntegrationHelper { * 2. Starts the Google Now Activity with an exit_out_right transition animation so that * the new Activity appears to slide in as another screen (similar to GEL). */ - public void registerSwipeBackGestureListenerAndStartGel(final Activity launcherActivity) { + public void registerSwipeBackGestureListenerAndStartGel(final Activity launcherActivity, boolean isLayoutRtl) { EdgeGestureManager edgeGestureManager = EdgeGestureManager.getInstance(); if(mEdgeGestureActivationListener == null) { mEdgeGestureActivationListener = new EdgeGestureManager.EdgeGestureActivationListener() { @@ -74,8 +75,9 @@ public class GelIntegrationHelper { edgeGestureManager.setEdgeGestureActivationListener(mEdgeGestureActivationListener); } mEdgeGestureActivationListener.restoreListenerState(); + int edge = isLayoutRtl ? EDGE_GESTURE_SERVICE_LEFT_EDGE : EDGE_GESTURE_SERVICE_RIGHT_EDGE; edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, - EDGE_GESTURE_SERVICE_RIGHT_EDGE); + edge); // Start the Google Now Activity Intent i = new Intent(INTENT_ACTION_ASSIST); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index c2e0dc9d9..45e56f4be 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -640,7 +640,35 @@ public class Launcher extends Activity /** To be overriden by subclasses to hint to Launcher that we have custom content */ protected boolean hasCustomContentToLeft() { - return false; + return isGelIntegrationSupported() && isGelIntegrationEnabled(); + } + + public boolean isGelIntegrationSupported() { + final SearchManager searchManager = + (SearchManager) getSystemService(Context.SEARCH_SERVICE); + ComponentName globalSearchActivity = searchManager.getGlobalSearchActivity(); + + // Currently the only custom content available is the GEL launcher integration, + // only supported on CyanogenMod. + return globalSearchActivity != null && isCM(); + } + + public boolean isGelIntegrationEnabled() { + return mGelIntegrationEnabled; + } + + public void onCustomContentLaunch() { + if(isGelIntegrationEnabled() && isGelIntegrationSupported()) { + GelIntegrationHelper.getInstance().registerSwipeBackGestureListenerAndStartGel(this, mWorkspace.isLayoutRtl()); + } + } + + /** + * Check if the device running this application is running CyanogenMod. + * @return true if this device is running CM. + */ + protected boolean isCM() { + return getPackageManager().hasSystemFeature("com.cyanogenmod.android"); } /** -- cgit v1.2.3