summaryrefslogtreecommitdiffstats
path: root/samples/ApiDemos
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2018-02-19 18:34:48 +0100
committerAdrian Roos <roosa@google.com>2018-02-19 18:34:48 +0100
commit71fc3601bd9a412fa7aa1f3f4c0853d245169dfb (patch)
treef2ee1ee3d1e9ab6de8c134810fa61177fe035571 /samples/ApiDemos
parentd1d75c073ff546e6814afef679e393261f6fc0a3 (diff)
downloadandroid_development-71fc3601bd9a412fa7aa1f3f4c0853d245169dfb.tar.gz
android_development-71fc3601bd9a412fa7aa1f3f4c0853d245169dfb.tar.bz2
android_development-71fc3601bd9a412fa7aa1f3f4c0853d245169dfb.zip
ApiSamples: Add PIP sample
Test: Open ApiSamples > App > Activity > Picture in Picture Change-Id: I205cdc00533b19be46c7837012a96705c7a4a62f
Diffstat (limited to 'samples/ApiDemos')
-rw-r--r--samples/ApiDemos/AndroidManifest.xml12
-rw-r--r--samples/ApiDemos/res/layout/picture_in_picture.xml32
-rw-r--r--samples/ApiDemos/res/values/strings.xml3
-rw-r--r--samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java42
4 files changed, 89 insertions, 0 deletions
diff --git a/samples/ApiDemos/AndroidManifest.xml b/samples/ApiDemos/AndroidManifest.xml
index 030184982..b1175f629 100644
--- a/samples/ApiDemos/AndroidManifest.xml
+++ b/samples/ApiDemos/AndroidManifest.xml
@@ -285,6 +285,18 @@
</intent-filter>
</activity>
+ <activity android:name=".app.PictureInPicture"
+ android:label="@string/activity_picture_in_picture"
+ android:resizeableActivity="true"
+ android:supportsPictureInPicture="true"
+ android:configChanges=
+ "screenSize|smallestScreenSize|screenLayout|orientation">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.SAMPLE_CODE" />
+ </intent-filter>
+ </activity>
+
<activity android:name=".app.PresentationActivity"
android:label="@string/activity_presentation">
<intent-filter>
diff --git a/samples/ApiDemos/res/layout/picture_in_picture.xml b/samples/ApiDemos/res/layout/picture_in_picture.xml
new file mode 100644
index 000000000..096ee3cf8
--- /dev/null
+++ b/samples/ApiDemos/res/layout/picture_in_picture.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2018 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.
+ -->
+
+<!-- Demonstrates implementation of a DeviceAdmin. -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical" android:padding="4dip"
+ android:gravity="center_horizontal"
+ android:layout_width="match_parent" android:layout_height="match_parent">
+
+ <Button android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:id="@+id/enter_pip"
+ android:text="@string/enter_picture_in_picture">
+
+ </Button>
+</LinearLayout>
+
diff --git a/samples/ApiDemos/res/values/strings.xml b/samples/ApiDemos/res/values/strings.xml
index 288e4774d..30d92ab88 100644
--- a/samples/ApiDemos/res/values/strings.xml
+++ b/samples/ApiDemos/res/values/strings.xml
@@ -62,6 +62,9 @@
instead of programmatically.</string>
<string name="screen_orientation">Screen Orientation</string>
+ <string name="activity_picture_in_picture">App/Activity/Picture in Picture</string>
+ <string name="enter_picture_in_picture">Enter picture-in-picture mode</string>
+
<string name="activity_translucent">App/Activity/Translucent</string>
<string name="translucent_background">Example of how you can make an
activity have a translucent background, compositing over
diff --git a/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java b/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java
new file mode 100644
index 000000000..43f554082
--- /dev/null
+++ b/samples/ApiDemos/src/com/example/android/apis/app/PictureInPicture.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 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.example.android.apis.app;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.widget.Button;
+
+import com.example.android.apis.R;
+
+public class PictureInPicture extends Activity {
+
+ private Button mEnterPip;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.picture_in_picture);
+
+ mEnterPip = (Button)findViewById(R.id.enter_pip);
+ mEnterPip.setOnClickListener((v) -> enterPictureInPictureMode());
+ }
+
+ @Override
+ protected void onUserLeaveHint() {
+ enterPictureInPictureMode();
+ }
+}