@@ -330,6 +330,9 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
330330 private int mHeadsUpNotificationDecay ;
331331 private boolean mHeadsUpExpandedByDefault ;
332332 private boolean mHeadsUpNotificationViewAttached ;
333+ private boolean mHeadsUpGravityBottom ;
334+ private boolean mStatusBarShows = true ;
335+ private boolean mImeIsShowing ;
333336
334337 // on-screen navigation buttons
335338 private NavigationBarView mNavigationBarView = null ;
@@ -472,6 +475,9 @@ void observe() {
472475 resolver .registerContentObserver (Settings .System .getUriFor (
473476 Settings .System .HEADS_UP_SHOW_UPDATE ), false , this ,
474477 UserHandle .USER_ALL );
478+ resolver .registerContentObserver (Settings .System .getUriFor (
479+ Settings .System .HEADS_UP_GRAVITY_BOTTOM ), false , this ,
480+ UserHandle .USER_ALL );
475481
476482 updateSettings ();
477483 }
@@ -912,6 +918,14 @@ public boolean onTouch(View v, MotionEvent event) {
912918 mContext .getContentResolver (),
913919 Settings .System .HEADS_UP_SHOW_UPDATE , 0 ,
914920 UserHandle .USER_CURRENT ) == 1 ;
921+ mHeadsUpGravityBottom = Settings .System .getIntForUser (
922+ mContext .getContentResolver (),
923+ Settings .System .HEADS_UP_GRAVITY_BOTTOM , 0 ,
924+ UserHandle .USER_CURRENT ) == 1 ;
925+ mHeadsUpGravityBottom = Settings .System .getIntForUser (
926+ mContext .getContentResolver (),
927+ Settings .System .HEADS_UP_GRAVITY_BOTTOM , 0 ,
928+ UserHandle .USER_CURRENT ) == 1 ;
915929
916930 if (MULTIUSER_DEBUG ) {
917931 mNotificationPanelDebugText = (TextView ) mNotificationPanel .findViewById (R .id .header_debug_info );
@@ -1480,6 +1494,10 @@ public void onClick(View v) {
14801494 }
14811495 };
14821496
1497+ private int getBottomGap () {
1498+ return mContext .getResources ().getDimensionPixelSize (R .dimen .heads_up_bottom_gap );
1499+ }
1500+
14831501 private int mShowSearchHoldoff = 0 ;
14841502 private Runnable mShowSearchPanel = new Runnable () {
14851503 public void run () {
@@ -1611,8 +1629,9 @@ private void addHeadsUpView() {
16111629 if (ActivityManager .isHighEndGfx ()) {
16121630 lp .flags |= WindowManager .LayoutParams .FLAG_HARDWARE_ACCELERATED ;
16131631 }
1614- lp .gravity = Gravity .TOP ;
1615- lp .y = getStatusBarHeight ();
1632+ lp .gravity = mHeadsUpGravityBottom && !mImeIsShowing ? Gravity .BOTTOM : Gravity .TOP ;
1633+ lp .y = mHeadsUpGravityBottom && !mImeIsShowing
1634+ ? getBottomGap () : (mStatusBarShows ? getStatusBarHeight () : 0 );
16161635 lp .setTitle ("Heads Up" );
16171636 lp .packageName = mContext .getPackageName ();
16181637 lp .windowAnimations = R .style .Animation_StatusBar_HeadsUp ;
@@ -1744,6 +1763,7 @@ public void hideHeadsUp() {
17441763
17451764 @ Override // CommandQueue
17461765 public void updateHeadsUpPosition (boolean statusBarShows ) {
1766+ mStatusBarShows = statusBarShows ;
17471767 // Change y layoutparams of heads up view when statusbar
17481768 // visibility changes.
17491769 // ToDo: We may want to animate this in future in the rare
@@ -1755,9 +1775,13 @@ public void updateHeadsUpPosition(boolean statusBarShows) {
17551775 if (mHeadsUpNotificationView != null ) {
17561776 WindowManager .LayoutParams lp = (WindowManager .LayoutParams )
17571777 mHeadsUpNotificationView .getLayoutParams ();
1758- lp .y = statusBarShows ? getStatusBarHeight () : 0 ;
1759- mWindowManager .updateViewLayout (mHeadsUpNotificationView , lp );
1760- }
1778+ if (lp != null ) {
1779+ lp .gravity = mHeadsUpGravityBottom && !mImeIsShowing ? Gravity .BOTTOM : Gravity .TOP ;
1780+ lp .y = mHeadsUpGravityBottom && !mImeIsShowing
1781+ ? getBottomGap () : (mStatusBarShows ? getStatusBarHeight () : 0 );
1782+ mWindowManager .updateViewLayout (mHeadsUpNotificationView , lp );
1783+ }
1784+ }
17611785 }
17621786
17631787 public void removeNotification (IBinder key ) {
@@ -3142,6 +3166,12 @@ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
31423166 boolean altBack = (backDisposition == InputMethodService .BACK_DISPOSITION_WILL_DISMISS )
31433167 || mImeShowing ;
31443168
3169+ // If IME shows and heads up gravity is at the bottom, move it to the top.
3170+ if (mImeIsShowing != altBack ) {
3171+ mImeIsShowing = altBack ;
3172+ updateHeadsUpPosition (mStatusBarShows );
3173+ }
3174+
31453175 setNavigationIconHints (
31463176 altBack ? (mNavigationIconHints | NAVIGATION_HINT_BACK_ALT )
31473177 : (mNavigationIconHints & ~NAVIGATION_HINT_BACK_ALT ));
@@ -4457,6 +4487,13 @@ public void onChange(boolean selfChange, Uri uri) {
44574487 mContext .getContentResolver (),
44584488 Settings .System .HEADS_UP_SHOW_UPDATE , 0 ,
44594489 UserHandle .USER_CURRENT ) == 1 ;
4490+ } else if (uri .equals (Settings .System .getUriFor (
4491+ Settings .System .HEADS_UP_GRAVITY_BOTTOM ))) {
4492+ mHeadsUpGravityBottom = Settings .System .getIntForUser (
4493+ mContext .getContentResolver (),
4494+ Settings .System .HEADS_UP_GRAVITY_BOTTOM , 0 ,
4495+ UserHandle .USER_CURRENT ) == 1 ;
4496+ updateHeadsUpPosition (mStatusBarShows );
44604497 }
44614498 updateSettings ();
44624499 }
0 commit comments