From cea9abbc5b1528e293d08b566a231b1b7f653ee1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Tue, 28 Feb 2023 18:32:07 +0100 Subject: [PATCH] Release 3.19.1 --- app/build.gradle | 4 +- app/src/main/assets/release_notes/notes.json | 5 ++ .../mastodon/ui/drawer/StatusAdapter.java | 79 ++++++++++++++++++- .../layouts/mastodon/layout/layout_media.xml | 12 +++ app/src/main/res/values/strings.xml | 3 +- app/src/main/res/xml/pref_timelines.xml | 9 +++ .../metadata/android/en/changelogs/482.txt | 4 +- 7 files changed, 107 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 4e93a7937..808cba9a0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,8 +13,8 @@ android { defaultConfig { minSdk 21 targetSdk 33 - versionCode 481 - versionName "3.19.0" + versionCode 482 + versionName "3.19.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } flavorDimensions "default" diff --git a/app/src/main/assets/release_notes/notes.json b/app/src/main/assets/release_notes/notes.json index 97b8611d1..c425f86c4 100644 --- a/app/src/main/assets/release_notes/notes.json +++ b/app/src/main/assets/release_notes/notes.json @@ -1,4 +1,9 @@ [ + { + "version": "3.19.1", + "code": "482", + "note": "Added:\n- Settings compose: display a dialog to warn if there are missing media description (default disabled)\n- Settings > Notification: disable battery optimization\n- Settings > Timelines: AutoPlay gif media (default: enabled)\n\nFixed:\n- Fix an issue with cache and fetch more\n- Cache view with large fonts\n- Bad behaviors with truncated messages" + }, { "version": "3.19.0", "code": "481", diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java index ddf67e19f..ac3d0c7af 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java +++ b/app/src/main/java/app/fedilab/android/mastodon/ui/drawer/StatusAdapter.java @@ -44,6 +44,7 @@ import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.CountDownTimer; @@ -91,6 +92,12 @@ import com.bumptech.glide.ListPreloader; import com.bumptech.glide.RequestBuilder; import com.bumptech.glide.request.RequestOptions; import com.github.stom79.mytransl.MyTransL; +import com.google.android.exoplayer2.ExoPlayer; +import com.google.android.exoplayer2.MediaItem; +import com.google.android.exoplayer2.Player; +import com.google.android.exoplayer2.source.ProgressiveMediaSource; +import com.google.android.exoplayer2.upstream.DataSource; +import com.google.android.exoplayer2.upstream.DefaultDataSource; import com.google.android.material.dialog.MaterialAlertDialogBuilder; import com.smarteist.autoimageslider.SliderAnimations; import com.smarteist.autoimageslider.SliderView; @@ -141,6 +148,7 @@ import app.fedilab.android.mastodon.client.entities.app.StatusDraft; import app.fedilab.android.mastodon.client.entities.app.Timeline; import app.fedilab.android.mastodon.exception.DBException; import app.fedilab.android.mastodon.helper.BlurHashDecoder; +import app.fedilab.android.mastodon.helper.CacheDataSourceFactory; import app.fedilab.android.mastodon.helper.CrossActionHelper; import app.fedilab.android.mastodon.helper.GlideApp; import app.fedilab.android.mastodon.helper.GlideFocus; @@ -1438,6 +1446,7 @@ public class StatusAdapter extends RecyclerView.Adapter }); } else { int mediaPosition = 1; + boolean autoplaygif = sharedpreferences.getBoolean(context.getString(R.string.SET_AUTO_PLAY_GIG_MEDIA), true); if (!fullAttachement || statusToDeal.sensitive) { int defaultHeight = (int) Helper.convertDpToPixel(300, context); if (measuredWidth > 0) { @@ -1530,10 +1539,72 @@ public class StatusAdapter extends RecyclerView.Adapter ratio = measuredWidth > 0 ? measuredWidth / mediaW : 1.0f; } } - loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, mediaW, mediaH, ratio, statusToDeal, attachment); + if (autoplaygif && attachment.type.equalsIgnoreCase("gifv")) { + + layoutMediaBinding.media.setVisibility(View.GONE); + layoutMediaBinding.mediaVideo.setVisibility(View.VISIBLE); + LinearLayout.LayoutParams lp; + if (fullAttachement && mediaH > 0 && (!statusToDeal.sensitive || expand_media)) { + lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, (int) (mediaH * ratio)); + } else { + lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + } + layoutMediaBinding.mediaVideo.setLayoutParams(lp); + + + layoutMediaBinding.mediaVideo.onResume(); + Uri uri = Uri.parse(attachment.url); + int video_cache = sharedpreferences.getInt(context.getString(R.string.SET_VIDEO_CACHE), Helper.DEFAULT_VIDEO_CACHE_MB); + ProgressiveMediaSource videoSource; + MediaItem mediaItem = new MediaItem.Builder().setUri(uri).build(); + if (video_cache == 0) { + DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context); + videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) + .createMediaSource(mediaItem); + } else { + CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(context); + videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory) + .createMediaSource(mediaItem); + } + ExoPlayer player = new ExoPlayer.Builder(context).build(); + player.setRepeatMode(Player.REPEAT_MODE_ONE); + layoutMediaBinding.mediaVideo.setPlayer(player); + player.setMediaSource(videoSource); + player.prepare(); + player.setPlayWhenReady(true); + } else { + loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, mediaW, mediaH, ratio, statusToDeal, attachment); + } } else if (layoutMediaBinding != null) { - loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment); + if (autoplaygif && attachment.type.equalsIgnoreCase("gifv")) { + layoutMediaBinding.media.setVisibility(View.GONE); + layoutMediaBinding.mediaVideo.setVisibility(View.VISIBLE); + layoutMediaBinding.mediaVideo.onResume(); + Uri uri = Uri.parse(attachment.url); + int video_cache = sharedpreferences.getInt(context.getString(R.string.SET_VIDEO_CACHE), Helper.DEFAULT_VIDEO_CACHE_MB); + ProgressiveMediaSource videoSource; + MediaItem mediaItem = new MediaItem.Builder().setUri(uri).build(); + if (video_cache == 0) { + DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(context); + videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory) + .createMediaSource(mediaItem); + } else { + CacheDataSourceFactory cacheDataSourceFactory = new CacheDataSourceFactory(context); + videoSource = new ProgressiveMediaSource.Factory(cacheDataSourceFactory) + .createMediaSource(mediaItem); + } + ExoPlayer player = new ExoPlayer.Builder(context).build(); + player.setRepeatMode(Player.REPEAT_MODE_ONE); + layoutMediaBinding.mediaVideo.setPlayer(player); + player.setMediaSource(videoSource); + player.prepare(); + player.setPlayWhenReady(true); + + } else { + loadAndAddAttachment(context, layoutMediaBinding, holder, adapter, mediaPosition, -1.f, -1.f, -1.f, statusToDeal, attachment); + } + } mediaPosition++; } @@ -2391,7 +2462,9 @@ public class StatusAdapter extends RecyclerView.Adapter lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutMediaBinding.media.setScaleType(ImageView.ScaleType.CENTER_CROP); } - + layoutMediaBinding.media.setVisibility(View.VISIBLE); + layoutMediaBinding.mediaVideo.setVisibility(View.GONE); + layoutMediaBinding.mediaVideo.onPause(); layoutMediaBinding.media.setLayoutParams(lp); float focusX = 0.f; diff --git a/app/src/main/res/layouts/mastodon/layout/layout_media.xml b/app/src/main/res/layouts/mastodon/layout/layout_media.xml index b92359f2f..4bd12af26 100644 --- a/app/src/main/res/layouts/mastodon/layout/layout_media.xml +++ b/app/src/main/res/layouts/mastodon/layout/layout_media.xml @@ -18,6 +18,18 @@ app:layout_constraintTop_toTopOf="parent" tools:ignore="ContentDescription" /> + + SYSTEM - + SET_AUTO_PLAY_GIG_MEDIA SET_FULL_PREVIEW SET_SHARE_DETAILS SET_CUSTOM_SHARING @@ -1926,4 +1926,5 @@ If there are missing media a dialog will be displayed with the ability to send the message without media description Send anyway Ignore battery optimizations + Autoplay animated media \ No newline at end of file diff --git a/app/src/main/res/xml/pref_timelines.xml b/app/src/main/res/xml/pref_timelines.xml index 808009421..a87801118 100644 --- a/app/src/main/res/xml/pref_timelines.xml +++ b/app/src/main/res/xml/pref_timelines.xml @@ -200,12 +200,21 @@ app:key="@string/SET_FULL_PREVIEW" app:singleLineTitle="false" app:title="@string/set_fit_preview" /> + + + + Notification: disable battery optimization - -Changed: -- +- Settings > Timelines: AutoPlay gif media (default: enabled) Fixed: - Fix an issue with cache and fetch more