inputmethod: allow hiding navigation ime bar

Change-Id: Iaa15dda08d614d01fae64ae2b5aa72f50513af99
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
2026-01-02 22:37:54 +07:00
parent ffe2e0cf00
commit f183e75d8f
2 changed files with 48 additions and 3 deletions

View File

@@ -61,6 +61,7 @@ import android.app.StatusBarManager;
import android.app.StatusBarManager.NavbarFlags;
import android.content.Context;
import android.content.res.Configuration;
import android.database.ContentObserver;
import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
@@ -69,12 +70,16 @@ import android.graphics.RectF;
import android.graphics.Region;
import android.inputmethodservice.InputMethodService.BackDispositionMode;
import android.inputmethodservice.InputMethodService.ImeWindowVisibility;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.telecom.TelecomManager;
import android.text.TextUtils;
import android.util.Log;
@@ -231,6 +236,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
private NavigationBarFrame mFrame;
private MotionEvent mCurrentDownEvent;
private final ContentObserver mNavBarObserver;
private @WindowVisibleState int mNavigationBarWindowState = WINDOW_STATE_SHOWING;
@NavbarFlags
@@ -649,6 +656,24 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
mView.setEdgeBackGestureHandler(mEdgeBackGestureHandler);
mView.setDisplayTracker(mDisplayTracker);
mNavBarMode = mNavigationModeController.addListener(mModeChangedListener);
mNavBarObserver = new ContentObserver(new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
super.onChange(selfChange, uri);
if (mView != null) {
mView.setNavBarMode(mNavBarMode, mNavigationModeController.getImeDrawsImeNavBar()
&& getShowNavBarIme());
}
}
};
}
private boolean getShowNavBarIme() {
return Settings.Secure.getIntForUser(
mContext.getContentResolver(),
"sysui_show_nav_bar_ime", 1,
UserHandle.USER_CURRENT) == 1;
}
public NavigationBarView getView() {
@@ -822,6 +847,13 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
AutoHideController autoHideController = mAutoHideControllerStore.forDisplay(mDisplayId);
setAutoHideController(autoHideController);
restoreAppearanceAndTransientState();
mContext.getContentResolver().registerContentObserver(
Settings.Secure.getUriFor("sysui_show_nav_bar_ime"),
false,
mNavBarObserver,
UserHandle.USER_ALL
);
}
@Override
@@ -839,6 +871,7 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
mNavBarHelper.removeNavTaskStateUpdater(mNavbarTaskbarStateUpdater);
mPipOptional.ifPresent(mView::removePipExclusionBoundsChangeListener);
mFrame = null;
mContext.getContentResolver().unregisterContentObserver(mNavBarObserver);
}
// TODO: Remove this when we update nav bar recreation
@@ -1838,7 +1871,8 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
}
private void setNavBarMode(int mode) {
mView.setNavBarMode(mode, mNavigationModeController.getImeDrawsImeNavBar());
mView.setNavBarMode(mode, mView.setNavBarMode(mode, mNavigationModeController.getImeDrawsImeNavBar()
&& getShowNavBarIme());
if (isGesturalMode(mode)) {
mRegionSamplingHelper.start(mSamplingBounds);
} else {

View File

@@ -508,6 +508,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
LineageSettings.Secure.FEATURE_TOUCH_HOVERING),
false, this, UserHandle.ALL);
}
resolver.registerContentObserverAsUser(Settings.Secure.getUriFor(
"sysui_show_nav_bar_ime"),
false, this, UserHandle.ALL);
}
@Override
@@ -523,6 +526,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
LineageSettings.System.HIGH_TOUCH_SENSITIVITY_ENABLE);
final Uri touchHoveringUri = LineageSettings.Secure.getUriFor(
LineageSettings.Secure.FEATURE_TOUCH_HOVERING);
final Uri navBarUri = Settings.Secure.getUriFor(
"sysui_show_nav_bar_ime");
synchronized (ImfLock.class) {
if (!mConcurrentMultiUserModeEnabled && mCurrentImeUserId != userId) {
return;
@@ -533,6 +538,8 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
updateTouchSensitivity();
} else if (touchHoveringUri.equals(uri)) {
updateTouchHovering();
} else if (navBarUri.equals(uri)) {
onUpdateResourceOverlay(userId);
}
}
}
@@ -1255,7 +1262,9 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
final boolean value =
InputMethodDrawsNavBarResourceMonitor.evaluate(context,
profileParentId);
userData.mImeDrawsNavBar.set(value);
final boolean showNavBarIme = Settings.Secure.getIntForUser(
context.getContentResolver(), "sysui_show_nav_bar_ime", 1, userId) == 1;
userData.mImeDrawsNavBar.set(value && showNavBarIme);
userData.mBackgroundLoadLatch.countDown();
Slog.d(TAG, "Complete initialization for user=" + userId);
@@ -5495,10 +5504,12 @@ public final class InputMethodManagerService implements IInputMethodManagerImpl.
final boolean value =
InputMethodDrawsNavBarResourceMonitor.evaluate(mContext, profileParentId);
final var profileUserIds = mUserManagerInternal.getProfileIds(profileParentId, false);
final boolean showNavBarIme = Settings.Secure.getIntForUser(
mContext.getContentResolver(), "sysui_show_nav_bar_ime", 1, userId) == 1;
final ArrayList<UserData> updatedUsers = new ArrayList<>();
for (int profileUserId : profileUserIds) {
final var userData = getUserData(profileUserId);
userData.mImeDrawsNavBar.set(value);
userData.mImeDrawsNavBar.set(value && showNavBarIme);
updatedUsers.add(userData);
}
synchronized (ImfLock.class) {