parent
10ed7e5177
commit
8c30200ced
|
@ -31,7 +31,7 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
||||||
|
|
||||||
private fun adjustTrackingProtection(host: String, context: Context, session: EngineSession) {
|
private fun adjustTrackingProtection(host: String, context: Context, session: EngineSession) {
|
||||||
val trackingProtectionException = ExceptionDomains(context).load().contains(host)
|
val trackingProtectionException = ExceptionDomains(context).load().contains(host)
|
||||||
val trackingProtectionEnabled = context.settings.shouldUseTrackingProtection
|
val trackingProtectionEnabled = context.settings().shouldUseTrackingProtection
|
||||||
if (trackingProtectionException || !trackingProtectionEnabled) {
|
if (trackingProtectionException || !trackingProtectionEnabled) {
|
||||||
session.disableTrackingProtection()
|
session.disableTrackingProtection()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -80,7 +80,7 @@ open class FenixApplication : Application() {
|
||||||
experimentLoader = loadExperiments()
|
experimentLoader = loadExperiments()
|
||||||
|
|
||||||
// Enable the service-experiments component
|
// Enable the service-experiments component
|
||||||
if (this.settings.isExperimentationEnabled) {
|
if (settings().isExperimentationEnabled) {
|
||||||
Experiments.initialize(
|
Experiments.initialize(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
mozilla.components.service.experiments.Configuration(
|
mozilla.components.service.experiments.Configuration(
|
||||||
|
@ -100,7 +100,7 @@ open class FenixApplication : Application() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupLeakCanary()
|
setupLeakCanary()
|
||||||
if (this.settings.isTelemetryEnabled) {
|
if (settings().isTelemetryEnabled) {
|
||||||
components.analytics.metrics.start()
|
components.analytics.metrics.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ open class FenixApplication : Application() {
|
||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
// Suppressing erroneous lint warning about using MODE_NIGHT_AUTO_BATTERY, a likely library bug
|
// Suppressing erroneous lint warning about using MODE_NIGHT_AUTO_BATTERY, a likely library bug
|
||||||
private fun setDayNightTheme() {
|
private fun setDayNightTheme() {
|
||||||
val settings = this.settings
|
val settings = this.settings()
|
||||||
when {
|
when {
|
||||||
settings.shouldUseLightTheme -> {
|
settings.shouldUseLightTheme -> {
|
||||||
AppCompatDelegate.setDefaultNightMode(
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
|
|
|
@ -95,7 +95,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
||||||
|
|
||||||
setupToolbarAndNavigation()
|
setupToolbarAndNavigation()
|
||||||
|
|
||||||
if (settings.isTelemetryEnabled) {
|
if (settings().isTelemetryEnabled) {
|
||||||
lifecycle.addObserver(BreadcrumbsRecorder(components.analytics.crashReporter,
|
lifecycle.addObserver(BreadcrumbsRecorder(components.analytics.crashReporter,
|
||||||
navHost.navController, ::getBreadcrumbMessage))
|
navHost.navController, ::getBreadcrumbMessage))
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
||||||
intent?.toSafeIntent()?.let {
|
intent?.toSafeIntent()?.let {
|
||||||
if (it.hasExtra(PRIVATE_BROWSING_MODE)) {
|
if (it.hasExtra(PRIVATE_BROWSING_MODE)) {
|
||||||
val startPrivateMode = it.getBooleanExtra(PRIVATE_BROWSING_MODE, false)
|
val startPrivateMode = it.getBooleanExtra(PRIVATE_BROWSING_MODE, false)
|
||||||
settings.usePrivateMode = startPrivateMode
|
settings().usePrivateMode = startPrivateMode
|
||||||
intent.removeExtra(PRIVATE_BROWSING_MODE)
|
intent.removeExtra(PRIVATE_BROWSING_MODE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun createBrowsingModeManager(): BrowsingModeManager {
|
protected open fun createBrowsingModeManager(): BrowsingModeManager {
|
||||||
return DefaultBrowsingModeManager(settings) { mode ->
|
return DefaultBrowsingModeManager(settings()) { mode ->
|
||||||
themeManager.currentTheme = mode
|
themeManager.currentTheme = mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,7 +532,7 @@ abstract class BaseBrowserFragment : Fragment(), BackHandler, SessionManager.Obs
|
||||||
* Updates the site permissions rules based on user settings.
|
* Updates the site permissions rules based on user settings.
|
||||||
*/
|
*/
|
||||||
private fun assignSitePermissionsRules() {
|
private fun assignSitePermissionsRules() {
|
||||||
val settings = requireContext().settings
|
val settings = requireContext().settings()
|
||||||
|
|
||||||
val rules: SitePermissionsRules = settings.getSitePermissionsCustomSettingsRules()
|
val rules: SitePermissionsRules = settings.getSitePermissionsCustomSettingsRules()
|
||||||
|
|
||||||
|
|
|
@ -395,12 +395,12 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler {
|
||||||
val yOffset = -containerHeight - (browserToolbarView.view.height / THREE * 2)
|
val yOffset = -containerHeight - (browserToolbarView.view.height / THREE * 2)
|
||||||
|
|
||||||
trackingOnboarding.showAsDropDown(tpIcon, xOffset, yOffset)
|
trackingOnboarding.showAsDropDown(tpIcon, xOffset, yOffset)
|
||||||
it.settings.incrementTrackingProtectionOnboardingCount()
|
it.settings().incrementTrackingProtectionOnboardingCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun shouldShowTrackingProtectionOnboarding(session: Session) =
|
private fun shouldShowTrackingProtectionOnboarding(session: Session) =
|
||||||
context?.settings?.shouldShowTrackingProtectionOnboarding ?: false &&
|
context?.settings()?.shouldShowTrackingProtectionOnboarding ?: false &&
|
||||||
session.trackerBlockingEnabled && session.trackersBlocked.isNotEmpty()
|
session.trackerBlockingEnabled && session.trackersBlocked.isNotEmpty()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -81,7 +81,7 @@ class Analytics(
|
||||||
LeanplumMetricsService(context as Application),
|
LeanplumMetricsService(context as Application),
|
||||||
AdjustMetricsService(context)
|
AdjustMetricsService(context)
|
||||||
),
|
),
|
||||||
isTelemetryEnabled = { context.settings.isTelemetryEnabled }
|
isTelemetryEnabled = { context.settings().isTelemetryEnabled }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ class BackgroundServices(
|
||||||
setOf("https://identity.mozilla.com/apps/oldsync")
|
setOf("https://identity.mozilla.com/apps/oldsync")
|
||||||
).also { accountManager ->
|
).also { accountManager ->
|
||||||
// TODO this needs to change once we have a SyncManager
|
// TODO this needs to change once we have a SyncManager
|
||||||
context.settings.fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
context.settings().fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
||||||
accountManager.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
accountManager.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
||||||
|
|
||||||
// Register a telemetry account observer to keep track of FxA auth metrics.
|
// Register a telemetry account observer to keep track of FxA auth metrics.
|
||||||
|
@ -244,13 +244,13 @@ class TelemetryAccountObserver(
|
||||||
metricController.track(Event.SyncAuthOtherExternal)
|
metricController.track(Event.SyncAuthOtherExternal)
|
||||||
}
|
}
|
||||||
// Used by Leanplum as a context variable.
|
// Used by Leanplum as a context variable.
|
||||||
context.settings.fxaSignedIn = true
|
context.settings().fxaSignedIn = true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onLoggedOut() {
|
override fun onLoggedOut() {
|
||||||
metricController.track(Event.SyncAuthSignOut)
|
metricController.track(Event.SyncAuthSignOut)
|
||||||
// Used by Leanplum as a context variable.
|
// Used by Leanplum as a context variable.
|
||||||
context.settings.fxaSignedIn = false
|
context.settings().fxaSignedIn = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,15 +50,15 @@ class Core(private val context: Context) {
|
||||||
val engine: Engine by lazy {
|
val engine: Engine by lazy {
|
||||||
val defaultSettings = DefaultSettings(
|
val defaultSettings = DefaultSettings(
|
||||||
requestInterceptor = AppRequestInterceptor(context),
|
requestInterceptor = AppRequestInterceptor(context),
|
||||||
remoteDebuggingEnabled = context.settings.isRemoteDebuggingEnabled,
|
remoteDebuggingEnabled = context.settings().isRemoteDebuggingEnabled,
|
||||||
testingModeEnabled = false,
|
testingModeEnabled = false,
|
||||||
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
||||||
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
||||||
preferredColorScheme = getPreferredColorScheme(),
|
preferredColorScheme = getPreferredColorScheme(),
|
||||||
automaticFontSizeAdjustment = context.settings.shouldUseAutoSize,
|
automaticFontSizeAdjustment = context.settings().shouldUseAutoSize,
|
||||||
fontInflationEnabled = context.settings.shouldUseAutoSize,
|
fontInflationEnabled = context.settings().shouldUseAutoSize,
|
||||||
suspendMediaWhenInactive = !FeatureFlags.mediaIntegration,
|
suspendMediaWhenInactive = !FeatureFlags.mediaIntegration,
|
||||||
allowAutoplayMedia = context.settings.isAutoPlayEnabled
|
allowAutoplayMedia = context.settings().isAutoPlayEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
GeckoEngine(context, defaultSettings, GeckoProvider.getOrCreateRuntime(context)).also {
|
GeckoEngine(context, defaultSettings, GeckoProvider.getOrCreateRuntime(context)).also {
|
||||||
|
@ -162,11 +162,11 @@ class Core(private val context: Context) {
|
||||||
* @return the constructed tracking protection policy based on preferences.
|
* @return the constructed tracking protection policy based on preferences.
|
||||||
*/
|
*/
|
||||||
fun createTrackingProtectionPolicy(
|
fun createTrackingProtectionPolicy(
|
||||||
normalMode: Boolean = context.settings.shouldUseTrackingProtection,
|
normalMode: Boolean = context.settings().shouldUseTrackingProtection,
|
||||||
privateMode: Boolean = true
|
privateMode: Boolean = true
|
||||||
): TrackingProtectionPolicy {
|
): TrackingProtectionPolicy {
|
||||||
val trackingProtectionPolicy =
|
val trackingProtectionPolicy =
|
||||||
if (context.settings.useStrictTrackingProtection) TrackingProtectionPolicy.strict() else
|
if (context.settings().useStrictTrackingProtection) TrackingProtectionPolicy.strict() else
|
||||||
TrackingProtectionPolicy.recommended()
|
TrackingProtectionPolicy.recommended()
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
|
@ -185,8 +185,8 @@ class Core(private val context: Context) {
|
||||||
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||||
Configuration.UI_MODE_NIGHT_YES
|
Configuration.UI_MODE_NIGHT_YES
|
||||||
return when {
|
return when {
|
||||||
context.settings.shouldUseDarkTheme -> PreferredColorScheme.Dark
|
context.settings().shouldUseDarkTheme -> PreferredColorScheme.Dark
|
||||||
context.settings.shouldUseLightTheme -> PreferredColorScheme.Light
|
context.settings().shouldUseLightTheme -> PreferredColorScheme.Light
|
||||||
inDark -> PreferredColorScheme.Dark
|
inDark -> PreferredColorScheme.Dark
|
||||||
else -> PreferredColorScheme.Light
|
else -> PreferredColorScheme.Light
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Search(private val context: Context) {
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
defaultSearchEngine = getDefaultSearchEngineAsync(
|
defaultSearchEngine = getDefaultSearchEngineAsync(
|
||||||
context,
|
context,
|
||||||
context.settings.defaultSearchEngineName
|
context.settings().defaultSearchEngineName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,9 +77,9 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
||||||
"fennec_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FIREFOX.productName),
|
"fennec_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FIREFOX.productName),
|
||||||
"focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName),
|
"focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName),
|
||||||
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName),
|
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName),
|
||||||
"fxa_signed_in" to application.settings.fxaSignedIn,
|
"fxa_signed_in" to application.settings().fxaSignedIn,
|
||||||
"fxa_has_synced_items" to application.settings.fxaHasSyncedItems,
|
"fxa_has_synced_items" to application.settings().fxaHasSyncedItems,
|
||||||
"search_widget_installed" to application.settings.searchWidgetInstalled
|
"search_widget_installed" to application.settings().searchWidgetInstalled
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldTrack(event: Event): Boolean {
|
override fun shouldTrack(event: Event): Boolean {
|
||||||
return application.settings.isTelemetryEnabled &&
|
return application.settings().isTelemetryEnabled &&
|
||||||
token.type != Token.Type.Invalid && !event.name.isNullOrEmpty()
|
token.type != Token.Type.Invalid && !event.name.isNullOrEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,9 +66,9 @@ class ToolbarIntegration(
|
||||||
val lottieDrawable = LottieDrawable()
|
val lottieDrawable = LottieDrawable()
|
||||||
lottieDrawable.composition = result
|
lottieDrawable.composition = result
|
||||||
toolbar.displayTrackingProtectionIcon =
|
toolbar.displayTrackingProtectionIcon =
|
||||||
context.settings.shouldUseTrackingProtection && FeatureFlags.etpCategories
|
context.settings().shouldUseTrackingProtection && FeatureFlags.etpCategories
|
||||||
toolbar.displaySeparatorView =
|
toolbar.displaySeparatorView =
|
||||||
context.settings.shouldUseTrackingProtection && FeatureFlags.etpCategories
|
context.settings().shouldUseTrackingProtection && FeatureFlags.etpCategories
|
||||||
|
|
||||||
toolbar.setTrackingProtectionIcons(
|
toolbar.setTrackingProtectionIcons(
|
||||||
iconOnNoTrackersBlocked = AppCompatResources.getDrawable(
|
iconOnNoTrackersBlocked = AppCompatResources.getDrawable(
|
||||||
|
@ -120,7 +120,7 @@ class ToolbarIntegration(
|
||||||
|
|
||||||
ToolbarAutocompleteFeature(toolbar).apply {
|
ToolbarAutocompleteFeature(toolbar).apply {
|
||||||
addDomainProvider(domainAutocompleteProvider)
|
addDomainProvider(domainAutocompleteProvider)
|
||||||
if (context.settings.shouldShowHistorySuggestions) {
|
if (context.settings().shouldShowHistorySuggestions) {
|
||||||
addHistoryStorageProvider(historyStorage)
|
addHistoryStorageProvider(historyStorage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ class CrashReporterFragment : Fragment() {
|
||||||
session = requireComponents.core.sessionManager.selectedSession,
|
session = requireComponents.core.sessionManager.selectedSession,
|
||||||
navController = findNavController(),
|
navController = findNavController(),
|
||||||
components = requireComponents,
|
components = requireComponents,
|
||||||
settings = requireContext().settings
|
settings = requireContext().settings()
|
||||||
)
|
)
|
||||||
|
|
||||||
restoreTabButton.setOnClickListener {
|
restoreTabButton.setOnClickListener {
|
||||||
|
|
|
@ -64,7 +64,7 @@ class CustomTabsIntegration(
|
||||||
val lottieDrawable = LottieDrawable()
|
val lottieDrawable = LottieDrawable()
|
||||||
lottieDrawable.composition = result
|
lottieDrawable.composition = result
|
||||||
toolbar.displayTrackingProtectionIcon =
|
toolbar.displayTrackingProtectionIcon =
|
||||||
activity.settings.shouldUseTrackingProtection && FeatureFlags.etpCategories
|
activity.settings().shouldUseTrackingProtection && FeatureFlags.etpCategories
|
||||||
toolbar.displaySeparatorView = false
|
toolbar.displaySeparatorView = false
|
||||||
|
|
||||||
toolbar.setTrackingProtectionIcons(
|
toolbar.setTrackingProtectionIcons(
|
||||||
|
|
|
@ -10,6 +10,9 @@ import android.view.WindowManager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to call immersive mode using the View to hide the status bar and navigation buttons.
|
* Attempts to call immersive mode using the View to hide the status bar and navigation buttons.
|
||||||
|
*
|
||||||
|
* We don't use the equivalent function from Android Components because the stable flag messes
|
||||||
|
* with the toolbar. See #1998 and #3272.
|
||||||
*/
|
*/
|
||||||
fun Activity.enterToImmersiveMode() {
|
fun Activity.enterToImmersiveMode() {
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
|
|
|
@ -27,9 +27,9 @@ import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.Config
|
import org.mozilla.fenix.Config
|
||||||
import org.mozilla.fenix.FenixApplication
|
import org.mozilla.fenix.FenixApplication
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
|
||||||
import org.mozilla.fenix.components.Components
|
import org.mozilla.fenix.components.Components
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
import org.mozilla.fenix.components.metrics.MetricController
|
||||||
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,6 +111,3 @@ fun Context.getColorFromAttr(@AttrRes attr: Int) =
|
||||||
|
|
||||||
fun Context.settings(isCrashReportEnabledInBuild: Boolean = BuildConfig.CRASH_REPORTING && Config.channel.isReleased) =
|
fun Context.settings(isCrashReportEnabledInBuild: Boolean = BuildConfig.CRASH_REPORTING && Config.channel.isReleased) =
|
||||||
Settings.getInstance(this, isCrashReportEnabledInBuild)
|
Settings.getInstance(this, isCrashReportEnabledInBuild)
|
||||||
|
|
||||||
val Context.settings: Settings
|
|
||||||
get() = Settings.getInstance(this)
|
|
||||||
|
|
|
@ -26,11 +26,11 @@ fun Resources.getSpannable(@StringRes id: Int, spanParts: List<Pair<Any, Iterabl
|
||||||
return resultCreator.toSpannableString()
|
return resultCreator.toSpannableString()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("Deprecation")
|
|
||||||
private fun getLocale(configuration: Configuration) =
|
private fun getLocale(configuration: Configuration) =
|
||||||
if (SDK_INT >= Build.VERSION_CODES.N) {
|
if (SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
configuration.locales[0]
|
configuration.locales[0]
|
||||||
} else {
|
} else {
|
||||||
|
@Suppress("Deprecation")
|
||||||
configuration.locale
|
configuration.locale
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ class SpannableStringCreator {
|
||||||
length += newText.length
|
length += newText.length
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toSpannableString() = SpannableString((parts.joinToString(""))).apply {
|
fun toSpannableString() = SpannableString(parts.joinToString("")).apply {
|
||||||
spanMap.forEach { entry ->
|
spanMap.forEach { entry ->
|
||||||
val range = entry.key
|
val range = entry.key
|
||||||
entry.value.forEach {
|
entry.value.forEach {
|
||||||
setSpan(it, range.start, range.endInclusive, SPAN_EXCLUSIVE_EXCLUSIVE)
|
setSpan(it, range.first, range.last, SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
val searchEngine = requireComponents.search.searchEngineManager.getDefaultSearchEngineAsync(
|
val searchEngine = requireComponents.search.searchEngineManager.getDefaultSearchEngineAsync(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
requireContext().settings.defaultSearchEngineName
|
requireContext().settings().defaultSearchEngineName
|
||||||
)
|
)
|
||||||
val searchIcon = BitmapDrawable(resources, searchEngine.icon)
|
val searchIcon = BitmapDrawable(resources, searchEngine.icon)
|
||||||
searchIcon.setBounds(0, 0, iconSize, iconSize)
|
searchIcon.setBounds(0, 0, iconSize, iconSize)
|
||||||
|
@ -269,7 +269,7 @@ class HomeFragment : Fragment() {
|
||||||
invokePendingDeleteJobs()
|
invokePendingDeleteJobs()
|
||||||
|
|
||||||
if (newMode == BrowsingMode.Private) {
|
if (newMode == BrowsingMode.Private) {
|
||||||
requireContext().settings.incrementNumTimesPrivateModeOpened()
|
requireContext().settings().incrementNumTimesPrivateModeOpened()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onboarding.userHasBeenOnboarded()) {
|
if (onboarding.userHasBeenOnboarded()) {
|
||||||
|
@ -325,7 +325,6 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, owner = this)
|
}, owner = this)
|
||||||
|
|
||||||
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
||||||
browsingModeManager.mode.isPrivate) {
|
browsingModeManager.mode.isPrivate) {
|
||||||
recommendPrivateBrowsingShortcut()
|
recommendPrivateBrowsingShortcut()
|
||||||
|
|
|
@ -68,7 +68,7 @@ class OnboardingThemePickerViewHolder(view: View) : RecyclerView.ViewHolder(view
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(view.context.settings) {
|
with(view.context.settings()) {
|
||||||
val radio = when {
|
val radio = when {
|
||||||
this.shouldUseLightTheme -> radioLightTheme
|
this.shouldUseLightTheme -> radioLightTheme
|
||||||
this.shouldUseDarkTheme -> radioDarkTheme
|
this.shouldUseDarkTheme -> radioDarkTheme
|
||||||
|
|
|
@ -23,7 +23,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
||||||
)
|
)
|
||||||
|
|
||||||
view.tracking_protection_toggle.apply {
|
view.tracking_protection_toggle.apply {
|
||||||
isChecked = view.context.settings.shouldUseTrackingProtection
|
isChecked = view.context.settings().shouldUseTrackingProtection
|
||||||
setOnCheckedChangeListener { _, isChecked ->
|
setOnCheckedChangeListener { _, isChecked ->
|
||||||
updateTrackingProtectionSetting(isChecked)
|
updateTrackingProtectionSetting(isChecked)
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTrackingProtectionSetting(enabled: Boolean) {
|
private fun updateTrackingProtectionSetting(enabled: Boolean) {
|
||||||
itemView.context.settings.shouldUseTrackingProtection = enabled
|
itemView.context.settings().shouldUseTrackingProtection = enabled
|
||||||
with(itemView.context.components) {
|
with(itemView.context.components) {
|
||||||
val policy = core.createTrackingProtectionPolicy(enabled)
|
val policy = core.createTrackingProtectionPolicy(enabled)
|
||||||
useCases.settingsUseCases.updateTrackingProtection.invoke(policy)
|
useCases.settingsUseCases.updateTrackingProtection.invoke(policy)
|
||||||
|
|
|
@ -45,7 +45,7 @@ class OnboardingRadioButton(context: Context, attrs: AttributeSet) : AppCompatRa
|
||||||
|
|
||||||
private fun updateRadioValue(isChecked: Boolean) {
|
private fun updateRadioValue(isChecked: Boolean) {
|
||||||
this.isChecked = isChecked
|
this.isChecked = isChecked
|
||||||
context.settings.preferences.edit {
|
context.settings().preferences.edit {
|
||||||
putBoolean(context.getString(key), isChecked)
|
putBoolean(context.getString(key), isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ class QuickActionSheet @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bounceSheet() {
|
fun bounceSheet() {
|
||||||
context.settings.incrementAutomaticBounceQuickActionSheetCount()
|
context.settings().incrementAutomaticBounceQuickActionSheetCount()
|
||||||
scope.launch(Dispatchers.Main) {
|
scope.launch(Dispatchers.Main) {
|
||||||
delay(BOUNCE_ANIMATION_DELAY_LENGTH)
|
delay(BOUNCE_ANIMATION_DELAY_LENGTH)
|
||||||
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
quickActionSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
|
|
@ -130,7 +130,7 @@ class QuickActionSheetView(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (quickActionSheetState.bounceNeeded && view.context.settings.shouldAutoBounceQuickActionSheet) {
|
if (quickActionSheetState.bounceNeeded && view.context.settings().shouldAutoBounceQuickActionSheet) {
|
||||||
quickActionSheet.bounceSheet()
|
quickActionSheet.bounceSheet()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ class QuickActionSheetView(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun notifyReaderModeButton(readable: Boolean) {
|
private fun notifyReaderModeButton(readable: Boolean) {
|
||||||
val settings = view.context.settings.preferences
|
val settings = view.context.settings().preferences
|
||||||
val shouldNotifyKey = view.context.getString(R.string.pref_key_reader_mode_notification)
|
val shouldNotifyKey = view.context.getString(R.string.pref_key_reader_mode_notification)
|
||||||
|
|
||||||
@DrawableRes
|
@DrawableRes
|
||||||
|
|
|
@ -96,10 +96,10 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
showShortcutEnginePicker = displayShortcutEnginePicker,
|
showShortcutEnginePicker = displayShortcutEnginePicker,
|
||||||
searchEngineSource = currentSearchEngine,
|
searchEngineSource = currentSearchEngine,
|
||||||
defaultEngineSource = currentSearchEngine,
|
defaultEngineSource = currentSearchEngine,
|
||||||
showSearchSuggestions = requireContext().settings.shouldShowSearchSuggestions,
|
showSearchSuggestions = requireContext().settings().shouldShowSearchSuggestions,
|
||||||
showClipboardSuggestions = requireContext().settings.shouldShowClipboardSuggestions,
|
showClipboardSuggestions = requireContext().settings().shouldShowClipboardSuggestions,
|
||||||
showHistorySuggestions = requireContext().settings.shouldShowHistorySuggestions,
|
showHistorySuggestions = requireContext().settings().shouldShowHistorySuggestions,
|
||||||
showBookmarkSuggestions = requireContext().settings.shouldShowBookmarkSuggestions,
|
showBookmarkSuggestions = requireContext().settings().shouldShowBookmarkSuggestions,
|
||||||
session = session,
|
session = session,
|
||||||
pastedText = pastedText
|
pastedText = pastedText
|
||||||
)
|
)
|
||||||
|
@ -230,7 +230,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
val currentDefaultEngine =
|
val currentDefaultEngine =
|
||||||
requireComponents.search.searchEngineManager.getDefaultSearchEngine(
|
requireComponents.search.searchEngineManager.getDefaultSearchEngine(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
requireContext().settings.defaultSearchEngineName
|
requireContext().settings().defaultSearchEngineName
|
||||||
)
|
)
|
||||||
|
|
||||||
if (searchStore.state.defaultEngineSource.searchEngine != currentDefaultEngine) {
|
if (searchStore.state.defaultEngineSource.searchEngine != currentDefaultEngine) {
|
||||||
|
@ -322,7 +322,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun historyStorageProvider(): HistoryStorage? {
|
private fun historyStorageProvider(): HistoryStorage? {
|
||||||
return if (requireContext().settings.shouldShowHistorySuggestions) {
|
return if (requireContext().settings().shouldShowHistorySuggestions) {
|
||||||
requireComponents.core.historyStorage
|
requireComponents.core.historyStorage
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class AccessibilityFragment : PreferenceFragmentCompat() {
|
||||||
getPreferenceKey(R.string.pref_key_accessibility_font_scale)
|
getPreferenceKey(R.string.pref_key_accessibility_font_scale)
|
||||||
)
|
)
|
||||||
textSizePreference?.setOnPreferenceChangeListener<Int> { preference, newTextSize ->
|
textSizePreference?.setOnPreferenceChangeListener<Int> { preference, newTextSize ->
|
||||||
val settings = preference.context.settings
|
val settings = preference.context.settings()
|
||||||
val components = preference.context.components
|
val components = preference.context.components
|
||||||
|
|
||||||
// Value is mapped from 0->30 in steps of 1 so let's convert to float in range 0.5->2.0
|
// Value is mapped from 0->30 in steps of 1 so let's convert to float in range 0.5->2.0
|
||||||
|
@ -43,12 +43,12 @@ class AccessibilityFragment : PreferenceFragmentCompat() {
|
||||||
components.useCases.sessionUseCases.reload()
|
components.useCases.sessionUseCases.reload()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
textSizePreference?.isVisible = !requireContext().settings.shouldUseAutoSize
|
textSizePreference?.isVisible = !requireContext().settings().shouldUseAutoSize
|
||||||
|
|
||||||
val useAutoSizePreference =
|
val useAutoSizePreference =
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_accessibility_auto_size))
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_accessibility_auto_size))
|
||||||
useAutoSizePreference?.setOnPreferenceChangeListener<Boolean> { preference, useAutoSize ->
|
useAutoSizePreference?.setOnPreferenceChangeListener<Boolean> { preference, useAutoSize ->
|
||||||
val settings = preference.context.settings
|
val settings = preference.context.settings()
|
||||||
val components = preference.context.components
|
val components = preference.context.components
|
||||||
|
|
||||||
// Save the new setting value
|
// Save the new setting value
|
||||||
|
|
|
@ -23,7 +23,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
||||||
SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
|
SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
|
||||||
when (key) {
|
when (key) {
|
||||||
getPreferenceKey(R.string.pref_key_telemetry) -> {
|
getPreferenceKey(R.string.pref_key_telemetry) -> {
|
||||||
if (sharedPreferences.getBoolean(key, requireContext().settings.isTelemetryEnabled)) {
|
if (sharedPreferences.getBoolean(key, requireContext().settings().isTelemetryEnabled)) {
|
||||||
context?.components?.analytics?.metrics?.start()
|
context?.components?.analytics?.metrics?.start()
|
||||||
} else {
|
} else {
|
||||||
context?.components?.analytics?.metrics?.stop()
|
context?.components?.analytics?.metrics?.stop()
|
||||||
|
@ -56,7 +56,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
||||||
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
|
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
|
||||||
|
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_telemetry))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_telemetry))?.apply {
|
||||||
isChecked = context.settings.isTelemetryEnabled
|
isChecked = context.settings().isTelemetryEnabled
|
||||||
|
|
||||||
val appName = context.getString(R.string.app_name)
|
val appName = context.getString(R.string.app_name)
|
||||||
summary = context.getString(R.string.preferences_usage_data_description, appName)
|
summary = context.getString(R.string.preferences_usage_data_description, appName)
|
||||||
|
@ -65,7 +65,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
||||||
}
|
}
|
||||||
|
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_experimentation))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_experimentation))?.apply {
|
||||||
isChecked = context.settings.isExperimentationEnabled
|
isChecked = context.settings().isExperimentationEnabled
|
||||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,13 +95,13 @@ open class RadioButtonPreference @JvmOverloads constructor(
|
||||||
private fun updateRadioValue(isChecked: Boolean) {
|
private fun updateRadioValue(isChecked: Boolean) {
|
||||||
persistBoolean(isChecked)
|
persistBoolean(isChecked)
|
||||||
radioButton?.isChecked = isChecked
|
radioButton?.isChecked = isChecked
|
||||||
context.settings.preferences.edit().putBoolean(key, isChecked)
|
context.settings().preferences.edit().putBoolean(key, isChecked)
|
||||||
.apply()
|
.apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindRadioButton(holder: PreferenceViewHolder) {
|
private fun bindRadioButton(holder: PreferenceViewHolder) {
|
||||||
radioButton = holder.findViewById(R.id.radio_button) as RadioButton
|
radioButton = holder.findViewById(R.id.radio_button) as RadioButton
|
||||||
radioButton?.isChecked = context.settings.preferences.getBoolean(key, defaultValue)
|
radioButton?.isChecked = context.settings().preferences.getBoolean(key, defaultValue)
|
||||||
radioButton?.setStartCheckedIndicator()
|
radioButton?.setStartCheckedIndicator()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
||||||
val trackingProtectionPreference =
|
val trackingProtectionPreference =
|
||||||
findPreference<Preference>(getPreferenceKey(R.string.pref_key_tracking_protection_settings))
|
findPreference<Preference>(getPreferenceKey(R.string.pref_key_tracking_protection_settings))
|
||||||
trackingProtectionPreference?.summary = context?.let {
|
trackingProtectionPreference?.summary = context?.let {
|
||||||
if (it.settings.shouldUseTrackingProtection) {
|
if (it.settings().shouldUseTrackingProtection) {
|
||||||
getString(R.string.tracking_protection_on)
|
getString(R.string.tracking_protection_on)
|
||||||
} else {
|
} else {
|
||||||
getString(R.string.tracking_protection_off)
|
getString(R.string.tracking_protection_off)
|
||||||
|
@ -140,9 +140,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
||||||
|
|
||||||
val themesPreference =
|
val themesPreference =
|
||||||
findPreference<Preference>(getPreferenceKey(R.string.pref_key_theme))
|
findPreference<Preference>(getPreferenceKey(R.string.pref_key_theme))
|
||||||
themesPreference?.summary = context?.let {
|
themesPreference?.summary = context?.settings()?.themeSettingString
|
||||||
it.settings.themeSettingString
|
|
||||||
}
|
|
||||||
|
|
||||||
val aboutPreference = findPreference<Preference>(getPreferenceKey(R.string.pref_key_about))
|
val aboutPreference = findPreference<Preference>(getPreferenceKey(R.string.pref_key_about))
|
||||||
val appName = getString(R.string.app_name)
|
val appName = getString(R.string.app_name)
|
||||||
|
@ -263,7 +261,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
||||||
val preferenceAlwaysOpenInPrivateMode = findPreference<SwitchPreference>(preferenceAlwaysOpenInPrivateModeKey)
|
val preferenceAlwaysOpenInPrivateMode = findPreference<SwitchPreference>(preferenceAlwaysOpenInPrivateModeKey)
|
||||||
|
|
||||||
preferenceAlwaysOpenInPrivateMode?.setOnPreferenceClickListener {
|
preferenceAlwaysOpenInPrivateMode?.setOnPreferenceClickListener {
|
||||||
requireContext().settings.alwaysOpenInPrivateMode = !requireContext().settings.alwaysOpenInPrivateMode
|
requireContext().settings().alwaysOpenInPrivateMode = !requireContext().settings().alwaysOpenInPrivateMode
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,7 +276,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceRemoteDebugging?.setOnPreferenceChangeListener { preference, newValue ->
|
preferenceRemoteDebugging?.setOnPreferenceChangeListener { preference, newValue ->
|
||||||
preference.context.settings.preferences.edit()
|
preference.context.settings().preferences.edit()
|
||||||
.putBoolean(preference.key, newValue as Boolean).apply()
|
.putBoolean(preference.key, newValue as Boolean).apply()
|
||||||
requireComponents.core.engine.settings.remoteDebuggingEnabled = newValue
|
requireComponents.core.engine.settings.remoteDebuggingEnabled = newValue
|
||||||
true
|
true
|
||||||
|
|
|
@ -12,7 +12,7 @@ open class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
|
||||||
|
|
||||||
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
||||||
val newBooleanValue = newValue as? Boolean ?: return false
|
val newBooleanValue = newValue as? Boolean ?: return false
|
||||||
preference.context.settings.preferences.edit {
|
preference.context.settings().preferences.edit {
|
||||||
putBoolean(preference.key, newBooleanValue)
|
putBoolean(preference.key, newBooleanValue)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -49,9 +49,9 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
|
||||||
val trackingProtectionKey = getPreferenceKey(R.string.pref_key_tracking_protection)
|
val trackingProtectionKey = getPreferenceKey(R.string.pref_key_tracking_protection)
|
||||||
val preferenceTP = findPreference<SwitchPreference>(trackingProtectionKey)
|
val preferenceTP = findPreference<SwitchPreference>(trackingProtectionKey)
|
||||||
|
|
||||||
preferenceTP?.isChecked = context!!.settings.shouldUseTrackingProtection
|
preferenceTP?.isChecked = requireContext().settings().shouldUseTrackingProtection
|
||||||
preferenceTP?.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
|
preferenceTP?.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
|
||||||
preference.context.settings.shouldUseTrackingProtection =
|
preference.context.settings().shouldUseTrackingProtection =
|
||||||
trackingProtectionOn
|
trackingProtectionOn
|
||||||
with(preference.context.components) {
|
with(preference.context.components) {
|
||||||
val policy = core.createTrackingProtectionPolicy(trackingProtectionOn)
|
val policy = core.createTrackingProtectionPolicy(trackingProtectionOn)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class QuickSettingsComponent(
|
||||||
): SitePermissions {
|
): SitePermissions {
|
||||||
|
|
||||||
return if (sitePermissions == null) {
|
return if (sitePermissions == null) {
|
||||||
val settings = context.settings
|
val settings = context.settings()
|
||||||
val origin = requireNotNull(url.toUri().host)
|
val origin = requireNotNull(url.toUri().host)
|
||||||
var location =
|
var location =
|
||||||
settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION).toStatus()
|
settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION).toStatus()
|
||||||
|
|
|
@ -46,7 +46,7 @@ class QuickSettingsUIView(
|
||||||
) {
|
) {
|
||||||
private val blockedByAndroidPhoneFeatures = mutableListOf<PhoneFeature>()
|
private val blockedByAndroidPhoneFeatures = mutableListOf<PhoneFeature>()
|
||||||
private inline val context get() = view.context
|
private inline val context get() = view.context
|
||||||
private val settings: Settings = context.settings
|
private val settings: Settings = context.settings()
|
||||||
private val trackingProtectionSettingView = TrackingProtectionSettingView(view, actionEmitter)
|
private val trackingProtectionSettingView = TrackingProtectionSettingView(view, actionEmitter)
|
||||||
private val labelAndActions = mapOf(
|
private val labelAndActions = mapOf(
|
||||||
CAMERA to findLabelActionPair(R.id.camera_icon, R.id.camera_action_label),
|
CAMERA to findLabelActionPair(R.id.camera_icon, R.id.camera_action_label),
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TrackingProtectionSettingView(
|
||||||
fun bind(isTrackingProtectionOn: Boolean) {
|
fun bind(isTrackingProtectionOn: Boolean) {
|
||||||
trackingProtectionSettingView.visibility =
|
trackingProtectionSettingView.visibility =
|
||||||
if (FeatureFlags.etpCategories) View.GONE else View.VISIBLE
|
if (FeatureFlags.etpCategories) View.GONE else View.VISIBLE
|
||||||
val globalTPSetting = trackingProtectionSwitch.context.settings.shouldUseTrackingProtection
|
val globalTPSetting = trackingProtectionSwitch.context.settings().shouldUseTrackingProtection
|
||||||
|
|
||||||
trackingProtectionAction.isVisible = !globalTPSetting
|
trackingProtectionAction.isVisible = !globalTPSetting
|
||||||
trackingProtectionAction.setOnClickListener(this)
|
trackingProtectionAction.setOnClickListener(this)
|
||||||
|
|
|
@ -26,6 +26,6 @@ class RadioSearchEngineListPreference @JvmOverloads constructor(
|
||||||
|
|
||||||
override fun onSearchEngineSelected(searchEngine: SearchEngine) {
|
override fun onSearchEngineSelected(searchEngine: SearchEngine) {
|
||||||
context.components.search.searchEngineManager.defaultSearchEngine = searchEngine
|
context.components.search.searchEngineManager.defaultSearchEngine = searchEngine
|
||||||
context.settings.defaultSearchEngineName = searchEngine.name
|
context.settings().defaultSearchEngineName = searchEngine.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,24 +26,24 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
val searchSuggestionsPreference =
|
val searchSuggestionsPreference =
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions))?.apply {
|
||||||
isChecked = context.settings.shouldShowSearchSuggestions
|
isChecked = context.settings().shouldShowSearchSuggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
searchSuggestionsPreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
searchSuggestionsPreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
|
|
||||||
val showHistorySuggestions =
|
val showHistorySuggestions =
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_browsing_history))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_browsing_history))?.apply {
|
||||||
isChecked = context.settings.shouldShowHistorySuggestions
|
isChecked = context.settings().shouldShowHistorySuggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
val showBookmarkSuggestions =
|
val showBookmarkSuggestions =
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_bookmarks))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_bookmarks))?.apply {
|
||||||
isChecked = context.settings.shouldShowBookmarkSuggestions
|
isChecked = context.settings().shouldShowBookmarkSuggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
val showClipboardSuggestions =
|
val showClipboardSuggestions =
|
||||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_clipboard_suggestions))?.apply {
|
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_clipboard_suggestions))?.apply {
|
||||||
isChecked = context.settings.shouldShowClipboardSuggestions
|
isChecked = context.settings().shouldShowClipboardSuggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
|
|
|
@ -69,7 +69,7 @@ abstract class SearchEngineListPreference @JvmOverloads constructor(
|
||||||
val selectedSearchEngine =
|
val selectedSearchEngine =
|
||||||
context.components.search.searchEngineManager.getDefaultSearchEngine(
|
context.components.search.searchEngineManager.getDefaultSearchEngine(
|
||||||
context,
|
context,
|
||||||
context.settings.defaultSearchEngineName
|
context.settings().defaultSearchEngineName
|
||||||
).identifier
|
).identifier
|
||||||
|
|
||||||
searchEngineGroup!!.removeAllViews()
|
searchEngineGroup!!.removeAllViews()
|
||||||
|
|
|
@ -55,7 +55,7 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
private fun initPhoneFeature(phoneFeature: PhoneFeature) {
|
private fun initPhoneFeature(phoneFeature: PhoneFeature) {
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
val settings = context.settings
|
val settings = context.settings()
|
||||||
|
|
||||||
val summary = phoneFeature.getActionLabel(context, settings = settings)
|
val summary = phoneFeature.getActionLabel(context, settings = settings)
|
||||||
val preferenceKey = phoneFeature.getPreferenceKey(context)
|
val preferenceKey = phoneFeature.getPreferenceKey(context)
|
||||||
|
|
|
@ -38,7 +38,7 @@ class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
||||||
private lateinit var radioAllow: RadioButton
|
private lateinit var radioAllow: RadioButton
|
||||||
private lateinit var radioBlock: RadioButton
|
private lateinit var radioBlock: RadioButton
|
||||||
private lateinit var blockedByAndroidView: View
|
private lateinit var blockedByAndroidView: View
|
||||||
val settings by lazy { requireContext().settings }
|
val settings by lazy { requireContext().settings() }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
@ -47,7 +47,7 @@ class SitePermissionsManagePhoneFeatureFragment : Fragment() {
|
||||||
|
|
||||||
(activity as AppCompatActivity).title = phoneFeature.getLabel(requireContext())
|
(activity as AppCompatActivity).title = phoneFeature.getLabel(requireContext())
|
||||||
(activity as AppCompatActivity).supportActionBar?.show()
|
(activity as AppCompatActivity).supportActionBar?.show()
|
||||||
settings = requireContext().settings
|
settings = requireContext().settings()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
|
|
@ -29,11 +29,11 @@ import androidx.core.graphics.drawable.toBitmap
|
||||||
class SearchWidgetProvider : AppWidgetProvider() {
|
class SearchWidgetProvider : AppWidgetProvider() {
|
||||||
|
|
||||||
override fun onEnabled(context: Context) {
|
override fun onEnabled(context: Context) {
|
||||||
context.settings.addSearchWidgetInstalled(1)
|
context.settings().addSearchWidgetInstalled(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
||||||
context.settings.addSearchWidgetInstalled(-appWidgetIds.size)
|
context.settings().addSearchWidgetInstalled(-appWidgetIds.size)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ class IntentReceiverActivityTest {
|
||||||
@Test
|
@Test
|
||||||
fun `process intent with alwaysOpenInPrivateMode set to true`() {
|
fun `process intent with alwaysOpenInPrivateMode set to true`() {
|
||||||
runBlockingTest {
|
runBlockingTest {
|
||||||
testContext.settings.alwaysOpenInPrivateMode = true
|
testContext.settings().alwaysOpenInPrivateMode = true
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
`when`(testContext.components.intentProcessors.privateIntentProcessor.process(intent)).thenReturn(true)
|
`when`(testContext.components.intentProcessors.privateIntentProcessor.process(intent)).thenReturn(true)
|
||||||
|
@ -52,7 +52,7 @@ class IntentReceiverActivityTest {
|
||||||
@Test
|
@Test
|
||||||
fun `process intent with alwaysOpenInPrivateMode set to false`() {
|
fun `process intent with alwaysOpenInPrivateMode set to false`() {
|
||||||
runBlockingTest {
|
runBlockingTest {
|
||||||
testContext.settings.alwaysOpenInPrivateMode = false
|
testContext.settings().alwaysOpenInPrivateMode = false
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
|
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
|
||||||
|
|
|
@ -32,8 +32,7 @@ class SettingsTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
settings = testContext.settings
|
settings = testContext.settings().apply(Settings::clear)
|
||||||
.apply(Settings::clear)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue