summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/Launcher.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/Launcher.java')
-rw-r--r--src/com/android/launcher3/Launcher.java78
1 files changed, 73 insertions, 5 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 45e56f4be..6ad36a21a 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -61,7 +61,6 @@ import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.PorterDuff;
-import android.graphics.PorterDuffColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
@@ -421,6 +420,34 @@ public class Launcher extends Activity
AppWidgetProviderInfo mSearchWidgetInfo;
AppWidgetHostView mSearchViewHost;
+ 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;
private AppDrawerListAdapter.DrawerType mDrawerType;
@@ -550,6 +577,8 @@ public class Launcher extends Activity
mSavedState = savedInstanceState;
restoreState(mSavedState);
+ restoreCustomContentMode();
+
if (PROFILE_STARTUP) {
android.os.Debug.stopMethodTracing();
}
@@ -593,6 +622,13 @@ public class Launcher extends Activity
@Override
public void onLauncherProviderChange() { }
+ public void restoreCustomContentMode() {
+ mCustomContentMode = CustomContentMode.getModeForValue(
+ SettingsProvider.getIntCustomDefault(this,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_PANEL_LEFT,
+ CustomContentMode.DISABLED.getValue()));
+ }
+
private void initializeDynamicGrid(boolean updateGrid) {
if (!updateGrid) {
LauncherAppState.setApplicationContext(getApplicationContext());
@@ -607,6 +643,8 @@ public class Launcher extends Activity
SettingsProvider.SETTINGS_UI_DRAWER_TYPE,
R.integer.preferences_interface_drawer_type_default));
+ restoreCustomContentMode();
+
// Determine the dynamic grid properties
Point smallestSize = new Point();
Point largestSize = new Point();
@@ -640,7 +678,23 @@ public class Launcher extends Activity
/** To be overriden by subclasses to hint to Launcher that we have custom content */
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() {
@@ -653,12 +707,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());
}
}
@@ -1181,6 +1239,12 @@ public class Launcher extends Activity
}
super.onResume();
+ updateGridIfNeeded();
+
+ if(isCustomContentModeGel() && isGelIntegrationSupported()) {
+ GelIntegrationHelper.getInstance().handleGelResume();
+ }
+
// Restore the previous launcher state
if (mOnResumeState == State.WORKSPACE) {
showWorkspace(false);
@@ -1334,6 +1398,10 @@ public class Launcher extends Activity
}
}
+ protected boolean isCustomContentModeGel() {
+ return mCustomContentMode == CustomContentMode.GEL;
+ }
+
public interface CustomContentCallbacks {
// Custom content is completely shown. {@code fromResume} indicates whether this was caused
// by a onResume or by scrolling otherwise.