0
0
Fork 0
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:
X1nto 2020-07-05 20:15:00 +04:00
parent 75202544b6
commit 87964d1fd7

View file

@ -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)
}
}
}