diff options
Diffstat (limited to 'packages/SystemUI/src')
5 files changed, 134 insertions, 53 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java index 62d7500..c91f513 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java @@ -54,7 +54,7 @@ public class CommandQueue extends IStatusBar.Stub { private static final int OP_EXPAND = 1; private static final int OP_COLLAPSE = 2; - private static final int MSG_SET_LIGHTS_ON = 7 << MSG_SHIFT; + private static final int MSG_SET_SYSTEMUI_VISIBILITY = 7 << MSG_SHIFT; private static final int MSG_TOP_APP_WINDOW_CHANGED = 8 << MSG_SHIFT; private static final int MSG_SHOW_IME_BUTTON = 9 << MSG_SHIFT; @@ -86,7 +86,7 @@ public class CommandQueue extends IStatusBar.Stub { public void disable(int state); public void animateExpand(); public void animateCollapse(); - public void setLightsOn(boolean on); + public void setSystemUiVisibility(int vis); public void topAppWindowChanged(boolean visible); public void setImeWindowStatus(IBinder token, int vis, int backDisposition); public void setHardKeyboardStatus(boolean available, boolean enabled); @@ -160,10 +160,10 @@ public class CommandQueue extends IStatusBar.Stub { } } - public void setLightsOn(boolean on) { + public void setSystemUiVisibility(int vis) { synchronized (mList) { - mHandler.removeMessages(MSG_SET_LIGHTS_ON); - mHandler.obtainMessage(MSG_SET_LIGHTS_ON, on ? 1 : 0, 0, null).sendToTarget(); + mHandler.removeMessages(MSG_SET_SYSTEMUI_VISIBILITY); + mHandler.obtainMessage(MSG_SET_SYSTEMUI_VISIBILITY, vis, 0, null).sendToTarget(); } } @@ -259,8 +259,8 @@ public class CommandQueue extends IStatusBar.Stub { mCallbacks.animateCollapse(); } break; - case MSG_SET_LIGHTS_ON: - mCallbacks.setLightsOn(msg.arg1 != 0); + case MSG_SET_SYSTEMUI_VISIBILITY: + mCallbacks.setSystemUiVisibility(msg.arg1); break; case MSG_TOP_APP_WINDOW_CHANGED: mCallbacks.topAppWindowChanged(msg.arg1 != 0); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java index ca75138..918d5a3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBar.java @@ -78,7 +78,7 @@ public abstract class StatusBar extends SystemUI implements CommandQueue.Callbac } disable(switches[0]); - setLightsOn(switches[1] != 0); + setSystemUiVisibility(switches[1]); topAppWindowChanged(switches[2] != 0); // StatusBarManagerService has a back up of IME token and it's restored here. setImeWindowStatus(binders.get(0), switches[3], switches[4]); 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 550fc57..2740898 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -17,11 +17,14 @@ package com.android.systemui.statusbar.phone; import android.animation.Animator; +import android.animation.AnimatorSet; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; +import android.content.res.Resources; import android.os.ServiceManager; import android.util.AttributeSet; +import android.util.Slog; import android.view.Display; import android.view.KeyEvent; import android.view.MotionEvent; @@ -36,6 +39,9 @@ import com.android.internal.statusbar.IStatusBarService; import com.android.systemui.R; public class NavigationBarView extends LinearLayout { + final static boolean DEBUG = false; + final static String TAG = "NavigationBarView"; + final static boolean DEBUG_DEADZONE = false; final static boolean NAVBAR_ALWAYS_AT_RIGHT = true; @@ -44,7 +50,12 @@ public class NavigationBarView extends LinearLayout { final Display mDisplay; View mCurrentView = null; View[] mRotatedViews = new View[4]; - Animator mLastAnimator = null; + AnimatorSet mLastAnimator = null; + + int mBarSize; + boolean mVertical; + + boolean mHidden; public View getRecentsButton() { return mCurrentView.findViewById(R.id.recent_apps); @@ -56,37 +67,53 @@ public class NavigationBarView extends LinearLayout { public NavigationBarView(Context context, AttributeSet attrs) { super(context, attrs); + mHidden = false; + mDisplay = ((WindowManager)context.getSystemService( Context.WINDOW_SERVICE)).getDefaultDisplay(); mBarService = IStatusBarService.Stub.asInterface( ServiceManager.getService(Context.STATUS_BAR_SERVICE)); - //setLayerType(View.LAYER_TYPE_HARDWARE, null); - - setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { - @Override - public void onSystemUiVisibilityChange(int visibility) { - boolean on = (visibility == View.STATUS_BAR_VISIBLE); - android.util.Log.d("NavigationBarView", "LIGHTS " - + (on ? "ON" : "OUT")); - setLights(on); - } - }); + final Resources res = mContext.getResources(); + mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size); + mVertical = false; } - private void setLights(final boolean on) { + public void setHidden(final boolean hide) { + if (hide == mHidden) return; + + mHidden = hide; + Slog.d(TAG, + (hide ? "HIDING" : "SHOWING") + " navigation bar"); + float oldAlpha = mCurrentView.getAlpha(); - android.util.Log.d("NavigationBarView", "animating alpha: " + oldAlpha + " -> " - + (on ? 1f : 0f)); + if (DEBUG) { + Slog.d(TAG, "animating alpha: " + oldAlpha + " -> " + + (!hide ? 1f : 0f)); + } if (mLastAnimator != null && mLastAnimator.isRunning()) mLastAnimator.cancel(); - mLastAnimator = ObjectAnimator.ofFloat(mCurrentView, "alpha", oldAlpha, on ? 1f : 0f) - .setDuration(on ? 250 : 1500); + if (!hide) { + setVisibility(View.VISIBLE); + } + + // play us off, animatorset + mLastAnimator = new AnimatorSet(); + mLastAnimator.playTogether( + ObjectAnimator.ofFloat(mCurrentView, "alpha", hide ? 0f : 1f), + ObjectAnimator.ofFloat(mCurrentView, + mVertical ? "translationX" : "translationY", + hide ? mBarSize : 0) + ); + mLastAnimator.setDuration(!hide ? 250 : 1000); mLastAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator _a) { mLastAnimator = null; + if (hide) { + setVisibility(View.INVISIBLE); + } } }); mLastAnimator.start(); @@ -108,7 +135,7 @@ public class NavigationBarView extends LinearLayout { @Override public boolean onTouchEvent(MotionEvent ev) { // immediately bring up the lights - setLights(true); + setHidden(false); return false; // pass it on } @@ -119,11 +146,14 @@ public class NavigationBarView extends LinearLayout { } mCurrentView = mRotatedViews[rot]; mCurrentView.setVisibility(View.VISIBLE); + mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270); if (DEBUG_DEADZONE) { mCurrentView.findViewById(R.id.deadzone).setBackgroundColor(0x808080FF); } - android.util.Log.d("NavigationBarView", "reorient(): rot=" + mDisplay.getRotation()); + if (DEBUG) { + Slog.d(TAG, "reorient(): rot=" + mDisplay.getRotation()); + } } } 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 21b774c..f55c2bc 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -198,6 +198,9 @@ public class PhoneStatusBar extends StatusBar { // for disabling the status bar int mDisabled = 0; + // tracking calls to View.setSystemUiVisibility() + int mSystemUiVisibility = View.SYSTEM_UI_FLAG_VISIBLE; + private class ExpandedDialog extends Dialog { ExpandedDialog(Context context) { super(context, com.android.internal.R.style.Theme_Light_NoTitleBar); @@ -253,20 +256,33 @@ public class PhoneStatusBar extends StatusBar { mIntruderAlertView.setVisibility(View.GONE); mIntruderAlertView.setClickable(true); + PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, + R.layout.status_bar, null); + sb.mService = this; + mStatusBarView = sb; + try { boolean showNav = res.getBoolean(com.android.internal.R.bool.config_showNavigationBar); if (showNav) { mNavigationBarView = (NavigationBarView) View.inflate(context, R.layout.navigation_bar, null); + + sb.setOnSystemUiVisibilityChangeListener( + new View.OnSystemUiVisibilityChangeListener() { + @Override + public void onSystemUiVisibilityChange(int visibility) { + if (DEBUG) { + Slog.d(TAG, "systemUi: " + visibility); + } + boolean hide = (0 != (visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)); + mNavigationBarView.setHidden(hide); + } + }); } } catch (Resources.NotFoundException ex) { // no nav bar for you } - PhoneStatusBarView sb = (PhoneStatusBarView)View.inflate(context, - R.layout.status_bar, null); - sb.mService = this; - // figure out which pixel-format to use for the status bar. mPixelFormat = PixelFormat.TRANSLUCENT; Drawable bg = sb.getBackground(); @@ -274,7 +290,6 @@ public class PhoneStatusBar extends StatusBar { mPixelFormat = bg.getOpacity(); } - mStatusBarView = sb; mStatusIcons = (LinearLayout)sb.findViewById(R.id.statusIcons); mNotificationIcons = (IconMerger)sb.findViewById(R.id.notificationIcons); mIcons = (LinearLayout)sb.findViewById(R.id.icons); @@ -1275,22 +1290,31 @@ public class PhoneStatusBar extends StatusBar { return false; } + @Override // CommandQueue + public void setSystemUiVisibility(int vis) { + if (vis != mSystemUiVisibility) { + mSystemUiVisibility = vis; + + if (0 != (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE)) { + animateCollapse(); + } + + notifyUiVisibilityChanged(); + } + } + public void setLightsOn(boolean on) { - Log.v(TAG, "lights " + (on ? "on" : "off")); - if (!on) { - // All we do for "lights out" mode on a phone is hide the status bar, - // which the window manager does. But we do need to hide the windowshade - // on our own. - animateCollapse(); + Log.v(TAG, "setLightsOn(" + on + ")"); + if (on) { + setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE); + } else { + setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE); } - notifyLightsChanged(on); } - private void notifyLightsChanged(boolean shown) { + private void notifyUiVisibilityChanged() { try { - Slog.d(TAG, "lights " + (shown?"on":"out")); - mWindowManager.statusBarVisibilityChanged( - shown ? View.STATUS_BAR_VISIBLE : View.STATUS_BAR_HIDDEN); + mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); } catch (RemoteException ex) { } } @@ -1715,10 +1739,10 @@ public class PhoneStatusBar extends StatusBar { } } + // The user is not allowed to get stuck without navigation UI. Upon the slightest user + // interaction we bring the navigation back. public void userActivity() { - try { - mBarService.setSystemUiVisibility(View.STATUS_BAR_VISIBLE); - } catch (RemoteException ex) { } + mNavigationBarView.setHidden(false); } public void toggleRecentApps() { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java index 96f6e2f..c6e546e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/tablet/TabletStatusBar.java @@ -176,6 +176,8 @@ public class TabletStatusBar extends StatusBar implements private InputMethodsPanel mInputMethodsPanel; private CompatModePanel mCompatModePanel; + int mSystemUiVisibility = 0; + public Context getContext() { return mContext; } protected void addPanelWindows() { @@ -729,14 +731,16 @@ public class TabletStatusBar extends StatusBar implements if (DEBUG) Slog.d(TAG, "hiding shadows (lights on)"); mBarContents.setVisibility(View.VISIBLE); mShadow.setVisibility(View.GONE); - notifyLightsChanged(true); + mSystemUiVisibility &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; + notifyUiVisibilityChanged(); break; case MSG_HIDE_CHROME: if (DEBUG) Slog.d(TAG, "showing shadows (lights out)"); animateCollapse(); mBarContents.setVisibility(View.GONE); mShadow.setVisibility(View.VISIBLE); - notifyLightsChanged(false); + mSystemUiVisibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE; + notifyUiVisibilityChanged(); break; case MSG_STOP_TICKER: mTicker.halt(); @@ -1025,17 +1029,40 @@ public class TabletStatusBar extends StatusBar implements mHandler.sendEmptyMessage(MSG_CLOSE_NOTIFICATION_PEEK); } - // called by StatusBar - @Override + private void notifyUiVisibilityChanged() { + try { + mWindowManager.statusBarVisibilityChanged(mSystemUiVisibility); + } catch (RemoteException ex) { + } + } + + @Override // CommandQueue + public void setSystemUiVisibility(int vis) { + if (vis != mSystemUiVisibility) { + mSystemUiVisibility = vis; + + mHandler.removeMessages(MSG_HIDE_CHROME); + mHandler.removeMessages(MSG_SHOW_CHROME); + mHandler.sendEmptyMessage(0 == (vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) + ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); + + notifyUiVisibilityChanged(); + } + } + public void setLightsOn(boolean on) { // Policy note: if the frontmost activity needs the menu key, we assume it is a legacy app // that can't handle lights-out mode. if (mMenuButton.getVisibility() == View.VISIBLE) { on = true; } - mHandler.removeMessages(MSG_HIDE_CHROME); - mHandler.removeMessages(MSG_SHOW_CHROME); - mHandler.sendEmptyMessage(on ? MSG_SHOW_CHROME : MSG_HIDE_CHROME); + + Slog.v(TAG, "setLightsOn(" + on + ")"); + if (on) { + setSystemUiVisibility(mSystemUiVisibility & ~View.SYSTEM_UI_FLAG_LOW_PROFILE); + } else { + setSystemUiVisibility(mSystemUiVisibility | View.SYSTEM_UI_FLAG_LOW_PROFILE); + } } public void topAppWindowChanged(boolean showMenu) { |
