From 38c7605ef5b2394b48a54702d6d67a1a2ac0b7fa Mon Sep 17 00:00:00 2001 From: Chris Narkiewicz Date: Sun, 16 Jun 2019 14:58:00 +0100 Subject: [PATCH] Fix crash when displaying video files 1) Bitmap decoder does not work with vector drawables directly 2) Dependency injection in PreviewMediaFragment Fixes #4121 Fixes #4129 Fixes #4150 Signed-off-by: Chris Narkiewicz --- .../java/com/nextcloud/client/di/ComponentsModule.java | 7 ++----- .../owncloud/android/datamodel/ThumbnailsCacheManager.java | 4 ++-- .../owncloud/android/ui/preview/PreviewMediaFragment.java | 3 ++- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/nextcloud/client/di/ComponentsModule.java b/src/main/java/com/nextcloud/client/di/ComponentsModule.java index 2835f2eaa8..77573a7ec4 100644 --- a/src/main/java/com/nextcloud/client/di/ComponentsModule.java +++ b/src/main/java/com/nextcloud/client/di/ComponentsModule.java @@ -136,11 +136,8 @@ abstract class ComponentsModule { @ContributesAndroidInjector abstract PreviewMediaFragment previewMediaFragment(); @ContributesAndroidInjector abstract PreviewTextFragment previewTextFragment(); - @ContributesAndroidInjector - abstract ReceiveExternalFilesActivity.DialogMultipleAccount dialogMultipleAccount(); - - @ContributesAndroidInjector - abstract ReceiveExternalFilesActivity.DialogInputUploadFilename dialogInputUploadFilename(); + @ContributesAndroidInjector abstract ReceiveExternalFilesActivity.DialogMultipleAccount dialogMultipleAccount(); + @ContributesAndroidInjector abstract ReceiveExternalFilesActivity.DialogInputUploadFilename dialogInputUploadFilename(); @ContributesAndroidInjector abstract FileUploader fileUploader(); @ContributesAndroidInjector abstract FileDownloader fileDownloader(); diff --git a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java index 79c4194696..09d2b1617e 100644 --- a/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java +++ b/src/main/java/com/owncloud/android/datamodel/ThumbnailsCacheManager.java @@ -1047,8 +1047,8 @@ public final class ThumbnailsCacheManager { } public static Bitmap addVideoOverlay(Bitmap thumbnail){ - Bitmap playButton = BitmapFactory.decodeResource(MainApp.getAppContext().getResources(), - R.drawable.view_play); + Drawable playButtonDrawable = MainApp.getAppContext().getResources().getDrawable(R.drawable.view_play); + Bitmap playButton = BitmapUtils.drawableToBitmap(playButtonDrawable); Bitmap resizedPlayButton = Bitmap.createScaledBitmap(playButton, (int) (thumbnail.getWidth() * 0.3), diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java b/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java index 5c3cebfd3a..d6cba983b2 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewMediaFragment.java @@ -55,6 +55,7 @@ import android.widget.Toast; import android.widget.VideoView; import com.nextcloud.client.account.UserAccountManager; +import com.nextcloud.client.di.Injectable; import com.owncloud.android.R; import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.files.FileMenuFilter; @@ -92,7 +93,7 @@ import androidx.annotation.StringRes; * By now, if the {@link OCFile} passed is not downloaded, an {@link IllegalStateException} is * generated on instantiation too. */ -public class PreviewMediaFragment extends FileFragment implements OnTouchListener { +public class PreviewMediaFragment extends FileFragment implements OnTouchListener, Injectable { private static final String TAG = PreviewMediaFragment.class.getSimpleName();