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 Nov 1, 2024
1 parent 8c528fc commit be3ca64
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 @@ -47,4 +47,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 @@ -43,6 +42,7 @@ import androidx.core.content.ContextCompat
import androidx.core.content.getSystemService
import com.airbnb.deeplinkdispatch.DeepLink
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 @@ -96,8 +96,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 @@ -56,6 +56,7 @@ coil = "2.7.0"
lottie = "6.6.0"
dotsindicator = "5.1.0"
deepLinkDispatch = "6.2.2"
mozilla-component-utils = "107.0.3"

google-services = "4.4.2"
crashlytics = "3.0.2"
Expand Down Expand Up @@ -183,23 +184,24 @@ profileinstaller = { group = "androidx.profileinstaller", name = "profileinstall
dotsindicator = { module = "com.tbuonomo:dotsindicator", version.ref = "dotsindicator" }
deeplink-dispatch = { group = "com.airbnb", name = "deeplinkdispatch", version.ref = "deepLinkDispatch" }
deeplink-dispatch-processor = { group = "com.airbnb", name = "deeplinkdispatch-processor", version.ref = "deepLinkDispatch" }
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 be3ca64

Please sign in to comment.