diff options
author | Hak Matsuda <hakuro@google.com> | 2013-12-05 15:03:26 -0800 |
---|---|---|
committer | Andrew Hsieh <andrewhsieh@google.com> | 2013-12-30 13:49:54 +0800 |
commit | 78bf63517058adcb5f8c1057e51f9a70598e4788 (patch) | |
tree | 9a43d557311de1ae08846a2eaa260593697144eb | |
parent | 2a0781b43d7187d687b646f0dabff2af12f3146c (diff) | |
download | android_development-78bf63517058adcb5f8c1057e51f9a70598e4788.tar.gz android_development-78bf63517058adcb5f8c1057e51f9a70598e4788.tar.bz2 android_development-78bf63517058adcb5f8c1057e51f9a70598e4788.zip |
Restore immersive mode when volume button has been pressed.
Workaround issue where SYSTEM_UI_FLAG_IMMERSIVE_STICKY is invalidated
when a volume button is pressed (internal bug ref b/11986621)
Immersive mode still does not recover when the screen has been
rotated, due to onSystemUiVisibilityChange is not triggered
when screen is rotated (internal bug ref b/11990702)
Change-Id: Ifdfe9b24d5c3c208441aeca0fbb2b1eaee39da95
2 files changed, 56 insertions, 7 deletions
diff --git a/ndk/platforms/android-17/samples/Teapot/src/com/sample/teapot/TeapotNativeActivity.java b/ndk/platforms/android-17/samples/Teapot/src/com/sample/teapot/TeapotNativeActivity.java index 32696b8ff..9e296e447 100644 --- a/ndk/platforms/android-17/samples/Teapot/src/com/sample/teapot/TeapotNativeActivity.java +++ b/ndk/platforms/android-17/samples/Teapot/src/com/sample/teapot/TeapotNativeActivity.java @@ -31,6 +31,22 @@ public class TeapotNativeActivity extends NativeActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //Hide toolbar + int SDK_INT = android.os.Build.VERSION.SDK_INT; + if(SDK_INT >= 19) + { + setImmersiveSticky(); + + View decorView = getWindow().getDecorView(); + decorView.setOnSystemUiVisibilityChangeListener + (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + setImmersiveSticky(); + } + }); + } + } protected void onResume() { @@ -48,14 +64,22 @@ public class TeapotNativeActivity extends NativeActivity { } else if(SDK_INT >= 19) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + setImmersiveSticky(); } } // Our popup window, you will call it from your C/C++ code later + void setImmersiveSticky() { + View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + TeapotNativeActivity _activity; PopupWindow _popupWindow; TextView _label; diff --git a/ndk/platforms/android-18/samples/MoreTeapots/src/com/sample/moreteapots/MoreTeapotsNativeActivity.java b/ndk/platforms/android-18/samples/MoreTeapots/src/com/sample/moreteapots/MoreTeapotsNativeActivity.java index ed5b1d309..14fe1baab 100644 --- a/ndk/platforms/android-18/samples/MoreTeapots/src/com/sample/moreteapots/MoreTeapotsNativeActivity.java +++ b/ndk/platforms/android-18/samples/MoreTeapots/src/com/sample/moreteapots/MoreTeapotsNativeActivity.java @@ -17,7 +17,9 @@ package com.sample.moreteapots; import android.app.NativeActivity; +import android.content.res.Configuration; import android.os.Bundle; +import android.util.Log; import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; @@ -31,6 +33,22 @@ public class MoreTeapotsNativeActivity extends NativeActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //Hide toolbar + int SDK_INT = android.os.Build.VERSION.SDK_INT; + Log.i("OnCreate", "OnCreate!!!"); + if(SDK_INT >= 19) + { + setImmersiveSticky(); + View decorView = getWindow().getDecorView(); + decorView.setOnSystemUiVisibilityChangeListener + (new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + setImmersiveSticky(); + } + }); + } + } protected void onResume() { @@ -48,9 +66,7 @@ public class MoreTeapotsNativeActivity extends NativeActivity { } else if(SDK_INT >= 19) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); + setImmersiveSticky(); } } @@ -65,6 +81,16 @@ public class MoreTeapotsNativeActivity extends NativeActivity { } // Our popup window, you will call it from your C/C++ code later + void setImmersiveSticky() { + View decorView = getWindow().getDecorView(); + decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); + } + MoreTeapotsNativeActivity _activity; PopupWindow _popupWindow; TextView _label; @@ -112,7 +138,6 @@ public class MoreTeapotsNativeActivity extends NativeActivity { @Override public void run() { _label.setText(String.format("%2.2f FPS", fFPS)); - }}); } } |