Custom tabs

This commit is contained in:
Sad Ellie 2023-10-28 22:52:51 +03:00
parent 88aadc7a1c
commit 754a8fb01b
3 changed files with 6 additions and 3 deletions

View File

@ -37,6 +37,7 @@ dependencies {
debugImplementation(libs.androidx.compose.ui.test.manifest) debugImplementation(libs.androidx.compose.ui.test.manifest)
implementation(libs.androidx.navigation.navigation.compose) implementation(libs.androidx.navigation.navigation.compose)
implementation(libs.androidx.browser.browser)
implementation(project(":core:base")) implementation(project(":core:base"))
} }

View File

@ -20,10 +20,10 @@ package com.sadellie.unitto.core.ui
import android.content.ActivityNotFoundException import android.content.ActivityNotFoundException
import android.content.Context import android.content.Context
import android.content.Intent
import android.content.res.Configuration import android.content.res.Configuration
import android.net.Uri import android.net.Uri
import android.widget.Toast import android.widget.Toast
import androidx.browser.customtabs.CustomTabsIntent
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalConfiguration
import com.sadellie.unitto.core.base.R import com.sadellie.unitto.core.base.R
@ -33,7 +33,7 @@ import com.sadellie.unitto.core.base.R
*/ */
fun openLink(mContext: Context, url: String) { fun openLink(mContext: Context, url: String) {
try { try {
mContext.startActivity(Intent(Intent.ACTION_VIEW).setData(Uri.parse(url))) CustomTabsIntent.Builder().build().launchUrl(mContext, Uri.parse(url))
} catch (e: ActivityNotFoundException) { } catch (e: ActivityNotFoundException) {
showToast(mContext, mContext.getString(R.string.error_label)) showToast(mContext, mContext.getString(R.string.error_label))
} }
@ -42,7 +42,7 @@ fun openLink(mContext: Context, url: String) {
fun showToast( fun showToast(
mContext: Context, mContext: Context,
text: String, text: String,
duration: Int = Toast.LENGTH_SHORT duration: Int = Toast.LENGTH_SHORT,
) { ) {
Toast.makeText(mContext, text, duration).show() Toast.makeText(mContext, text, duration).show()
} }

View File

@ -2,6 +2,7 @@
appCode = "28" appCode = "28"
appName = "Olive Green" appName = "Olive Green"
androidxBrowserBrowser = "1.6.0"
androidGradlePlugin = "8.1.2" androidGradlePlugin = "8.1.2"
androidxAppCompatAppCompat = "1.6.1" androidxAppCompatAppCompat = "1.6.1"
androidxCompose = "1.6.0-alpha08" androidxCompose = "1.6.0-alpha08"
@ -32,6 +33,7 @@ orgRobolectricRobolectric = "4.10.3"
[libraries] [libraries]
androidx-appcompat-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompatAppCompat" } androidx-appcompat-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompatAppCompat" }
androidx-browser-browser = { group = "androidx.browser", name = "browser", version.ref = "androidxBrowserBrowser" }
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version.ref = "androidxComposeMaterial3" }
androidx-compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "androidxCompose" } androidx-compose-material-icons-extended = { group = "androidx.compose.material", name = "material-icons-extended", version.ref = "androidxCompose" }
androidx-compose-ui = { group = "androidx.compose.ui", name = "ui", version.ref = "androidxCompose" } androidx-compose-ui = { group = "androidx.compose.ui", name = "ui", version.ref = "androidxCompose" }