Skip to content

Commit 780a13b

Browse files
John SpurlockAndroid (Google) Code Review
authored andcommitted
Merge "Fix nav bar glitch when quickly turning screen off then on." into jb-mr1-dev
2 parents 36425d1 + 1bbd49d commit 780a13b

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import android.animation.Animator;
2020
import android.animation.AnimatorListenerAdapter;
21+
import android.animation.LayoutTransition;
2122
import android.app.StatusBarManager;
2223
import android.content.Context;
2324
import android.content.res.Resources;
@@ -34,6 +35,7 @@
3435
import android.view.MotionEvent;
3536
import android.view.View;
3637
import android.view.Surface;
38+
import android.view.ViewGroup;
3739
import android.view.WindowManager;
3840
import android.widget.ImageView;
3941
import android.widget.LinearLayout;
@@ -62,6 +64,7 @@ public class NavigationBarView extends LinearLayout {
6264

6365
int mBarSize;
6466
boolean mVertical;
67+
boolean mScreenOn;
6568

6669
boolean mHidden, mLowProfile, mShowMenu;
6770
int mDisabledFlags = 0;
@@ -169,6 +172,11 @@ public NavigationBarView(Context context, AttributeSet attrs) {
169172
mBackAltLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime);
170173
}
171174

175+
public void notifyScreenOn(boolean screenOn) {
176+
mScreenOn = screenOn;
177+
setDisabledFlags(mDisabledFlags, true);
178+
}
179+
172180
View.OnTouchListener mLightsOutListener = new View.OnTouchListener() {
173181
@Override
174182
public boolean onTouch(View v, MotionEvent ev) {
@@ -231,6 +239,16 @@ public void setDisabledFlags(int disabledFlags, boolean force) {
231239

232240
setSlippery(disableHome && disableRecent && disableBack);
233241

242+
if (!mScreenOn && mCurrentView != null) {
243+
ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons);
244+
LayoutTransition lt = navButtons == null ? null : navButtons.getLayoutTransition();
245+
if (lt != null) {
246+
lt.disableTransitionType(
247+
LayoutTransition.CHANGE_APPEARING | LayoutTransition.CHANGE_DISAPPEARING |
248+
LayoutTransition.APPEARING | LayoutTransition.DISAPPEARING);
249+
}
250+
}
251+
234252
getBackButton() .setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE);
235253
getHomeButton() .setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE);
236254
getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE);

packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,11 @@ private void repositionNavigationBar() {
783783
mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams());
784784
}
785785

786+
private void notifyNavigationBarScreenOn(boolean screenOn) {
787+
if (mNavigationBarView == null) return;
788+
mNavigationBarView.notifyScreenOn(screenOn);
789+
}
790+
786791
private WindowManager.LayoutParams getNavigationBarLayoutParams() {
787792
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(
788793
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
@@ -2256,6 +2261,7 @@ public void onReceive(Context context, Intent intent) {
22562261
else if (Intent.ACTION_SCREEN_OFF.equals(action)) {
22572262
// no waiting!
22582263
makeExpandedInvisible();
2264+
notifyNavigationBarScreenOn(false);
22592265
}
22602266
else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
22612267
if (DEBUG) {
@@ -2271,6 +2277,7 @@ else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) {
22712277
else if (Intent.ACTION_SCREEN_ON.equals(action)) {
22722278
// work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018)
22732279
repositionNavigationBar();
2280+
notifyNavigationBarScreenOn(true);
22742281
}
22752282
}
22762283
};

policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,13 @@ private void adjustStatusBarLocked() {
13061306
// (like recents). Temporary enable/disable (e.g. the "back" button) are
13071307
// done in KeyguardHostView.
13081308
flags |= StatusBarManager.DISABLE_RECENT;
1309+
if (!mScreenOn) {
1310+
// Disable all navbar buttons on screen off. The navigation bar will hide
1311+
// these immediately to avoid seeing the end of layout transition animations
1312+
// if quickly turning back on.
1313+
flags |= StatusBarManager.DISABLE_HOME;
1314+
flags |= StatusBarManager.DISABLE_BACK;
1315+
}
13091316
if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) {
13101317
// showing secure lockscreen; disable expanding.
13111318
flags |= StatusBarManager.DISABLE_EXPAND;

0 commit comments

Comments
 (0)