diff options
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | WallpaperPicker/src/android/util/Pools.java | 165 | ||||
-rw-r--r-- | res/values/cm_strings.xml | 7 | ||||
-rw-r--r-- | res/values/preferences_defaults.xml | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 38 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 17 |
7 files changed, 64 insertions, 169 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4538cfd9d..b689f9661 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -84,6 +84,8 @@ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.BROADCAST_STICKY"/> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> + <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 0e4ece733..dc9b4c69e 100644 --- a/res/values/cm_strings.xml +++ b/res/values/cm_strings.xml @@ -49,6 +49,10 @@ <string name="grid_size_custom">Custom (<xliff:g id="rows">%1$d</xliff:g> \u00d7 <xliff:g id="columns">%2$d</xliff:g>)</string> <string name="preferences_interface_homescreen_custom">Select custom size</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> + + <!-- Folder titles --> <string name="google_title" translatable="false">Google</string> <string name="play_folder_title">Play</string> @@ -77,6 +81,9 @@ <!-- 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> + <!-- Dialog --> <string name="dialog_confirm">Confirm</string> diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml index 5693dbb75..bbff0fe8a 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/Launcher.java b/src/com/android/launcher3/Launcher.java index 6ad36a21a..0094a2b85 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -284,6 +284,8 @@ public class Launcher extends Activity private static int NEW_APPS_ANIMATION_DELAY = 500; private static final int SINGLE_FRAME_DELAY = 16; + private boolean mGelIntegrationEnabled = false; + private final BroadcastReceiver mCloseSystemDialogsReceiver = new CloseSystemDialogsIntentReceiver(); private final ContentObserver mWidgetObserver = new AppWidgetResetObserver(); @@ -645,6 +647,8 @@ public class Launcher extends Activity restoreCustomContentMode(); + restoreGelSetting(); + // Determine the dynamic grid properties Point smallestSize = new Point(); Point largestSize = new Point(); @@ -697,6 +701,30 @@ public class Launcher extends Activity return false; } + protected boolean hasCustomContentToLeft() { + 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); + } + } + public boolean isGelIntegrationSupported() { final SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); @@ -730,7 +758,15 @@ public class Launcher extends Activity } /** - * 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}. */ diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index da80f6622..1bd4f894f 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -23,6 +23,7 @@ public class OverviewSettingsPanel { private View mOverviewPanel; private SettingsPinnedHeaderAdapter mSettingsAdapter; private PinnedHeaderListView mListView; + private String[] mValues; OverviewSettingsPanel(Launcher launcher, View overviewPanel) { mLauncher = launcher; @@ -177,7 +178,7 @@ public class OverviewSettingsPanel { res.getString(R.string.scrolling_wallpaper), res.getString(R.string.grid_size_text)}; 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 3db96c2df..b3da60224 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1294,6 +1294,7 @@ public class Workspace extends SmoothPagedView int ccIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID); if (hasCustomContent() && getNextPage() == ccIndex && !mCustomContentShowing) { mCustomContentShowing = true; + if (mCustomContentCallbacks != null) { mCustomContentCallbacks.onShow(false); mCustomContentShowTime = System.currentTimeMillis(); @@ -1340,7 +1341,7 @@ public class Workspace extends SmoothPagedView int customPageIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID); if (hasCustomContent() && whichPage == customPageIndex && !mCustomContentShowing) { if(!isInOverviewMode()) { - mLauncher.onCustomContentLaunch(); + mCustomContentShowing = true; } } } @@ -1434,6 +1435,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; @@ -1667,7 +1669,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() { @@ -2157,6 +2165,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); } |