diff options
author | Chris Wren <cwren@android.com> | 2015-12-11 15:00:30 -0500 |
---|---|---|
committer | Chris Wren <cwren@android.com> | 2015-12-11 15:00:30 -0500 |
commit | f2fb547cba78d5626a0e76184d1ce21d90d5c279 (patch) | |
tree | 5f0471d94b496da99387f7c33d06997f3a2b7d7f | |
parent | 205fde7e15f6c304f91a022bae51f8720530425f (diff) | |
download | experimental-f2fb547cba78d5626a0e76184d1ce21d90d5c279.tar.gz |
support over-lockscreen fullscreen for testing.
Change-Id: I4f2745ff735488f9eddc055902726ad5ad232ef8
4 files changed, 53 insertions, 9 deletions
diff --git a/NotificationShowcase/AndroidManifest.xml b/NotificationShowcase/AndroidManifest.xml index b260759..8153a43 100644 --- a/NotificationShowcase/AndroidManifest.xml +++ b/NotificationShowcase/AndroidManifest.xml @@ -6,9 +6,9 @@ <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="21" /> - <uses-permission android:name="android.permission.READ_CONTACTS"> + <uses-permission android:name="android.permission.READ_CONTACTS" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> - </uses-permission> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".NotificationShowcaseActivity" android:label="@string/app_name"> @@ -18,7 +18,8 @@ </intent-filter> </activity> <activity android:name=".FullScreenActivity" - android:label="@string/full_screen_name"> + android:label="@string/full_screen_name" + android:showForAllUsers="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> </intent-filter> diff --git a/NotificationShowcase/res/layout/full_screen.xml b/NotificationShowcase/res/layout/full_screen.xml index 6ff7552..a29f305 100644 --- a/NotificationShowcase/res/layout/full_screen.xml +++ b/NotificationShowcase/res/layout/full_screen.xml @@ -1,13 +1,26 @@ <?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="match_parent"> + android:layout_height="match_parent" + android:orientation="vertical" + > - <ImageView - android:layout_height="match_parent" - android:layout_width="match_parent" + <ImageView android:layout_width="match_parent" + android:layout_height="0dp" + android:orientation="vertical" + android:layout_weight="1" android:src="@drawable/page_hed" android:onClick="dismiss" /> -</FrameLayout>
\ No newline at end of file + + <Button + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_gravity="bottom" + android:text="@string/hang_up_button_label" + android:onClick="dismiss" + android:layout_weight="0" + /> + +</LinearLayout>
\ No newline at end of file diff --git a/NotificationShowcase/res/values/strings.xml b/NotificationShowcase/res/values/strings.xml index 965308e..ca534c9 100644 --- a/NotificationShowcase/res/values/strings.xml +++ b/NotificationShowcase/res/values/strings.xml @@ -121,4 +121,6 @@ <item>-1</item> <item>-2</item> </string-array> + + <string name="hang_up_button_label">hang up</string> </resources> diff --git a/NotificationShowcase/src/com/android/example/notificationshowcase/FullScreenActivity.java b/NotificationShowcase/src/com/android/example/notificationshowcase/FullScreenActivity.java index 8286f69..80578aa 100644 --- a/NotificationShowcase/src/com/android/example/notificationshowcase/FullScreenActivity.java +++ b/NotificationShowcase/src/com/android/example/notificationshowcase/FullScreenActivity.java @@ -22,17 +22,35 @@ import android.app.PendingIntent; import android.content.Context; import android.content.Intent; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; +import android.os.Message; +import android.os.PowerManager; import android.view.View; +import android.view.WindowManager; public class FullScreenActivity extends Activity { private static final String TAG = "NotificationShowcase"; public static final String EXTRA_ID = "id"; + private Handler mHandler = new Handler(Looper.getMainLooper()); + private PowerManager.WakeLock mWakeLock; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.full_screen); + + PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); + mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Incoming Call"); + mWakeLock.acquire(15 * 1000); + + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | + WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | + WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | + WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); + final Intent intent = getIntent(); if (intent != null && intent.hasExtra(EXTRA_ID)) { final int id = intent.getIntExtra(EXTRA_ID, -1); @@ -42,9 +60,19 @@ public class FullScreenActivity extends Activity { noMa.cancel(NotificationService.NOTIFICATION_ID + id); } } + + mHandler.postDelayed(new Runnable() { + @Override + public void run() { + dismiss(null); + } + }, 30 * 1000); } public void dismiss(View v) { + if (mWakeLock.isHeld()) { + mWakeLock.release(); + } finish(); } |