diff --git a/app/src/main/java/com/vanced/manager/ui/viewmodels/AboutViewModel.kt b/app/src/main/java/com/vanced/manager/ui/viewmodels/AboutViewModel.kt index 3804771d..4c582297 100644 --- a/app/src/main/java/com/vanced/manager/ui/viewmodels/AboutViewModel.kt +++ b/app/src/main/java/com/vanced/manager/ui/viewmodels/AboutViewModel.kt @@ -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 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)) + 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) + } } } \ No newline at end of file