Loading app/src/main/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".mastodon.activities.MediaActivity" android:hardwareAccelerated="false" android:hardwareAccelerated="true" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/Transparent" /> Loading app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,9 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac if (bundle != null) { mediaPosition = bundle.getInt(Helper.ARG_MEDIA_POSITION, 1); if(mediaPosition < 1 ) { mediaPosition = 1; } attachments = (ArrayList<Attachment>) bundle.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = bundle.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) bundle.getSerializable(Helper.ARG_STATUS); Loading Loading @@ -230,6 +233,9 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac public void onPageSelected(int position) { mediaPosition = position; if(mediaPosition < 1 ) { mediaPosition = 1; } String description = attachments.get(position).description; if (handler != null) { handler.removeCallbacksAndMessages(null); Loading app/src/main/java/app/fedilab/android/mastodon/helper/MediaHelper.java +27 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.media.MediaRecorder; import android.media.MediaScannerConnection; Loading Loading @@ -266,6 +267,32 @@ public class MediaHelper { ); } public static Drawable rescaleImageIfNeeded(Activity activity, Drawable image) { if (!(image instanceof BitmapDrawable)) { return image; } int maxSize = 2000; int width = image.getIntrinsicWidth(); int height = image.getIntrinsicHeight(); float scaleFactor; if(width > maxSize || height > maxSize) { if(width >= height) { scaleFactor = (float) maxSize / width; } else { scaleFactor = (float) maxSize / height; } } else { return image; } Bitmap b = ((BitmapDrawable)image).getBitmap(); int sizeX = Math.round(image.getIntrinsicWidth() * scaleFactor); int sizeY = Math.round(image.getIntrinsicHeight() * scaleFactor); Bitmap bitmapResized = Bitmap.createScaledBitmap(b, sizeX, sizeY, false); image = new BitmapDrawable(activity.getResources(), bitmapResized); return image; } /** * Record media * Loading app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +7 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.fragment.media; * see <http://www.gnu.org/licenses>. */ import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.drawable.Drawable; Loading Loading @@ -58,6 +59,7 @@ import app.fedilab.android.mastodon.activities.MediaActivity; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.helper.CacheDataSourceFactory; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MediaHelper; import app.fedilab.android.mastodon.viewmodel.mastodon.TimelinesVM; import es.dmoral.toasty.Toasty; Loading Loading @@ -167,7 +169,9 @@ public class FragmentMedia extends Fragment { return; } binding.mediaPicture.setZoomable(true); binding.mediaPicture.setImageDrawable(resource); Drawable scaledRessource = MediaHelper.rescaleImageIfNeeded(requireActivity(), resource); binding.mediaPicture.setImageDrawable(scaledRessource); if (attachment.type.equalsIgnoreCase("image") && !attachment.url.toLowerCase().endsWith(".gif")) { binding.mediaPicture.setVisibility(View.VISIBLE); Loading @@ -185,7 +189,8 @@ public class FragmentMedia extends Fragment { return; } binding.loader.setVisibility(View.GONE); binding.mediaPicture.setImageDrawable(resource); Drawable scaledRessource = MediaHelper.rescaleImageIfNeeded(requireActivity(), resource); binding.mediaPicture.setImageDrawable(scaledRessource); binding.mediaPicture.setZoomable(true); } Loading app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true" android:fitsSystemWindows="true" android:fitsSystemWindows="false" android:background="@android:color/transparent"> Loading @@ -35,6 +35,7 @@ <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/description_container" android:fitsSystemWindows="true" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" android:background="#AA000000" Loading Loading
app/src/main/AndroidManifest.xml +1 −1 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ android:configChanges="keyboardHidden|orientation|screenSize" /> <activity android:name=".mastodon.activities.MediaActivity" android:hardwareAccelerated="false" android:hardwareAccelerated="true" android:configChanges="keyboardHidden|orientation|screenSize" android:theme="@style/Transparent" /> Loading
app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +6 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,9 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac if (bundle != null) { mediaPosition = bundle.getInt(Helper.ARG_MEDIA_POSITION, 1); if(mediaPosition < 1 ) { mediaPosition = 1; } attachments = (ArrayList<Attachment>) bundle.getSerializable(Helper.ARG_MEDIA_ARRAY); mediaFromProfile = bundle.getBoolean(Helper.ARG_MEDIA_ARRAY_PROFILE, false); status = (Status) bundle.getSerializable(Helper.ARG_STATUS); Loading Loading @@ -230,6 +233,9 @@ public class MediaActivity extends BaseBarActivity implements OnDownloadInterfac public void onPageSelected(int position) { mediaPosition = position; if(mediaPosition < 1 ) { mediaPosition = 1; } String description = attachments.get(position).description; if (handler != null) { handler.removeCallbacksAndMessages(null); Loading
app/src/main/java/app/fedilab/android/mastodon/helper/MediaHelper.java +27 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Matrix; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.media.MediaRecorder; import android.media.MediaScannerConnection; Loading Loading @@ -266,6 +267,32 @@ public class MediaHelper { ); } public static Drawable rescaleImageIfNeeded(Activity activity, Drawable image) { if (!(image instanceof BitmapDrawable)) { return image; } int maxSize = 2000; int width = image.getIntrinsicWidth(); int height = image.getIntrinsicHeight(); float scaleFactor; if(width > maxSize || height > maxSize) { if(width >= height) { scaleFactor = (float) maxSize / width; } else { scaleFactor = (float) maxSize / height; } } else { return image; } Bitmap b = ((BitmapDrawable)image).getBitmap(); int sizeX = Math.round(image.getIntrinsicWidth() * scaleFactor); int sizeY = Math.round(image.getIntrinsicHeight() * scaleFactor); Bitmap bitmapResized = Bitmap.createScaledBitmap(b, sizeX, sizeY, false); image = new BitmapDrawable(activity.getResources(), bitmapResized); return image; } /** * Record media * Loading
app/src/main/java/app/fedilab/android/mastodon/ui/fragment/media/FragmentMedia.java +7 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package app.fedilab.android.mastodon.ui.fragment.media; * see <http://www.gnu.org/licenses>. */ import android.content.SharedPreferences; import android.graphics.Color; import android.graphics.drawable.Drawable; Loading Loading @@ -58,6 +59,7 @@ import app.fedilab.android.mastodon.activities.MediaActivity; import app.fedilab.android.mastodon.client.entities.api.Attachment; import app.fedilab.android.mastodon.helper.CacheDataSourceFactory; import app.fedilab.android.mastodon.helper.Helper; import app.fedilab.android.mastodon.helper.MediaHelper; import app.fedilab.android.mastodon.viewmodel.mastodon.TimelinesVM; import es.dmoral.toasty.Toasty; Loading Loading @@ -167,7 +169,9 @@ public class FragmentMedia extends Fragment { return; } binding.mediaPicture.setZoomable(true); binding.mediaPicture.setImageDrawable(resource); Drawable scaledRessource = MediaHelper.rescaleImageIfNeeded(requireActivity(), resource); binding.mediaPicture.setImageDrawable(scaledRessource); if (attachment.type.equalsIgnoreCase("image") && !attachment.url.toLowerCase().endsWith(".gif")) { binding.mediaPicture.setVisibility(View.VISIBLE); Loading @@ -185,7 +189,8 @@ public class FragmentMedia extends Fragment { return; } binding.loader.setVisibility(View.GONE); binding.mediaPicture.setImageDrawable(resource); Drawable scaledRessource = MediaHelper.rescaleImageIfNeeded(requireActivity(), resource); binding.mediaPicture.setImageDrawable(scaledRessource); binding.mediaPicture.setZoomable(true); } Loading
app/src/main/res/layouts/mastodon/layout/activity_media_pager.xml +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:animateLayoutChanges="true" android:fitsSystemWindows="true" android:fitsSystemWindows="false" android:background="@android:color/transparent"> Loading @@ -35,6 +35,7 @@ <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/description_container" android:fitsSystemWindows="true" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" android:background="#AA000000" Loading