Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ae3b0266 authored by Aayush Gupta's avatar Aayush Gupta Committed by Aayush Gupta
Browse files

play-services-core: Use androix.browser to launch a custom tab

parent ef1533bf
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ buildscript {

    ext.annotationVersion = '1.2.0'
    ext.appcompatVersion = '1.4.1'
    ext.browserVersion = '1.4.0'
    ext.coreVersion = '1.7.0'
    ext.fragmentVersion = '1.4.0'
    ext.lifecycleVersion = '2.4.0'
@@ -32,7 +33,7 @@ buildscript {

    ext.androidBuildVersionTools = '30.0.2'

    ext.androidMinSdk = 14
    ext.androidMinSdk = 16
    ext.androidTargetSdk = 29
    ext.androidCompileSdk = 31

+1 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ dependencies {
    // AndroidX UI
    implementation "androidx.multidex:multidex:$multidexVersion"
    implementation "androidx.appcompat:appcompat:$appcompatVersion"
    implementation "androidx.browser:browser:$browserVersion"
    implementation "androidx.mediarouter:mediarouter:$mediarouterVersion"
    implementation "androidx.preference:preference-ktx:$preferenceVersion"
    implementation "androidx.webkit:webkit:$webkitVersion"
+3 −33
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.ActivityNotFoundException
import android.content.ComponentName
import android.content.Intent
import android.net.Uri
import androidx.browser.customtabs.CustomTabsIntent

class SettingsFragment : ResourceSettingsFragment() {
    override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@@ -49,7 +50,8 @@ class SettingsFragment : ResourceSettingsFragment() {
            true
        }
        findPreference<Preference>(PREF_EXPOSURE_INSTALL)?.onPreferenceClickListener = Preference.OnPreferenceClickListener {
            openBrowserAt(EXPOSURE_INSTALL_DOC_URL)
            val customTabsIntent = CustomTabsIntent.Builder().build()
            customTabsIntent.launchUrl(it.context, Uri.parse(EXPOSURE_INSTALL_DOC_URL))
            true
        }
        findPreference<Preference>(PREF_ABOUT)!!.onPreferenceClickListener = Preference.OnPreferenceClickListener {
@@ -67,38 +69,6 @@ class SettingsFragment : ResourceSettingsFragment() {
        }
    }

    private fun launchComponent(packageName: String, name: String) {
        val launch_intent = Intent("android.intent.action.MAIN")
        launch_intent.addCategory("android.intent.category.LAUNCHER")
        launch_intent.component = ComponentName(packageName, name)
        launch_intent.putExtra("open_search", true)
        launch_intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
        requireActivity().startActivity(launch_intent)
    }

    fun startApplication(application_name: String?) {
        try {
            val intent = Intent("android.intent.action.MAIN")
            intent.addCategory("android.intent.category.LAUNCHER")
            intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
            val resolveinfo_list = requireActivity().packageManager.queryIntentActivities(intent, 0)
            for (info in resolveinfo_list) {
                if (info.activityInfo.packageName == application_name) {
                    launchComponent(info.activityInfo.packageName, info.activityInfo.name)
                    break
                }
            }
        } catch (e: ActivityNotFoundException) {
            e.message
        }
    }

    fun openBrowserAt(url: String) {
        val intent = Intent(Intent.ACTION_VIEW)
        intent.data = Uri.parse(url)
        startActivity(intent)
    }

    private suspend fun updateDetails(context: Context) {
        val gcmServiceInfo = getGcmServiceInfo(context)
        if (gcmServiceInfo.configuration.enabled) {