From b5af62c3eae6501c6db3561976fd4ac7458c5763 Mon Sep 17 00:00:00 2001 From: Valere Date: Tue, 27 Aug 2019 16:50:02 +0200 Subject: [PATCH 1/2] Some video won't play VideoView fails to play some remote uri video on some device. For now video is downloaded locally in internal cache then played. This offers basic support before full media preview implementation --- CHANGES.md | 1 + .../features/media/VideoContentRenderer.kt | 36 ++++++++++++++++--- .../layout/activity_video_media_viewer.xml | 3 ++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a3b3776156..2c498851bc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ Bugfix: - Fix text diff linebreak display (#441) - Date change message repeats for each redaction until a normal message (#358) - Slide-in reply icon is distorted (#423) + - Some video won't play Translations: - diff --git a/vector/src/main/java/im/vector/riotx/features/media/VideoContentRenderer.kt b/vector/src/main/java/im/vector/riotx/features/media/VideoContentRenderer.kt index 22650b0edf..0509a0d480 100644 --- a/vector/src/main/java/im/vector/riotx/features/media/VideoContentRenderer.kt +++ b/vector/src/main/java/im/vector/riotx/features/media/VideoContentRenderer.kt @@ -89,18 +89,44 @@ class VideoContentRenderer @Inject constructor(private val activeSessionHolder: }) } } else { - thumbnailView.isVisible = false - loadingView.isVisible = false val resolvedUrl = contentUrlResolver.resolveFullSize(data.url) if (resolvedUrl == null) { + thumbnailView.isVisible = false + loadingView.isVisible = false errorView.isVisible = true errorView.setText(R.string.unknown_error) } else { - videoView.isVisible = true - videoView.setVideoPath(resolvedUrl) - videoView.start() + + //Temporary code, some remote videos are not played by videoview setVideoUri + //So for now we download them then play + thumbnailView.isVisible = true + loadingView.isVisible = true + + activeSessionHolder.getActiveSession() + .downloadFile( + FileService.DownloadMode.FOR_INTERNAL_USE, + data.eventId, + data.filename, + data.url, + null, + object : MatrixCallback { + override fun onSuccess(data: File) { + thumbnailView.isVisible = false + loadingView.isVisible = false + videoView.isVisible = true + + videoView.setVideoPath(data.path) + videoView.start() + } + + override fun onFailure(failure: Throwable) { + loadingView.isVisible = false + errorView.isVisible = true + errorView.text = errorFormatter.toHumanReadable(failure) + } + }) } } } diff --git a/vector/src/main/res/layout/activity_video_media_viewer.xml b/vector/src/main/res/layout/activity_video_media_viewer.xml index f21e6daf5f..c68577bcd5 100644 --- a/vector/src/main/res/layout/activity_video_media_viewer.xml +++ b/vector/src/main/res/layout/activity_video_media_viewer.xml @@ -34,7 +34,9 @@ android:id="@+id/videoMediaViewerThumbnailView" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_gravity="center" android:visibility="gone" + android:scaleType="centerInside" tools:visibility="visible" /> Date: Tue, 27 Aug 2019 15:36:44 +0200 Subject: [PATCH 2/2] Improve read receipt design --- .../DisplayReadReceiptsBottomSheet.kt | 2 +- .../main/res/drawable/pill_receipt_black.xml | 6 ++++ .../main/res/drawable/pill_receipt_dark.xml | 6 ++++ .../main/res/drawable/pill_receipt_light.xml | 6 ++++ .../res/layout/item_display_read_receipt.xml | 22 +++---------- .../res/layout/item_simple_reaction_info.xml | 18 ++--------- .../main/res/layout/view_read_receipts.xml | 31 ++++++++++++------- vector/src/main/res/values/attrs.xml | 1 + vector/src/main/res/values/strings_riotX.xml | 1 + vector/src/main/res/values/styles_riot.xml | 19 ++++++++++++ vector/src/main/res/values/theme_black.xml | 2 ++ vector/src/main/res/values/theme_dark.xml | 2 ++ vector/src/main/res/values/theme_light.xml | 2 ++ 13 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 vector/src/main/res/drawable/pill_receipt_black.xml create mode 100644 vector/src/main/res/drawable/pill_receipt_dark.xml create mode 100644 vector/src/main/res/drawable/pill_receipt_light.xml diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt index b8c1519f4c..42ad166429 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt @@ -69,7 +69,7 @@ class DisplayReadReceiptsBottomSheet : VectorBaseBottomSheetDialogFragment() { val dividerItemDecoration = DividerItemDecoration(epoxyRecyclerView.context, LinearLayout.VERTICAL) epoxyRecyclerView.addItemDecoration(dividerItemDecoration) - bottomSheetTitle.text = getString(R.string.read_receipts_list) + bottomSheetTitle.text = getString(R.string.read_at) epoxyController.setData(displayReadReceiptArgs.readReceipts) } diff --git a/vector/src/main/res/drawable/pill_receipt_black.xml b/vector/src/main/res/drawable/pill_receipt_black.xml new file mode 100644 index 0000000000..e63903550d --- /dev/null +++ b/vector/src/main/res/drawable/pill_receipt_black.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pill_receipt_dark.xml b/vector/src/main/res/drawable/pill_receipt_dark.xml new file mode 100644 index 0000000000..5442f13985 --- /dev/null +++ b/vector/src/main/res/drawable/pill_receipt_dark.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/drawable/pill_receipt_light.xml b/vector/src/main/res/drawable/pill_receipt_light.xml new file mode 100644 index 0000000000..66875dc1b1 --- /dev/null +++ b/vector/src/main/res/drawable/pill_receipt_light.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/vector/src/main/res/layout/item_display_read_receipt.xml b/vector/src/main/res/layout/item_display_read_receipt.xml index 9b4072ab76..2aa4485c4e 100644 --- a/vector/src/main/res/layout/item_display_read_receipt.xml +++ b/vector/src/main/res/layout/item_display_read_receipt.xml @@ -5,38 +5,26 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical" + android:minHeight="40dp" android:orientation="horizontal" android:paddingStart="8dp" android:paddingEnd="8dp"> \ No newline at end of file diff --git a/vector/src/main/res/layout/item_simple_reaction_info.xml b/vector/src/main/res/layout/item_simple_reaction_info.xml index 06f94fc8cf..02a36fc6d0 100644 --- a/vector/src/main/res/layout/item_simple_reaction_info.xml +++ b/vector/src/main/res/layout/item_simple_reaction_info.xml @@ -6,6 +6,7 @@ android:gravity="center_vertical" android:orientation="horizontal" android:paddingStart="8dp" + android:minHeight="40dp" android:paddingEnd="8dp"> diff --git a/vector/src/main/res/layout/view_read_receipts.xml b/vector/src/main/res/layout/view_read_receipts.xml index e3cbc6ba06..f477a979ec 100644 --- a/vector/src/main/res/layout/view_read_receipts.xml +++ b/vector/src/main/res/layout/view_read_receipts.xml @@ -9,48 +9,55 @@ diff --git a/vector/src/main/res/values/attrs.xml b/vector/src/main/res/values/attrs.xml index 368c03c0c1..e9a4296add 100644 --- a/vector/src/main/res/values/attrs.xml +++ b/vector/src/main/res/values/attrs.xml @@ -88,6 +88,7 @@ + diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 118fde8442..23ea1e2f0b 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -2,5 +2,6 @@ + Read at \ No newline at end of file diff --git a/vector/src/main/res/values/styles_riot.xml b/vector/src/main/res/values/styles_riot.xml index 80f5148a6e..d1894254cd 100644 --- a/vector/src/main/res/values/styles_riot.xml +++ b/vector/src/main/res/values/styles_riot.xml @@ -319,4 +319,23 @@ @drawable/vector_label_background_light + + + + \ No newline at end of file diff --git a/vector/src/main/res/values/theme_black.xml b/vector/src/main/res/values/theme_black.xml index 7b582e20dc..129a2e9b1c 100644 --- a/vector/src/main/res/values/theme_black.xml +++ b/vector/src/main/res/values/theme_black.xml @@ -75,6 +75,8 @@ #FF4D4D4D + @drawable/pill_receipt_black + @color/riot_primary_background_color_black @color/primary_color_black diff --git a/vector/src/main/res/values/theme_dark.xml b/vector/src/main/res/values/theme_dark.xml index b5796eb9db..4143229293 100644 --- a/vector/src/main/res/values/theme_dark.xml +++ b/vector/src/main/res/values/theme_dark.xml @@ -163,6 +163,8 @@ @android:color/white @color/riot_primary_text_color_dark + @drawable/pill_receipt_dark + @drawable/direct_chat_circle_dark #FF454545 diff --git a/vector/src/main/res/values/theme_light.xml b/vector/src/main/res/values/theme_light.xml index 56f2b90be9..8d51486e76 100644 --- a/vector/src/main/res/values/theme_light.xml +++ b/vector/src/main/res/values/theme_light.xml @@ -163,6 +163,8 @@ @color/riot_primary_text_color_light @android:color/white + @drawable/pill_receipt_light + @drawable/direct_chat_circle_light #FFD3EFE1