From e1eb049d05f3f8100118e2f2cdd0f3e9f17c1202 Mon Sep 17 00:00:00 2001 From: Katharine Chui Date: Tue, 16 Nov 2021 23:44:45 +0800 Subject: [PATCH] prevent bottomSheet from growing a padding getting into/leaving fullscreen --- .../card_locker/LoyaltyCardViewActivity.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java index 357dfde6a..d7b1b7335 100644 --- a/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java +++ b/app/src/main/java/protect/card_locker/LoyaltyCardViewActivity.java @@ -51,6 +51,7 @@ import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.widget.NestedScrollView; import androidx.core.widget.TextViewCompat; + import protect.card_locker.async.TaskHandler; import protect.card_locker.preferences.Settings; @@ -59,6 +60,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements private GestureDetector mGestureDetector; + CoordinatorLayout coordinatorLayout; TextView cardIdFieldView; BottomSheetBehavior behavior; LinearLayout bottomSheet; @@ -257,6 +259,7 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements db = new DBHelper(this); importURIHelper = new ImportURIHelper(this); + coordinatorLayout = findViewById(R.id.coordinator_layout); cardIdFieldView = findViewById(R.id.cardIdView); bottomSheet = findViewById(R.id.bottom_sheet); bottomSheetContentWrapper = findViewById(R.id.bottomSheetContentWrapper); @@ -413,10 +416,6 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements ); } } - // XXX - // from android 5 - 9 a padding magically grows on top of bottomSheet after leaving fullscreen - // I suspect that it's a bug with going into immersive mode then out, along with coordinator layout bottom sheet - Log.d("adjustLayoutHeights", "padding top: " + bottomSheet.getPaddingTop() + " padding bottom: " + bottomSheet.getPaddingBottom()); } @@ -898,6 +897,8 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements behavior.setState(BottomSheetBehavior.STATE_COLLAPSED); editButton.hide(); + // android 5-9, avoid padding growing on top of bottomSheet + coordinatorLayout.removeView(bottomSheet); // Set Android to fullscreen mode getWindow().getDecorView().setSystemUiVisibility( @@ -940,6 +941,11 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements & ~View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY & ~View.SYSTEM_UI_FLAG_FULLSCREEN ); + + // android 5-9, avoid padding growing on top of bottomSheet + if (bottomSheet.getParent() != coordinatorLayout) { + coordinatorLayout.addView(bottomSheet); + } } Log.d("setFullScreen", "Is full screen enabled? " + enabled + " Zoom Level = " + barcodeScaler.getProgress());