From a312018441d0856a87b2d2835736d030ccc74108 Mon Sep 17 00:00:00 2001 From: Grishka Date: Fri, 25 Oct 2024 04:31:54 +0300 Subject: [PATCH] Open old file picker by long-pressing "add media" button (AND-194) --- .../android/fragments/ComposeFragment.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java index 8a12b5f1..ce5eb9b6 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java @@ -290,7 +290,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE languageBtn=view.findViewById(R.id.btn_language); replyText=view.findViewById(R.id.reply_text); - mediaBtn.setOnClickListener(v->openFilePicker()); + mediaBtn.setOnClickListener(v->openFilePicker(false)); + if(UiUtils.isPhotoPickerAvailable()){ + mediaBtn.setOnLongClickListener(v->{ + openFilePicker(true); + return true; + }); + } pollBtn.setOnClickListener(v->togglePoll()); emojiBtn.setOnClickListener(v->emojiKeyboard.toggleKeyboardPopup(mainEditText)); spoilerBtn.setOnClickListener(v->toggleSpoiler()); @@ -887,9 +893,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE * *

For earlier versions use the built in docs ui via {@link Intent#ACTION_GET_CONTENT} */ - private void openFilePicker(){ + private void openFilePicker(boolean forceGetContent){ Intent intent; - boolean usePhotoPicker=UiUtils.isPhotoPickerAvailable(); + boolean usePhotoPicker=!forceGetContent && UiUtils.isPhotoPickerAvailable(); if(usePhotoPicker){ intent=new Intent(MediaStore.ACTION_PICK_IMAGES); if(mediaViewController.getMaxAttachments()-mediaViewController.getMediaAttachmentsCount()>1)