Skip to content

Commit

Permalink
[feature/#946] Apply mozilla component utils (DownloadUtils)
Browse files Browse the repository at this point in the history
  • Loading branch information
l2hyunwoo committed Oct 29, 2024
1 parent 4e66166 commit 4291d92
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
1 change: 1 addition & 0 deletions core/webview/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ dependencies {
implementation(libs.material)
implementation(libs.constraintlayout)
implementation(libs.swipe.refresh.layout)
implementation(libs.mozilla.component.utils)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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<DownloadManager>() ?: return@setDownloadListener
val request = DownloadManager.Request(Uri.parse(url))
.setMimeType(mimetype)
Expand Down
30 changes: 16 additions & 14 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dependencyResolutionManagement {
mavenCentral()
gradlePluginPortal()
maven { setUrl("https://jitpack.io") }
maven { setUrl("https://maven.mozilla.org/maven2") }
}
}
rootProject.name = "SOPT"
Expand Down

0 comments on commit 4291d92

Please sign in to comment.