diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher/home/Home.java | 17 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 78 | ||||
-rw-r--r-- | src/com/android/launcher3/OverviewSettingsPanel.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 34 | ||||
-rw-r--r-- | src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java | 41 | ||||
-rw-r--r-- | src/com/android/launcher3/settings/SettingsProvider.java | 1 | ||||
-rw-r--r-- | src/org/cyanogenmod/trebuchet/CustomHomeLauncher.java (renamed from src/org/cyanogenmod/trebuchet/TrebuchetLauncher.java) | 33 | ||||
-rw-r--r-- | src/org/cyanogenmod/trebuchet/home/HomeWrapper.java | 32 |
8 files changed, 217 insertions, 20 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"; diff --git a/src/org/cyanogenmod/trebuchet/TrebuchetLauncher.java b/src/org/cyanogenmod/trebuchet/CustomHomeLauncher.java index ec91e10d7..47c9c3b2c 100644 --- a/src/org/cyanogenmod/trebuchet/TrebuchetLauncher.java +++ b/src/org/cyanogenmod/trebuchet/CustomHomeLauncher.java @@ -40,9 +40,9 @@ import org.cyanogenmod.trebuchet.home.HomeWrapper; import java.lang.Override; -public class TrebuchetLauncher extends Launcher { +public class CustomHomeLauncher extends Launcher { - private static final String TAG = "TrebuchetLauncher"; + private static final String TAG = "CustomHomeLauncher"; private static final boolean DEBUG = false; private static final float MIN_PROGRESS = 0; @@ -54,7 +54,8 @@ public class TrebuchetLauncher extends Launcher { private final ComponentName mComponentName; private final HomeWrapper mInstance; - private HomeAppStub(int uid, ComponentName componentName, Context context) + private HomeAppStub(int uid, ComponentName componentName, + Context context, Context homeActivityContext) throws SecurityException, ReflectiveOperationException { super(); mUid = uid; @@ -64,7 +65,8 @@ public class TrebuchetLauncher extends Launcher { ClassLoader classloader = context.getClassLoader(); Class<?> homeInterface = classloader.loadClass(Home.class.getName()); Class<?> homeClazz = classloader.loadClass(mComponentName.getClassName()); - mInstance = new HomeWrapper(context, homeInterface, homeClazz.newInstance()); + mInstance = new HomeWrapper(context, homeInterface, + homeClazz.newInstance(), homeActivityContext); } @Override @@ -197,8 +199,8 @@ public class TrebuchetLauncher extends Launcher { } @Override - protected boolean hasCustomContentToLeft() { - return mCurrentHomeApp != null && super.hasCustomContentToLeft(); + protected boolean isCustomHomeActive() { + return mCurrentHomeApp != null; } @Override @@ -212,7 +214,10 @@ public class TrebuchetLauncher extends Launcher { if (mCurrentHomeApp != null) { mQsbScroller = addToCustomContentPage(mCurrentHomeApp.mInstance.createCustomView(), mCustomContentCallbacks, mCurrentHomeApp.mInstance.getName()); - mQsbScroller.setScrollY(200); + + if (!isCustomContentModeGel()) { + mCurrentHomeApp.mInstance.setShowContent(true); + } } } @@ -230,6 +235,18 @@ public class TrebuchetLauncher extends Launcher { mCurrentHomeApp.mInstance.onRequestSearch(mode); } + @Override + public void updateDynamicGrid() { + super.updateDynamicGrid(); + + if (isCustomContentModeGel() && mCurrentHomeApp != null) { + mCurrentHomeApp.mInstance.setShowContent(false); + } else if (getCustomContentMode() == CustomContentMode.CUSTOM_HOME + && mCurrentHomeApp != null) { + mCurrentHomeApp.mInstance.setShowContent(true); + } + } + private synchronized void obtainCurrentHomeAppStubLocked(boolean invalidate) { if (DEBUG) Log.d(TAG, "obtainCurrentHomeAppStubLocked called (" + invalidate + ")"); @@ -255,7 +272,7 @@ public class TrebuchetLauncher extends Launcher { continue; } try { - mCurrentHomeApp = new HomeAppStub(key, pkg, ctx); + mCurrentHomeApp = new HomeAppStub(key, pkg, ctx, this); } catch (ReflectiveOperationException ex) { if (!DEBUG) { Log.w(TAG, "Cannot instantiate home package: " + qualifiedPkg + ". Ignored."); diff --git a/src/org/cyanogenmod/trebuchet/home/HomeWrapper.java b/src/org/cyanogenmod/trebuchet/home/HomeWrapper.java index df8b6cae6..1c7dfda66 100644 --- a/src/org/cyanogenmod/trebuchet/home/HomeWrapper.java +++ b/src/org/cyanogenmod/trebuchet/home/HomeWrapper.java @@ -18,6 +18,7 @@ package org.cyanogenmod.trebuchet.home; import android.content.Context; import android.util.Base64; +import android.util.Log; import android.util.SparseArray; import android.view.View; @@ -45,6 +46,7 @@ public class HomeWrapper { private static final int M_LAST_ID = M_ID_GETOPERATIONFLAGS + 1; private final Context mContext; + private final Context mHostActivityContext; private final Class<?> mClass; private final Object mInstance; @@ -53,12 +55,16 @@ public class HomeWrapper { private final int mNotificationFlags; private final int mOperationFlags; - public HomeWrapper(Context context, Class<?> cls, Object instance) throws SecurityException { + public HomeWrapper(Context context, Class<?> cls, + Object instance, + Context hostActivityContext) throws SecurityException { super(); mContext = context; + mHostActivityContext = hostActivityContext; mClass = cls; mInstance = instance; cachedMethods = new SparseArray<Method>(M_LAST_ID); + setHostActivityContext(); final String sha1 = createDigest(cls); if (!sha1.equals(Home.SIGNATURE)) { @@ -71,11 +77,35 @@ public class HomeWrapper { mOperationFlags = getOperationFlags(); } + /** @see Home#setHostActivityContext(Context) **/ + private void setHostActivityContext() { + try { + Method method = mClass.getMethod("setHostActivityContext", Context.class); + method.invoke(mInstance, mHostActivityContext); + } catch (ReflectiveOperationException ex) { + throw new SecurityException(ex); + } + } + /** @see Home#onStart(Context) **/ public void onStart() { invokeVoidContextMethod(M_ID_ONSTART, "onStart"); } + /** + * Load and show the content of this home app if true, + * hide and remove providers if false. + * @param showContent Should content be shown + */ + public void setShowContent(boolean showContent) { + try { + Method method = mClass.getMethod("setShowContent", Context.class, boolean.class); + method.invoke(mInstance, mContext, showContent); + } catch (ReflectiveOperationException ex) { + throw new SecurityException(ex); + } + } + /** @see Home#onDestroy(Context) **/ public void onDestroy() { invokeVoidContextMethod(M_ID_ONDESTROY, "onDestroy"); |