mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-27 05:23:00 +00:00
fixed url opening in about menu
This commit is contained in:
parent
75202544b6
commit
87964d1fd7
1 changed files with 14 additions and 6 deletions
|
@ -6,16 +6,24 @@ import android.net.Uri
|
|||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.R
|
||||
|
||||
open class AboutViewModel(application: Application): AndroidViewModel(application) {
|
||||
class AboutViewModel(application: Application): AndroidViewModel(application) {
|
||||
|
||||
fun openUrl(Url: String) {
|
||||
val customTabPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication()).getBoolean("use_customtabs", true)
|
||||
if (customTabPrefs) {
|
||||
val builder = CustomTabsIntent.Builder()
|
||||
builder.setToolbarColor(ContextCompat.getColor(getApplication(), R.color.GitHub))
|
||||
val customTabsIntent = builder.build()
|
||||
customTabsIntent.intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
customTabsIntent.launchUrl(getApplication(), Uri.parse(Url))
|
||||
} else {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(Url))
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
ContextCompat.startActivity(getApplication(), intent, null)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue