1
0
Fork 0

Closes #7346: Enable dynamic app links in Fenix (#7361)

master
Roger Yang 2020-01-02 13:08:11 -05:00 committed by GitHub
parent bb9ec4dae9
commit f6e286fd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 7 deletions

View File

@ -79,7 +79,6 @@ import org.mozilla.fenix.downloads.DownloadNotificationBottomSheetDialog
import org.mozilla.fenix.downloads.DownloadService import org.mozilla.fenix.downloads.DownloadService
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.enterToImmersiveMode import org.mozilla.fenix.ext.enterToImmersiveMode
import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.getRootView import org.mozilla.fenix.ext.getRootView
import org.mozilla.fenix.ext.hideToolbar import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.metrics import org.mozilla.fenix.ext.metrics
@ -307,9 +306,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
sessionManager = sessionManager, sessionManager = sessionManager,
sessionId = customTabSessionId, sessionId = customTabSessionId,
fragmentManager = parentFragmentManager, fragmentManager = parentFragmentManager,
launchInApp = { context.settings().preferences.getBoolean( launchInApp = { context.settings().openLinksInExternalApp }
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false)
}
), ),
owner = this, owner = this,
view = view view = view

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix.components
import android.content.Context import android.content.Context
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.preference.PreferenceManager
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -19,7 +20,6 @@ import org.mozilla.fenix.R
import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.getPreferenceKey import org.mozilla.fenix.ext.getPreferenceKey
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.isInExperiment import org.mozilla.fenix.isInExperiment
import org.mozilla.fenix.settings.SupportUtils import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.test.Mockable import org.mozilla.fenix.test.Mockable
@ -52,7 +52,7 @@ class Services(
context, context,
interceptLinkClicks = true, interceptLinkClicks = true,
launchInApp = { launchInApp = {
context.settings().preferences.getBoolean( PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false) context.getPreferenceKey(R.string.pref_key_open_links_in_external_app), false)
} }
) )

View File

@ -417,4 +417,9 @@ class Settings private constructor(
return false return false
} }
var openLinksInExternalApp by booleanPreference(
appContext.getPreferenceKey(R.string.pref_key_open_links_in_external_app),
default = false
)
} }

File diff suppressed because one or more lines are too long

View File

@ -220,6 +220,8 @@
<string name="preferences_search_bookmarks">Search bookmarks</string> <string name="preferences_search_bookmarks">Search bookmarks</string>
<!-- Preference for account settings --> <!-- Preference for account settings -->
<string name="preferences_account_settings">Account settings</string> <string name="preferences_account_settings">Account settings</string>
<!-- Preference for open links in third party apps -->
<string name="preferences_open_links_in_apps">Open links in apps</string>
<!-- Account Preferences --> <!-- Account Preferences -->
<!-- Preference for triggering sync --> <!-- Preference for triggering sync -->

View File

@ -88,6 +88,11 @@
android:icon="@drawable/ic_data_collection" android:icon="@drawable/ic_data_collection"
android:key="@string/pref_key_data_choices" android:key="@string/pref_key_data_choices"
android:title="@string/preferences_data_collection" /> android:title="@string/preferences_data_collection" />
<androidx.preference.SwitchPreference
android:defaultValue="false"
android:icon="@drawable/ic_app_links"
android:key="@string/pref_key_open_links_in_external_app"
android:title="@string/preferences_open_links_in_apps" />
<androidx.preference.SwitchPreference <androidx.preference.SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:icon="@drawable/ic_info" android:icon="@drawable/ic_info"