Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 3a6ace5

Browse files
committed
add back file opener
closes #328
1 parent 1e825c9 commit 3a6ace5

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

mastodon/src/main/java/org/joinmastodon/android/fragments/ComposeFragment.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
174174
private int charCount, charLimit, trimmedCharCount;
175175

176176
private Button publishButton, languageButton, scheduleTimeBtn, draftsBtn;
177-
private PopupMenu languagePopup, visibilityPopup, draftOptionsPopup;
177+
private PopupMenu languagePopup, visibilityPopup, draftOptionsPopup, attachPopup;
178178
private ImageButton mediaBtn, pollBtn, emojiBtn, spoilerBtn, visibilityBtn, scheduleDraftDismiss;
179179
private ImageView sensitiveIcon;
180180
private ComposeMediaLayout attachmentsView;
@@ -327,7 +327,19 @@ public void getOutline(View view, Outline outline){
327327
sensitiveItem=view.findViewById(R.id.sensitive_item);
328328
replyText=view.findViewById(R.id.reply_text);
329329

330-
mediaBtn.setOnClickListener(v->openFilePicker());
330+
if (isPhotoPickerAvailable()) {
331+
PopupMenu attachPopup = new PopupMenu(getContext(), mediaBtn);
332+
attachPopup.inflate(R.menu.attach);
333+
attachPopup.setOnMenuItemClickListener(i -> {
334+
openFilePicker(i.getItemId() == R.id.media);
335+
return true;
336+
});
337+
UiUtils.enablePopupMenuIcons(getContext(), attachPopup);
338+
mediaBtn.setOnClickListener(v->attachPopup.show());
339+
mediaBtn.setOnTouchListener(attachPopup.getDragToOpenListener());
340+
} else {
341+
mediaBtn.setOnClickListener(v -> openFilePicker(false));
342+
}
331343
pollBtn.setOnClickListener(v->togglePoll());
332344
emojiBtn.setOnClickListener(v->emojiKeyboard.toggleKeyboardPopup(mainEditText));
333345
spoilerBtn.setOnClickListener(v->toggleSpoiler());
@@ -1176,9 +1188,9 @@ private boolean isPhotoPickerAvailable() {
11761188
*
11771189
* <p>For earlier versions use the built in docs ui via {@link Intent#ACTION_GET_CONTENT}
11781190
*/
1179-
private void openFilePicker(){
1191+
private void openFilePicker(boolean photoPicker){
11801192
Intent intent;
1181-
boolean usePhotoPicker = isPhotoPickerAvailable();
1193+
boolean usePhotoPicker = photoPicker && isPhotoPickerAvailable();
11821194
if (usePhotoPicker) {
11831195
intent = new Intent(MediaStore.ACTION_PICK_IMAGES);
11841196
intent.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, MediaStore.getPickImagesMaxLimit());
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
2+
<path android:pathData="M11.772 3.744c2.342-2.344 6.14-2.344 8.484 0 2.283 2.283 2.341 5.948 0.175 8.302l-0.188 0.197-8.8 8.798-0.036 0.03c-1.462 1.317-3.716 1.273-5.123-0.135-1.319-1.319-1.441-3.381-0.366-4.838 0.023-0.046 0.051-0.09 0.085-0.13l0.053-0.06 0.087-0.088 0.141-0.148 0.003 0.003 7.436-7.454c0.266-0.267 0.682-0.291 0.976-0.074l0.084 0.073c0.267 0.265 0.292 0.682 0.074 0.976L14.785 9.28 7.19 16.893c-0.718 0.876-0.668 2.17 0.15 2.988 0.829 0.829 2.149 0.868 3.024 0.118l8.833-8.83c1.756-1.758 1.756-4.607-0.002-6.365-1.702-1.702-4.43-1.755-6.196-0.16l-0.168 0.16L12.82 4.82l-9.537 9.536c-0.293 0.293-0.768 0.293-1.06 0-0.267-0.266-0.29-0.683-0.073-0.977l0.073-0.084 9.549-9.55h0.001z" android:fillColor="@color/fluent_default_icon_tint"/>
3+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
2+
<path android:pathData="M18.5 20c0 0.275-0.224 0.5-0.5 0.5H6c-0.276 0-0.5-0.225-0.5-0.5V4c0-0.275 0.224-0.5 0.5-0.5h6V8c0 1.104 0.896 2 2 2h4.5v10zm-5-15.379L17.378 8.5H14c-0.276 0-0.5-0.225-0.5-0.5V4.621zm5.914 3.793l-5.829-5.828C13.559 2.56 13.527 2.54 13.5 2.516c-0.071-0.064-0.141-0.127-0.219-0.18-0.04-0.027-0.086-0.045-0.128-0.068-0.071-0.04-0.141-0.084-0.216-0.116-0.197-0.082-0.409-0.123-0.624-0.138C12.266 2.011 12.22 2 12.172 2H6C4.896 2 4 2.896 4 4v16c0 1.104 0.896 2 2 2h12c1.104 0 2-0.896 2-2V9.828c0-0.53-0.211-1.039-0.586-1.414z" android:fillColor="@color/fluent_default_icon_tint"/>
3+
</vector>

mastodon/src/main/res/layout/fragment_compose.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@
329329
android:tintMode="src_in"
330330
android:contentDescription="@string/add_media"
331331
android:tooltipText="@string/add_media"
332-
android:src="@drawable/ic_fluent_image_24_regular"/>
332+
android:src="@drawable/ic_fluent_attach_24_regular"/>
333333

334334
<ImageButton
335335
android:id="@+id/btn_poll"

mastodon/src/main/res/menu/attach.xml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item
4+
android:id="@+id/media"
5+
android:title="@string/sk_add_media"
6+
android:icon="@drawable/ic_fluent_image_24_regular" />
7+
<item
8+
android:id="@+id/file"
9+
android:title="@string/sk_attach_file"
10+
android:icon="@drawable/ic_fluent_document_24_regular" />
11+
</menu>

mastodon/src/main/res/values/strings_sk.xml

+2
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,6 @@
174174
<string name="sk_post_edited">edited</string>
175175
<string name="sk_notification_type_update">Edited posts</string>
176176
<string name="sk_notify_update">Edits a reblogged post</string>
177+
<string name="sk_add_media">Add media</string>
178+
<string name="sk_attach_file">Attach file</string>
177179
</resources>

0 commit comments

Comments
 (0)