diff options
author | Thomas <tschneider.ac@gmail.com> | 2022-07-20 10:10:59 +0200 |
---|---|---|
committer | Thomas <tschneider.ac@gmail.com> | 2022-07-20 10:10:59 +0200 |
commit | 10e66a3e7e2e000269352b438b143cb28256fd97 (patch) | |
tree | e277858a24f4563b178028dee562707a6be04646 /app | |
parent | c97c2e465bc7c7a89d17b8f843b6c1588ae525f2 (diff) |
Fix issue #262 - Long press to store media
Diffstat (limited to 'app')
4 files changed, 30 insertions, 2 deletions
diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 99be394d8..b83511698 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -1748,4 +1748,5 @@ public class Helper { } return null; } + } diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java index 3559fa5c6..2a45f7c8b 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/StatusAdapter.java @@ -128,6 +128,7 @@ import app.fedilab.android.helper.GlideFocus; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.LongClickLinkMovementMethod; import app.fedilab.android.helper.MastodonHelper; +import app.fedilab.android.helper.MediaHelper; import app.fedilab.android.helper.SpannableHelper; import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.ui.fragment.timeline.FragmentMastodonContext; @@ -323,6 +324,7 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> boolean confirmBoost = sharedpreferences.getBoolean(context.getString(R.string.SET_NOTIF_VALIDATION), true); boolean fullAttachement = sharedpreferences.getBoolean(context.getString(R.string.SET_FULL_PREVIEW), false); boolean displayBookmark = sharedpreferences.getBoolean(context.getString(R.string.SET_DISPLAY_BOOKMARK), false); + boolean long_press_media = sharedpreferences.getBoolean(context.getString(R.string.SET_LONG_PRESS_STORE_MEDIA), false); if (MainActivity.currentAccount != null && MainActivity.currentAccount.api == Account.API.PLEROMA) { holder.binding.layoutReactions.getRoot().setVisibility(View.VISIBLE); @@ -1120,6 +1122,19 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> } else { layoutMediaBinding.playMusic.setVisibility(View.GONE); } + String finalUrl; + if (statusToDeal.media_attachments.get(0).url == null) { + finalUrl = statusToDeal.media_attachments.get(0).remote_url; + } else { + finalUrl = statusToDeal.media_attachments.get(0).url; + } + layoutMediaBinding.media.setOnLongClickListener(v -> { + if (long_press_media) { + MediaHelper.manageMove(context, finalUrl, false); + } + return true; + }); + float focusX = 0.f; float focusY = 0.f; if (statusToDeal.media_attachments.get(0).meta != null && statusToDeal.media_attachments.get(0).meta.focus != null) { @@ -1162,6 +1177,18 @@ public class StatusAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> focusY = statusToDeal.media_attachments.get(0).meta.focus.y; } + String finalUrl; + if (attachment.url == null) { + finalUrl = attachment.remote_url; + } else { + finalUrl = attachment.url; + } + layoutMediaBinding.media.setOnLongClickListener(v -> { + if (long_press_media) { + MediaHelper.manageMove(context, finalUrl, false); + } + return true; + }); if (fullAttachement) { lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.FIT_CENTER); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 32a3f6d88..05a4af2d2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -848,7 +848,7 @@ </string-array> - <string name="SET_LONG_PRESS_MEDIA" translatable="false">SET_LONG_PRESS_MEDIA</string> + <string name="SET_LONG_PRESS_STORE_MEDIA" translatable="false">SET_LONG_PRESS_STORE_MEDIA</string> <string name="SET_UNFOLLOW_VALIDATION" translatable="false">SET_UNFOLLOW_VALIDATION</string> <string name="SET_DISPLAY_ADMIN_STATUSES" translatable="false">SET_DISPLAY_ADMIN_STATUSES</string> <string name="SET_LED_COLOUR_VAL" translatable="false">SET_LED_COLOUR_VAL</string> diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml index 1b9a9c738..bf408875c 100644 --- a/app/src/main/res/xml/pref_timelines.xml +++ b/app/src/main/res/xml/pref_timelines.xml @@ -43,7 +43,7 @@ app:iconSpaceReserved="false" android:defaultValue="false" app:singleLineTitle="false" - app:key="@string/SET_LONG_PRESS_MEDIA" + app:key="@string/SET_LONG_PRESS_STORE_MEDIA" app:title="@string/set_long_press_media" /> <SwitchPreferenceCompat app:iconSpaceReserved="false" |