diff options
-rw-r--r-- | Android.mk | 2 | ||||
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | WallpaperPicker/src/android/util/Pools.java | 165 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 5 | ||||
-rw-r--r-- | res/values/preferences_defaults.xml | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/DragLayer.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/GelIntegrationHelper.java | 100 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 50 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 53 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 32 | ||||
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 1 |
12 files changed, 261 insertions, 184 deletions
diff --git a/Android.mk b/Android.mk index fa93d17dd..2d4b0a005 100644 --- a/Android.mk +++ b/Android.mk @@ -36,7 +36,7 @@ LOCAL_AAPT_FLAGS := --auto-add-overlay LOCAL_PROTOC_OPTIMIZE_TYPE := nano LOCAL_PROTOC_FLAGS := --proto_path=$(LOCAL_PATH)/protos/ -LOCAL_SDK_VERSION := 19 +# LOCAL_SDK_VERSION := 19 LOCAL_PACKAGE_NAME := Trebuchet LOCAL_PRIVILEGED_MODULE := true diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 9e8065d36..b2c577ee1 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -56,6 +56,8 @@ <uses-permission android:name="android.permission.BIND_APPWIDGET" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> + <uses-permission android:name="android.permission.INJECT_EVENTS" /> + <uses-permission android:name="android.permission.GET_TASKS"/> <uses-permission android:name="com.android.launcher.permission.READ_SETTINGS" /> <uses-permission android:name="com.android.launcher.permission.WRITE_SETTINGS" /> <uses-permission android:name="com.android.launcher3.permission.READ_SETTINGS" /> diff --git a/WallpaperPicker/src/android/util/Pools.java b/WallpaperPicker/src/android/util/Pools.java deleted file mode 100644 index 40bab1eae..000000000 --- a/WallpaperPicker/src/android/util/Pools.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.util; - -/** - * Helper class for crating pools of objects. An example use looks like this: - * <pre> - * public class MyPooledClass { - * - * private static final SynchronizedPool<MyPooledClass> sPool = - * new SynchronizedPool<MyPooledClass>(10); - * - * public static MyPooledClass obtain() { - * MyPooledClass instance = sPool.acquire(); - * return (instance != null) ? instance : new MyPooledClass(); - * } - * - * public void recycle() { - * // Clear state if needed. - * sPool.release(this); - * } - * - * . . . - * } - * </pre> - * - * @hide - */ -public final class Pools { - - /** - * Interface for managing a pool of objects. - * - * @param <T> The pooled type. - */ - public static interface Pool<T> { - - /** - * @return An instance from the pool if such, null otherwise. - */ - public T acquire(); - - /** - * Release an instance to the pool. - * - * @param instance The instance to release. - * @return Whether the instance was put in the pool. - * - * @throws IllegalStateException If the instance is already in the pool. - */ - public boolean release(T instance); - } - - private Pools() { - /* do nothing - hiding constructor */ - } - - /** - * Simple (non-synchronized) pool of objects. - * - * @param <T> The pooled type. - */ - public static class SimplePool<T> implements Pool<T> { - private final Object[] mPool; - - private int mPoolSize; - - /** - * Creates a new instance. - * - * @param maxPoolSize The max pool size. - * - * @throws IllegalArgumentException If the max pool size is less than zero. - */ - public SimplePool(int maxPoolSize) { - if (maxPoolSize <= 0) { - throw new IllegalArgumentException("The max pool size must be > 0"); - } - mPool = new Object[maxPoolSize]; - } - - @Override - @SuppressWarnings("unchecked") - public T acquire() { - if (mPoolSize > 0) { - final int lastPooledIndex = mPoolSize - 1; - T instance = (T) mPool[lastPooledIndex]; - mPool[lastPooledIndex] = null; - mPoolSize--; - return instance; - } - return null; - } - - @Override - public boolean release(T instance) { - if (isInPool(instance)) { - throw new IllegalStateException("Already in the pool!"); - } - if (mPoolSize < mPool.length) { - mPool[mPoolSize] = instance; - mPoolSize++; - return true; - } - return false; - } - - private boolean isInPool(T instance) { - for (int i = 0; i < mPoolSize; i++) { - if (mPool[i] == instance) { - return true; - } - } - return false; - } - } - - /** - * Synchronized) pool of objects. - * - * @param <T> The pooled type. - */ - public static class SynchronizedPool<T> extends SimplePool<T> { - private final Object mLock = new Object(); - - /** - * Creates a new instance. - * - * @param maxPoolSize The max pool size. - * - * @throws IllegalArgumentException If the max pool size is less than zero. - */ - public SynchronizedPool(int maxPoolSize) { - super(maxPoolSize); - } - - @Override - public T acquire() { - synchronized (mLock) { - return super.acquire(); - } - } - - @Override - public boolean release(T element) { - synchronized (mLock) { - return super.release(element); - } - } - } -}
\ No newline at end of file diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml index 4d24dffcc..5681a769d 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -68,6 +68,9 @@ <string name="preferences_interface_drawer_hide_icon_labels_title">Hide icon labels</string> <string name="preferences_interface_drawer_hide_icon_labels_summary">Hide icon labels in drawer</string> + <!-- Settings toast messages --> + <string name="preferences_search_screen_left_unsupported_toast">You must have a supported search app and CyanogenMod to use this feature.</string> + <!-- Dock --> <string name="preferences_interface_dock_title">Dock</string> @@ -106,6 +109,8 @@ <string name="hide_icon_labels">Hide icon labels</string> <!-- Protected Apps --> <string name="protected_app_settings">Protected apps</string> + <!-- Text for hiding/showing search screen on left (if installed) --> + <string name="search_screen_left_text">Search panel</string> <!-- Settings states --> <string name="setting_state_on">ON</string> <string name="setting_state_off">OFF</string> diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml index 28d8ce857..b6ae9a6e6 100644 --- a/res/values/preferences_defaults.xml +++ b/res/values/preferences_defaults.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <resources> <bool name="preferences_interface_homescreen_search_default">true</bool> + <bool name="preferences_interface_homescreen_search_screen_left_default">false</bool> <string name="preferences_interface_homescreen_scrolling_transition_effect">none</string> <bool name="preferences_interface_homescreen_scrolling_wallpaper_scroll_default">true</bool> <bool name="preferences_interface_homescreen_scrolling_page_outlines_default">@bool/config_workspaceDefaultShowOutlines</bool> diff --git a/src/com/android/launcher3/DragLayer.java b/src/com/android/launcher3/DragLayer.java index b832494a2..3ff4293af 100644 --- a/src/com/android/launcher3/DragLayer.java +++ b/src/com/android/launcher3/DragLayer.java @@ -814,7 +814,7 @@ public class DragLayer extends FrameLayout implements ViewGroup.OnHierarchyChang /** * Note: this is a reimplementation of View.isLayoutRtl() since that is currently hidden api. */ - private boolean isLayoutRtl() { + public boolean isLayoutRtl() { return (getLayoutDirection() == LAYOUT_DIRECTION_RTL); } diff --git a/src/com/android/launcher3/GelIntegrationHelper.java b/src/com/android/launcher3/GelIntegrationHelper.java new file mode 100644 index 000000000..abda537a2 --- /dev/null +++ b/src/com/android/launcher3/GelIntegrationHelper.java @@ -0,0 +1,100 @@ +package com.android.launcher3; + +import android.app.Activity; +import android.app.ActivityManager; +import android.content.ComponentName; +import android.content.Intent; +import android.service.gesture.EdgeGestureManager; +import com.android.internal.util.gesture.EdgeGesturePosition; + +import java.util.List; + +/** + * A singleton wrapper class for GEL Integration. + * Requires EdgeGestureManager functionality that is only available + * in CyanogenMod. + */ +public class GelIntegrationHelper { + // The Intent for the search activity (resolves to Google Now when installed) + public final static String INTENT_ACTION_ASSIST = "android.intent.action.ASSIST"; + + private static final String GEL_ACTIVITY = "com.google.android.velvet.ui.VelvetActivity"; + 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_NO_EDGE = -1; + + private EdgeGestureManager.EdgeGestureActivationListener mEdgeGestureActivationListener = null; + private static GelIntegrationHelper sInstance; + + private GelIntegrationHelper() {} + + public static GelIntegrationHelper getInstance() { + if(sInstance == null) { + sInstance = new GelIntegrationHelper(); + } + return sInstance; + } + + /** + * 1. Registers an EdgeGestureActivationListener with the EdgeGestureManager so that + * the user can return to Trebuchet when they swipe from the right edge of the device. + * 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) { + EdgeGestureManager edgeGestureManager = EdgeGestureManager.getInstance(); + if(mEdgeGestureActivationListener == null) { + mEdgeGestureActivationListener = new EdgeGestureManager.EdgeGestureActivationListener() { + ActivityManager mAm = (ActivityManager) + launcherActivity.getSystemService(Activity.ACTIVITY_SERVICE); + + @Override + public void onEdgeGestureActivation(int touchX, int touchY, + EdgeGesturePosition position, int flags) { + // Retrieve the top level activity information + List< ActivityManager.RunningTaskInfo > taskInfo = mAm.getRunningTasks(1); + ComponentName topActivityComponentInfo = taskInfo.get(0).topActivity; + String topActivityClassName = topActivityComponentInfo.getClassName(); + String topActivityPackageName = topActivityComponentInfo.getPackageName(); + + // If the top level activity is Google Now, return to home. + // Otherwise, do nothing. + if(GEL_ACTIVITY.equals(topActivityClassName) + && GEL_PACKAGE_NAME.equals(topActivityPackageName)) { + Intent homeIntent = new Intent(Intent.ACTION_MAIN); + homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + homeIntent.addCategory(Intent.CATEGORY_HOME); + launcherActivity.startActivity(homeIntent); + launcherActivity.overridePendingTransition(0, R.anim.exit_out_left); + dropEventsUntilLift(); + } + } + }; + edgeGestureManager.setEdgeGestureActivationListener(mEdgeGestureActivationListener); + } + mEdgeGestureActivationListener.restoreListenerState(); + edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, + EDGE_GESTURE_SERVICE_RIGHT_EDGE); + + // Start the Google Now Activity + Intent i = new Intent(INTENT_ACTION_ASSIST); + launcherActivity.startActivity(i); + launcherActivity.overridePendingTransition(0, R.anim.exit_out_right); + } + + /** + * Handle necessary cleanup and reset tasks for GEL integration, to be called from onResume. + */ + public void handleGelResume() { + // If there is an active EdgeGestureActivationListener for GEL integration, + // it should stop listening when we have resumed the launcher. + if(mEdgeGestureActivationListener != null) { + EdgeGestureManager edgeGestureManager = EdgeGestureManager.getInstance(); + // Update the listener so it is not listening to any postions (-1) + edgeGestureManager.updateEdgeGestureActivationListener(mEdgeGestureActivationListener, + EDGE_GESTURE_SERVICE_NO_EDGE); + } + } + +} diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 1209355ea..d30cde45b 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -241,6 +241,8 @@ 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(); @@ -484,6 +486,8 @@ public class Launcher extends Activity mSavedState = savedInstanceState; restoreState(mSavedState); + restoreGelSetting(); + if (PROFILE_STARTUP) { android.os.Debug.stopMethodTracing(); } @@ -531,6 +535,12 @@ 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); + } + private void initializeDynamicGrid() { LauncherAppState.setApplicationContext(getApplicationContext()); LauncherAppState app = LauncherAppState.getInstance(); @@ -539,6 +549,8 @@ public class Launcher extends Activity SettingsProvider.SETTINGS_UI_HOMESCREEN_HIDE_ICON_LABELS, R.bool.preferences_interface_homescreen_hide_icon_labels_default); + restoreGelSetting(); + // Determine the dynamic grid properties Point smallestSize = new Point(); Point largestSize = new Point(); @@ -565,13 +577,41 @@ public class Launcher extends Activity sPausedFromUserAction = true; } - /** To be overriden by subclasses to hint to Launcher that we have custom content */ + /** To be overridden 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); + } } /** - * To be overridden by subclasses to populate the custom content container and call + * 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"); + } + + /** + * To be overridden by subclasses to create the custom content and call * {@link #addToCustomContentPage}. This will only be invoked if * {@link #hasCustomContentToLeft()} is {@code true}. */ @@ -1001,6 +1041,10 @@ public class Launcher extends Activity } super.onResume(); + if(isGelIntegrationEnabled() && isGelIntegrationSupported()) { + GelIntegrationHelper.getInstance().handleGelResume(); + } + // Restore the previous launcher state if (mOnResumeState == State.WORKSPACE) { showWorkspace(false); diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index fd8095f87..e3fbfa3ed 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -24,6 +24,7 @@ public class OverviewSettingsPanel { private View mOverviewPanel; private SettingsPinnedHeaderAdapter mSettingsAdapter; private PinnedHeaderListView mListView; + private String[] mValues; OverviewSettingsPanel(Launcher launcher, View overviewPanel) { mLauncher = launcher; @@ -40,11 +41,25 @@ public class OverviewSettingsPanel { String[] headers = new String[] { res.getString(R.string.home_screen_settings), res.getString(R.string.drawer_settings)}; - String[] values = new String[] { - res.getString(R.string.home_screen_search_text), - res.getString(R.string.scroll_effect_text), - res.getString(R.string.larger_icons_text), - res.getString(R.string.hide_icon_labels)}; + + String[] values; + if(mLauncher.isGelIntegrationSupported()) { + 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.larger_icons_text), + res.getString(R.string.hide_icon_labels)}; + } else { + values = new String[]{ + res.getString(R.string.home_screen_search_text), + res.getString(R.string.scroll_effect_text), + res.getString(R.string.larger_icons_text), + res.getString(R.string.hide_icon_labels)}; + } + + mValues = values; + String[] valuesDrawer = new String[] { res.getString(R.string.scroll_effect_text), res.getString(R.string.drawer_sorting_text), @@ -162,13 +177,8 @@ public class OverviewSettingsPanel { mSettingsAdapter.changeCursor(0, createCursor(res .getString(R.string.home_screen_settings), new String[]{})); } else { - String[] values = new String[] { - res.getString(R.string.home_screen_search_text), - res.getString(R.string.scroll_effect_text), - res.getString(R.string.larger_icons_text), - res.getString(R.string.hide_icon_labels)}; mSettingsAdapter.changeCursor(0, createCursor(res - .getString(R.string.home_screen_settings), values)); + .getString(R.string.home_screen_settings), mValues)); } // Make sure overview panel is drawn above apps customize and collapsed diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index bba10a118..a5a1f5460 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1257,12 +1257,13 @@ public class Workspace extends SmoothPagedView if (hasCustomContent() && getNextPage() == 0 && !mCustomContentShowing) { mCustomContentShowing = true; + if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onShow(); mCustomContentShowTime = System.currentTimeMillis(); mLauncher.updateVoiceButtonProxyVisible(false); } - } else if (hasCustomContent() && getNextPage() != 0 && mCustomContentShowing) { + } else if (hasCustomContent() && mCustomContentShowing) { mCustomContentShowing = false; if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onHide(); @@ -1296,6 +1297,22 @@ 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()) { + mCustomContentShowing = true; + // Start Google Now and register the gesture to return to Trebuchet + mLauncher.onCustomContentLaunch(); + } + } + } + protected void snapToPage(int whichPage, int duration, Runnable r) { if (mDelayedSnapToPageRunnable != null) { mDelayedSnapToPageRunnable.run(); @@ -1379,6 +1396,7 @@ public class Workspace extends SmoothPagedView int firstIndex = numCustomPages(); // Exclude the last extra empty screen (if we have > MIN_PARALLAX_PAGE_SPAN pages) int lastIndex = getChildCount() - 1 - emptyExtraPages; + if (isLayoutRtl()) { int temp = firstIndex; firstIndex = lastIndex; @@ -1619,7 +1637,13 @@ public class Workspace extends SmoothPagedView } public int numCustomPages() { - return hasCustomContent() ? 1 : 0; + // GEL integration is a special case (not a *real* screen) and should + // not be counted as custom content. + if(mLauncher.isGelIntegrationEnabled()) { + return 0; + } else { + return hasCustomContent() ? 1 : 0; + } } public boolean isOnOrMovingToCustomContent() { @@ -1801,6 +1825,16 @@ public class Workspace extends SmoothPagedView // Force the wallpaper offset steps to be set again, because another app might have changed // them mLastSetWallpaperOffsetSteps = 0f; + + // Never resume to the custom page if GEL integration is enabled. + 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. + mCustomContentShowing = mCustomContentShowing + || (customPageIndex == getCurrentPage() && hasCustomContent()); + if (mCustomContentShowing && mLauncher.isGelIntegrationEnabled()) { + moveToScreen((customPageIndex + 1), true); + } } @Override @@ -2082,6 +2116,11 @@ public class Workspace extends SmoothPagedView int start = numCustomPages(); int end = getChildCount() - 1; + // For GEL integration, do not include the first page (GEL) + if(mLauncher.isGelIntegrationEnabled()) { + start += 1; + } + range[0] = Math.max(0, Math.min(start, getChildCount() - 1)); range[1] = Math.max(0, end); } @@ -4811,7 +4850,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) + && mLauncher.isGelIntegrationEnabled()) { + 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 499995375..f096ee0cb 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; +import android.widget.Toast; import com.android.launcher3.Launcher; import com.android.launcher3.OverviewSettingsPanel; import com.android.launcher3.PagedView; @@ -119,6 +120,17 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { R.string.setting_state_on) : res.getString( R.string.setting_state_off); ((TextView) v.findViewById(R.id.item_state)).setText(state); + } else if (title.equals(res + .getString(R.string.search_screen_left_text))) { + boolean current = SettingsProvider + .getBoolean( + mContext, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, + R.bool.preferences_interface_homescreen_search_screen_left_default); + String state = current ? res.getString( + R.string.setting_state_on) : res.getString( + R.string.setting_state_off); + ((TextView) v.findViewById(R.id.item_state)).setText(state); } v.setTag(partition); @@ -228,6 +240,26 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { intent.setClassName(OverviewSettingsPanel.ANDROID_SETTINGS, OverviewSettingsPanel.ANDROID_PROTECTED_APPS); mLauncher.startActivity(intent); + } else if (value.equals(res + .getString(R.string.search_screen_left_text)) && + ((Integer)v.getTag() == OverviewSettingsPanel.HOME_SETTINGS_POSITION)) { + + boolean current = SettingsProvider.getBoolean(mContext, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, + R.bool.preferences_interface_homescreen_search_screen_left_default); + + // If GEL integration is not supported, do not allow the user to turn it on. + if(!current && !mLauncher.isGelIntegrationSupported()) { + Toast.makeText(mLauncher.getApplicationContext(), + res.getString(R.string.preferences_search_screen_left_unsupported_toast), + Toast.LENGTH_SHORT).show(); + } else { + onSettingsBooleanChanged( + v, + SettingsProvider.SETTINGS_UI_HOMESCREEN_SEARCH_SCREEN_LEFT, + R.bool.preferences_interface_homescreen_search_screen_left_default); + mLauncher.updateDynamicGrid(); + } } View defaultHome = mLauncher.findViewById(R.id.default_home_screen_panel); diff --git a/src/com/android/launcher3/settings/SettingsProvider.java b/src/com/android/launcher3/settings/SettingsProvider.java index 5be13a44d..de1d4002e 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_SCREEN_LEFT = "ui_homescreen_search_screen_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"; |