summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml8
-rw-r--r--res/values/cm_strings.xml7
-rw-r--r--res/values/preferences_defaults.xml1
-rw-r--r--src/com/android/launcher/home/Home.java17
-rw-r--r--src/com/android/launcher3/Launcher.java79
-rw-r--r--src/com/android/launcher3/OverviewSettingsPanel.java28
-rw-r--r--src/com/android/launcher3/Workspace.java14
-rw-r--r--src/com/android/launcher3/list/SettingsPinnedHeaderAdapter.java74
-rw-r--r--src/com/android/launcher3/settings/SettingsProvider.java2
-rw-r--r--src/org/cyanogenmod/trebuchet/CustomHomeLauncher.java (renamed from src/org/cyanogenmod/trebuchet/TrebuchetLauncher.java)32
-rw-r--r--src/org/cyanogenmod/trebuchet/home/HomeWrapper.java32
11 files changed, 213 insertions, 81 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index dd1761512..830e2c4b4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -52,7 +52,13 @@
android:name="com.android.launcher3.permission.RECEIVE_LAUNCH_BROADCASTS"
android:protectionLevel="signature"
/>
+ <permission
+ android:name="com.google.android.apps.dashclock.permission.READ_EXTENSION_DATA"
+ android:label="@string/permission_label_read_extension_data"
+ android:description="@string/permission_desc_read_extension_data"
+ android:protectionLevel="normal" />
+ <uses-permission android:name="com.google.android.apps.dashclock.permission.READ_EXTENSION_DATA" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.SET_WALLPAPER" />
<uses-permission android:name="android.permission.SET_WALLPAPER_HINTS" />
@@ -78,7 +84,7 @@
android:requiredForAllUsers="true"
android:supportsRtl="true">
<activity
- android:name="org.cyanogenmod.trebuchet.TrebuchetLauncher"
+ android:name="org.cyanogenmod.trebuchet.CustomHomeLauncher"
android:launchMode="singleTask"
android:clearTaskOnLaunch="true"
android:stateNotNeeded="true"
diff --git a/res/values/cm_strings.xml b/res/values/cm_strings.xml
index 72bbb4a1a..76c48ad45 100644
--- a/res/values/cm_strings.xml
+++ b/res/values/cm_strings.xml
@@ -29,6 +29,10 @@
<string name="setting_state_on">ON</string>
<string name="setting_state_off">OFF</string>
+ <!-- Search Panel states -->
+ <string name="search_panel_gel">Google Now</string>
+ <string name="search_panel_custom_home">CM Home</string>
+
<!-- Themes button -->
<string name="themes_button_text">Themes</string>
@@ -88,4 +92,7 @@
<!-- Dialog -->
<string name="dialog_confirm">Confirm</string>
+ <!-- Dashclock permission info (for CMHome) -->
+ <string name="permission_desc_read_extension_data">Allows requesting DashClock extension data</string>
+ <string name="permission_label_read_extension_data">Request DashClock extension data</string>
</resources>
diff --git a/res/values/preferences_defaults.xml b/res/values/preferences_defaults.xml
index 64d904a0f..a3b835dc6 100644
--- a/res/values/preferences_defaults.xml
+++ b/res/values/preferences_defaults.xml
@@ -1,7 +1,6 @@
<?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/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";
diff --git a/src/org/cyanogenmod/trebuchet/TrebuchetLauncher.java b/src/org/cyanogenmod/trebuchet/CustomHomeLauncher.java
index 3c5e6a70b..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,6 +214,10 @@ public class TrebuchetLauncher extends Launcher {
if (mCurrentHomeApp != null) {
mQsbScroller = addToCustomContentPage(mCurrentHomeApp.mInstance.createCustomView(),
mCustomContentCallbacks, mCurrentHomeApp.mInstance.getName());
+
+ if (!isCustomContentModeGel()) {
+ mCurrentHomeApp.mInstance.setShowContent(true);
+ }
}
}
@@ -229,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 + ")");
@@ -254,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");