Fix issue #262 - Long press to store media

This commit is contained in:
Thomas 2022-07-20 10:10:59 +02:00
parent c97c2e465b
commit 10e66a3e7e
4 changed files with 30 additions and 2 deletions

View file

@ -1748,4 +1748,5 @@ public class Helper {
}
return null;
}
}

View file

@ -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);

View file

@ -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>

View file

@ -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"