parent
cd533854e6
commit
a31eb1f371
|
@ -12,7 +12,7 @@ import mozilla.components.concept.engine.request.RequestInterceptor
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.exceptions.ExceptionDomains
|
import org.mozilla.fenix.exceptions.ExceptionDomains
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
import java.net.MalformedURLException
|
import java.net.MalformedURLException
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
|
||||||
|
@ -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.load(context).contains(host)
|
val trackingProtectionException = ExceptionDomains.load(context).contains(host)
|
||||||
val trackingProtectionEnabled = Settings.getInstance(context).shouldUseTrackingProtection
|
val trackingProtectionEnabled = context.settings.shouldUseTrackingProtection
|
||||||
if (trackingProtectionException || !trackingProtectionEnabled) {
|
if (trackingProtectionException || !trackingProtectionEnabled) {
|
||||||
session.disableTrackingProtection()
|
session.disableTrackingProtection()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -32,9 +32,9 @@ import mozilla.components.support.rusthttp.RustHttpConfig
|
||||||
import mozilla.components.support.rustlog.RustLog
|
import mozilla.components.support.rustlog.RustLog
|
||||||
import org.mozilla.fenix.GleanMetrics.ExperimentsMetrics
|
import org.mozilla.fenix.GleanMetrics.ExperimentsMetrics
|
||||||
import org.mozilla.fenix.components.Components
|
import org.mozilla.fenix.components.Components
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.session.NotificationSessionObserver
|
import org.mozilla.fenix.session.NotificationSessionObserver
|
||||||
import org.mozilla.fenix.session.VisibilityLifecycleCallback
|
import org.mozilla.fenix.session.VisibilityLifecycleCallback
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@SuppressLint("Registered")
|
@SuppressLint("Registered")
|
||||||
|
@ -80,7 +80,7 @@ open class FenixApplication : Application() {
|
||||||
experimentLoader = loadExperiments()
|
experimentLoader = loadExperiments()
|
||||||
|
|
||||||
// Enable the service-experiments component
|
// Enable the service-experiments component
|
||||||
if (Settings.getInstance(this).isExperimentationEnabled) {
|
if (this.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 (Settings.getInstance(this).isTelemetryEnabled) {
|
if (this.settings.isTelemetryEnabled) {
|
||||||
components.analytics.metrics.start()
|
components.analytics.metrics.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,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 = Settings.getInstance(this)
|
val settings = this.settings
|
||||||
when {
|
when {
|
||||||
settings.shouldUseLightTheme -> {
|
settings.shouldUseLightTheme -> {
|
||||||
AppCompatDelegate.setDefaultNightMode(
|
AppCompatDelegate.setDefaultNightMode(
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.mozilla.fenix.ext.alreadyOnDestination
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.getRootView
|
import org.mozilla.fenix.ext.getRootView
|
||||||
import org.mozilla.fenix.ext.nav
|
import org.mozilla.fenix.ext.nav
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor
|
import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor
|
||||||
import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor
|
import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor
|
||||||
|
@ -58,7 +59,6 @@ import org.mozilla.fenix.settings.SettingsFragmentDirections
|
||||||
import org.mozilla.fenix.share.ShareFragment
|
import org.mozilla.fenix.share.ShareFragment
|
||||||
import org.mozilla.fenix.theme.DefaultThemeManager
|
import org.mozilla.fenix.theme.DefaultThemeManager
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
||||||
open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback {
|
open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback {
|
||||||
|
@ -92,7 +92,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
||||||
|
|
||||||
setupToolbarAndNavigation()
|
setupToolbarAndNavigation()
|
||||||
|
|
||||||
if (Settings.getInstance(this).isTelemetryEnabled) {
|
if (settings.isTelemetryEnabled) {
|
||||||
if (isSentryEnabled()) {
|
if (isSentryEnabled()) {
|
||||||
lifecycle.addObserver(SentryBreadcrumbsRecorder(navHost.navController, ::getSentryBreadcrumbMessage))
|
lifecycle.addObserver(SentryBreadcrumbsRecorder(navHost.navController, ::getSentryBreadcrumbMessage))
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun createBrowsingModeManager(): BrowsingModeManager {
|
protected open fun createBrowsingModeManager(): BrowsingModeManager {
|
||||||
return DefaultBrowsingModeManager(Settings.getInstance(this)) { mode ->
|
return DefaultBrowsingModeManager(settings) { mode ->
|
||||||
themeManager.currentTheme = mode
|
themeManager.currentTheme = mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.mozilla.fenix.customtabs.AuthCustomTabActivity
|
||||||
import org.mozilla.fenix.customtabs.CustomTabActivity
|
import org.mozilla.fenix.customtabs.CustomTabActivity
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.metrics
|
import org.mozilla.fenix.ext.metrics
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class IntentReceiverActivity : Activity() {
|
class IntentReceiverActivity : Activity() {
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class IntentReceiverActivity : Activity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val isPrivate = Settings.getInstance(this).usePrivateMode
|
val isPrivate = this.settings.usePrivateMode
|
||||||
|
|
||||||
MainScope().launch {
|
MainScope().launch {
|
||||||
// The intent property is nullable, but the rest of the code below
|
// The intent property is nullable, but the rest of the code below
|
||||||
|
|
|
@ -69,10 +69,10 @@ 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.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior
|
import org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior
|
||||||
import org.mozilla.fenix.settings.SupportUtils
|
import org.mozilla.fenix.settings.SupportUtils
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base fragment extended by [BrowserFragment].
|
* Base fragment extended by [BrowserFragment].
|
||||||
|
@ -501,7 +501,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 = Settings.getInstance(requireContext())
|
val settings = requireContext().settings
|
||||||
|
|
||||||
val rules: SitePermissionsRules = settings.getSitePermissionsCustomSettingsRules()
|
val rules: SitePermissionsRules = settings.getSitePermissionsCustomSettingsRules()
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ import org.mozilla.fenix.components.metrics.AdjustMetricsService
|
||||||
import org.mozilla.fenix.components.metrics.GleanMetricsService
|
import org.mozilla.fenix.components.metrics.GleanMetricsService
|
||||||
import org.mozilla.fenix.components.metrics.LeanplumMetricsService
|
import org.mozilla.fenix.components.metrics.LeanplumMetricsService
|
||||||
import org.mozilla.fenix.components.metrics.MetricController
|
import org.mozilla.fenix.components.metrics.MetricController
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.test.Mockable
|
import org.mozilla.fenix.test.Mockable
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
import org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID
|
import org.mozilla.geckoview.BuildConfig.MOZ_APP_BUILDID
|
||||||
import org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION
|
import org.mozilla.geckoview.BuildConfig.MOZ_APP_VERSION
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ class Analytics(
|
||||||
LeanplumMetricsService(context as Application),
|
LeanplumMetricsService(context as Application),
|
||||||
AdjustMetricsService(context)
|
AdjustMetricsService(context)
|
||||||
),
|
),
|
||||||
isTelemetryEnabled = { Settings.getInstance(context).isTelemetryEnabled }
|
isTelemetryEnabled = { context.settings.isTelemetryEnabled }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ import org.mozilla.fenix.Experiments
|
||||||
import org.mozilla.fenix.R
|
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.settings
|
||||||
import org.mozilla.fenix.isInExperiment
|
import org.mozilla.fenix.isInExperiment
|
||||||
import org.mozilla.fenix.test.Mockable
|
import org.mozilla.fenix.test.Mockable
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component group for background services. These are the components that need to be accessed from within a
|
* Component group for background services. These are the components that need to be accessed from within a
|
||||||
|
@ -142,7 +142,7 @@ class BackgroundServices(
|
||||||
|
|
||||||
context.components.analytics.metrics.track(Event.SyncAuthSignOut)
|
context.components.analytics.metrics.track(Event.SyncAuthSignOut)
|
||||||
|
|
||||||
Settings.getInstance(context).fxaSignedIn = false
|
context.settings.fxaSignedIn = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
|
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
|
||||||
|
@ -152,7 +152,7 @@ class BackgroundServices(
|
||||||
|
|
||||||
context.components.analytics.metrics.track(Event.SyncAuthSignIn)
|
context.components.analytics.metrics.track(Event.SyncAuthSignIn)
|
||||||
|
|
||||||
Settings.getInstance(context).fxaSignedIn = true
|
context.settings.fxaSignedIn = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,13 +174,11 @@ class BackgroundServices(
|
||||||
// See https://github.com/mozilla-mobile/android-components/issues/3732
|
// See https://github.com/mozilla-mobile/android-components/issues/3732
|
||||||
setOf("https://identity.mozilla.com/apps/oldsync")
|
setOf("https://identity.mozilla.com/apps/oldsync")
|
||||||
).also {
|
).also {
|
||||||
Settings.getInstance(context).fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
context.settings.fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
||||||
|
|
||||||
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
||||||
|
|
||||||
// Enable push if we have the config.
|
// Enable push if we have the config.
|
||||||
if (pushConfig != null) {
|
if (pushConfig != null) {
|
||||||
|
|
||||||
// Register our account observer so we know how to update our push subscriptions.
|
// Register our account observer so we know how to update our push subscriptions.
|
||||||
it.register(accountObserver)
|
it.register(accountObserver)
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ import mozilla.components.feature.session.HistoryDelegate
|
||||||
import org.mozilla.fenix.AppRequestInterceptor
|
import org.mozilla.fenix.AppRequestInterceptor
|
||||||
import org.mozilla.fenix.FeatureFlags
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.test.Mockable
|
import org.mozilla.fenix.test.Mockable
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit
|
||||||
*/
|
*/
|
||||||
@Mockable
|
@Mockable
|
||||||
class Core(private val context: Context) {
|
class Core(private val context: Context) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The browser engine component initialized based on the build
|
* The browser engine component initialized based on the build
|
||||||
* configuration (see build variants).
|
* configuration (see build variants).
|
||||||
|
@ -49,12 +48,12 @@ 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 = Settings.getInstance(context).isRemoteDebuggingEnabled,
|
remoteDebuggingEnabled = context.settings.isRemoteDebuggingEnabled,
|
||||||
testingModeEnabled = false,
|
testingModeEnabled = false,
|
||||||
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
||||||
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
||||||
preferredColorScheme = getPreferredColorScheme(),
|
preferredColorScheme = getPreferredColorScheme(),
|
||||||
automaticFontSizeAdjustment = Settings.getInstance(context).shouldUseAutoSize,
|
automaticFontSizeAdjustment = context.settings.shouldUseAutoSize,
|
||||||
suspendMediaWhenInactive = !FeatureFlags.mediaIntegration
|
suspendMediaWhenInactive = !FeatureFlags.mediaIntegration
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -149,7 +148,7 @@ 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 = Settings.getInstance(context).shouldUseTrackingProtection,
|
normalMode: Boolean = context.settings.shouldUseTrackingProtection,
|
||||||
privateMode: Boolean = true
|
privateMode: Boolean = true
|
||||||
): TrackingProtectionPolicy {
|
): TrackingProtectionPolicy {
|
||||||
val trackingProtectionPolicy = TrackingProtectionPolicy.recommended()
|
val trackingProtectionPolicy = TrackingProtectionPolicy.recommended()
|
||||||
|
@ -170,8 +169,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 {
|
||||||
Settings.getInstance(context).shouldUseDarkTheme -> PreferredColorScheme.Dark
|
context.settings.shouldUseDarkTheme -> PreferredColorScheme.Dark
|
||||||
Settings.getInstance(context).shouldUseLightTheme -> PreferredColorScheme.Light
|
context.settings.shouldUseLightTheme -> PreferredColorScheme.Light
|
||||||
inDark -> PreferredColorScheme.Dark
|
inDark -> PreferredColorScheme.Dark
|
||||||
else -> PreferredColorScheme.Light
|
else -> PreferredColorScheme.Light
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@ import kotlinx.coroutines.launch
|
||||||
import mozilla.components.browser.search.SearchEngineManager
|
import mozilla.components.browser.search.SearchEngineManager
|
||||||
import mozilla.components.browser.search.provider.AssetsSearchEngineProvider
|
import mozilla.components.browser.search.provider.AssetsSearchEngineProvider
|
||||||
import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider
|
import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.test.Mockable
|
import org.mozilla.fenix.test.Mockable
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component group for all search engine integration related functionality.
|
* Component group for all search engine integration related functionality.
|
||||||
|
@ -33,7 +33,7 @@ class Search(private val context: Context) {
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
defaultSearchEngine = getDefaultSearchEngineAsync(
|
defaultSearchEngine = getDefaultSearchEngineAsync(
|
||||||
context,
|
context,
|
||||||
Settings.getInstance(context).defaultSearchEngineName
|
context.settings.defaultSearchEngineName
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import com.leanplum.LeanplumActivityHelper
|
||||||
import com.leanplum.annotations.Parser
|
import com.leanplum.annotations.Parser
|
||||||
import com.leanplum.internal.LeanplumInternal
|
import com.leanplum.internal.LeanplumInternal
|
||||||
import org.mozilla.fenix.BuildConfig
|
import org.mozilla.fenix.BuildConfig
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
import java.util.UUID.randomUUID
|
import java.util.UUID.randomUUID
|
||||||
|
|
||||||
private val Event.name: String?
|
private val Event.name: String?
|
||||||
|
@ -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 Settings.getInstance(application).fxaSignedIn,
|
"fxa_signed_in" to application.settings.fxaSignedIn,
|
||||||
"fxa_has_synced_items" to Settings.getInstance(application).fxaHasSyncedItems,
|
"fxa_has_synced_items" to application.settings.fxaHasSyncedItems,
|
||||||
"search_widget_installed" to Settings.getInstance(application).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 Settings.getInstance(application).isTelemetryEnabled &&
|
return application.settings.isTelemetryEnabled &&
|
||||||
token.type != Token.Type.Invalid && !event.name.isNullOrEmpty()
|
token.type != Token.Type.Invalid && !event.name.isNullOrEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ import mozilla.components.support.ktx.android.view.hideKeyboard
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.nav
|
import org.mozilla.fenix.ext.nav
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
class ToolbarIntegration(
|
class ToolbarIntegration(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -90,7 +90,7 @@ class ToolbarIntegration(
|
||||||
|
|
||||||
ToolbarAutocompleteFeature(toolbar).apply {
|
ToolbarAutocompleteFeature(toolbar).apply {
|
||||||
addDomainProvider(domainAutocompleteProvider)
|
addDomainProvider(domainAutocompleteProvider)
|
||||||
if (Settings.getInstance(context).shouldShowHistorySuggestions) {
|
if (context.settings.shouldShowHistorySuggestions) {
|
||||||
addHistoryStorageProvider(historyStorage)
|
addHistoryStorageProvider(historyStorage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.nav
|
import org.mozilla.fenix.ext.nav
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class CrashReporterFragment : Fragment() {
|
class CrashReporterFragment : Fragment() {
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
@ -69,7 +69,7 @@ class CrashReporterFragment : Fragment() {
|
||||||
|
|
||||||
private fun submitReportIfNecessary(crash: Crash) {
|
private fun submitReportIfNecessary(crash: Crash) {
|
||||||
var didSubmitCrashReport = false
|
var didSubmitCrashReport = false
|
||||||
if (Settings.getInstance(context!!).isCrashReportingEnabled && sendCrashCheckbox.isChecked) {
|
if (requireContext().settings.isCrashReportingEnabled && sendCrashCheckbox.isChecked) {
|
||||||
requireComponents.analytics.crashReporter.submitReport(crash)
|
requireComponents.analytics.crashReporter.submitReport(crash)
|
||||||
didSubmitCrashReport = true
|
didSubmitCrashReport = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,14 @@ import androidx.fragment.app.FragmentActivity
|
||||||
import mozilla.components.browser.search.SearchEngineManager
|
import mozilla.components.browser.search.SearchEngineManager
|
||||||
import mozilla.components.support.base.log.Log
|
import mozilla.components.support.base.log.Log
|
||||||
import mozilla.components.support.base.log.Log.Priority.WARN
|
import mozilla.components.support.base.log.Log.Priority.WARN
|
||||||
|
import org.mozilla.fenix.BuildConfig
|
||||||
|
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.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.utils.Settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the BrowserApplication object from a context.
|
* Get the BrowserApplication object from a context.
|
||||||
|
@ -105,3 +108,9 @@ fun Context.getRootView(): View? =
|
||||||
@ColorInt
|
@ColorInt
|
||||||
fun Context.getColorFromAttr(@AttrRes attr: Int) =
|
fun Context.getColorFromAttr(@AttrRes attr: Int) =
|
||||||
ContextCompat.getColor(this, ThemeManager.resolveAttribute(attr, this))
|
ContextCompat.getColor(this, ThemeManager.resolveAttribute(attr, this))
|
||||||
|
|
||||||
|
fun Context.settings(isCrashReportEnabledInBuild: Boolean = BuildConfig.CRASH_REPORTING && Config.channel.isReleased) =
|
||||||
|
Settings.getInstance(this, isCrashReportEnabledInBuild)
|
||||||
|
|
||||||
|
val Context.settings: Settings
|
||||||
|
get() = Settings.getInstance(this)
|
||||||
|
|
|
@ -12,7 +12,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.onboarding_theme_picker.view.*
|
import kotlinx.android.synthetic.main.onboarding_theme_picker.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class OnboardingThemePickerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
class OnboardingThemePickerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class OnboardingThemePickerViewHolder(view: View) : RecyclerView.ViewHolder(view
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
with(Settings.getInstance(view.context)) {
|
with(view.context.settings) {
|
||||||
val radio = when {
|
val radio = when {
|
||||||
this.shouldUseLightTheme -> radioLightTheme
|
this.shouldUseLightTheme -> radioLightTheme
|
||||||
this.shouldUseDarkTheme -> radioDarkTheme
|
this.shouldUseDarkTheme -> radioDarkTheme
|
||||||
|
|
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.onboarding_tracking_protection.view.*
|
import kotlinx.android.synthetic.main.onboarding_tracking_protection.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
||||||
)
|
)
|
||||||
|
|
||||||
view.tracking_protection_toggle.apply {
|
view.tracking_protection_toggle.apply {
|
||||||
isChecked = Settings.getInstance(view.context).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) {
|
||||||
Settings.getInstance(itemView.context).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)
|
||||||
|
|
|
@ -10,7 +10,7 @@ import androidx.appcompat.widget.AppCompatRadioButton
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.content.withStyledAttributes
|
import androidx.core.content.withStyledAttributes
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class OnboardingRadioButton(context: Context, attrs: AttributeSet) : AppCompatRadioButton(context, attrs) {
|
class OnboardingRadioButton(context: Context, attrs: AttributeSet) : AppCompatRadioButton(context, attrs) {
|
||||||
private val radioGroups = mutableListOf<OnboardingRadioButton>()
|
private val radioGroups = mutableListOf<OnboardingRadioButton>()
|
||||||
|
@ -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
|
||||||
Settings.getInstance(context).preferences.edit {
|
context.settings.preferences.edit {
|
||||||
putBoolean(context.getString(key), isChecked)
|
putBoolean(context.getString(key), isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
const val POSITION_SNAP_BUFFER = 1f
|
const val POSITION_SNAP_BUFFER = 1f
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class QuickActionSheet @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bounceSheet() {
|
fun bounceSheet() {
|
||||||
Settings.getInstance(context).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
|
||||||
|
|
|
@ -17,8 +17,8 @@ import kotlinx.android.synthetic.main.layout_quick_action_sheet.*
|
||||||
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
|
import kotlinx.android.synthetic.main.layout_quick_action_sheet.view.*
|
||||||
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
|
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
interface QuickActionSheetViewInteractor {
|
interface QuickActionSheetViewInteractor {
|
||||||
fun onQuickActionSheetOpened()
|
fun onQuickActionSheetOpened()
|
||||||
|
@ -130,7 +130,7 @@ class QuickActionSheetView(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (quickActionSheetState.bounceNeeded && Settings.getInstance(view.context).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 = Settings.getInstance(view.context).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
|
||||||
|
|
|
@ -40,9 +40,9 @@ import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.getColorFromAttr
|
import org.mozilla.fenix.ext.getColorFromAttr
|
||||||
import org.mozilla.fenix.ext.getSpannable
|
import org.mozilla.fenix.ext.getSpannable
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.search.awesomebar.AwesomeBarView
|
import org.mozilla.fenix.search.awesomebar.AwesomeBarView
|
||||||
import org.mozilla.fenix.search.toolbar.ToolbarView
|
import org.mozilla.fenix.search.toolbar.ToolbarView
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
@Suppress("TooManyFunctions", "LargeClass")
|
@Suppress("TooManyFunctions", "LargeClass")
|
||||||
class SearchFragment : Fragment(), BackHandler {
|
class SearchFragment : Fragment(), BackHandler {
|
||||||
|
@ -91,10 +91,10 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
showShortcutEnginePicker = displayShortcutEnginePicker,
|
showShortcutEnginePicker = displayShortcutEnginePicker,
|
||||||
searchEngineSource = currentSearchEngine,
|
searchEngineSource = currentSearchEngine,
|
||||||
defaultEngineSource = currentSearchEngine,
|
defaultEngineSource = currentSearchEngine,
|
||||||
showSearchSuggestions = Settings.getInstance(requireContext()).shouldShowSearchSuggestions,
|
showSearchSuggestions = requireContext().settings.shouldShowSearchSuggestions,
|
||||||
showClipboardSuggestions = Settings.getInstance(requireContext()).shouldShowClipboardSuggestions,
|
showClipboardSuggestions = requireContext().settings.shouldShowClipboardSuggestions,
|
||||||
showHistorySuggestions = Settings.getInstance(requireContext()).shouldShowHistorySuggestions,
|
showHistorySuggestions = requireContext().settings.shouldShowHistorySuggestions,
|
||||||
showBookmarkSuggestions = Settings.getInstance(requireContext()).shouldShowBookmarkSuggestions,
|
showBookmarkSuggestions = requireContext().settings.shouldShowBookmarkSuggestions,
|
||||||
session = session
|
session = session
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -212,7 +212,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
val currentDefaultEngine =
|
val currentDefaultEngine =
|
||||||
requireComponents.search.searchEngineManager.getDefaultSearchEngine(
|
requireComponents.search.searchEngineManager.getDefaultSearchEngine(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
Settings.getInstance(requireContext()).defaultSearchEngineName
|
requireContext().settings.defaultSearchEngineName
|
||||||
)
|
)
|
||||||
|
|
||||||
if (searchStore.state.defaultEngineSource.searchEngine != currentDefaultEngine) {
|
if (searchStore.state.defaultEngineSource.searchEngine != currentDefaultEngine) {
|
||||||
|
@ -292,7 +292,7 @@ class SearchFragment : Fragment(), BackHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun historyStorageProvider(): HistoryStorage? {
|
private fun historyStorageProvider(): HistoryStorage? {
|
||||||
return if (Settings.getInstance(requireContext()).shouldShowHistorySuggestions) {
|
return if (requireContext().settings.shouldShowHistorySuggestions) {
|
||||||
requireComponents.core.historyStorage
|
requireComponents.core.historyStorage
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import androidx.preference.SwitchPreference
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
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.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays font size controls for accessibility.
|
* Displays font size controls for accessibility.
|
||||||
|
@ -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 = Settings.getInstance(preference.context)
|
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 = !Settings.getInstance(context!!).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 = Settings.getInstance(preference.context)
|
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
|
||||||
|
|
|
@ -12,7 +12,7 @@ import androidx.preference.SwitchPreference
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
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.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lets the user toggle telemetry on/off.
|
* Lets the user toggle telemetry on/off.
|
||||||
|
@ -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, Settings.getInstance(requireContext()).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 = Settings.getInstance(context).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 = Settings.getInstance(context).isExperimentationEnabled
|
isChecked = context.settings.isExperimentationEnabled
|
||||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import androidx.core.text.HtmlCompat
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceViewHolder
|
import androidx.preference.PreferenceViewHolder
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class RadioButtonPreference @JvmOverloads constructor(
|
class RadioButtonPreference @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -76,13 +76,13 @@ class RadioButtonPreference @JvmOverloads constructor(
|
||||||
private fun updateRadioValue(isChecked: Boolean) {
|
private fun updateRadioValue(isChecked: Boolean) {
|
||||||
persistBoolean(isChecked)
|
persistBoolean(isChecked)
|
||||||
radioButton.isChecked = isChecked
|
radioButton.isChecked = isChecked
|
||||||
Settings.getInstance(context).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 = Settings.getInstance(context).preferences.getBoolean(key, false)
|
radioButton.isChecked = context.settings.preferences.getBoolean(key, false)
|
||||||
radioButton.setStartCheckedIndicator()
|
radioButton.setStartCheckedIndicator()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.widget.CompoundButton
|
||||||
import mozilla.components.browser.search.SearchEngine
|
import mozilla.components.browser.search.SearchEngine
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class RadioSearchEngineListPreference @JvmOverloads constructor(
|
class RadioSearchEngineListPreference @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -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
|
||||||
Settings.getInstance(context).defaultSearchEngineName = searchEngine.name
|
context.settings.defaultSearchEngineName = searchEngine.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreference
|
import androidx.preference.SwitchPreference
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.getPreferenceKey
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class SearchEngineFragment : PreferenceFragmentCompat() {
|
class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
|
@ -25,24 +25,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 = Settings.getInstance(context).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 = Settings.getInstance(context).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 = Settings.getInstance(context).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 = Settings.getInstance(context).shouldShowClipboardSuggestions
|
isChecked = context.settings.shouldShowClipboardSuggestions
|
||||||
}
|
}
|
||||||
|
|
||||||
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||||
|
|
|
@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.search_engine_radio_button.view.*
|
||||||
import mozilla.components.browser.search.SearchEngine
|
import mozilla.components.browser.search.SearchEngine
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
abstract class SearchEngineListPreference @JvmOverloads constructor(
|
abstract class SearchEngineListPreference @JvmOverloads constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
|
@ -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,
|
||||||
Settings.getInstance(context).defaultSearchEngineName
|
context.settings.defaultSearchEngineName
|
||||||
).identifier
|
).identifier
|
||||||
|
|
||||||
searchEngineGroup!!.removeAllViews()
|
searchEngineGroup!!.removeAllViews()
|
||||||
|
|
|
@ -56,6 +56,7 @@ 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.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
||||||
|
@ -119,7 +120,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 (org.mozilla.fenix.utils.Settings.getInstance(it).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)
|
||||||
|
@ -129,7 +130,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?.let {
|
||||||
org.mozilla.fenix.utils.Settings.getInstance(it).themeSettingString
|
it.settings.themeSettingString
|
||||||
}
|
}
|
||||||
|
|
||||||
val aboutPreference = findPreference<Preference>(getPreferenceKey(R.string.pref_key_about))
|
val aboutPreference = findPreference<Preference>(getPreferenceKey(R.string.pref_key_about))
|
||||||
|
@ -249,7 +250,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
||||||
}
|
}
|
||||||
|
|
||||||
preferenceRemoteDebugging?.setOnPreferenceChangeListener { preference, newValue ->
|
preferenceRemoteDebugging?.setOnPreferenceChangeListener { preference, newValue ->
|
||||||
org.mozilla.fenix.utils.Settings.getInstance(preference.context).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
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.mozilla.fenix.settings
|
||||||
|
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the corresponding [android.content.SharedPreferences] when the boolean [Preference] is changed.
|
* Updates the corresponding [android.content.SharedPreferences] when the boolean [Preference] is changed.
|
||||||
|
@ -12,7 +12,7 @@ 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
|
||||||
Settings.getInstance(preference.context).preferences.edit {
|
preference.context.settings.preferences.edit {
|
||||||
putBoolean(preference.key, newBooleanValue)
|
putBoolean(preference.key, newBooleanValue)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -12,7 +12,7 @@ import androidx.preference.Preference.OnPreferenceClickListener
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.getPreferenceKey
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions")
|
@SuppressWarnings("TooManyFunctions")
|
||||||
class SitePermissionsFragment : PreferenceFragmentCompat() {
|
class SitePermissionsFragment : PreferenceFragmentCompat() {
|
||||||
|
@ -54,7 +54,7 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
|
||||||
|
|
||||||
private fun initPhoneFeature(phoneFeature: PhoneFeature) {
|
private fun initPhoneFeature(phoneFeature: PhoneFeature) {
|
||||||
val context = requireContext()
|
val context = requireContext()
|
||||||
val settings = Settings.getInstance(context)
|
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)
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jetbrains.anko.noButton
|
||||||
import org.jetbrains.anko.yesButton
|
import org.jetbrains.anko.yesButton
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.requireComponents
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions")
|
@SuppressWarnings("TooManyFunctions")
|
||||||
class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
||||||
|
@ -35,7 +35,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 { Settings.getInstance(requireContext()) }
|
val settings by lazy { requireContext().settings }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
|
@ -25,6 +25,7 @@ import mozilla.components.feature.sitepermissions.SitePermissionsRules
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ASK_TO_ALLOW
|
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ASK_TO_ALLOW
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED
|
import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.utils.Settings
|
||||||
|
|
||||||
@SuppressWarnings("TooManyFunctions")
|
@SuppressWarnings("TooManyFunctions")
|
||||||
|
@ -42,7 +43,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 = Settings.getInstance(requireContext())
|
settings = requireContext().settings
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import androidx.preference.SwitchPreference
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
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.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the toggle for tracking protection and a button to open
|
* Displays the toggle for tracking protection and a button to open
|
||||||
|
@ -40,9 +40,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 = Settings.getInstance(context!!).shouldUseTrackingProtection
|
preferenceTP?.isChecked = context!!.settings.shouldUseTrackingProtection
|
||||||
preferenceTP?.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
|
preferenceTP?.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
|
||||||
Settings.getInstance(preference.context).shouldUseTrackingProtection = trackingProtectionOn
|
preference.context.settings.shouldUseTrackingProtection = trackingProtectionOn
|
||||||
with(preference.context.components) {
|
with(preference.context.components) {
|
||||||
val policy = core.createTrackingProtectionPolicy(trackingProtectionOn)
|
val policy = core.createTrackingProtectionPolicy(trackingProtectionOn)
|
||||||
useCases.settingsUseCases.updateTrackingProtection(policy)
|
useCases.settingsUseCases.updateTrackingProtection(policy)
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.mvi.Action
|
import org.mozilla.fenix.mvi.Action
|
||||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||||
import org.mozilla.fenix.mvi.Change
|
import org.mozilla.fenix.mvi.Change
|
||||||
|
@ -19,7 +20,6 @@ import org.mozilla.fenix.mvi.UIView
|
||||||
import org.mozilla.fenix.mvi.ViewState
|
import org.mozilla.fenix.mvi.ViewState
|
||||||
import org.mozilla.fenix.settings.PhoneFeature
|
import org.mozilla.fenix.settings.PhoneFeature
|
||||||
import org.mozilla.fenix.settings.toggle
|
import org.mozilla.fenix.settings.toggle
|
||||||
import org.mozilla.fenix.utils.Settings
|
|
||||||
|
|
||||||
class QuickSettingsComponent(
|
class QuickSettingsComponent(
|
||||||
private val container: ViewGroup,
|
private val container: ViewGroup,
|
||||||
|
@ -46,7 +46,7 @@ class QuickSettingsComponent(
|
||||||
): SitePermissions {
|
): SitePermissions {
|
||||||
|
|
||||||
return if (sitePermissions == null) {
|
return if (sitePermissions == null) {
|
||||||
val settings = Settings.getInstance(context)
|
val settings = context.settings
|
||||||
val origin = requireNotNull(url.toUri().host)
|
val origin = requireNotNull(url.toUri().host)
|
||||||
var location = settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION).toStatus()
|
var location = settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION).toStatus()
|
||||||
var camera = settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.CAMERA).toStatus()
|
var camera = settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.CAMERA).toStatus()
|
||||||
|
|
|
@ -24,6 +24,7 @@ import mozilla.components.feature.sitepermissions.SitePermissions.Status.NO_DECI
|
||||||
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
import mozilla.components.support.ktx.android.net.hostWithoutCommonPrefixes
|
||||||
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.mvi.UIView
|
import org.mozilla.fenix.mvi.UIView
|
||||||
import org.mozilla.fenix.settings.PhoneFeature
|
import org.mozilla.fenix.settings.PhoneFeature
|
||||||
import org.mozilla.fenix.settings.PhoneFeature.CAMERA
|
import org.mozilla.fenix.settings.PhoneFeature.CAMERA
|
||||||
|
@ -45,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 = Settings.getInstance(context)
|
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),
|
||||||
|
|
|
@ -13,7 +13,7 @@ import androidx.core.view.isVisible
|
||||||
import io.reactivex.Observer
|
import io.reactivex.Observer
|
||||||
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
import mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
|
|
||||||
class TrackingProtectionSettingView(
|
class TrackingProtectionSettingView(
|
||||||
container: View,
|
container: View,
|
||||||
|
@ -29,7 +29,7 @@ class TrackingProtectionSettingView(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(isTrackingProtectionOn: Boolean) {
|
fun bind(isTrackingProtectionOn: Boolean) {
|
||||||
val globalTPSetting = Settings.getInstance(trackingProtectionSwitch.context).shouldUseTrackingProtection
|
val globalTPSetting = trackingProtectionSwitch.context.settings.shouldUseTrackingProtection
|
||||||
|
|
||||||
trackingProtectionAction.isVisible = !globalTPSetting
|
trackingProtectionAction.isVisible = !globalTPSetting
|
||||||
trackingProtectionAction.setOnClickListener(this)
|
trackingProtectionAction.setOnClickListener(this)
|
||||||
|
|
|
@ -19,7 +19,7 @@ import androidx.annotation.Dimension.DP
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.IntentReceiverActivity
|
import org.mozilla.fenix.IntentReceiverActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.utils.Settings
|
import org.mozilla.fenix.ext.settings
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.appcompat.widget.AppCompatDrawableManager
|
import androidx.appcompat.widget.AppCompatDrawableManager
|
||||||
import androidx.core.graphics.drawable.toBitmap
|
import androidx.core.graphics.drawable.toBitmap
|
||||||
|
@ -28,11 +28,11 @@ import androidx.core.graphics.drawable.toBitmap
|
||||||
class SearchWidgetProvider : AppWidgetProvider() {
|
class SearchWidgetProvider : AppWidgetProvider() {
|
||||||
|
|
||||||
override fun onEnabled(context: Context) {
|
override fun onEnabled(context: Context) {
|
||||||
Settings.getInstance(context).addSearchWidgetInstalled(1)
|
context.settings.addSearchWidgetInstalled(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
||||||
Settings.getInstance(context).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) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mozilla.fenix.TestApplication
|
import org.mozilla.fenix.TestApplication
|
||||||
import org.mozilla.fenix.ext.clearAndCommit
|
import org.mozilla.fenix.ext.clearAndCommit
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.settings.PhoneFeature
|
import org.mozilla.fenix.settings.PhoneFeature
|
||||||
import org.robolectric.annotation.Config
|
import org.robolectric.annotation.Config
|
||||||
|
|
||||||
|
@ -30,7 +31,7 @@ class SettingsTest {
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
settings = Settings.getInstance(testContext)
|
settings = testContext.settings
|
||||||
.apply(Settings::clear)
|
.apply(Settings::clear)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ class SettingsTest {
|
||||||
fun isCrashReportingEnabled_enabledInBuild() {
|
fun isCrashReportingEnabled_enabledInBuild() {
|
||||||
// When
|
// When
|
||||||
clearExistingInstance()
|
clearExistingInstance()
|
||||||
val settings = Settings.getInstance(testContext, isCrashReportEnabledInBuild = true)
|
val settings = testContext.settings(true)
|
||||||
.apply(Settings::clear)
|
.apply(Settings::clear)
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
|
@ -81,7 +82,7 @@ class SettingsTest {
|
||||||
fun isCrashReportingEnabled_disabledInBuild() {
|
fun isCrashReportingEnabled_disabledInBuild() {
|
||||||
// When
|
// When
|
||||||
clearExistingInstance()
|
clearExistingInstance()
|
||||||
val settings = Settings.getInstance(testContext, isCrashReportEnabledInBuild = false)
|
val settings = testContext.settings(false)
|
||||||
.apply(Settings::clear)
|
.apply(Settings::clear)
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
|
|
Loading…
Reference in New Issue