Open old file picker by long-pressing "add media" button (AND-194)

This commit is contained in:
Grishka 2024-10-25 04:31:54 +03:00
parent 3026bd5c51
commit a312018441
1 changed files with 9 additions and 3 deletions

View File

@ -290,7 +290,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE
languageBtn=view.findViewById(R.id.btn_language); languageBtn=view.findViewById(R.id.btn_language);
replyText=view.findViewById(R.id.reply_text); 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()); pollBtn.setOnClickListener(v->togglePoll());
emojiBtn.setOnClickListener(v->emojiKeyboard.toggleKeyboardPopup(mainEditText)); emojiBtn.setOnClickListener(v->emojiKeyboard.toggleKeyboardPopup(mainEditText));
spoilerBtn.setOnClickListener(v->toggleSpoiler()); spoilerBtn.setOnClickListener(v->toggleSpoiler());
@ -887,9 +893,9 @@ public class ComposeFragment extends MastodonToolbarFragment implements ComposeE
* *
* <p>For earlier versions use the built in docs ui via {@link Intent#ACTION_GET_CONTENT} * <p>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; Intent intent;
boolean usePhotoPicker=UiUtils.isPhotoPickerAvailable(); boolean usePhotoPicker=!forceGetContent && UiUtils.isPhotoPickerAvailable();
if(usePhotoPicker){ if(usePhotoPicker){
intent=new Intent(MediaStore.ACTION_PICK_IMAGES); intent=new Intent(MediaStore.ACTION_PICK_IMAGES);
if(mediaViewController.getMaxAttachments()-mediaViewController.getMediaAttachmentsCount()>1) if(mediaViewController.getMaxAttachments()-mediaViewController.getMediaAttachmentsCount()>1)