From 996cd2cd2c57c69ff7c1cb1df77ca6d83896a442 Mon Sep 17 00:00:00 2001 From: StellarSand Date: Fri, 25 Jul 2025 23:34:24 +0530 Subject: [PATCH] Proper fix for FAB being hidden by keyboard (#2579) --- app/src/main/AndroidManifest.xml | 3 ++- .../card_locker/LoyaltyCardEditActivity.java | 18 +++++---------- .../card_locker/ManageGroupActivity.java | 2 +- .../main/java/protect/card_locker/Utils.java | 22 +++++++++++++++++++ 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 57d875c67..98f978d98 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -75,7 +75,8 @@ + android:theme="@style/AppTheme.NoActionBar" + android:windowSoftInputMode="adjustResize"/> { + Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); + + ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams(); + layoutParams.leftMargin = insets.left; + layoutParams.bottomMargin = insets.bottom; + layoutParams.rightMargin = insets.right; + layoutParams.topMargin = insets.top; + view.setLayoutParams(layoutParams); + + // This is required to move the FAB above the keyboard when keyboard is open + Insets imeInsets = windowInsets.getInsets(WindowInsetsCompat.Type.ime()); + boolean isKeyboardVisible = windowInsets.isVisible(WindowInsetsCompat.Type.ime()); + fab.setTranslationY(isKeyboardVisible ? (- imeInsets.bottom) : 0); + + return WindowInsetsCompat.CONSUMED; + }); + } public static ImageView.ScaleType getRecommendedScaleTypeForThumbnailImage(@Nullable Bitmap image) { // Return something sensible if no image