aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/cyanogenmod/externalviews/ExternalView.java9
-rw-r--r--src/java/cyanogenmod/externalviews/ExternalViewProviderService.java26
-rw-r--r--src/java/cyanogenmod/externalviews/KeyguardExternalView.java44
-rw-r--r--src/java/cyanogenmod/externalviews/KeyguardExternalViewProviderService.java48
4 files changed, 113 insertions, 14 deletions
diff --git a/src/java/cyanogenmod/externalviews/ExternalView.java b/src/java/cyanogenmod/externalviews/ExternalView.java
index a593af3..3c3adb4 100644
--- a/src/java/cyanogenmod/externalviews/ExternalView.java
+++ b/src/java/cyanogenmod/externalviews/ExternalView.java
@@ -39,10 +39,11 @@ import java.util.LinkedList;
public class ExternalView extends View implements Application.ActivityLifecycleCallbacks,
ViewTreeObserver.OnPreDrawListener {
- private Context mContext;
private LinkedList<Runnable> mQueue = new LinkedList<Runnable>();
- private volatile IExternalViewProvider mExternalViewProvider;
- private final ExternalViewProperties mExternalViewProperties;
+
+ protected Context mContext;
+ protected final ExternalViewProperties mExternalViewProperties;
+ protected volatile IExternalViewProvider mExternalViewProvider;
public ExternalView(Context context, AttributeSet attrs) {
this(context, attrs, null);
@@ -94,7 +95,7 @@ public class ExternalView extends View implements Application.ActivityLifecycleC
}
}
- private void performAction(Runnable r) {
+ protected void performAction(Runnable r) {
if (mExternalViewProvider != null) {
r.run();
} else {
diff --git a/src/java/cyanogenmod/externalviews/ExternalViewProviderService.java b/src/java/cyanogenmod/externalviews/ExternalViewProviderService.java
index 4523002..b15e01a 100644
--- a/src/java/cyanogenmod/externalviews/ExternalViewProviderService.java
+++ b/src/java/cyanogenmod/externalviews/ExternalViewProviderService.java
@@ -81,6 +81,12 @@ public abstract class ExternalViewProviderService extends Service {
protected abstract Provider createExternalView(Bundle options);
protected abstract class Provider {
+ public static final int DEFAULT_WINDOW_TYPE = WindowManager.LayoutParams.TYPE_PHONE;
+ public static final int DEFAULT_WINDOW_FLAGS =
+ WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
+ WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;;
+
private final class ProviderImpl extends IExternalViewProvider.Stub {
private final Window mWindow;
private final WindowManager.LayoutParams mParams;
@@ -88,15 +94,13 @@ public abstract class ExternalViewProviderService extends Service {
private boolean mShouldShow = true;
private boolean mAskedShow = false;
- public ProviderImpl() {
+ public ProviderImpl(Provider provider) {
mWindow = new PhoneWindow(ExternalViewProviderService.this);
((ViewGroup) mWindow.getDecorView()).addView(onCreateView());
mParams = new WindowManager.LayoutParams();
- mParams.type = WindowManager.LayoutParams.TYPE_PHONE;
- mParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
- WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
- WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
+ mParams.type = provider.getWindowType();
+ mParams.flags = provider.getWindowFlags();
mParams.gravity = Gravity.LEFT | Gravity.TOP;
mParams.format = PixelFormat.TRANSPARENT;
}
@@ -202,7 +206,7 @@ public abstract class ExternalViewProviderService extends Service {
}
}
- private final ProviderImpl mImpl = new ProviderImpl();
+ private final ProviderImpl mImpl = new ProviderImpl(this);
private final Bundle mOptions;
protected Provider(Bundle options) {
@@ -220,5 +224,13 @@ public abstract class ExternalViewProviderService extends Service {
protected void onPause() {}
protected void onStop() {}
protected void onDetach() {}
+
+ /*package*/ int getWindowType() {
+ return DEFAULT_WINDOW_TYPE;
+ }
+
+ /*package*/ int getWindowFlags() {
+ return DEFAULT_WINDOW_FLAGS;
+ }
}
-}
+} \ No newline at end of file
diff --git a/src/java/cyanogenmod/externalviews/KeyguardExternalView.java b/src/java/cyanogenmod/externalviews/KeyguardExternalView.java
index 07098a9..516422f 100644
--- a/src/java/cyanogenmod/externalviews/KeyguardExternalView.java
+++ b/src/java/cyanogenmod/externalviews/KeyguardExternalView.java
@@ -13,34 +13,72 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package cyanogenmod.externalviews;
import android.content.Context;
import android.content.ComponentName;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.os.RemoteException;
import android.util.AttributeSet;
+import android.view.WindowManager;
+/**
+ * TODO: unhide once documented and finalized
+ * @hide
+ */
public final class KeyguardExternalView extends ExternalView {
public static final String EXTRA_PERMISSION_LIST = "permissions_list";
public static final String CATEGORY_KEYGUARD_GRANT_PERMISSION
= "org.cyanogenmod.intent.category.KEYGUARD_GRANT_PERMISSION";
+ private final Point mDisplaySize;
+
public KeyguardExternalView(Context context, AttributeSet attrs) {
- super(context,attrs);
+ this(context, attrs, null);
}
public KeyguardExternalView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context,attrs,defStyleAttr);
+ this(context,attrs);
}
public KeyguardExternalView(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
- super(context,attrs,defStyleAttr,defStyleRes);
+ this(context,attrs);
}
public KeyguardExternalView(Context context, AttributeSet attributeSet,
ComponentName componentName) {
super(context,attributeSet,componentName);
+ mDisplaySize = new Point();
+ WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ wm.getDefaultDisplay().getRealSize(mDisplaySize);
}
+ @Override
+ public boolean onPreDraw() {
+ if (!mExternalViewProperties.hasChanged()) {
+ return true;
+ }
+ // keyguard views always take up the full screen when visible
+ final int x = mExternalViewProperties.getX();
+ final int y = mExternalViewProperties.getY();
+ final int width = mDisplaySize.x - x;
+ final int height = mDisplaySize.y - y;
+ final boolean visible = mExternalViewProperties.isVisible();
+ final Rect clipRect = new Rect(x, y, width + x, height + y);
+ performAction(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ mExternalViewProvider.alterWindow(x, y, width, height, visible,
+ clipRect);
+ } catch (RemoteException e) {
+ }
+ }
+ });
+ return true;
+ }
}
diff --git a/src/java/cyanogenmod/externalviews/KeyguardExternalViewProviderService.java b/src/java/cyanogenmod/externalviews/KeyguardExternalViewProviderService.java
new file mode 100644
index 0000000..208b667
--- /dev/null
+++ b/src/java/cyanogenmod/externalviews/KeyguardExternalViewProviderService.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2015 The CyanogenMod 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 cyanogenmod.externalviews;
+
+import android.os.Bundle;
+import android.view.WindowManager;
+
+/**
+ * TODO: unhide once documented and finalized
+ * @hide
+ */
+public abstract class KeyguardExternalViewProviderService extends ExternalViewProviderService {
+
+ private static final String TAG = KeyguardExternalViewProviderService.class.getSimpleName();
+ private static final boolean DEBUG = false;
+
+ protected abstract class Provider extends ExternalViewProviderService.Provider {
+ protected Provider(Bundle options) {
+ super(options);
+ }
+
+ /*package*/ final int getWindowType() {
+ return WindowManager.LayoutParams.TYPE_KEYGUARD_PANEL;
+ }
+
+ /*package*/ final int getWindowFlags() {
+ return WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL |
+ WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS |
+ WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN |
+ WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
+ WindowManager.LayoutParams.FLAG_FULLSCREEN;
+ }
+ }
+}