Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0c5f6f6d authored by Matt Garnes's avatar Matt Garnes Committed by Raj Yengisetty
Browse files

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
parent cfad40b9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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);
+29 −1
Original line number Diff line number Diff line
@@ -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");
    }

    /**