android5.1系统定制应用全屏界面实现禁止状态栏下拉

参照http://www.tuicool.com/articles/iEb6Jb基础上修改

在Activity添加:

private static final int SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED = 0x00002000;

findViewById(R.id.scrollView1).setSystemUiVisibility(SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED);

在frameworks/base打补丁如下

From c58540f82c51ba7b6846e447bc3328ee91d5379f Mon Sep 17 00:00:00 2001
From: weitf 
Date: Thu, 12 Nov 2015 10:31:06 +0800
Subject: [PATCH] Prohibit state bar drop-down

---
 core/java/android/view/View.java                   |    8 ++++++
 .../internal/policy/impl/PhoneWindowManager.java   |   29 ++++++++++++++++++++
 2 files changed, 37 insertions(+)
 mode change 100644 => 100755 core/java/android/view/View.java

diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
old mode 100644
new mode 100755
index b01201a..c6e3332
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -2599,6 +2599,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
      * with one or both of those flags.

*/ public static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 0x00001000; + + /** + * @hide + * + * NOTE: Flag for {@link #setSystemUiVisibility(int)}: It help user to disable transient + * status bar triggered by gesture + */ + public static final int SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED = 0x00002000; /** * @deprecated Use {@link #SYSTEM_UI_FLAG_LOW_PROFILE} instead. diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java index f6d58ba..a0fba7b 100755 --- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -1385,6 +1385,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { new SystemGesturesPointerEventListener.Callbacks() { @Override public void onSwipeFromTop() { + + //aded by inet_weitf @20151109 + if (isGestureIsolated()) + return; + //added end + if (mStatusBar != null) { requestTransientBars(mStatusBar); } @@ -1394,6 +1400,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } @Override public void onSwipeFromBottom() { + + //aded by inet_weitf @20151109 + if (isGestureIsolated()) + return; + //added end + if (mNavigationBar != null && mNavigationBarOnBottom) { requestTransientBars(mNavigationBar); } @@ -1403,6 +1415,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } @Override public void onSwipeFromRight() { + + //aded by inet_weitf @20151109 + if (isGestureIsolated()) + return; + //added end + if (mNavigationBar != null && !mNavigationBarOnBottom) { requestTransientBars(mNavigationBar); } @@ -1411,6 +1429,17 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void onDebug() { // no-op } + + //aded by inet_weitf @20151109 + private boolean isGestureIsolated() { + WindowState win = mFocusedWindow != null ? mFocusedWindow : mTopFullscreenOpaqueWindowState; + if (win != null && (win.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_IMMERSIVE_GESTURE_ISOLATED) != 0) + return true; + else + return false; + } + //added end + }); mImmersiveModeConfirmation = new ImmersiveModeConfirmation(mContext); mWindowManagerFuncs.registerPointerEventListener(mSystemGestures); -- 1.7.9.5

你可能感兴趣的:(Android,frameworks)