settings to automatically fetch remote media when it fails (default: disabled)

fetch_indicator
Thomas 2 years ago
parent 8c74343843
commit 68d9abea67

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

@ -2,4 +2,5 @@
<resources>
<string name="fetch_remote_media">Automatically fetch remote media when they are not available</string>
</resources>

@ -1127,6 +1127,8 @@
<string name="SET_DISPLAY_ALL_NOTIFICATIONS_TYPE" translatable="false">SET_DISPLAY_ALL_NOTIFICATIONS_TYPE</string>
<string name="SET_EXCLUDED_NOTIFICATIONS_TYPE" translatable="false">SET_EXCLUDED_NOTIFICATIONS_TYPE</string>
<string name="SET_EXPAND_MEDIA" translatable="false">SET_EXPAND_MEDIA</string>
<string name="SET_FETCH_REMOTE_MEDIA" translatable="false">SET_FETCH_REMOTE_MEDIA</string>
<string name="SET_GROUP_REBLOGS" translatable="false">SET_GROUP_REBLOGS</string>
<string name="SET_BOOST_ORIGINAL_DATE" translatable="false">SET_BOOST_ORIGINAL_DATE</string>
<string name="SET_TRUNCATE_LINKS" translatable="false">SET_TRUNCATE_LINKS</string>

@ -25,6 +25,12 @@
app:key="@string/SET_EXPAND_MEDIA"
app:singleLineTitle="false"
app:title="@string/expand_image" />
<SwitchPreferenceCompat
android:defaultValue="false"
app:iconSpaceReserved="false"
app:key="@string/SET_FETCH_REMOTE_MEDIA"
app:singleLineTitle="false"
app:title="@string/fetch_remote_media" />
<SwitchPreferenceCompat
android:defaultValue="true"
app:iconSpaceReserved="false"

@ -0,0 +1,9 @@
Added:
- Add a button to fetch remote media when it fails
- Add a settings to automatically fetch remote media when it fails (default: disabled)
Changed:
Fixed:
- Some settings not properly restored (multiple choices)
Loading…
Cancel
Save