diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java
index 14461db42..9c7896989 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java
@@ -186,14 +186,24 @@ public class FragmentMedia extends Fragment {
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
scheduleStartPostponedTransition(binding.mediaPicture);
- Toasty.error(requireActivity(), getString(R.string.toast_error_media), Toasty.LENGTH_SHORT).show();
- binding.loadRemote.setVisibility(View.VISIBLE);
- binding.loadRemote.setOnClickListener(v -> {
+ SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
+ boolean autofetch = sharedpreferences.getBoolean(getString(R.string.SET_FETCH_REMOTE_MEDIA), false);
+ if (autofetch) {
binding.loadRemote.setVisibility(View.GONE);
binding.loader.setVisibility(View.GONE);
Glide.with(requireActivity())
.load(attachment.remote_url).into(binding.mediaPicture);
- });
+ } else {
+ Toasty.error(requireActivity(), getString(R.string.toast_error_media), Toasty.LENGTH_SHORT).show();
+ binding.loadRemote.setVisibility(View.VISIBLE);
+ binding.loadRemote.setOnClickListener(v -> {
+ binding.loadRemote.setVisibility(View.GONE);
+ binding.loader.setVisibility(View.GONE);
+ Glide.with(requireActivity())
+ .load(attachment.remote_url).into(binding.mediaPicture);
+ });
+ }
+
}
@Override
@@ -259,13 +269,21 @@ public class FragmentMedia extends Fragment {
@Override
public void onPlayerError(@NonNull PlaybackException error) {
Player.Listener.super.onPlayerError(error);
- Toasty.error(requireActivity(), getString(R.string.toast_error_media), Toasty.LENGTH_SHORT).show();
- binding.loadRemote.setVisibility(View.VISIBLE);
- binding.loadRemote.setOnClickListener(v -> {
+ SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
+ boolean autofetch = sharedpreferences.getBoolean(getString(R.string.SET_FETCH_REMOTE_MEDIA), false);
+ if (autofetch) {
binding.loadRemote.setVisibility(View.GONE);
binding.loader.setVisibility(View.GONE);
loadVideo(attachment.remote_url, type);
- });
+ } else {
+ Toasty.error(requireActivity(), getString(R.string.toast_error_media), Toasty.LENGTH_SHORT).show();
+ binding.loadRemote.setVisibility(View.VISIBLE);
+ binding.loadRemote.setOnClickListener(v -> {
+ binding.loadRemote.setVisibility(View.GONE);
+ binding.loader.setVisibility(View.GONE);
+ loadVideo(attachment.remote_url, type);
+ });
+ }
}
});
diff --git a/app/src/main/res/layouts/mastodon/values/strings.xml b/app/src/main/res/layouts/mastodon/values/strings.xml
index 78554f9eb..714050d20 100644
--- a/app/src/main/res/layouts/mastodon/values/strings.xml
+++ b/app/src/main/res/layouts/mastodon/values/strings.xml
@@ -2,4 +2,5 @@
+ Automatically fetch remote media when they are not available
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ba9663138..6acb19fba 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1127,6 +1127,8 @@
SET_DISPLAY_ALL_NOTIFICATIONS_TYPE
SET_EXCLUDED_NOTIFICATIONS_TYPE
SET_EXPAND_MEDIA
+ SET_FETCH_REMOTE_MEDIA
+
SET_GROUP_REBLOGS
SET_BOOST_ORIGINAL_DATE
SET_TRUNCATE_LINKS
diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml
index d205ddaad..9ebc9db5c 100644
--- a/app/src/main/res/xml/pref_timelines.xml
+++ b/app/src/main/res/xml/pref_timelines.xml
@@ -25,6 +25,12 @@
app:key="@string/SET_EXPAND_MEDIA"
app:singleLineTitle="false"
app:title="@string/expand_image" />
+