summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher/home/Home.java17
-rw-r--r--src/com/android/launcher3/Launcher.java78
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java1
-rw-r--r--src/com/android/launcher3/Workspace.java34
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java41
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java1
6 files changed, 161 insertions, 11 deletions
diff --git a/src/com/android/launcher/home/Home.java b/src/com/android/launcher/home/Home.java
index 5dce71e86..e6fedc8db 100644
--- a/src/com/android/launcher/home/Home.java
+++ b/src/com/android/launcher/home/Home.java
@@ -65,7 +65,7 @@ public interface Home {
* </pre><br/>
* DO NOT MODIFY!
*/
- public static final String SIGNATURE = "5/A6Mxkz8gHHzzVf4qZR+hiSOAw=";
+ public static final String SIGNATURE = "sZFp8JclUBYdIw0QaJZDosZ8SWM=";
/**
* Defines the name of the metadata used to declared the full qualified Home stub class
@@ -98,6 +98,14 @@ public interface Home {
public static final int MODE_SEARCH_VOICE = 0x0001;
/**
+ * Invoked when creating the Home object to set
+ * a reference to the host Activity that will
+ * contain this instance.
+ * @param context The Activity Context of the host activity.
+ */
+ void setHostActivityContext(Context context);
+
+ /**
* Invoked the first time the <code>Home</code> app is created.<br/>
* This method should be used by implementors classes of this protocol to load the needed
* resources.
@@ -106,6 +114,13 @@ public interface Home {
void onStart(Context context);
/**
+ * Load and show the content of this home app if true,
+ * hide and remove providers if false.
+ * @param showContent Should content be shown
+ */
+ void setShowContent(boolean showContent);
+
+ /**
* Invoked when the <code>Home</code> app should be destroy.<br/>
* This method should be used by implementors classes of this protocol to unload all unneeded
* resources.
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.
diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java
index fef164383..da80f6622 100644
--- a/src/com/android/launcher3/OverviewSettingsPanel.java
+++ b/src/com/android/launcher3/OverviewSettingsPanel.java
@@ -43,6 +43,7 @@ public class OverviewSettingsPanel {
String[] values = new String[]{
res.getString(R.string.home_screen_search_text),
+ res.getString(R.string.search_screen_left_text),
res.getString(R.string.scroll_effect_text),
res.getString(R.string.icon_labels),
res.getString(R.string.scrolling_wallpaper),
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 051c48a8d..3db96c2df 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1331,6 +1331,20 @@ public class Workspace extends SmoothPagedView
snapToPage(whichPage, SLOW_PAGE_SNAP_ANIMATION_DURATION, r);
}
+ @Override
+ protected void snapToPage(int whichPage, int delta, int duration, boolean immediate,
+ TimeInterpolator interpolator) {
+ super.snapToPage(whichPage, delta, duration, immediate, interpolator);
+
+ // Trigger onCustomContentLaunch if we have just snapped to the custom page.
+ int customPageIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
+ if (hasCustomContent() && whichPage == customPageIndex && !mCustomContentShowing) {
+ if(!isInOverviewMode()) {
+ mLauncher.onCustomContentLaunch();
+ }
+ }
+ }
+
protected void snapToPage(int whichPage, int duration, Runnable r) {
if (mDelayedSnapToPageRunnable != null) {
mDelayedSnapToPageRunnable.run();
@@ -1836,10 +1850,14 @@ public class Workspace extends SmoothPagedView
int customPageIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
// mCustomContentShowing can be lost if the Activity is recreated,
// So make sure it is set to the right value.
+ boolean restoreCustomContentShowing = ((customPageIndex == getCurrentPage())
+ || (customPageIndex == getNextPage()))
+ && hasCustomContent();
mCustomContentShowing = mCustomContentShowing
- || (customPageIndex == getCurrentPage()
- && hasCustomContent());
- if (mCustomContentShowing && mLauncher.isGelIntegrationEnabled()) {
+ || restoreCustomContentShowing;
+ if (mCustomContentShowing
+ && (mLauncher.getCustomContentMode() == Launcher.CustomContentMode.GEL)
+ && !isInOverviewMode()) {
moveToScreen((customPageIndex + 1), true);
}
}
@@ -5353,7 +5371,15 @@ public class Workspace extends SmoothPagedView
}
void moveToDefaultScreen(boolean animate) {
- moveToScreen(getPageIndexForScreenId(mDefaultScreenId), animate);
+ // Do not use the custom page or index -1 as default,
+ // if GEL integration is enabled.
+ int idx = getPageIndexForScreenId(mDefaultScreenId);
+ int ccIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID);
+ if(hasCustomContent() && (idx == ccIndex || idx == -1)
+ && !isInOverviewMode()) {
+ idx = 1;
+ }
+ moveToScreen(idx, animate);
}
void moveToCustomContentScreen(boolean animate) {
diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
index df9a1f05b..2dbc2aeed 100644
--- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
+++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java
@@ -97,7 +97,6 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
Resources res = mLauncher.getResources();
-
boolean current = false;
String state = "";
@@ -230,6 +229,24 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
((TextView) v.findViewById(R.id.item_state)).setText(state);
}
+ public void updateSearchPanelItem(View v) {
+ String state = "";
+ switch (mLauncher.getCustomContentMode()) {
+ case DISABLED:
+ state = mLauncher.getResources().getString(
+ R.string.setting_state_off);
+ break;
+ case GEL:
+ state = mLauncher.getResources().getString(R.string.search_panel_gel);
+ break;
+ default:
+ state = mLauncher.getResources().getString(
+ R.string.search_panel_custom_home);
+ break;
+ }
+ ((TextView) v.findViewById(R.id.item_state)).setText(state);
+ }
+
public void updateDynamicGridSizeSettingsItem(View v) {
DeviceProfile.GridSize gridSize = DeviceProfile.GridSize.getModeForValue(
SettingsProvider.getIntCustomDefault(mLauncher,
@@ -452,4 +469,26 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter {
return isDisabled;
}
+
+ private void onClickSearchPanelButton() {
+ int searchPanelVal = SettingsProvider.getIntCustomDefault(mLauncher,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_PANEL_LEFT,
+ Launcher.CustomContentMode.DISABLED.getValue());
+
+ Launcher.CustomContentMode nextCCMode =
+ Launcher.CustomContentMode.getModeForValue(searchPanelVal + 1);
+ if(nextCCMode == Launcher.CustomContentMode.GEL && !mLauncher.isGelIntegrationSupported()) {
+ // GEL is not supported, skip that option
+ searchPanelVal++;
+ }
+
+ searchPanelVal = (searchPanelVal + 1) % Launcher.CustomContentMode.values().length;
+ mLauncher.setCustomContentMode(Launcher.CustomContentMode.getModeForValue(searchPanelVal));
+
+ SettingsProvider.putInt(mLauncher,
+ SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_PANEL_LEFT,
+ searchPanelVal);
+
+ notifyDataSetChanged();
+ }
}
diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java
index f520ef2ac..2765f7681 100644
--- a/src/com/android/launcher3/settings/SettingsProvider.java
+++ b/src/com/android/launcher3/settings/SettingsProvider.java
@@ -26,6 +26,7 @@ public final class SettingsProvider {
public static final String SETTINGS_UI_HOMESCREEN_DEFAULT_SCREEN_ID = "ui_homescreen_default_screen_id";
public static final String SETTINGS_UI_HOMESCREEN_SEARCH = "ui_homescreen_search";
+ public static final String SETTINGS_UI_HOMESCREEN_SEARCH_PANEL_LEFT = "ui_homescreen_search_panel_left";
public static final String SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS = "ui_homescreen_general_hide_icon_labels";
public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_TRANSITION_EFFECT = "ui_homescreen_scrolling_transition_effect";
public static final String SETTINGS_UI_HOMESCREEN_SCROLLING_WALLPAPER_SCROLL = "ui_homescreen_scrolling_wallpaper_scroll";