@@ -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,10 @@ 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 ;
915925
916926 if (MULTIUSER_DEBUG ) {
917927 mNotificationPanelDebugText = (TextView ) mNotificationPanel .findViewById (R .id .header_debug_info );
@@ -1480,6 +1490,10 @@ public void onClick(View v) {
14801490 }
14811491 };
14821492
1493+ private int getBottomGap () {
1494+ return mContext .getResources ().getDimensionPixelSize (R .dimen .heads_up_bottom_gap );
1495+ }
1496+
14831497 private int mShowSearchHoldoff = 0 ;
14841498 private Runnable mShowSearchPanel = new Runnable () {
14851499 public void run () {
@@ -1611,8 +1625,9 @@ private void addHeadsUpView() {
16111625 if (ActivityManager .isHighEndGfx ()) {
16121626 lp .flags |= WindowManager .LayoutParams .FLAG_HARDWARE_ACCELERATED ;
16131627 }
1614- lp .gravity = Gravity .TOP ;
1615- lp .y = getStatusBarHeight ();
1628+ lp .gravity = mHeadsUpGravityBottom && !mImeIsShowing ? Gravity .BOTTOM : Gravity .TOP ;
1629+ lp .y = mHeadsUpGravityBottom && !mImeIsShowing
1630+ ? getBottomGap () : (mStatusBarShows ? getStatusBarHeight () : 0 );
16161631 lp .setTitle ("Heads Up" );
16171632 lp .packageName = mContext .getPackageName ();
16181633 lp .windowAnimations = R .style .Animation_StatusBar_HeadsUp ;
@@ -1744,6 +1759,7 @@ public void hideHeadsUp() {
17441759
17451760 @ Override // CommandQueue
17461761 public void updateHeadsUpPosition (boolean statusBarShows ) {
1762+ mStatusBarShows = statusBarShows ;
17471763 // Change y layoutparams of heads up view when statusbar
17481764 // visibility changes.
17491765 // ToDo: We may want to animate this in future in the rare
@@ -1755,9 +1771,13 @@ public void updateHeadsUpPosition(boolean statusBarShows) {
17551771 if (mHeadsUpNotificationView != null ) {
17561772 WindowManager .LayoutParams lp = (WindowManager .LayoutParams )
17571773 mHeadsUpNotificationView .getLayoutParams ();
1758- lp .y = statusBarShows ? getStatusBarHeight () : 0 ;
1759- mWindowManager .updateViewLayout (mHeadsUpNotificationView , lp );
1760- }
1774+ if (lp != null ) {
1775+ lp .gravity = mHeadsUpGravityBottom && !mImeIsShowing ? Gravity .BOTTOM : Gravity .TOP ;
1776+ lp .y = mHeadsUpGravityBottom && !mImeIsShowing
1777+ ? getBottomGap () : (mStatusBarShows ? getStatusBarHeight () : 0 );
1778+ mWindowManager .updateViewLayout (mHeadsUpNotificationView , lp );
1779+ }
1780+ }
17611781 }
17621782
17631783 public void removeNotification (IBinder key ) {
@@ -3142,6 +3162,12 @@ public void setImeWindowStatus(IBinder token, int vis, int backDisposition) {
31423162 boolean altBack = (backDisposition == InputMethodService .BACK_DISPOSITION_WILL_DISMISS )
31433163 || mImeShowing ;
31443164
3165+ // If IME shows and heads up gravity is at the bottom, move it to the top.
3166+ if (mImeIsShowing != altBack ) {
3167+ mImeIsShowing = altBack ;
3168+ updateHeadsUpPosition (mStatusBarShows );
3169+ }
3170+
31453171 setNavigationIconHints (
31463172 altBack ? (mNavigationIconHints | NAVIGATION_HINT_BACK_ALT )
31473173 : (mNavigationIconHints & ~NAVIGATION_HINT_BACK_ALT ));
@@ -4457,6 +4483,13 @@ public void onChange(boolean selfChange, Uri uri) {
44574483 mContext .getContentResolver (),
44584484 Settings .System .HEADS_UP_SHOW_UPDATE , 0 ,
44594485 UserHandle .USER_CURRENT ) == 1 ;
4486+ } else if (uri .equals (Settings .System .getUriFor (
4487+ Settings .System .HEADS_UP_GRAVITY_BOTTOM ))) {
4488+ mHeadsUpGravityBottom = Settings .System .getIntForUser (
4489+ mContext .getContentResolver (),
4490+ Settings .System .HEADS_UP_GRAVITY_BOTTOM , 0 ,
4491+ UserHandle .USER_CURRENT ) == 1 ;
4492+ updateHeadsUpPosition (mStatusBarShows );
44604493 }
44614494 updateSettings ();
44624495 }
0 commit comments