Skip to content

Commit 2069166

Browse files
committed
inputmethod: allow hiding navigation ime bar
Change-Id: Iaa15dda08d614d01fae64ae2b5aa72f50513af99
1 parent 5006ba2 commit 2069166

2 files changed

Lines changed: 46 additions & 8 deletions

File tree

packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import android.app.StatusBarManager.NavbarFlags;
6363
import android.content.Context;
6464
import android.content.res.Configuration;
65+
import android.database.ContentObserver;
6566
import android.graphics.Insets;
6667
import android.graphics.PixelFormat;
6768
import android.graphics.Point;
@@ -70,12 +71,16 @@
7071
import android.graphics.Region;
7172
import android.inputmethodservice.InputMethodService.BackDispositionMode;
7273
import android.inputmethodservice.InputMethodService.ImeWindowVisibility;
74+
import android.net.Uri;
7375
import android.os.Binder;
7476
import android.os.Bundle;
7577
import android.os.Handler;
78+
import android.os.Looper;
7679
import android.os.RemoteException;
7780
import android.os.Trace;
81+
import android.os.UserHandle;
7882
import android.provider.DeviceConfig;
83+
import android.provider.Settings;
7984
import android.telecom.TelecomManager;
8085
import android.text.TextUtils;
8186
import android.util.Log;
@@ -234,6 +239,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
234239
private EdgeBackGestureHandler mEdgeBackGestureHandler;
235240
private NavigationBarFrame mFrame;
236241
private MotionEvent mCurrentDownEvent;
242+
243+
private final ContentObserver mNavBarObserver;
237244

238245
private @WindowVisibleState int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
239246

@@ -690,6 +697,23 @@ public boolean isSamplingEnabled() {
690697
mView.setEdgeBackGestureHandler(mEdgeBackGestureHandler);
691698
mView.setDisplayTracker(mDisplayTracker);
692699
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;
693717
}
694718

695719
public NavigationBarView getView() {
@@ -864,6 +888,13 @@ public void onViewAttached() {
864888
AutoHideController autoHideController = mAutoHideControllerStore.forDisplay(mDisplayId);
865889
setAutoHideController(autoHideController);
866890
restoreAppearanceAndTransientState();
891+
892+
mContext.getContentResolver().registerContentObserver(
893+
Settings.Secure.getUriFor("sysui_show_nav_bar_ime"),
894+
false,
895+
mNavBarObserver,
896+
UserHandle.USER_ALL
897+
);
867898
}
868899

869900
@Override
@@ -897,6 +928,7 @@ public void onViewDetached() {
897928
mPipOptional.ifPresent(mView::removePipExclusionBoundsChangeListener);
898929
mFrame = null;
899930
mOrientationHandle = null;
931+
mContext.getContentResolver().unregisterContentObserver(mNavBarObserver);
900932
}
901933

902934
// TODO: Remove this when we update nav bar recreation
@@ -2044,7 +2076,7 @@ public void setNavigationBarLumaSamplingEnabled(boolean enable) {
20442076
}
20452077

20462078
private void setNavBarMode(int mode) {
2047-
mView.setNavBarMode(mode, mNavigationModeController.getImeDrawsImeNavBar());
2079+
mView.setNavBarMode(mode, getShowNavBarIme());
20482080
if (isGesturalMode(mode)) {
20492081
mRegionSamplingHelper.start(mSamplingBounds);
20502082
} else {

services/core/java/com/android/server/inputmethod/InputMethodManagerService.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,9 @@ void registerContentObserverForAllUsers() {
505505
LineageSettings.Secure.FEATURE_TOUCH_HOVERING),
506506
false, this, UserHandle.ALL);
507507
}
508+
resolver.registerContentObserverAsUser(Settings.Secure.getUriFor(
509+
"sysui_show_nav_bar_ime"),
510+
false, this, UserHandle.ALL);
508511
}
509512

510513
@Override
@@ -520,6 +523,8 @@ private void onChangeInternal(@NonNull Uri uri, @UserIdInt int userId) {
520523
LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
521524
final Uri touchHoveringUri = LineageSettings.Secure.getUriFor(
522525
LineageSettings.Secure.FEATURE_TOUCH_HOVERING);
526+
final Uri navBarUri = Settings.Secure.getUriFor(
527+
"sysui_show_nav_bar_ime");
523528
synchronized (ImfLock.class) {
524529
if (!mConcurrentMultiUserModeEnabled && mCurrentImeUserId != userId) {
525530
return;
@@ -530,6 +535,8 @@ private void onChangeInternal(@NonNull Uri uri, @UserIdInt int userId) {
530535
updateTouchSensitivity();
531536
} else if (touchHoveringUri.equals(uri)) {
532537
updateTouchHovering();
538+
} else if (navBarUri.equals(uri)) {
539+
onUpdateResourceOverlay(userId);
533540
}
534541
}
535542
}
@@ -1241,10 +1248,9 @@ private void initializeUsersAsync(@UserIdInt int[] userIds) {
12411248
InputMethodSettingsRepository.put(userId, settings);
12421249

12431250
final int profileParentId = userManagerInternal.getProfileParentId(userId);
1244-
final boolean value =
1245-
InputMethodDrawsNavBarResourceMonitor.evaluate(context,
1246-
profileParentId);
1247-
userData.mImeDrawsNavBar.set(value);
1251+
final boolean showNavBarIme = Settings.Secure.getIntForUser(
1252+
context.getContentResolver(), "sysui_show_nav_bar_ime", 1, userId) == 1;
1253+
userData.mImeDrawsNavBar.set(showNavBarIme);
12481254

12491255
userData.mBackgroundLoadLatch.countDown();
12501256
Slog.d(TAG, "Complete initialization for user=" + userId);
@@ -5248,13 +5254,13 @@ void sendOnNavButtonFlagsChangedLocked(@NonNull UserData userData) {
52485254
@WorkerThread
52495255
private void onUpdateResourceOverlay(@UserIdInt int userId) {
52505256
final int profileParentId = mUserManagerInternal.getProfileParentId(userId);
5251-
final boolean value =
5252-
InputMethodDrawsNavBarResourceMonitor.evaluate(mContext, profileParentId);
52535257
final var profileUserIds = mUserManagerInternal.getProfileIds(profileParentId, false);
5258+
final boolean showNavBarIme = Settings.Secure.getIntForUser(
5259+
mContext.getContentResolver(), "sysui_show_nav_bar_ime", 1, userId) == 1;
52545260
final ArrayList<UserData> updatedUsers = new ArrayList<>();
52555261
for (int profileUserId : profileUserIds) {
52565262
final var userData = getUserData(profileUserId);
5257-
userData.mImeDrawsNavBar.set(value);
5263+
userData.mImeDrawsNavBar.set(showNavBarIme);
52585264
updatedUsers.add(userData);
52595265
}
52605266
synchronized (ImfLock.class) {

0 commit comments

Comments
 (0)