Initial commit, Advanced immersive mode sample.
Change-Id: If5b72bced87c810700d449a329c8e1b2f99e81e6
diff --git a/ui/BasicImmersiveMode/build.gradle b/ui/BasicImmersiveMode/build.gradle
deleted file mode 100644
index 597d6d4..0000000
--- a/ui/BasicImmersiveMode/build.gradle
+++ /dev/null
@@ -1,8 +0,0 @@
-
-// BEGIN_EXCLUDE
-apply from: "../../../../build/build.gradle"
-samplegen {
- pathToBuild "../../../../build"
- pathToSamplesCommon "../../common"
-}
-// END_EXCLUDE
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/.gitignore b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/.gitignore
similarity index 100%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/.gitignore
rename to ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/.gitignore
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/README-singleview.txt
similarity index 100%
copy from ui/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt
copy to ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/README-singleview.txt
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/build.gradle b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/build.gradle
similarity index 85%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/build.gradle
rename to ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/build.gradle
index 9a70bb6..03db3dd 100644
--- a/ui/BasicImmersiveMode/BasicImmersiveModeSample/build.gradle
+++ b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/build.gradle
@@ -1,19 +1,21 @@
+
+
+
buildscript {
repositories {
mavenCentral()
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.5.+'
+ classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
dependencies {
- // Add the support lib that is appropriate for SDK 11
+ // Add the support lib that is appropriate for SDK 4
compile "com.android.support:support-v4:18.0.+"
- compile "com.android.support:gridlayout-v7:18.0.+"
}
// The sample build uses multiple directories to
@@ -25,7 +27,7 @@
'template'] // boilerplate code that is generated by the sample template process
android {
- compileSdkVersion "android-KeyLimePie"
+ compileSdkVersion 19
buildToolsVersion "18.0.1"
sourceSets {
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/proguard-project.txt
similarity index 100%
copy from ui/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt
copy to ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/proguard-project.txt
diff --git a/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/AndroidManifest.xml b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..1d01856
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/AndroidManifest.xml
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 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.
+-->
+
+<!-- the versionCode is an integer representation of this version of your application. New
+ versions get higher numbers, so the upgrade system can avoid dealing with the ambiguity
+ of "1.9" vs "1.10". versionName, on the other hand, can be whatever you want, as the code
+ that handles upgrading Android apps between versions on your device just ignores it.-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.advancedimmersivemode"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <!-- This sample is to demonstrate features released in API 19.
+ So while it would technically run on an earlier version of Android,
+ there wouldn't be much point) -->
+ <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="19" />
+ <!-- allowBackup declares if the app can be part of device-wide backups such as "adb backup" -->
+ <!-- theme is a way of applying UI decisions across your entire application. You can also
+ define it on a per-application basis. -->
+ <application
+ android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <!-- Every activity needs its own Manifest element. The intent-filter contained in the
+ element declares the intents that can be used to activate this Activity. For instance,
+ the one below flags this Activity as a "main" entry point of this app, and suitable
+ for creating a shortcut to in the Launcher. If you wanted your app to have 5
+ different Activities available in the launcher, you could just make 5 activities
+ with that intent filter. Please don't do that. Just because it's a good example
+ doesn't mean it's a good idea. -->
+ <activity android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:uiOptions="splitActionBarWhenNarrow">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+</manifest>
diff --git a/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/java/com/example/android/advancedimmersivemode/AdvancedImmersiveModeFragment.java b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/java/com/example/android/advancedimmersivemode/AdvancedImmersiveModeFragment.java
new file mode 100644
index 0000000..fe11ecb
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/src/main/java/com/example/android/advancedimmersivemode/AdvancedImmersiveModeFragment.java
@@ -0,0 +1,174 @@
+/*
+* Copyright (C) 2012 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.advancedimmersivemode;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+
+import com.example.android.common.logger.Log;
+
+/**
+ * Demonstrates how to update the app's UI by toggling immersive mode.
+ * Checkboxes are also made available for toggling other UI flags which can
+ * alter the behavior of immersive mode.
+ */
+public class AdvancedImmersiveModeFragment extends Fragment {
+
+ public static final String TAG = "AdvancedImmersiveModeFragment";
+ public CheckBox mHideNavCheckbox;
+ public CheckBox mHideStatusBarCheckBox;
+ public CheckBox mImmersiveModeCheckBox;
+ public CheckBox mImmersiveModeStickyCheckBox;
+ public CheckBox mLowProfileCheckBox;
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ final View decorView = getActivity().getWindow().getDecorView();
+ ViewGroup parentView = (ViewGroup) getActivity().getWindow().getDecorView()
+ .findViewById(R.id.sample_main_layout);
+
+ mLowProfileCheckBox = new CheckBox(getActivity());
+ mLowProfileCheckBox.setText("Enable Low Profile mode.");
+ parentView.addView(mLowProfileCheckBox);
+
+ mHideNavCheckbox = new CheckBox(getActivity());
+ mHideNavCheckbox.setChecked(true);
+ mHideNavCheckbox.setText("Hide Navigation bar");
+ parentView.addView(mHideNavCheckbox);
+
+ mHideStatusBarCheckBox = new CheckBox(getActivity());
+ mHideStatusBarCheckBox.setChecked(true);
+ mHideStatusBarCheckBox.setText("Hide Status Bar");
+ parentView.addView(mHideStatusBarCheckBox);
+
+ mImmersiveModeCheckBox = new CheckBox(getActivity());
+ mImmersiveModeCheckBox.setText("Enable Immersive Mode.");
+ parentView.addView(mImmersiveModeCheckBox);
+
+ mImmersiveModeStickyCheckBox = new CheckBox(getActivity());
+ mImmersiveModeStickyCheckBox.setText("Enable Immersive Mode (Sticky)");
+ parentView.addView(mImmersiveModeStickyCheckBox);
+
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == R.id.sample_action) {
+ toggleImmersiveMode();
+ }
+ return true;
+ }
+
+ /**
+ * Detects and toggles immersive mode (also known as "hidey bar" mode).
+ */
+ public void toggleImmersiveMode() {
+
+ // BEGIN_INCLUDE (get_current_ui_flags)
+ // The "Decor View" is the parent view of the Activity. It's also conveniently the easiest
+ // one to find from within a fragment, since there's a handy helper method to pull it, and
+ // we don't have to bother with picking a view somewhere deeper in the hierarchy and calling
+ // "findViewById" on it.
+ View decorView = getActivity().getWindow().getDecorView();
+ int uiOptions = decorView.getSystemUiVisibility();
+ int newUiOptions = uiOptions;
+ // END_INCLUDE (get_current_ui_flags)
+
+ // BEGIN_INCLUDE (toggle_lowprofile_mode)
+ // Low profile mode doesn't resize the screen at all, but it covers the nav & status bar
+ // icons with black so they're less distracting. Unlike "full screen" and "hide nav bar,"
+ // this mode doesn't interact with immersive mode at all, but it's instructive when running
+ // this sample to observe the differences in behavior.
+ if (mLowProfileCheckBox.isChecked()) {
+ newUiOptions |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ } else {
+ newUiOptions &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE;
+ }
+ // END_INCLUDE (toggle_lowprofile_mode)
+
+ // BEGIN_INCLUDE (toggle_fullscreen_mode)
+ // When enabled, this flag hides non-critical UI, such as the status bar,
+ // which usually shows notification icons, battery life, etc
+ // on phone-sized devices. The bar reappears when the user swipes it down. When immersive
+ // mode is also enabled, the app-drawable area expands, and when the status bar is swiped
+ // down, it appears semi-transparently and slides in over the app, instead of pushing it
+ // down.
+ if (mHideStatusBarCheckBox.isChecked()) {
+ newUiOptions |= View.SYSTEM_UI_FLAG_FULLSCREEN;
+ } else {
+ newUiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
+ }
+ // END_INCLUDE (toggle_fullscreen_mode)
+
+ // BEGIN_INCLUDE (toggle_hidenav_mode)
+ // When enabled, this flag hides the black nav bar along the bottom,
+ // where the home/back buttons are. The nav bar normally instantly reappears
+ // when the user touches the screen. When immersive mode is also enabled, the nav bar
+ // stays hidden until the user swipes it back.
+ if (mHideNavCheckbox.isChecked()) {
+ newUiOptions |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ } else {
+ newUiOptions &= ~View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
+ }
+ // END_INCLUDE (toggle_hidenav_mode)
+
+ // BEGIN_INCLUDE (toggle_immersive_mode)
+ // Immersive mode doesn't do anything without at least one of the previous flags
+ // enabled. When enabled, it allows the user to swipe the status and/or nav bars
+ // off-screen. When the user swipes the bars back onto the screen, the flags are cleared
+ // and immersive mode is automatically disabled.
+ if (mImmersiveModeCheckBox.isChecked()) {
+ newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE;
+ } else {
+ newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE;
+ }
+ // END_INCLUDE (toggle_immersive_mode)
+
+ // BEGIN_INCLUDE (toggle_immersive_mode_sticky)
+ // There's actually two forms of immersive mode, normal and "sticky". Sticky immersive mode
+ // is different in 2 key ways:
+ //
+ // * Uses semi-transparent bars for the nav and status bars
+ // * This UI flag will *not* be cleared when the user interacts with the UI.
+ // When the user swipes, the bars will temporarily appear for a few seconds and then
+ // disappear again.
+ if (mImmersiveModeStickyCheckBox.isChecked()) {
+ newUiOptions |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ } else {
+ newUiOptions &= ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
+ }
+ // END_INCLUDE (toggle_immersive_mode_sticky)
+
+ // BEGIN_INCLUDE (set_ui_flags)
+ //Set the new UI flags.
+ decorView.setSystemUiVisibility(newUiOptions);
+ Log.i(TAG, "Current height: " + decorView.getHeight() + ", width: " + decorView.getWidth());
+ // END_INCLUDE (set_ui_flags)
+ }
+}
diff --git a/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/AndroidManifest.xml b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/AndroidManifest.xml
new file mode 100644
index 0000000..7117969
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 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 name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.advancedimmersivemode.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="19"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.advancedimmersivemode"
+ android:label="Tests for com.example.android.advancedimmersivemode" />
+
+</manifest>
\ No newline at end of file
diff --git a/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/src/com/example/android/advancedimmersivemode/tests/SampleTests.java b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/src/com/example/android/advancedimmersivemode/tests/SampleTests.java
new file mode 100644
index 0000000..c51a488
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/AdvancedImmersiveModeSample/tests/src/com/example/android/advancedimmersivemode/tests/SampleTests.java
@@ -0,0 +1,126 @@
+/*
+* Copyright 2013 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.
+*/
+/*
+* Copyright (C) 2013 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.advancedimmersivemode.tests;
+
+import com.example.android.advancedimmersivemode.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
+
+/**
+* Tests for AdvancedImmersiveMode sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private AdvancedImmersiveModeFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ mTestActivity = getActivity();
+ mTestFragment = (AdvancedImmersiveModeFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ assertNotNull("mTestActivity is null", mTestActivity);
+ assertNotNull("mTestFragment is null", mTestFragment);
+ }
+
+
+ /**
+ * Verify that the UI flags actually changed when the toggle method is called.
+ */
+ @UiThreadTest
+ public void testFlagsChanged() {
+ int uiFlags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
+ mTestFragment.mImmersiveModeCheckBox.setChecked(true);
+ mTestFragment.mHideNavCheckbox.setChecked(true);
+ mTestFragment.mHideStatusBarCheckBox.setChecked(true);
+ mTestFragment.toggleImmersiveMode();
+ int newUiFlags = getActivity().getWindow().getDecorView().getSystemUiVisibility();
+ assertTrue("UI Flags didn't toggle.", uiFlags != newUiFlags);
+ }
+
+ /**
+ * Verify that the view's height actually changed when the toggle method is called.
+ * This should result in a change in height for the DecorView.
+ */
+ public void testDecorHeightExpanded() {
+ // Grab the initial height of the DecorWindow.
+ int startingHeight = getActivity().getWindow().getDecorView().getHeight();
+
+ // In order to test that this worked: Need to toggle the immersive mode on the UI thread,
+ // wait a suitable amount of time (this test goes with 200 ms), then check to see if the
+ // height changed.
+ try {
+ Runnable testRunnable = (new Runnable() {
+ public void run() {
+ // Toggle immersive mode
+ mTestFragment.mImmersiveModeCheckBox.setChecked(true);
+ mTestFragment.mHideNavCheckbox.setChecked(true);
+ mTestFragment.mHideStatusBarCheckBox.setChecked(true);
+ mTestFragment.toggleImmersiveMode();
+ synchronized(this) {
+ // Notify any thread waiting on this runnable that it can continue
+ this.notify();
+ }
+ }
+ });
+ synchronized(testRunnable) {
+ // Since toggling immersive mode makes changes to the view hierarchy, it needs to run
+ // on the UI thread, or crashing will occur.
+ mTestActivity.runOnUiThread(testRunnable);
+ testRunnable.wait();
+
+ }
+ synchronized(this) {
+ //Wait about 200ms for the change to take place
+ wait(200L);
+ }
+ } catch (Throwable throwable) {
+ fail(throwable.getMessage());
+ }
+
+ int expandedHeight = getActivity().getWindow().getDecorView().getHeight();
+ assertTrue("Bars aren't hidden.", expandedHeight != startingHeight);
+ }
+
+}
\ No newline at end of file
diff --git a/ui/window/AdvancedImmersiveMode/_index.jd b/ui/window/AdvancedImmersiveMode/_index.jd
new file mode 100644
index 0000000..2faca3c
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/_index.jd
@@ -0,0 +1,14 @@
+
+
+
+page.tags="AdvancedImmersiveMode"
+sample.group=UI
+@jd:body
+
+<p>
+
+ \"Immersive Mode\" is a new UI mode which improves \"hide full screen\" and
+ \"hide nav bar\" modes, by letting users swipe the bars in and out. To try it out,
+ enable \"Immersive Mode\" using the checkbox below and click \"Try these settings!\"
+
+ </p>
diff --git a/ui/window/AdvancedImmersiveMode/build.gradle b/ui/window/AdvancedImmersiveMode/build.gradle
new file mode 100644
index 0000000..c7f6491
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/build.gradle
@@ -0,0 +1,8 @@
+
+// BEGIN_EXCLUDE
+apply from: "../../../../../build/build.gradle"
+samplegen {
+ pathToBuild "../../../../../build"
+ pathToSamplesCommon "../../../common"
+}
+// END_EXCLUDE
diff --git a/ui/BasicImmersiveMode/buildSrc/build.gradle b/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
similarity index 64%
rename from ui/BasicImmersiveMode/buildSrc/build.gradle
rename to ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
index 8c294c2..7cebf71 100644
--- a/ui/BasicImmersiveMode/buildSrc/build.gradle
+++ b/ui/window/AdvancedImmersiveMode/buildSrc/build.gradle
@@ -8,7 +8,7 @@
sourceSets {
main {
groovy {
- srcDir new File(rootDir, "../../../../../build/buildSrc/src/main/groovy")
+ srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
}
}
}
diff --git a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar b/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
copy from ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar
copy to ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties b/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
similarity index 94%
rename from ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
rename to ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
index 5c22dec..861eddc 100644
--- a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/window/AdvancedImmersiveMode/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
diff --git a/ui/BasicImmersiveMode/gradlew b/ui/window/AdvancedImmersiveMode/gradlew
similarity index 100%
copy from ui/BasicImmersiveMode/gradlew
copy to ui/window/AdvancedImmersiveMode/gradlew
diff --git a/ui/BasicImmersiveMode/gradlew.bat b/ui/window/AdvancedImmersiveMode/gradlew.bat
similarity index 100%
copy from ui/BasicImmersiveMode/gradlew.bat
copy to ui/window/AdvancedImmersiveMode/gradlew.bat
diff --git a/ui/window/AdvancedImmersiveMode/settings.gradle b/ui/window/AdvancedImmersiveMode/settings.gradle
new file mode 100644
index 0000000..0f7ed4b
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/settings.gradle
@@ -0,0 +1 @@
+include 'AdvancedImmersiveModeSample'
diff --git a/ui/window/AdvancedImmersiveMode/template-params.xml b/ui/window/AdvancedImmersiveMode/template-params.xml
new file mode 100644
index 0000000..3ae1faa
--- /dev/null
+++ b/ui/window/AdvancedImmersiveMode/template-params.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2013 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.
+-->
+<sample>
+ <name>AdvancedImmersiveMode</name>
+ <package>com.example.android.advancedimmersivemode</package>
+ <group>UI</group>
+
+
+ <!-- change minSdk if needed-->
+ <minSdk>4</minSdk>
+ <compileSdkVersion>19</compileSdkVersion>
+
+ <strings>
+ <intro>
+ <![CDATA[
+ \"Immersive Mode\" is a new UI mode which improves \"hide full screen\" and
+ \"hide nav bar\" modes, by letting users swipe the bars in and out. This sample
+ lets the user experiment with immersive mode by enabling it and seeing how it interacts
+ with some of the other UI flags related to full-screen apps.
+ \n\nThis sample also lets the user choose between normal immersive mode and "sticky"
+ immersive mode, which removes the status bar and nav bar
+ a few seconds after the user has swiped them back in.
+ ]]>
+ </intro>
+ <sample_action>Try these settings!</sample_action>
+ </strings>
+
+ <template src="base"/>
+ <template src="SingleView"/>
+ <common src="logger"/>
+ <common src="activities"/>
+
+</sample>
diff --git a/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/.gitignore b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 2013 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.
+src/template/
+src/common/
+build.gradle
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt
similarity index 100%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/README-singleview.txt
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt
similarity index 100%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/proguard-project.txt
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml
similarity index 91%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml
index bc85cf0..00b4e3c 100644
--- a/ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/AndroidManifest.xml
@@ -27,7 +27,8 @@
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
- android:label="@string/app_name">
+ android:label="@string/app_name"
+ android:uiOptions="splitActionBarWhenNarrow">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
similarity index 85%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
index d9e8ef8..a675e05 100644
--- a/ui/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/java/com/example/android/basicimmersivemode/BasicImmersiveModeFragment.java
@@ -1,5 +1,5 @@
/*
-* Copyright (C) 2012 The Android Open Source Project
+* Copyright (C) 2013 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.
@@ -55,7 +55,7 @@
}
/**
- * Detects and toggles immersive mode (also known as "hidey bar" mode).
+ * Detects and toggles immersive mode.
*/
public void toggleHideyBar() {
// BEGIN_INCLUDE (get_current_ui_flags)
@@ -66,20 +66,22 @@
// END_INCLUDE (get_current_ui_flags)
// BEGIN_INCLUDE (toggle_ui_flags)
boolean isImmersiveModeEnabled =
- ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE) == uiOptions);
+ ((uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY) == uiOptions);
if (isImmersiveModeEnabled) {
Log.i(TAG, "Turning immersive mode mode off. ");
} else {
Log.i(TAG, "Turning immersive mode mode on.");
}
- // Immersive mode: Backward compatible to KitKat.
+ // Immersive mode: Backward compatible to KitKat (API 19).
// Note that this flag doesn't do anything by itself, it only augments the behavior
// of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of this sample
// all three flags are being toggled together.
+ // This sample uses the "sticky" form of immersive mode, which will let the user swipe
+ // the bars back in again, but will automatically make them disappear a few seconds later.
newUiOptions ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
newUiOptions ^= View.SYSTEM_UI_FLAG_FULLSCREEN;
- newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE;
+ newUiOptions ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
getActivity().getWindow().getDecorView().setSystemUiVisibility(newUiOptions);
//END_INCLUDE (set_ui_flags)
}
diff --git a/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-hdpi/ic_launcher.png b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..b1efaf4
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-mdpi/ic_launcher.png b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..f5f9244
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xhdpi/ic_launcher.png b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..5d07b3f
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xxhdpi/ic_launcher.png b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..6ef21e1
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/tests/AndroidManifest.xml b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/tests/AndroidManifest.xml
similarity index 100%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/tests/AndroidManifest.xml
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/tests/AndroidManifest.xml
diff --git a/ui/BasicImmersiveMode/BasicImmersiveModeSample/tests/src/com/example/android/basicimmersivemode/tests/SampleTests.java b/ui/window/BasicImmersiveMode/BasicImmersiveModeSample/tests/src/com/example/android/basicimmersivemode/tests/SampleTests.java
similarity index 100%
rename from ui/BasicImmersiveMode/BasicImmersiveModeSample/tests/src/com/example/android/basicimmersivemode/tests/SampleTests.java
rename to ui/window/BasicImmersiveMode/BasicImmersiveModeSample/tests/src/com/example/android/basicimmersivemode/tests/SampleTests.java
diff --git a/ui/window/BasicImmersiveMode/_index.jd b/ui/window/BasicImmersiveMode/_index.jd
new file mode 100644
index 0000000..fc4ff9c
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/_index.jd
@@ -0,0 +1,13 @@
+
+
+
+page.tags="BasicImmersiveMode"
+sample.group=UI
+@jd:body
+
+<p>
+
+ Introductory text that explains what the sample is intended to demonstrate. Edit
+ in template-params.xml.
+
+ </p>
diff --git a/ui/window/BasicImmersiveMode/build.gradle b/ui/window/BasicImmersiveMode/build.gradle
new file mode 100644
index 0000000..ffb5c2f
--- /dev/null
+++ b/ui/window/BasicImmersiveMode/build.gradle
@@ -0,0 +1,11 @@
+
+
+
+
+// BEGIN_EXCLUDE
+apply from: "../../../../../build/build.gradle"
+samplegen {
+ pathToBuild "../../../../../build"
+ pathToSamplesCommon "../../../common"
+}
+// END_EXCLUDE
diff --git a/ui/BasicImmersiveMode/buildSrc/build.gradle b/ui/window/BasicImmersiveMode/buildSrc/build.gradle
similarity index 63%
copy from ui/BasicImmersiveMode/buildSrc/build.gradle
copy to ui/window/BasicImmersiveMode/buildSrc/build.gradle
index 8c294c2..e344a8c 100644
--- a/ui/BasicImmersiveMode/buildSrc/build.gradle
+++ b/ui/window/BasicImmersiveMode/buildSrc/build.gradle
@@ -1,3 +1,6 @@
+
+
+
repositories {
mavenCentral()
}
@@ -8,7 +11,7 @@
sourceSets {
main {
groovy {
- srcDir new File(rootDir, "../../../../../build/buildSrc/src/main/groovy")
+ srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
}
}
}
diff --git a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar b/ui/window/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar
rename to ui/window/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties b/ui/window/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
similarity index 94%
copy from ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
copy to ui/window/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
index 5c22dec..861eddc 100644
--- a/ui/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
+++ b/ui/window/BasicImmersiveMode/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
+distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
diff --git a/ui/BasicImmersiveMode/gradlew b/ui/window/BasicImmersiveMode/gradlew
similarity index 100%
rename from ui/BasicImmersiveMode/gradlew
rename to ui/window/BasicImmersiveMode/gradlew
diff --git a/ui/BasicImmersiveMode/gradlew.bat b/ui/window/BasicImmersiveMode/gradlew.bat
similarity index 100%
rename from ui/BasicImmersiveMode/gradlew.bat
rename to ui/window/BasicImmersiveMode/gradlew.bat
diff --git a/ui/BasicImmersiveMode/settings.gradle b/ui/window/BasicImmersiveMode/settings.gradle
similarity index 91%
rename from ui/BasicImmersiveMode/settings.gradle
rename to ui/window/BasicImmersiveMode/settings.gradle
index ebe5776..8dda383 100644
--- a/ui/BasicImmersiveMode/settings.gradle
+++ b/ui/window/BasicImmersiveMode/settings.gradle
@@ -1 +1,4 @@
+
+
+
include 'BasicImmersiveModeSample'
diff --git a/ui/BasicImmersiveMode/template-params.xml b/ui/window/BasicImmersiveMode/template-params.xml
similarity index 79%
rename from ui/BasicImmersiveMode/template-params.xml
rename to ui/window/BasicImmersiveMode/template-params.xml
index 317c0c3..5c7b73c 100644
--- a/ui/BasicImmersiveMode/template-params.xml
+++ b/ui/window/BasicImmersiveMode/template-params.xml
@@ -17,6 +17,7 @@
<sample>
<name>BasicImmersiveMode</name>
<package>com.example.android.basicimmersivemode</package>
+ <group>UI</group>
@@ -27,8 +28,9 @@
<strings>
<intro>
<![CDATA[
- Introductory text that explains what the sample is intended to demonstrate. Edit
- in template-params.xml.
+ \"Immersive Mode\" is a new UI mode which improves \"hide full screen\" and
+ \"hide nav bar\" modes, by letting users swipe the bars in and out. This sample
+ demonstrates how to enable and disable immersive mode programmatically.
]]>
</intro>
<sample_action>Toggle Immersive Mode!</sample_action>