|
62 | 62 | import android.app.StatusBarManager.NavbarFlags; |
63 | 63 | import android.content.Context; |
64 | 64 | import android.content.res.Configuration; |
| 65 | +import android.database.ContentObserver; |
65 | 66 | import android.graphics.Insets; |
66 | 67 | import android.graphics.PixelFormat; |
67 | 68 | import android.graphics.Point; |
|
70 | 71 | import android.graphics.Region; |
71 | 72 | import android.inputmethodservice.InputMethodService.BackDispositionMode; |
72 | 73 | import android.inputmethodservice.InputMethodService.ImeWindowVisibility; |
| 74 | +import android.net.Uri; |
73 | 75 | import android.os.Binder; |
74 | 76 | import android.os.Bundle; |
75 | 77 | import android.os.Handler; |
| 78 | +import android.os.Looper; |
76 | 79 | import android.os.RemoteException; |
77 | 80 | import android.os.Trace; |
| 81 | +import android.os.UserHandle; |
78 | 82 | import android.provider.DeviceConfig; |
| 83 | +import android.provider.Settings; |
79 | 84 | import android.telecom.TelecomManager; |
80 | 85 | import android.text.TextUtils; |
81 | 86 | import android.util.Log; |
@@ -234,6 +239,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements |
234 | 239 | private EdgeBackGestureHandler mEdgeBackGestureHandler; |
235 | 240 | private NavigationBarFrame mFrame; |
236 | 241 | private MotionEvent mCurrentDownEvent; |
| 242 | + |
| 243 | + private final ContentObserver mNavBarObserver; |
237 | 244 |
|
238 | 245 | private @WindowVisibleState int mNavigationBarWindowState = WINDOW_STATE_SHOWING; |
239 | 246 |
|
@@ -690,6 +697,23 @@ public boolean isSamplingEnabled() { |
690 | 697 | mView.setEdgeBackGestureHandler(mEdgeBackGestureHandler); |
691 | 698 | mView.setDisplayTracker(mDisplayTracker); |
692 | 699 | mNavBarMode = mNavigationModeController.addListener(mModeChangedListener); |
| 700 | + |
| 701 | + mNavBarObserver = new ContentObserver(new Handler(Looper.getMainLooper())) { |
| 702 | + @Override |
| 703 | + public void onChange(boolean selfChange, Uri uri) { |
| 704 | + super.onChange(selfChange, uri); |
| 705 | + if (mView != null) { |
| 706 | + mView.setNavBarMode(mNavBarMode, getShowNavBarIme()); |
| 707 | + } |
| 708 | + } |
| 709 | + }; |
| 710 | + } |
| 711 | + |
| 712 | + private boolean getShowNavBarIme() { |
| 713 | + return Settings.Secure.getIntForUser( |
| 714 | + mContext.getContentResolver(), |
| 715 | + "sysui_show_nav_bar_ime", 1, |
| 716 | + UserHandle.USER_CURRENT) == 1; |
693 | 717 | } |
694 | 718 |
|
695 | 719 | public NavigationBarView getView() { |
@@ -864,6 +888,13 @@ public void onViewAttached() { |
864 | 888 | AutoHideController autoHideController = mAutoHideControllerStore.forDisplay(mDisplayId); |
865 | 889 | setAutoHideController(autoHideController); |
866 | 890 | restoreAppearanceAndTransientState(); |
| 891 | + |
| 892 | + mContext.getContentResolver().registerContentObserver( |
| 893 | + Settings.Secure.getUriFor("sysui_show_nav_bar_ime"), |
| 894 | + false, |
| 895 | + mNavBarObserver, |
| 896 | + UserHandle.USER_ALL |
| 897 | + ); |
867 | 898 | } |
868 | 899 |
|
869 | 900 | @Override |
@@ -897,6 +928,7 @@ public void onViewDetached() { |
897 | 928 | mPipOptional.ifPresent(mView::removePipExclusionBoundsChangeListener); |
898 | 929 | mFrame = null; |
899 | 930 | mOrientationHandle = null; |
| 931 | + mContext.getContentResolver().unregisterContentObserver(mNavBarObserver); |
900 | 932 | } |
901 | 933 |
|
902 | 934 | // TODO: Remove this when we update nav bar recreation |
@@ -2044,7 +2076,7 @@ public void setNavigationBarLumaSamplingEnabled(boolean enable) { |
2044 | 2076 | } |
2045 | 2077 |
|
2046 | 2078 | private void setNavBarMode(int mode) { |
2047 | | - mView.setNavBarMode(mode, mNavigationModeController.getImeDrawsImeNavBar()); |
| 2079 | + mView.setNavBarMode(mode, getShowNavBarIme()); |
2048 | 2080 | if (isGesturalMode(mode)) { |
2049 | 2081 | mRegionSamplingHelper.start(mSamplingBounds); |
2050 | 2082 | } else { |
|
0 commit comments