From 4291d92ab27e7072451486c67d7cb80458c46792 Mon Sep 17 00:00:00 2001 From: HyunWoo Lee Date: Tue, 29 Oct 2024 12:03:26 +0900 Subject: [PATCH] [feature/#946] Apply mozilla component utils (DownloadUtils) --- core/webview/build.gradle.kts | 1 + .../official/webview/view/WebViewActivity.kt | 10 +++++-- gradle/libs.versions.toml | 30 ++++++++++--------- settings.gradle.kts | 1 + 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/core/webview/build.gradle.kts b/core/webview/build.gradle.kts index 5711f9b5d..2cb8d0660 100644 --- a/core/webview/build.gradle.kts +++ b/core/webview/build.gradle.kts @@ -41,4 +41,5 @@ dependencies { implementation(libs.material) implementation(libs.constraintlayout) implementation(libs.swipe.refresh.layout) + implementation(libs.mozilla.component.utils) } diff --git a/core/webview/src/main/java/org/sopt/official/webview/view/WebViewActivity.kt b/core/webview/src/main/java/org/sopt/official/webview/view/WebViewActivity.kt index ee0ab3421..ebe051aab 100644 --- a/core/webview/src/main/java/org/sopt/official/webview/view/WebViewActivity.kt +++ b/core/webview/src/main/java/org/sopt/official/webview/view/WebViewActivity.kt @@ -31,7 +31,6 @@ import android.net.Uri import android.os.Bundle import android.os.Environment import android.webkit.CookieManager -import android.webkit.URLUtil import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebView @@ -42,6 +41,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.ContextCompat import androidx.core.content.getSystemService import dagger.hilt.android.AndroidEntryPoint +import mozilla.components.support.utils.DownloadUtils import org.sopt.official.common.util.viewBinding import org.sopt.official.common.view.toast import org.sopt.official.webview.databinding.ActivityWebViewBinding @@ -94,8 +94,12 @@ class WebViewActivity : AppCompatActivity() { android.Manifest.permission.WRITE_EXTERNAL_STORAGE ) == android.content.pm.PackageManager.PERMISSION_GRANTED ) { - - val fileName = URLUtil.guessFileName(url, URLDecoder.decode(contentDisposition, "utf-8"), mimetype) + val fileName = DownloadUtils.guessFileName( + contentDisposition = URLDecoder.decode(contentDisposition, "utf-8"), + null, + url = url, + mimeType = mimetype + ) val downloadManager = getSystemService() ?: return@setDownloadListener val request = DownloadManager.Request(Uri.parse(url)) .setMimeType(mimetype) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7279f82a0..eea1b6648 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -55,6 +55,7 @@ compose-destination = "1.11.7" coil = "2.7.0" lottie = "6.6.0" dotsindicator = "5.1.0" +mozilla-component-utils = "107.0.3" google-services = "4.4.2" crashlytics = "3.0.2" @@ -180,23 +181,24 @@ constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayo benchmark-macro-junit4 = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "benchmark-macro-junit4" } profileinstaller = { group = "androidx.profileinstaller", name = "profileinstaller", version.ref = "profileinstaller" } dotsindicator = { module = "com.tbuonomo:dotsindicator", version.ref = "dotsindicator" } +mozilla-component-utils = { module = "org.mozilla.components:support-utils", version.ref = "mozilla-component-utils" } [bundles] compose = [ - "compose-ui", - "compose-foundation", - "compose-ui-tooling", - "compose-activity", - "compose-animation", - "compose-viewmodel", - "compose-material", - "compose-material-three", - "compose-material-icons-extended", - "compose-material-icons", - "compose-runtime", - "compose-ui-tooling-preview", - "compose-hilt-navigation", - "compose-lottie", + "compose-ui", + "compose-foundation", + "compose-ui-tooling", + "compose-activity", + "compose-animation", + "compose-viewmodel", + "compose-material", + "compose-material-three", + "compose-material-icons-extended", + "compose-material-icons", + "compose-runtime", + "compose-ui-tooling-preview", + "compose-hilt-navigation", + "compose-lottie", ] compose-test = ["compose-junit"] compose-android-test = ["compose-ui-test"] diff --git a/settings.gradle.kts b/settings.gradle.kts index 0340a6ea4..47d064826 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,6 +13,7 @@ dependencyResolutionManagement { mavenCentral() gradlePluginPortal() maven { setUrl("https://jitpack.io") } + maven { setUrl("https://maven.mozilla.org/maven2") } } } rootProject.name = "SOPT"