mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-04 23:53:51 -04:00
Reset state on paused to prevent layout glitches
This commit is contained in:
@@ -145,6 +145,12 @@ public class LoyaltyCardViewActivity extends AppCompatActivity
|
||||
|
||||
Log.i(TAG, "To view card: " + loyaltyCardId);
|
||||
|
||||
if(barcodeIsFullscreen)
|
||||
{
|
||||
// Properly reset state to prevent any issues
|
||||
recreate();
|
||||
}
|
||||
|
||||
// The brightness value is on a scale from [0, ..., 1], where
|
||||
// '1' is the brightest. We attempt to maximize the brightness
|
||||
// to help barcode readers scan the barcode.
|
||||
|
||||
@@ -738,6 +738,21 @@ public class LoyaltyCardViewActivityTest
|
||||
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
|
||||
assertEquals(View.GONE, collapsingToolbarLayout.getVisibility());
|
||||
|
||||
// Resuming the activity should revert the state to normal view
|
||||
activityController.pause();
|
||||
activityController.resume();
|
||||
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
|
||||
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
|
||||
assertNotEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
|
||||
assertEquals(View.VISIBLE, collapsingToolbarLayout.getVisibility());
|
||||
|
||||
// Clicking the barcode should still work to fullscreen again
|
||||
barcodeImage.performClick();
|
||||
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
|
||||
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY, uiOptions);
|
||||
assertEquals(uiOptions | View.SYSTEM_UI_FLAG_FULLSCREEN, uiOptions);
|
||||
assertEquals(View.GONE, collapsingToolbarLayout.getVisibility());
|
||||
|
||||
// In full screen mode, back button should disable fullscreen
|
||||
activity.onBackPressed();
|
||||
uiOptions = activity.getWindow().getDecorView().getSystemUiVisibility();
|
||||
|
||||
Reference in New Issue
Block a user