From f1b9f7e9fe67da45cffd9f46560755d13fb583ec Mon Sep 17 00:00:00 2001 From: pandasoft0 Date: Wed, 20 Mar 2019 21:26:39 +0300 Subject: [PATCH] Fix issue with floating media bar after permissions request (#1134) --- .../keylesspalace/tusky/ComposeActivity.java | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 7a1941155..a91d5c175 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -818,16 +818,29 @@ public final class ComposeActivity } private void onMediaPick() { - addMediaBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); + addMediaBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() { + @Override + public void onStateChanged(@NonNull View bottomSheet, int newState) { + //Wait until bottom sheet is not collapsed and show next screen after + if (newState==BottomSheetBehavior.STATE_COLLAPSED){ + addMediaBehavior.setBottomSheetCallback(null); + if (ContextCompat.checkSelfPermission(ComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(ComposeActivity.this, + new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, + PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); + } else { + initiateMediaPicking(); + } + } + } - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) - != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, - PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE); - } else { - initiateMediaPicking(); - } + @Override + public void onSlide(@NonNull View bottomSheet, float slideOffset) { + + } + }); + addMediaBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED); } @Override