From 1bbd49d72eee001137b6d6e6ab3f353fe2c0433c Mon Sep 17 00:00:00 2001 From: John Spurlock Date: Fri, 19 Oct 2012 11:09:32 -0400 Subject: [PATCH] Fix nav bar glitch when quickly turning screen off then on. Keyguard now disables all navbar buttons when turning screen off instead of only recents. Navbar is told about screen off/on and disables the layout transition animation on screen off - if the user quickly turns the screen back on they do not see the end of the fade out animation. Bug:7377776 Change-Id: I96a050d58c6c9ce8537f50408655006fadbfcd4f --- .../statusbar/phone/NavigationBarView.java | 18 ++++++++++++++++++ .../statusbar/phone/PhoneStatusBar.java | 7 +++++++ .../impl/keyguard/KeyguardViewMediator.java | 7 +++++++ 3 files changed, 32 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 770ae6db4736c..eef54460d8afc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -18,6 +18,7 @@ package com.android.systemui.statusbar.phone; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; +import android.animation.LayoutTransition; import android.app.StatusBarManager; import android.content.Context; import android.content.res.Resources; @@ -34,6 +35,7 @@ import android.view.Display; import android.view.MotionEvent; import android.view.View; import android.view.Surface; +import android.view.ViewGroup; import android.view.WindowManager; import android.widget.ImageView; import android.widget.LinearLayout; @@ -62,6 +64,7 @@ public class NavigationBarView extends LinearLayout { int mBarSize; boolean mVertical; + boolean mScreenOn; boolean mHidden, mLowProfile, mShowMenu; int mDisabledFlags = 0; @@ -169,6 +172,11 @@ public class NavigationBarView extends LinearLayout { mBackAltLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_ime); } + public void notifyScreenOn(boolean screenOn) { + mScreenOn = screenOn; + setDisabledFlags(mDisabledFlags, true); + } + View.OnTouchListener mLightsOutListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent ev) { @@ -231,6 +239,16 @@ public class NavigationBarView extends LinearLayout { setSlippery(disableHome && disableRecent && disableBack); + if (!mScreenOn && mCurrentView != null) { + ViewGroup navButtons = (ViewGroup) mCurrentView.findViewById(R.id.nav_buttons); + LayoutTransition lt = navButtons == null ? null : navButtons.getLayoutTransition(); + if (lt != null) { + lt.disableTransitionType( + LayoutTransition.CHANGE_APPEARING | LayoutTransition.CHANGE_DISAPPEARING | + LayoutTransition.APPEARING | LayoutTransition.DISAPPEARING); + } + } + getBackButton() .setVisibility(disableBack ? View.INVISIBLE : View.VISIBLE); getHomeButton() .setVisibility(disableHome ? View.INVISIBLE : View.VISIBLE); getRecentsButton().setVisibility(disableRecent ? View.INVISIBLE : View.VISIBLE); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index f906176650e79..1e0ab1bb3d450 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -783,6 +783,11 @@ public class PhoneStatusBar extends BaseStatusBar { mWindowManager.updateViewLayout(mNavigationBarView, getNavigationBarLayoutParams()); } + private void notifyNavigationBarScreenOn(boolean screenOn) { + if (mNavigationBarView == null) return; + mNavigationBarView.notifyScreenOn(screenOn); + } + private WindowManager.LayoutParams getNavigationBarLayoutParams() { WindowManager.LayoutParams lp = new WindowManager.LayoutParams( LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, @@ -2256,6 +2261,7 @@ public class PhoneStatusBar extends BaseStatusBar { else if (Intent.ACTION_SCREEN_OFF.equals(action)) { // no waiting! makeExpandedInvisible(); + notifyNavigationBarScreenOn(false); } else if (Intent.ACTION_CONFIGURATION_CHANGED.equals(action)) { if (DEBUG) { @@ -2271,6 +2277,7 @@ public class PhoneStatusBar extends BaseStatusBar { else if (Intent.ACTION_SCREEN_ON.equals(action)) { // work around problem where mDisplay.getRotation() is not stable while screen is off (bug 7086018) repositionNavigationBar(); + notifyNavigationBarScreenOn(true); } } }; diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java index ceb032559c578..cb70922e01ba9 100644 --- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java +++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java @@ -1306,6 +1306,13 @@ public class KeyguardViewMediator { // (like recents). Temporary enable/disable (e.g. the "back" button) are // done in KeyguardHostView. flags |= StatusBarManager.DISABLE_RECENT; + if (!mScreenOn) { + // Disable all navbar buttons on screen off. The navigation bar will hide + // these immediately to avoid seeing the end of layout transition animations + // if quickly turning back on. + flags |= StatusBarManager.DISABLE_HOME; + flags |= StatusBarManager.DISABLE_BACK; + } if (isSecure() || !ENABLE_INSECURE_STATUS_BAR_EXPAND) { // showing secure lockscreen; disable expanding. flags |= StatusBarManager.DISABLE_EXPAND;