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/org | |
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/org')
-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.java | 32 |
2 files changed, 56 insertions, 8 deletions
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"); |