+
+ protected int getBottomMargin(Context context, UIHost host) {
+ return host instanceof SecondaryHomeActivity
+ && !U.isShowHideNavbarSupported()
+ && TaskbarPosition.isBottom(context) ? U.getNavbarHeight(context) : -1;
+ }
+
+ protected void applyMarginFix(UIHost host, View layout, ViewParams params) {
+ if(U.getCurrentApiVersion() <= 29.0 || !(host instanceof SecondaryHomeActivity))
+ return;
+
+ layout.setOnApplyWindowInsetsListener((v, insets) -> {
+ boolean isImeVisible = CompatUtils.isImeVisible(v);
+ if(isImeVisible != prevImeVisibility) {
+ prevImeVisibility = isImeVisible;
+
+ ViewParams newParams = isImeVisible ? params.updateBottomMargin(0) : params;
+ host.updateViewLayout(layout, newParams);
+
+ if(isImeFixDisabled() && !U.isLibrary(context)) {
+ SharedPreferences pref = U.getSharedPreferences(context);
+ if(!pref.getBoolean(PREF_DESKTOP_MODE_IME_FIX, false)) {
+ pref.edit().putBoolean(PREF_DESKTOP_MODE_IME_FIX, true).apply();
+ U.showToastLong(context, R.string.tb_desktop_mode_ime_fix_toast);
+ }
+ }
+ }
+
+ return insets;
+ });
+ }
+
+ protected boolean isImeFixDisabled() {
+ String ime = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
+ return !ime.startsWith(BuildConfig.BASE_APPLICATION_ID) && !ime.startsWith("com.farmerbb.secondscreen");
+ }