diff options
author | Matt Garnes <matt@cyngn.com> | 2014-06-20 13:39:50 -0700 |
---|---|---|
committer | Matt Garnes <matt@cyngn.com> | 2014-07-15 12:02:49 -0700 |
commit | 4a65b0c3022357d2b14db196224931cc35f14417 (patch) | |
tree | a7cf6c311589d8430f0a50627d894815380ad7da /src/com/android | |
parent | 7a1a596b98941f7bda517e5c401086e57c9dff61 (diff) | |
download | android_packages_apps_Trebuchet-4a65b0c3022357d2b14db196224931cc35f14417.tar.gz android_packages_apps_Trebuchet-4a65b0c3022357d2b14db196224931cc35f14417.tar.bz2 android_packages_apps_Trebuchet-4a65b0c3022357d2b14db196224931cc35f14417.zip |
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
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/launcher/home/Home.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 79 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 28 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 74 | ||||
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 2 |
6 files changed, 143 insertions, 71 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 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(); diff --git a/src/com/android/launcher3/OverviewSettingsPanel.java b/src/com/android/launcher3/OverviewSettingsPanel.java index 9c0e4b453..e14b78942 100644 --- a/src/com/android/launcher3/OverviewSettingsPanel.java +++ b/src/com/android/launcher3/OverviewSettingsPanel.java @@ -43,25 +43,13 @@ public class OverviewSettingsPanel { res.getString(R.string.drawer_settings), res.getString(R.string.app_settings)}; - 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.icon_labels), - res.getString(R.string.scrolling_wallpaper), - res.getString(R.string.grid_size_text)}; - } else { - values = new String[]{ - res.getString(R.string.home_screen_search_text), - res.getString(R.string.scroll_effect_text), - res.getString(R.string.icon_labels), - res.getString(R.string.scrolling_wallpaper), - res.getString(R.string.grid_size_text)}; - } - - mValues = values; + mValues = 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), + res.getString(R.string.grid_size_text)}; String[] valuesDrawer = new String[] { res.getString(R.string.scroll_effect_text), @@ -80,7 +68,7 @@ public class OverviewSettingsPanel { mSettingsAdapter.addPartition(false, true); mSettingsAdapter.mPinnedHeaderCount = headers.length; - mSettingsAdapter.changeCursor(0, createCursor(headers[0], values)); + mSettingsAdapter.changeCursor(0, createCursor(headers[0], mValues)); mSettingsAdapter.changeCursor(1, createCursor(headers[1], valuesDrawer)); mSettingsAdapter.changeCursor(2, createCursor(headers[2], valuesApp)); mListView.setAdapter(mSettingsAdapter); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 63e893da1..7501dbf7d 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1309,8 +1309,6 @@ public class Workspace extends SmoothPagedView 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(); } } @@ -1833,10 +1831,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); } } @@ -4931,7 +4933,7 @@ public class Workspace extends SmoothPagedView int idx = getPageIndexForScreenId(mDefaultScreenId); int ccIndex = getPageIndexForScreenId(CUSTOM_CONTENT_SCREEN_ID); if(hasCustomContent() && (idx == ccIndex || idx == -1) - && mLauncher.isGelIntegrationEnabled()) { + && !isInOverviewMode()) { idx = 1; } moveToScreen(idx, animate); diff --git a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java index 7fb15fc12..a4a68fb85 100644 --- a/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java +++ b/src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java @@ -124,15 +124,7 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { ((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); + updateSearchPanelItem(v); } else if (title.equals(res.getString(R.string.scrolling_wallpaper))) { boolean current = SettingsProvider .getBoolean( @@ -186,6 +178,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, @@ -293,25 +303,11 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { } 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.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.restoreGelSetting(); - mLauncher.getWorkspace().updatePageScrollForCustomPage(!current); - mLauncher.setUpdateDynamicGrid(); - } + onClickSearchPanelButton(); + boolean customContentEnabled = + mLauncher.getCustomContentMode() != Launcher.CustomContentMode.DISABLED; + mLauncher.getWorkspace().updatePageScrollForCustomPage(customContentEnabled); + mLauncher.setUpdateDynamicGrid(); } else if (value.equals(res .getString(R.string.grid_size_text))) { mLauncher.onClickDynamicGridSizeButton(); @@ -370,4 +366,26 @@ public class SettingsPinnedHeaderAdapter extends PinnedHeaderListAdapter { notifyDataSetChanged(); } + + 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 32329ab83..8cde92555 100644 --- a/src/com/android/launcher3/settings/SettingsProvider.java +++ b/src/com/android/launcher3/settings/SettingsProvider.java @@ -26,7 +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_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"; |