From 31734c050d2ebf292928239e74e15cb560d720a2 Mon Sep 17 00:00:00 2001 From: skydoves Date: Thu, 22 Feb 2024 10:21:17 +0900 Subject: [PATCH] Migrate to PhotoView library and remove jitpack dependencies --- build.gradle | 9 --------- .../kotlin/io/getstream/chat/android/Dependencies.kt | 6 +++--- stream-chat-android-ui-components/build.gradle | 3 +-- .../ui/navigation/destinations/AttachmentDestination.kt | 8 ++++++-- .../layout/stream_ui_item_attachment_gallery_image.xml | 2 +- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/build.gradle b/build.gradle index b77bf1486c6..12aba91ede2 100644 --- a/build.gradle +++ b/build.gradle @@ -60,15 +60,6 @@ allprojects { repositories { google() mavenCentral() - maven { - url "https://jitpack.io" - content { - includeModule("com.github.chrisbanes", "PhotoView") - - // https://github.com/stfalcon-studio/StfalconImageViewer/issues/69 - includeModule("com.github.stfalcon-studio", "StfalconImageViewer") - } - } } } diff --git a/buildSrc/src/main/kotlin/io/getstream/chat/android/Dependencies.kt b/buildSrc/src/main/kotlin/io/getstream/chat/android/Dependencies.kt index 8feccd378af..39cd4ad334b 100644 --- a/buildSrc/src/main/kotlin/io/getstream/chat/android/Dependencies.kt +++ b/buildSrc/src/main/kotlin/io/getstream/chat/android/Dependencies.kt @@ -65,7 +65,7 @@ object Versions { internal const val OK2CURL = "0.8.0" internal const val OKHTTP = "4.11.0" internal const val PERMISSIONX = "1.7.1" - internal const val PHOTOVIEW = "2.3.0" + internal const val PHOTOVIEW = "1.0.1" internal const val RETROFIT = "2.9.0" internal const val ROBOLECTRIC = "4.10.3" internal const val ROOM = "2.5.2" @@ -196,7 +196,8 @@ object Dependencies { const val okhttpLoggingInterceptor = "com.squareup.okhttp3:logging-interceptor:${Versions.OKHTTP}" const val okhttpMockWebserver = "com.squareup.okhttp3:mockwebserver:${Versions.OKHTTP}" const val permissionx = "com.guolindev.permissionx:permissionx:${Versions.PERMISSIONX}" - const val photoview = "com.github.chrisbanes:PhotoView:${Versions.PHOTOVIEW}" + const val photoview = "io.getstream:photoview:${Versions.PHOTOVIEW}" + const val photoviewDialog = "io.getstream:photoview-dialog:${Versions.PHOTOVIEW}" const val retrofit = "com.squareup.retrofit2:retrofit:${Versions.RETROFIT}" const val retrofitMoshiConverter = "com.squareup.retrofit2:converter-moshi:${Versions.RETROFIT}" const val robolectric = "org.robolectric:robolectric:${Versions.ROBOLECTRIC}" @@ -207,7 +208,6 @@ object Dependencies { const val shimmer = "com.facebook.shimmer:shimmer:${Versions.SHIMMER}" const val shot = "com.karumi:shot:${Versions.SHOT}" const val spotlessGradlePlugin = "com.diffplug.spotless:spotless-plugin-gradle:${Versions.SPOTLESS}" - const val stfalconImageViewer = "com.github.stfalcon-studio:StfalconImageViewer:${Versions.STFALCON_IMAGE_VIEWER}" const val streamLog = "io.getstream:stream-log:${Versions.STREAM_LOG}" const val streamLogAndroid = "io.getstream:stream-log-android:${Versions.STREAM_LOG}" const val streamLogAndroidFile = "io.getstream:stream-log-android-file:${Versions.STREAM_LOG}" diff --git a/stream-chat-android-ui-components/build.gradle b/stream-chat-android-ui-components/build.gradle index ec84dfd4a67..27d4c9f962f 100644 --- a/stream-chat-android-ui-components/build.gradle +++ b/stream-chat-android-ui-components/build.gradle @@ -81,12 +81,11 @@ dependencies { implementation Dependencies.androidxFragmentKtx implementation Dependencies.androidxViewPager2 implementation Dependencies.androidxCoreKtx - implementation Dependencies.photoview + implementation Dependencies.photoviewDialog implementation Dependencies.coil implementation Dependencies.coilGif implementation Dependencies.coilVideo implementation Dependencies.androidxStartup - implementation Dependencies.stfalconImageViewer implementation Dependencies.androidxLifecycleLiveDataKtx implementation Dependencies.keyboardVisibilityEvent implementation Dependencies.permissionx diff --git a/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt b/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt index eed7339edd8..29c0e934a4e 100644 --- a/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt +++ b/stream-chat-android-ui-components/src/main/kotlin/io/getstream/chat/android/ui/navigation/destinations/AttachmentDestination.kt @@ -20,7 +20,6 @@ import android.content.Context import android.content.Intent import android.widget.ImageView import android.widget.Toast -import com.stfalcon.imageviewer.StfalconImageViewer import io.getstream.chat.android.client.utils.attachment.isAudio import io.getstream.chat.android.client.utils.attachment.isFile import io.getstream.chat.android.client.utils.attachment.isImage @@ -35,6 +34,7 @@ import io.getstream.chat.android.ui.feature.gallery.AttachmentMediaActivity import io.getstream.chat.android.ui.utils.load import io.getstream.chat.android.uiutils.model.MimeType import io.getstream.log.taggedLogger +import io.getstream.photoview.dialog.PhotoViewDialog public open class AttachmentDestination( public var message: Message, @@ -68,16 +68,19 @@ public open class AttachmentDestination( url = attachment.titleLink ?: attachment.ogUrl ?: attachment.assetUrl type = AttachmentType.LINK } + attachment.isGif() -> { url = attachment.imageUrl type = AttachmentType.GIPHY } + else -> { showImageViewer(message, attachment) return } } } + AttachmentType.GIPHY -> url = attachment.thumbUrl AttachmentType.PRODUCT -> url = attachment.url } @@ -127,6 +130,7 @@ public open class AttachmentDestination( ) start(intent) } + docMimeType(mimeType) -> { val intent = Intent(context, AttachmentDocumentActivity::class.java).apply { putExtra("url", url) @@ -178,7 +182,7 @@ public open class AttachmentDestination( val attachmentIndex = message.attachments.indexOf(attachment) - StfalconImageViewer + PhotoViewDialog .Builder(context, imageUrls, ImageView::load) .withStartPosition( if (attachmentIndex in imageUrls.indices) attachmentIndex else 0, diff --git a/stream-chat-android-ui-components/src/main/res/layout/stream_ui_item_attachment_gallery_image.xml b/stream-chat-android-ui-components/src/main/res/layout/stream_ui_item_attachment_gallery_image.xml index 02dd1444d58..0eccd2cd4a4 100644 --- a/stream-chat-android-ui-components/src/main/res/layout/stream_ui_item_attachment_gallery_image.xml +++ b/stream-chat-android-ui-components/src/main/res/layout/stream_ui_item_attachment_gallery_image.xml @@ -33,7 +33,7 @@ app:layout_constraintTop_toTopOf="parent" /> -