Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I1c70495dbe84bc171f2301039b34a8c03fb2ac4f
- Loading branch information
Jeremy Walker
committed
Jul 30, 2019
1 parent
d9965d0
commit 13da7d7
Showing
77 changed files
with
3,848 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
# GOOGLE SAMPLE PACKAGING DATA | ||
# | ||
# This file is used by Google as part of our samples packaging process. | ||
# End users may safely ignore this file. It has no relevance to other systems. | ||
--- | ||
status: PUBLISHED | ||
technologies: [Android] | ||
categories: [UI] | ||
languages: [Java] | ||
solutions: [Mobile] | ||
github: android/views-widgets | ||
level: INTERMEDIATE | ||
icon: screenshots/icon-web.png | ||
apiRefs: | ||
- android:android.content.Intent | ||
- android:android.app.ActivityOptions | ||
license: apache2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
buildscript { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.3.0' | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
jcenter() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 27 | ||
|
||
defaultConfig { | ||
applicationId "com.android.multiwindowplayground" | ||
minSdkVersion 24 | ||
targetSdkVersion 27 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
|
||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_7 | ||
targetCompatibility JavaVersion.VERSION_1_7 | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
testCompile 'junit:junit:4.12' | ||
compile 'com.android.support:appcompat-v7:27.0.0' | ||
androidTestCompile 'com.android.support:support-annotations:27.0.0' | ||
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' | ||
} |
86 changes: 86 additions & 0 deletions
86
MultiWindowPlayground/Application/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
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. | ||
--> | ||
|
||
<manifest package="com.android.multiwindowplayground" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/MultiWindowSampleTheme"> | ||
<!-- The launcher Activity that is started when the application is first started. | ||
Note that we are setting the task affinity to "" to ensure each activity is launched | ||
into a separate task stack. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.MainActivity" | ||
android:taskAffinity=""> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
<!-- This Activity cannot be resized and is always displayed full screen. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.UnresizableActivity" | ||
android:resizeableActivity="false" | ||
android:taskAffinity="" /> | ||
|
||
<!-- This Activity has a default size (750x500dp) with a minimum size | ||
(500dp at its shortest side). It is launched in the top/end (top/right) corner by default. | ||
These attributes are defined in the 'layout' tag within an Activity definition. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.MinimumSizeActivity" | ||
android:launchMode="singleInstance" | ||
android:taskAffinity=""> | ||
<layout | ||
android:defaultHeight="500dp" | ||
android:defaultWidth="750dp" | ||
android:gravity="top|end" | ||
android:minWidth="500dp" | ||
android:minHeight="500dp" /> | ||
</activity> | ||
|
||
<!-- In split-screen mode, this Activity is launched adjacent to another Activity. This is | ||
controlled via a flag set in the intent that launches this Activity. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.AdjacentActivity" | ||
android:taskAffinity="" /> | ||
|
||
<!-- This Activity is launched within an area defined in its launch intent. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.LaunchBoundsActivity" | ||
android:taskAffinity="" /> | ||
|
||
<!-- This activity handles all configuration changes itself. | ||
Callbacks for configuration changes are received in 'onConfigurationChanged'. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.CustomConfigurationChangeActivity" | ||
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
android:launchMode="singleInstance" | ||
android:taskAffinity="" /> | ||
|
||
<!-- This Activity is launched in a new task without any special flags or settings. --> | ||
<activity | ||
android:name="com.android.multiwindowplayground.activities.BasicActivity" | ||
android:launchMode="singleInstance" | ||
android:taskAffinity="" /> | ||
|
||
</application> | ||
|
||
</manifest> |
117 changes: 117 additions & 0 deletions
117
...wPlayground/Application/src/main/java/com/android/multiwindowplayground/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* 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.multiwindowplayground; | ||
|
||
import com.android.multiwindowplayground.activities.AdjacentActivity; | ||
import com.android.multiwindowplayground.activities.BasicActivity; | ||
import com.android.multiwindowplayground.activities.CustomConfigurationChangeActivity; | ||
import com.android.multiwindowplayground.activities.LaunchBoundsActivity; | ||
import com.android.multiwindowplayground.activities.LoggingActivity; | ||
import com.android.multiwindowplayground.activities.MinimumSizeActivity; | ||
import com.android.multiwindowplayground.activities.UnresizableActivity; | ||
|
||
import android.app.ActivityOptions; | ||
import android.content.Intent; | ||
import android.graphics.Rect; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
|
||
public class MainActivity extends LoggingActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
View multiDisabledMessage = findViewById(R.id.warning_multiwindow_disabled); | ||
// Display an additional message if the app is not in multiwindow mode. | ||
if (!isInMultiWindowMode()) { | ||
multiDisabledMessage.setVisibility(View.VISIBLE); | ||
} else { | ||
multiDisabledMessage.setVisibility(View.GONE); | ||
} | ||
} | ||
|
||
public void onStartUnresizableClick(View view) { | ||
Log.d(mLogTag, "** starting UnresizableActivity"); | ||
|
||
/* | ||
* This activity is marked as 'unresizable' in the AndroidManifest. We need to specify the | ||
* FLAG_ACTIVITY_NEW_TASK flag here to launch it into a new task stack, otherwise the | ||
* properties from the root activity would have been inherited (which was here marked as | ||
* resizable by default). | ||
*/ | ||
Intent intent = new Intent(this, UnresizableActivity.class); | ||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(intent); | ||
} | ||
|
||
public void onStartMinimumSizeActivity(View view) { | ||
Log.d(mLogTag, "** starting MinimumSizeActivity"); | ||
|
||
startActivity(new Intent(this, MinimumSizeActivity.class)); | ||
} | ||
|
||
public void onStartAdjacentActivity(View view) { | ||
Log.d(mLogTag, "** starting AdjacentActivity"); | ||
|
||
/* | ||
* Start this activity adjacent to the focused activity (ie. this activity) if possible. | ||
* Note that this flag is just a hint to the system and may be ignored. For example, | ||
* if the activity is launched within the same task, it will be launched on top of the | ||
* previous activity that started the Intent. That's why the Intent.FLAG_ACTIVITY_NEW_TASK | ||
* flag is specified here in the intent - this will start the activity in a new task. | ||
*/ | ||
Intent intent = new Intent(this, AdjacentActivity.class); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT | Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(intent); | ||
} | ||
|
||
public void onStartLaunchBoundsActivity(View view) { | ||
Log.d(mLogTag, "** starting LaunchBoundsActivity"); | ||
|
||
// Define the bounds in which the Activity will be launched into. | ||
Rect bounds = new Rect(500, 300, 100, 0); | ||
|
||
// Set the bounds as an activity option. | ||
ActivityOptions options = ActivityOptions.makeBasic(); | ||
options.setLaunchBounds(bounds); | ||
|
||
// Start the LaunchBoundsActivity with the specified options | ||
Intent intent = new Intent(this, LaunchBoundsActivity.class); | ||
startActivity(intent, options.toBundle()); | ||
|
||
} | ||
|
||
public void onStartBasicActivity(View view) { | ||
Log.d(mLogTag, "** starting BasicActivity"); | ||
|
||
// Start an Activity with the default options in the 'singleTask' launch mode as defined in | ||
// the AndroidManifest.xml. | ||
startActivity(new Intent(this, BasicActivity.class)); | ||
|
||
} | ||
|
||
public void onStartCustomConfigurationActivity(View view) { | ||
Log.d(mLogTag, "** starting CustomConfigurationChangeActivity"); | ||
|
||
// Start an Activity that handles all configuration changes itself. | ||
startActivity(new Intent(this, CustomConfigurationChangeActivity.class)); | ||
|
||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...lication/src/main/java/com/android/multiwindowplayground/activities/AdjacentActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.multiwindowplayground.activities; | ||
|
||
import com.android.multiwindowplayground.R; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
/** | ||
* This Activity is to be launched adjacent to another Activity using the {@link | ||
* android.content.Intent#FLAG_ACTIVITY_LAUNCH_ADJACENT}. | ||
* | ||
* @see com.android.multiwindowplayground.MainActivity#onStartAdjacentActivity(View) | ||
*/ | ||
public class AdjacentActivity extends LoggingActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_logging); | ||
|
||
setBackgroundColor(R.color.teal); | ||
setDescription(R.string.activity_adjacent_description); | ||
} | ||
|
||
} |
43 changes: 43 additions & 0 deletions
43
...Application/src/main/java/com/android/multiwindowplayground/activities/BasicActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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.multiwindowplayground.activities; | ||
|
||
import com.android.multiwindowplayground.R; | ||
|
||
import android.os.Bundle; | ||
import android.view.View; | ||
|
||
/** | ||
* This activity is the most basic, simeple use case and is to be launched without any special | ||
* flags | ||
* or settings. | ||
* | ||
* @see com.android.multiwindowplayground.MainActivity#onStartBasicActivity(View) | ||
*/ | ||
public class BasicActivity extends LoggingActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_logging); | ||
|
||
// Set the color and description | ||
setDescription(R.string.activity_description_basic); | ||
setBackgroundColor(R.color.gray); | ||
|
||
} | ||
} |
Oops, something went wrong.