PIP: Implement the initial version of onboarding screen
Redlines and assets will be applied later.
Bug: 26676479
Change-Id: I1a42fad0b918681c64ae84abb1bff8fac3289004
diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml
index 2713fb5..c74e411 100644
--- a/packages/SystemUI/AndroidManifest.xml
+++ b/packages/SystemUI/AndroidManifest.xml
@@ -349,6 +349,12 @@
android:resizeable="true"
android:supportsPictureInPicture="true"
android:excludeFromRecents="true" />
+ <activity
+ android:name="com.android.systemui.tv.pip.PipOnboardingActivity"
+ android:exported="true"
+ android:theme="@style/PipTheme"
+ android:launchMode="singleTop"
+ android:excludeFromRecents="true" />
<!-- platform logo easter egg activity -->
<activity
diff --git a/packages/SystemUI/res/layout/tv_pip_menu.xml b/packages/SystemUI/res/layout/tv_pip_menu.xml
index a638d17..3562c64 100644
--- a/packages/SystemUI/res/layout/tv_pip_menu.xml
+++ b/packages/SystemUI/res/layout/tv_pip_menu.xml
@@ -17,45 +17,37 @@
*/
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <FrameLayout
- android:layout_alignParentEnd="true"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:paddingStart="10dp"
- android:paddingEnd="10dp"
- android:background="#88FFFFFF">
- <LinearLayout
- android:orientation="vertical"
- android:layout_gravity="center_vertical"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="end"
+ android:paddingStart="10dp"
+ android:paddingEnd="10dp"
+ android:background="#88FFFFFF"
+ android:gravity="center_vertical" >
- <Button android:id="@+id/full"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/pip_fullscreen"
- android:textSize="10sp"
- android:focusable="true" />
+ <Button android:id="@+id/full"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/pip_fullscreen"
+ android:textSize="10sp"
+ android:focusable="true" />
- <Button android:id="@+id/exit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/pip_exit"
- android:textSize="10sp"
- android:focusable="true" />
+ <Button android:id="@+id/exit"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/pip_exit"
+ android:textSize="10sp"
+ android:focusable="true" />
- <Button android:id="@+id/cancel"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:text="@string/pip_cancel"
- android:textSize="10sp"
- android:focusable="true" />
- </LinearLayout>
- </FrameLayout>
-</RelativeLayout>
+ <Button android:id="@+id/cancel"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/pip_cancel"
+ android:textSize="10sp"
+ android:focusable="true" />
+</LinearLayout>
diff --git a/packages/SystemUI/res/layout/tv_pip_onboarding.xml b/packages/SystemUI/res/layout/tv_pip_onboarding.xml
new file mode 100644
index 0000000..ef39555
--- /dev/null
+++ b/packages/SystemUI/res/layout/tv_pip_onboarding.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+**
+** Copyright 2016, The Android Open Source 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.
+*/
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#C00288D1"
+ android:gravity="center"
+ android:orientation="vertical" >
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="30sp"
+ android:textColor="@android:color/white"
+ android:text="@string/pip_onboarding_title" />
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/ic_sysbar_home" />
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:padding="30dp"
+ android:textSize="13sp"
+ android:textColor="@android:color/white"
+ android:text="@string/pip_onboarding_description" />
+ <Button
+ android:id="@+id/close"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="15sp"
+ android:textAllCaps="true"
+ android:text="@string/pip_onboarding_button" />
+</LinearLayout>
diff --git a/packages/SystemUI/res/layout/tv_pip_overlay.xml b/packages/SystemUI/res/layout/tv_pip_overlay.xml
index e8691b5..6d9c48d 100644
--- a/packages/SystemUI/res/layout/tv_pip_overlay.xml
+++ b/packages/SystemUI/res/layout/tv_pip_overlay.xml
@@ -17,17 +17,13 @@
*/
-->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/guide_overlay"
android:layout_width="match_parent"
- android:layout_height="match_parent">
- <TextView
- android:id="@+id/guide_overlay"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="bottom"
- android:padding="3dp"
- android:textSize="13sp"
- android:textColor="#111111"
- android:background="#99EEEEEE"
- android:text="@string/pip_hold_home" />
-</FrameLayout>
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:padding="3dp"
+ android:textSize="13sp"
+ android:textColor="#111111"
+ android:background="#99EEEEEE"
+ android:text="@string/pip_hold_home" />
diff --git a/packages/SystemUI/res/values/strings_tv.xml b/packages/SystemUI/res/values/strings_tv.xml
index c64327d..7c4768d 100644
--- a/packages/SystemUI/res/values/strings_tv.xml
+++ b/packages/SystemUI/res/values/strings_tv.xml
@@ -17,6 +17,8 @@
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- Picture-in-Picture menu -->
+ <eat-comment />
<!-- Button to close PIP on PIP UI -->
<string name="pip_exit" translatable="false">Close PIP</string>
<!-- Button to move PIP screen to the fullscreen on PIP UI -->
@@ -29,4 +31,13 @@
<string name="pip_cancel" translatable="false">Cancel</string>
<!-- Overlay text on PIP -->
<string name="pip_hold_home" translatable="false">Hold HOME to control PIP</string>
+
+ <!-- Picture-in-Picture onboarding screen -->
+ <eat-comment />
+ <!-- Title for onboarding screen. -->
+ <string name="pip_onboarding_title" translatable="false">Picture-in-picture</string>
+ <!-- Description for onboarding screen. -->
+ <string name="pip_onboarding_description" translatable="false">Press and hold the HOME\nbutton to close or control it</string>
+ <!-- Button to close onboarding screen. -->
+ <string name="pip_onboarding_button" translatable="false">Got it</string>
</resources>
diff --git a/packages/SystemUI/src/com/android/systemui/Prefs.java b/packages/SystemUI/src/com/android/systemui/Prefs.java
index 7933cc6..e2b3777 100644
--- a/packages/SystemUI/src/com/android/systemui/Prefs.java
+++ b/packages/SystemUI/src/com/android/systemui/Prefs.java
@@ -43,6 +43,7 @@
Key.DND_FAVORITE_BUCKET_INDEX,
Key.DND_NONE_SELECTED,
Key.DND_FAVORITE_ZEN,
+ Key.TV_PICTURE_IN_PICTURE_ONBOARDING_SHOWN,
})
public @interface Key {
String OVERVIEW_SEARCH_APP_WIDGET_ID = "searchAppWidgetId";
@@ -58,6 +59,7 @@
String DND_FAVORITE_BUCKET_INDEX = "DndCountdownMinuteIndex";
String DND_NONE_SELECTED = "DndNoneSelected";
String DND_FAVORITE_ZEN = "DndFavoriteZen";
+ String TV_PICTURE_IN_PICTURE_ONBOARDING_SHOWN = "TvPictureInPictureOnboardingShown";
}
public static boolean getBoolean(Context context, @Key String key, boolean defaultValue) {
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
index 6febe5f..3e47d85 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
@@ -32,11 +32,14 @@
import android.os.RemoteException;
import android.util.Log;
+import com.android.systemui.Prefs;
+
import java.util.ArrayList;
import java.util.List;
import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
+import static com.android.systemui.Prefs.Key.TV_PICTURE_IN_PICTURE_ONBOARDING_SHOWN;
/**
* Manages the picture-in-picture (PIP) UI and states.
@@ -44,6 +47,7 @@
public class PipManager {
private static final String TAG = "PipManager";
private static final boolean DEBUG = false;
+ private static final boolean DEBUG_FORCE_ONBOARDING = false;
private static PipManager sPipManager;
@@ -65,6 +69,7 @@
private Rect mMenuModePipBound;
private boolean mInitialized;
private int mPipTaskId = TASK_ID_NO_PIP;
+ private boolean mOnboardingShown;
private final Runnable mOnActivityPinnedRunnable = new Runnable() {
@Override
@@ -83,6 +88,7 @@
if (DEBUG) Log.d(TAG, "PINNED_STACK:" + stackInfo);
mPipTaskId = stackInfo.taskIds[stackInfo.taskIds.length - 1];
showPipOverlay(false);
+ launchPipOnboardingActivityIfNeeded();
}
};
private final Runnable mOnTaskStackChanged = new Runnable() {
@@ -145,6 +151,8 @@
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_MEDIA_RESOURCE_GRANTED);
mContext.registerReceiver(mBroadcastReceiver, intentFilter);
+ mOnboardingShown = Prefs.getBoolean(
+ mContext, TV_PICTURE_IN_PICTURE_ONBOARDING_SHOWN, false);
}
/**
@@ -169,7 +177,7 @@
}
/**
- * Closes PIP (PIPped activity and PIP system UI).
+ * Closes PIP (PIPed activity and PIP system UI).
*/
public void closePip() {
mState = STATE_NO_PIP;
@@ -194,7 +202,7 @@
}
/**
- * Moves the PIPped activity to the fullscreen and closes PIP system UI.
+ * Moves the PIPed activity to the fullscreen and closes PIP system UI.
*/
public void movePipToFullscreen() {
mState = STATE_NO_PIP;
@@ -260,6 +268,17 @@
mListeners.remove(listener);
}
+ private void launchPipOnboardingActivityIfNeeded() {
+ if (DEBUG_FORCE_ONBOARDING || !mOnboardingShown) {
+ mOnboardingShown = true;
+ Prefs.putBoolean(mContext, TV_PICTURE_IN_PICTURE_ONBOARDING_SHOWN, true);
+
+ Intent intent = new Intent(mContext, PipOnboardingActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivity(intent);
+ }
+ }
+
private boolean hasPipTasks() {
try {
StackInfo stackInfo = mActivityManager.getStackInfo(PINNED_STACK_ID);
@@ -334,7 +353,7 @@
*/
public interface Listener {
/**
- * Invoked when a PIPped activity is closed.
+ * Invoked when a PIPed activity is closed.
*/
void onPipActivityClosed();
/**
@@ -342,7 +361,7 @@
*/
void onShowPipMenu();
/**
- * Invoked when the PIPped activity is returned back to the fullscreen.
+ * Invoked when the PIPed activity is returned back to the fullscreen.
*/
void onMoveToFullscreen();
}
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipOnboardingActivity.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipOnboardingActivity.java
new file mode 100644
index 0000000..a0b913a
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipOnboardingActivity.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 The Android Open Source 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 com.android.systemui.tv.pip;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.View;
+
+import com.android.systemui.R;
+
+/**
+ * Activity to show an overlay on top of PIP activity to show how to pop up PIP menu.
+ */
+public class PipOnboardingActivity extends Activity implements PipManager.Listener {
+ private final PipManager mPipManager = PipManager.getInstance();
+
+ @Override
+ protected void onCreate(Bundle bundle) {
+ super.onCreate(bundle);
+ setContentView(R.layout.tv_pip_onboarding);
+ mPipManager.addListener(this);
+ findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ finish();
+ }
+ });
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mPipManager.removeListener(this);
+ }
+
+ @Override
+ public void onPipActivityClosed() {
+ finish();
+ }
+
+ @Override
+ public void onShowPipMenu() {
+ finish();
+ }
+
+ @Override
+ public void onMoveToFullscreen() {
+ finish();
+ }
+}