From 4a65b0c3022357d2b14db196224931cc35f14417 Mon Sep 17 00:00:00 2001 From: Matt Garnes Date: Fri, 20 Jun 2014 13:39:50 -0700 Subject: Add support for CMHome (1/2) Add permission for DashClock extensions. Change Trebuchet to allow viewing additional screen. Add setting that to configure Google Now / CMHome. Change-Id: I63286a2cce87455ed411bd4c77680200eec89be7 --- src/com/android/launcher3/Launcher.java | 79 ++++++++++++++++++++++++++------- 1 file changed, 64 insertions(+), 15 deletions(-) (limited to 'src/com/android/launcher3/Launcher.java') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index fac0b8835..fbb3189f9 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -56,7 +56,6 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.net.Uri; @@ -243,8 +242,6 @@ public class Launcher extends Activity private static int NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS = 5; private static int NEW_APPS_ANIMATION_DELAY = 500; - private boolean mGelIntegrationEnabled = false; - private final BroadcastReceiver mCloseSystemDialogsReceiver = new CloseSystemDialogsIntentReceiver(); private final ContentObserver mWidgetObserver = new AppWidgetResetObserver(); @@ -380,6 +377,34 @@ public class Launcher extends Activity private BubbleTextView mWaitingForResume; + public enum CustomContentMode { + DISABLED(0), + GEL(1), + CUSTOM_HOME(2); + + private final int mValue; + private CustomContentMode(int value) { + mValue = value; + } + + public int getValue() { + return mValue; + } + + public static CustomContentMode getModeForValue(int value) { + switch (value) { + case 0: + return DISABLED; + case 1: + return GEL; + default : + return CUSTOM_HOME; + } + } + } + + private CustomContentMode mCustomContentMode = CustomContentMode.CUSTOM_HOME; + // Preferences private boolean mHideIconLabels; @@ -492,7 +517,7 @@ public class Launcher extends Activity mSavedState = savedInstanceState; restoreState(mSavedState); - restoreGelSetting(); + restoreCustomContentMode(); if (PROFILE_STARTUP) { android.os.Debug.stopMethodTracing(); @@ -541,10 +566,11 @@ public class Launcher extends Activity "cyanogenmod.permission.PROTECTED_APP", null); } - public void restoreGelSetting() { - mGelIntegrationEnabled = SettingsProvider.getBoolean(this, - SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, - R.bool.preferences_interface_homescreen_search_screen_left_default); + public void restoreCustomContentMode() { + mCustomContentMode = CustomContentMode.getModeForValue( + SettingsProvider.getIntCustomDefault(this, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_PANEL_LEFT, + CustomContentMode.DISABLED.getValue())); } void initializeDynamicGrid() { @@ -555,7 +581,7 @@ public class Launcher extends Activity SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, R.bool.preferences_interface_homescreen_hide_icon_labels_default); - restoreGelSetting(); + restoreCustomContentMode(); // Determine the dynamic grid properties Point smallestSize = new Point(); @@ -589,7 +615,23 @@ public class Launcher extends Activity } protected boolean hasCustomContentToLeft() { - return isGelIntegrationSupported() && isGelIntegrationEnabled(); + switch(getCustomContentMode()) { + case GEL: + return isGelIntegrationSupported(); + case CUSTOM_HOME: + return isCustomHomeActive(); + default: + return false; + } + } + + /** + * Returns true if the custom home application is initialized and ready + * for the user to scroll to it. To be implemented by subclasses. + * @return True if the custom home view is initialized. + */ + protected boolean isCustomHomeActive() { + return false; } public boolean isGelIntegrationSupported() { @@ -602,12 +644,16 @@ public class Launcher extends Activity return globalSearchActivity != null && isCM(); } - public boolean isGelIntegrationEnabled() { - return mGelIntegrationEnabled; + public CustomContentMode getCustomContentMode() { + return mCustomContentMode; + } + + public void setCustomContentMode(CustomContentMode customContentMode) { + mCustomContentMode = customContentMode; } public void onCustomContentLaunch() { - if(isGelIntegrationEnabled() && isGelIntegrationSupported()) { + if(isCustomContentModeGel() && isGelIntegrationSupported()) { GelIntegrationHelper.getInstance().registerSwipeBackGestureListenerAndStartGel(this, mWorkspace.isLayoutRtl()); } } @@ -1060,10 +1106,9 @@ public class Launcher extends Activity } super.onResume(); - updateGridIfNeeded(); - if(isGelIntegrationEnabled() && isGelIntegrationSupported()) { + if(isCustomContentModeGel() && isGelIntegrationSupported()) { GelIntegrationHelper.getInstance().handleGelResume(); } @@ -1221,6 +1266,10 @@ public class Launcher extends Activity } } + protected boolean isCustomContentModeGel() { + return mCustomContentMode == CustomContentMode.GEL; + } + public interface CustomContentCallbacks { // Custom content is completely shown public void onShow(); -- cgit v1.2.3