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.exceptions.ExceptionDomains
|
||||
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.URL
|
||||
|
||||
|
@ -31,7 +31,7 @@ class AppRequestInterceptor(private val context: Context) : RequestInterceptor {
|
|||
|
||||
private fun adjustTrackingProtection(host: String, context: Context, session: EngineSession) {
|
||||
val trackingProtectionException = ExceptionDomains.load(context).contains(host)
|
||||
val trackingProtectionEnabled = Settings.getInstance(context).shouldUseTrackingProtection
|
||||
val trackingProtectionEnabled = context.settings.shouldUseTrackingProtection
|
||||
if (trackingProtectionException || !trackingProtectionEnabled) {
|
||||
session.disableTrackingProtection()
|
||||
} else {
|
||||
|
|
|
@ -32,9 +32,9 @@ import mozilla.components.support.rusthttp.RustHttpConfig
|
|||
import mozilla.components.support.rustlog.RustLog
|
||||
import org.mozilla.fenix.GleanMetrics.ExperimentsMetrics
|
||||
import org.mozilla.fenix.components.Components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.session.NotificationSessionObserver
|
||||
import org.mozilla.fenix.session.VisibilityLifecycleCallback
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import java.io.File
|
||||
|
||||
@SuppressLint("Registered")
|
||||
|
@ -80,7 +80,7 @@ open class FenixApplication : Application() {
|
|||
experimentLoader = loadExperiments()
|
||||
|
||||
// Enable the service-experiments component
|
||||
if (Settings.getInstance(this).isExperimentationEnabled) {
|
||||
if (this.settings.isExperimentationEnabled) {
|
||||
Experiments.initialize(
|
||||
applicationContext,
|
||||
mozilla.components.service.experiments.Configuration(
|
||||
|
@ -100,7 +100,7 @@ open class FenixApplication : Application() {
|
|||
}
|
||||
|
||||
setupLeakCanary()
|
||||
if (Settings.getInstance(this).isTelemetryEnabled) {
|
||||
if (this.settings.isTelemetryEnabled) {
|
||||
components.analytics.metrics.start()
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ open class FenixApplication : Application() {
|
|||
@SuppressLint("WrongConstant")
|
||||
// Suppressing erroneous lint warning about using MODE_NIGHT_AUTO_BATTERY, a likely library bug
|
||||
private fun setDayNightTheme() {
|
||||
val settings = Settings.getInstance(this)
|
||||
val settings = this.settings
|
||||
when {
|
||||
settings.shouldUseLightTheme -> {
|
||||
AppCompatDelegate.setDefaultNightMode(
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.mozilla.fenix.ext.alreadyOnDestination
|
|||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.getRootView
|
||||
import org.mozilla.fenix.ext.nav
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||
import org.mozilla.fenix.home.intent.CrashReporterIntentProcessor
|
||||
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.theme.DefaultThemeManager
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
||||
open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback {
|
||||
|
@ -92,7 +92,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
|||
|
||||
setupToolbarAndNavigation()
|
||||
|
||||
if (Settings.getInstance(this).isTelemetryEnabled) {
|
||||
if (settings.isTelemetryEnabled) {
|
||||
if (isSentryEnabled()) {
|
||||
lifecycle.addObserver(SentryBreadcrumbsRecorder(navHost.navController, ::getSentryBreadcrumbMessage))
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
|
|||
}
|
||||
|
||||
protected open fun createBrowsingModeManager(): BrowsingModeManager {
|
||||
return DefaultBrowsingModeManager(Settings.getInstance(this)) { mode ->
|
||||
return DefaultBrowsingModeManager(settings) { mode ->
|
||||
themeManager.currentTheme = mode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.mozilla.fenix.customtabs.AuthCustomTabActivity
|
|||
import org.mozilla.fenix.customtabs.CustomTabActivity
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.metrics
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class IntentReceiverActivity : Activity() {
|
||||
|
||||
|
@ -32,7 +32,7 @@ class IntentReceiverActivity : Activity() {
|
|||
return
|
||||
}
|
||||
|
||||
val isPrivate = Settings.getInstance(this).usePrivateMode
|
||||
val isPrivate = this.settings.usePrivateMode
|
||||
|
||||
MainScope().launch {
|
||||
// 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.enterToImmersiveMode
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.quickactionsheet.QuickActionSheetBehavior
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
private fun assignSitePermissionsRules() {
|
||||
val settings = Settings.getInstance(requireContext())
|
||||
val settings = requireContext().settings
|
||||
|
||||
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.LeanplumMetricsService
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
import org.mozilla.fenix.ext.settings
|
||||
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_VERSION
|
||||
|
||||
|
@ -81,7 +81,7 @@ class Analytics(
|
|||
LeanplumMetricsService(context as Application),
|
||||
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.components.metrics.Event
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.isInExperiment
|
||||
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
|
||||
|
@ -142,7 +142,7 @@ class BackgroundServices(
|
|||
|
||||
context.components.analytics.metrics.track(Event.SyncAuthSignOut)
|
||||
|
||||
Settings.getInstance(context).fxaSignedIn = false
|
||||
context.settings.fxaSignedIn = false
|
||||
}
|
||||
|
||||
override fun onAuthenticated(account: OAuthAccount, authType: AuthType) {
|
||||
|
@ -152,7 +152,7 @@ class BackgroundServices(
|
|||
|
||||
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
|
||||
setOf("https://identity.mozilla.com/apps/oldsync")
|
||||
).also {
|
||||
Settings.getInstance(context).fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
||||
|
||||
context.settings.fxaHasSyncedItems = syncConfig?.supportedEngines?.isNotEmpty() ?: false
|
||||
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
||||
|
||||
// Enable push if we have the config.
|
||||
if (pushConfig != null) {
|
||||
|
||||
// Register our account observer so we know how to update our push subscriptions.
|
||||
it.register(accountObserver)
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ import mozilla.components.feature.session.HistoryDelegate
|
|||
import org.mozilla.fenix.AppRequestInterceptor
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.test.Mockable
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,6 @@ import java.util.concurrent.TimeUnit
|
|||
*/
|
||||
@Mockable
|
||||
class Core(private val context: Context) {
|
||||
|
||||
/**
|
||||
* The browser engine component initialized based on the build
|
||||
* configuration (see build variants).
|
||||
|
@ -49,12 +48,12 @@ class Core(private val context: Context) {
|
|||
val engine: Engine by lazy {
|
||||
val defaultSettings = DefaultSettings(
|
||||
requestInterceptor = AppRequestInterceptor(context),
|
||||
remoteDebuggingEnabled = Settings.getInstance(context).isRemoteDebuggingEnabled,
|
||||
remoteDebuggingEnabled = context.settings.isRemoteDebuggingEnabled,
|
||||
testingModeEnabled = false,
|
||||
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
||||
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
||||
preferredColorScheme = getPreferredColorScheme(),
|
||||
automaticFontSizeAdjustment = Settings.getInstance(context).shouldUseAutoSize,
|
||||
automaticFontSizeAdjustment = context.settings.shouldUseAutoSize,
|
||||
suspendMediaWhenInactive = !FeatureFlags.mediaIntegration
|
||||
)
|
||||
|
||||
|
@ -149,7 +148,7 @@ class Core(private val context: Context) {
|
|||
* @return the constructed tracking protection policy based on preferences.
|
||||
*/
|
||||
fun createTrackingProtectionPolicy(
|
||||
normalMode: Boolean = Settings.getInstance(context).shouldUseTrackingProtection,
|
||||
normalMode: Boolean = context.settings.shouldUseTrackingProtection,
|
||||
privateMode: Boolean = true
|
||||
): TrackingProtectionPolicy {
|
||||
val trackingProtectionPolicy = TrackingProtectionPolicy.recommended()
|
||||
|
@ -170,8 +169,8 @@ class Core(private val context: Context) {
|
|||
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
Configuration.UI_MODE_NIGHT_YES
|
||||
return when {
|
||||
Settings.getInstance(context).shouldUseDarkTheme -> PreferredColorScheme.Dark
|
||||
Settings.getInstance(context).shouldUseLightTheme -> PreferredColorScheme.Light
|
||||
context.settings.shouldUseDarkTheme -> PreferredColorScheme.Dark
|
||||
context.settings.shouldUseLightTheme -> PreferredColorScheme.Light
|
||||
inDark -> PreferredColorScheme.Dark
|
||||
else -> PreferredColorScheme.Light
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import kotlinx.coroutines.launch
|
|||
import mozilla.components.browser.search.SearchEngineManager
|
||||
import mozilla.components.browser.search.provider.AssetsSearchEngineProvider
|
||||
import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.test.Mockable
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* Component group for all search engine integration related functionality.
|
||||
|
@ -33,7 +33,7 @@ class Search(private val context: Context) {
|
|||
GlobalScope.launch {
|
||||
defaultSearchEngine = getDefaultSearchEngineAsync(
|
||||
context,
|
||||
Settings.getInstance(context).defaultSearchEngineName
|
||||
context.settings.defaultSearchEngineName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.leanplum.LeanplumActivityHelper
|
|||
import com.leanplum.annotations.Parser
|
||||
import com.leanplum.internal.LeanplumInternal
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import java.util.UUID.randomUUID
|
||||
|
||||
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),
|
||||
"focus_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.FOCUS.productName),
|
||||
"klar_installed" to installedApps.contains(MozillaProductDetector.MozillaProducts.KLAR.productName),
|
||||
"fxa_signed_in" to Settings.getInstance(application).fxaSignedIn,
|
||||
"fxa_has_synced_items" to Settings.getInstance(application).fxaHasSyncedItems,
|
||||
"search_widget_installed" to Settings.getInstance(application).searchWidgetInstalled
|
||||
"fxa_signed_in" to application.settings.fxaSignedIn,
|
||||
"fxa_has_synced_items" to application.settings.fxaHasSyncedItems,
|
||||
"search_widget_installed" to application.settings.searchWidgetInstalled
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
|||
}
|
||||
|
||||
override fun shouldTrack(event: Event): Boolean {
|
||||
return Settings.getInstance(application).isTelemetryEnabled &&
|
||||
return application.settings.isTelemetryEnabled &&
|
||||
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.ext.components
|
||||
import org.mozilla.fenix.ext.nav
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
class ToolbarIntegration(
|
||||
context: Context,
|
||||
|
@ -90,7 +90,7 @@ class ToolbarIntegration(
|
|||
|
||||
ToolbarAutocompleteFeature(toolbar).apply {
|
||||
addDomainProvider(domainAutocompleteProvider)
|
||||
if (Settings.getInstance(context).shouldShowHistorySuggestions) {
|
||||
if (context.settings.shouldShowHistorySuggestions) {
|
||||
addHistoryStorageProvider(historyStorage)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.mozilla.fenix.components.metrics.Event
|
|||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.nav
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class CrashReporterFragment : Fragment() {
|
||||
override fun onCreateView(
|
||||
|
@ -69,7 +69,7 @@ class CrashReporterFragment : Fragment() {
|
|||
|
||||
private fun submitReportIfNecessary(crash: Crash) {
|
||||
var didSubmitCrashReport = false
|
||||
if (Settings.getInstance(context!!).isCrashReportingEnabled && sendCrashCheckbox.isChecked) {
|
||||
if (requireContext().settings.isCrashReportingEnabled && sendCrashCheckbox.isChecked) {
|
||||
requireComponents.analytics.crashReporter.submitReport(crash)
|
||||
didSubmitCrashReport = true
|
||||
}
|
||||
|
|
|
@ -23,11 +23,14 @@ import androidx.fragment.app.FragmentActivity
|
|||
import mozilla.components.browser.search.SearchEngineManager
|
||||
import mozilla.components.support.base.log.Log
|
||||
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.R
|
||||
import org.mozilla.fenix.theme.ThemeManager
|
||||
import org.mozilla.fenix.components.Components
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* Get the BrowserApplication object from a context.
|
||||
|
@ -105,3 +108,9 @@ fun Context.getRootView(): View? =
|
|||
@ColorInt
|
||||
fun Context.getColorFromAttr(@AttrRes attr: Int) =
|
||||
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 org.mozilla.fenix.R
|
||||
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) {
|
||||
|
||||
|
@ -68,7 +68,7 @@ class OnboardingThemePickerViewHolder(view: View) : RecyclerView.ViewHolder(view
|
|||
}
|
||||
}
|
||||
|
||||
with(Settings.getInstance(view.context)) {
|
||||
with(view.context.settings) {
|
||||
val radio = when {
|
||||
this.shouldUseLightTheme -> radioLightTheme
|
||||
this.shouldUseDarkTheme -> radioDarkTheme
|
||||
|
|
|
@ -9,7 +9,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import kotlinx.android.synthetic.main.onboarding_tracking_protection.view.*
|
||||
import org.mozilla.fenix.R
|
||||
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) {
|
||||
|
||||
|
@ -23,7 +23,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
|||
)
|
||||
|
||||
view.tracking_protection_toggle.apply {
|
||||
isChecked = Settings.getInstance(view.context).shouldUseTrackingProtection
|
||||
isChecked = view.context.settings.shouldUseTrackingProtection
|
||||
setOnCheckedChangeListener { _, isChecked ->
|
||||
updateTrackingProtectionSetting(isChecked)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ class OnboardingTrackingProtectionViewHolder(view: View) : RecyclerView.ViewHold
|
|||
}
|
||||
|
||||
private fun updateTrackingProtectionSetting(enabled: Boolean) {
|
||||
Settings.getInstance(itemView.context).shouldUseTrackingProtection = enabled
|
||||
itemView.context.settings.shouldUseTrackingProtection = enabled
|
||||
with(itemView.context.components) {
|
||||
val policy = core.createTrackingProtectionPolicy(enabled)
|
||||
useCases.settingsUseCases.updateTrackingProtection.invoke(policy)
|
||||
|
|
|
@ -10,7 +10,7 @@ import androidx.appcompat.widget.AppCompatRadioButton
|
|||
import androidx.core.content.edit
|
||||
import androidx.core.content.withStyledAttributes
|
||||
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) {
|
||||
private val radioGroups = mutableListOf<OnboardingRadioButton>()
|
||||
|
@ -45,7 +45,7 @@ class OnboardingRadioButton(context: Context, attrs: AttributeSet) : AppCompatRa
|
|||
|
||||
private fun updateRadioValue(isChecked: Boolean) {
|
||||
this.isChecked = isChecked
|
||||
Settings.getInstance(context).preferences.edit {
|
||||
context.settings.preferences.edit {
|
||||
putBoolean(context.getString(key), isChecked)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import kotlinx.coroutines.cancel
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
const val POSITION_SNAP_BUFFER = 1f
|
||||
|
||||
|
@ -64,7 +64,7 @@ class QuickActionSheet @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun bounceSheet() {
|
||||
Settings.getInstance(context).incrementAutomaticBounceQuickActionSheetCount()
|
||||
context.settings.incrementAutomaticBounceQuickActionSheetCount()
|
||||
scope.launch(Dispatchers.Main) {
|
||||
delay(BOUNCE_ANIMATION_DELAY_LENGTH)
|
||||
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 mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.components.toolbar.BrowserFragmentState
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
interface QuickActionSheetViewInteractor {
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ class QuickActionSheetView(
|
|||
}
|
||||
|
||||
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)
|
||||
|
||||
@DrawableRes
|
||||
|
|
|
@ -40,9 +40,9 @@ import org.mozilla.fenix.components.metrics.Event
|
|||
import org.mozilla.fenix.ext.getColorFromAttr
|
||||
import org.mozilla.fenix.ext.getSpannable
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.search.awesomebar.AwesomeBarView
|
||||
import org.mozilla.fenix.search.toolbar.ToolbarView
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
class SearchFragment : Fragment(), BackHandler {
|
||||
|
@ -91,10 +91,10 @@ class SearchFragment : Fragment(), BackHandler {
|
|||
showShortcutEnginePicker = displayShortcutEnginePicker,
|
||||
searchEngineSource = currentSearchEngine,
|
||||
defaultEngineSource = currentSearchEngine,
|
||||
showSearchSuggestions = Settings.getInstance(requireContext()).shouldShowSearchSuggestions,
|
||||
showClipboardSuggestions = Settings.getInstance(requireContext()).shouldShowClipboardSuggestions,
|
||||
showHistorySuggestions = Settings.getInstance(requireContext()).shouldShowHistorySuggestions,
|
||||
showBookmarkSuggestions = Settings.getInstance(requireContext()).shouldShowBookmarkSuggestions,
|
||||
showSearchSuggestions = requireContext().settings.shouldShowSearchSuggestions,
|
||||
showClipboardSuggestions = requireContext().settings.shouldShowClipboardSuggestions,
|
||||
showHistorySuggestions = requireContext().settings.shouldShowHistorySuggestions,
|
||||
showBookmarkSuggestions = requireContext().settings.shouldShowBookmarkSuggestions,
|
||||
session = session
|
||||
)
|
||||
)
|
||||
|
@ -212,7 +212,7 @@ class SearchFragment : Fragment(), BackHandler {
|
|||
val currentDefaultEngine =
|
||||
requireComponents.search.searchEngineManager.getDefaultSearchEngine(
|
||||
requireContext(),
|
||||
Settings.getInstance(requireContext()).defaultSearchEngineName
|
||||
requireContext().settings.defaultSearchEngineName
|
||||
)
|
||||
|
||||
if (searchStore.state.defaultEngineSource.searchEngine != currentDefaultEngine) {
|
||||
|
@ -292,7 +292,7 @@ class SearchFragment : Fragment(), BackHandler {
|
|||
}
|
||||
|
||||
private fun historyStorageProvider(): HistoryStorage? {
|
||||
return if (Settings.getInstance(requireContext()).shouldShowHistorySuggestions) {
|
||||
return if (requireContext().settings.shouldShowHistorySuggestions) {
|
||||
requireComponents.core.historyStorage
|
||||
} else null
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import androidx.preference.SwitchPreference
|
|||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
/**
|
||||
* Displays font size controls for accessibility.
|
||||
|
@ -29,7 +29,7 @@ class AccessibilityFragment : PreferenceFragmentCompat() {
|
|||
getPreferenceKey(R.string.pref_key_accessibility_font_scale)
|
||||
)
|
||||
textSizePreference?.setOnPreferenceChangeListener<Int> { preference, newTextSize ->
|
||||
val settings = Settings.getInstance(preference.context)
|
||||
val settings = preference.context.settings
|
||||
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
|
||||
|
@ -43,12 +43,12 @@ class AccessibilityFragment : PreferenceFragmentCompat() {
|
|||
components.useCases.sessionUseCases.reload()
|
||||
true
|
||||
}
|
||||
textSizePreference?.isVisible = !Settings.getInstance(context!!).shouldUseAutoSize
|
||||
textSizePreference?.isVisible = !requireContext().settings.shouldUseAutoSize
|
||||
|
||||
val useAutoSizePreference =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_accessibility_auto_size))
|
||||
useAutoSizePreference?.setOnPreferenceChangeListener<Boolean> { preference, useAutoSize ->
|
||||
val settings = Settings.getInstance(preference.context)
|
||||
val settings = preference.context.settings
|
||||
val components = preference.context.components
|
||||
|
||||
// Save the new setting value
|
||||
|
|
|
@ -12,7 +12,7 @@ import androidx.preference.SwitchPreference
|
|||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
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.
|
||||
|
@ -23,7 +23,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
|||
SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
|
||||
when (key) {
|
||||
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()
|
||||
} else {
|
||||
context?.components?.analytics?.metrics?.stop()
|
||||
|
@ -56,7 +56,7 @@ class DataChoicesFragment : PreferenceFragmentCompat() {
|
|||
setPreferencesFromResource(R.xml.data_choices_preferences, rootKey)
|
||||
|
||||
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)
|
||||
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 {
|
||||
isChecked = Settings.getInstance(context).isExperimentationEnabled
|
||||
isChecked = context.settings.isExperimentationEnabled
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import androidx.core.text.HtmlCompat
|
|||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceViewHolder
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class RadioButtonPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -76,13 +76,13 @@ class RadioButtonPreference @JvmOverloads constructor(
|
|||
private fun updateRadioValue(isChecked: Boolean) {
|
||||
persistBoolean(isChecked)
|
||||
radioButton.isChecked = isChecked
|
||||
Settings.getInstance(context).preferences.edit().putBoolean(key, isChecked)
|
||||
context.settings.preferences.edit().putBoolean(key, isChecked)
|
||||
.apply()
|
||||
}
|
||||
|
||||
private fun bindRadioButton(holder: PreferenceViewHolder) {
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import android.widget.CompoundButton
|
|||
import mozilla.components.browser.search.SearchEngine
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class RadioSearchEngineListPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -26,6 +26,6 @@ class RadioSearchEngineListPreference @JvmOverloads constructor(
|
|||
|
||||
override fun onSearchEngineSelected(searchEngine: 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 org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class SearchEngineFragment : PreferenceFragmentCompat() {
|
||||
|
||||
|
@ -25,24 +25,24 @@ class SearchEngineFragment : PreferenceFragmentCompat() {
|
|||
|
||||
val searchSuggestionsPreference =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_search_suggestions))?.apply {
|
||||
isChecked = Settings.getInstance(context).shouldShowSearchSuggestions
|
||||
isChecked = context.settings.shouldShowSearchSuggestions
|
||||
}
|
||||
|
||||
searchSuggestionsPreference?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
|
||||
val showHistorySuggestions =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_browsing_history))?.apply {
|
||||
isChecked = Settings.getInstance(context).shouldShowHistorySuggestions
|
||||
isChecked = context.settings.shouldShowHistorySuggestions
|
||||
}
|
||||
|
||||
val showBookmarkSuggestions =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_search_bookmarks))?.apply {
|
||||
isChecked = Settings.getInstance(context).shouldShowBookmarkSuggestions
|
||||
isChecked = context.settings.shouldShowBookmarkSuggestions
|
||||
}
|
||||
|
||||
val showClipboardSuggestions =
|
||||
findPreference<SwitchPreference>(getPreferenceKey(R.string.pref_key_show_clipboard_suggestions))?.apply {
|
||||
isChecked = Settings.getInstance(context).shouldShowClipboardSuggestions
|
||||
isChecked = context.settings.shouldShowClipboardSuggestions
|
||||
}
|
||||
|
||||
showHistorySuggestions?.onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
|
|
|
@ -20,7 +20,7 @@ import kotlinx.android.synthetic.main.search_engine_radio_button.view.*
|
|||
import mozilla.components.browser.search.SearchEngine
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
abstract class SearchEngineListPreference @JvmOverloads constructor(
|
||||
context: Context,
|
||||
|
@ -69,7 +69,7 @@ abstract class SearchEngineListPreference @JvmOverloads constructor(
|
|||
val selectedSearchEngine =
|
||||
context.components.search.searchEngineManager.getDefaultSearchEngine(
|
||||
context,
|
||||
Settings.getInstance(context).defaultSearchEngineName
|
||||
context.settings.defaultSearchEngineName
|
||||
).identifier
|
||||
|
||||
searchEngineGroup!!.removeAllViews()
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.mozilla.fenix.components.metrics.Event
|
|||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.utils.ItsNotBrokenSnack
|
||||
|
||||
@SuppressWarnings("TooManyFunctions", "LargeClass")
|
||||
|
@ -119,7 +120,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
|||
val trackingProtectionPreference =
|
||||
findPreference<Preference>(getPreferenceKey(R.string.pref_key_tracking_protection_settings))
|
||||
trackingProtectionPreference?.summary = context?.let {
|
||||
if (org.mozilla.fenix.utils.Settings.getInstance(it).shouldUseTrackingProtection) {
|
||||
if (it.settings.shouldUseTrackingProtection) {
|
||||
getString(R.string.tracking_protection_on)
|
||||
} else {
|
||||
getString(R.string.tracking_protection_off)
|
||||
|
@ -129,7 +130,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
|||
val themesPreference =
|
||||
findPreference<Preference>(getPreferenceKey(R.string.pref_key_theme))
|
||||
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))
|
||||
|
@ -249,7 +250,7 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
|
|||
}
|
||||
|
||||
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()
|
||||
requireComponents.core.engine.settings.remoteDebuggingEnabled = newValue
|
||||
true
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.mozilla.fenix.settings
|
|||
|
||||
import androidx.core.content.edit
|
||||
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.
|
||||
|
@ -12,7 +12,7 @@ class SharedPreferenceUpdater : Preference.OnPreferenceChangeListener {
|
|||
|
||||
override fun onPreferenceChange(preference: Preference, newValue: Any?): Boolean {
|
||||
val newBooleanValue = newValue as? Boolean ?: return false
|
||||
Settings.getInstance(preference.context).preferences.edit {
|
||||
preference.context.settings.preferences.edit {
|
||||
putBoolean(preference.key, newBooleanValue)
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -12,7 +12,7 @@ import androidx.preference.Preference.OnPreferenceClickListener
|
|||
import androidx.preference.PreferenceFragmentCompat
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.getPreferenceKey
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
@SuppressWarnings("TooManyFunctions")
|
||||
class SitePermissionsFragment : PreferenceFragmentCompat() {
|
||||
|
@ -54,7 +54,7 @@ class SitePermissionsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
private fun initPhoneFeature(phoneFeature: PhoneFeature) {
|
||||
val context = requireContext()
|
||||
val settings = Settings.getInstance(context)
|
||||
val settings = context.settings
|
||||
|
||||
val summary = phoneFeature.getActionLabel(context, settings = settings)
|
||||
val preferenceKey = phoneFeature.getPreferenceKey(context)
|
||||
|
|
|
@ -26,7 +26,7 @@ import org.jetbrains.anko.noButton
|
|||
import org.jetbrains.anko.yesButton
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.requireComponents
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
@SuppressWarnings("TooManyFunctions")
|
||||
class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
||||
|
@ -35,7 +35,7 @@ class SitePermissionsManageExceptionsPhoneFeatureFragment : Fragment() {
|
|||
private lateinit var radioAllow: RadioButton
|
||||
private lateinit var radioBlock: RadioButton
|
||||
private lateinit var blockedByAndroidView: View
|
||||
val settings by lazy { Settings.getInstance(requireContext()) }
|
||||
val settings by lazy { requireContext().settings }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
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.BLOCKED
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
@SuppressWarnings("TooManyFunctions")
|
||||
|
@ -42,7 +43,7 @@ class SitePermissionsManagePhoneFeatureFragment : Fragment() {
|
|||
|
||||
(activity as AppCompatActivity).title = phoneFeature.getLabel(requireContext())
|
||||
(activity as AppCompatActivity).supportActionBar?.show()
|
||||
settings = Settings.getInstance(requireContext())
|
||||
settings = requireContext().settings
|
||||
}
|
||||
|
||||
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.ext.components
|
||||
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
|
||||
|
@ -40,9 +40,9 @@ class TrackingProtectionFragment : PreferenceFragmentCompat() {
|
|||
val trackingProtectionKey = getPreferenceKey(R.string.pref_key_tracking_protection)
|
||||
val preferenceTP = findPreference<SwitchPreference>(trackingProtectionKey)
|
||||
|
||||
preferenceTP?.isChecked = Settings.getInstance(context!!).shouldUseTrackingProtection
|
||||
preferenceTP?.isChecked = context!!.settings.shouldUseTrackingProtection
|
||||
preferenceTP?.setOnPreferenceChangeListener<Boolean> { preference, trackingProtectionOn ->
|
||||
Settings.getInstance(preference.context).shouldUseTrackingProtection = trackingProtectionOn
|
||||
preference.context.settings.shouldUseTrackingProtection = trackingProtectionOn
|
||||
with(preference.context.components) {
|
||||
val policy = core.createTrackingProtectionPolicy(trackingProtectionOn)
|
||||
useCases.settingsUseCases.updateTrackingProtection(policy)
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.view.ViewGroup
|
|||
import androidx.core.net.toUri
|
||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.mvi.Action
|
||||
import org.mozilla.fenix.mvi.ActionBusFactory
|
||||
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.settings.PhoneFeature
|
||||
import org.mozilla.fenix.settings.toggle
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
class QuickSettingsComponent(
|
||||
private val container: ViewGroup,
|
||||
|
@ -46,7 +46,7 @@ class QuickSettingsComponent(
|
|||
): SitePermissions {
|
||||
|
||||
return if (sitePermissions == null) {
|
||||
val settings = Settings.getInstance(context)
|
||||
val settings = context.settings
|
||||
val origin = requireNotNull(url.toUri().host)
|
||||
var location = settings.getSitePermissionsPhoneFeatureAction(PhoneFeature.LOCATION).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.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.mvi.UIView
|
||||
import org.mozilla.fenix.settings.PhoneFeature
|
||||
import org.mozilla.fenix.settings.PhoneFeature.CAMERA
|
||||
|
@ -45,7 +46,7 @@ class QuickSettingsUIView(
|
|||
) {
|
||||
private val blockedByAndroidPhoneFeatures = mutableListOf<PhoneFeature>()
|
||||
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 labelAndActions = mapOf(
|
||||
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 mozilla.components.support.ktx.android.view.putCompoundDrawablesRelativeWithIntrinsicBounds
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
||||
class TrackingProtectionSettingView(
|
||||
container: View,
|
||||
|
@ -29,7 +29,7 @@ class TrackingProtectionSettingView(
|
|||
}
|
||||
|
||||
fun bind(isTrackingProtectionOn: Boolean) {
|
||||
val globalTPSetting = Settings.getInstance(trackingProtectionSwitch.context).shouldUseTrackingProtection
|
||||
val globalTPSetting = trackingProtectionSwitch.context.settings.shouldUseTrackingProtection
|
||||
|
||||
trackingProtectionAction.isVisible = !globalTPSetting
|
||||
trackingProtectionAction.setOnClickListener(this)
|
||||
|
|
|
@ -19,7 +19,7 @@ import androidx.annotation.Dimension.DP
|
|||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.IntentReceiverActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import android.os.Build
|
||||
import androidx.appcompat.widget.AppCompatDrawableManager
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
|
@ -28,11 +28,11 @@ import androidx.core.graphics.drawable.toBitmap
|
|||
class SearchWidgetProvider : AppWidgetProvider() {
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
Settings.getInstance(context).addSearchWidgetInstalled(1)
|
||||
context.settings.addSearchWidgetInstalled(1)
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.junit.Test
|
|||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.TestApplication
|
||||
import org.mozilla.fenix.ext.clearAndCommit
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.settings.PhoneFeature
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
|
@ -30,7 +31,7 @@ class SettingsTest {
|
|||
|
||||
@Before
|
||||
fun setUp() {
|
||||
settings = Settings.getInstance(testContext)
|
||||
settings = testContext.settings
|
||||
.apply(Settings::clear)
|
||||
}
|
||||
|
||||
|
@ -70,7 +71,7 @@ class SettingsTest {
|
|||
fun isCrashReportingEnabled_enabledInBuild() {
|
||||
// When
|
||||
clearExistingInstance()
|
||||
val settings = Settings.getInstance(testContext, isCrashReportEnabledInBuild = true)
|
||||
val settings = testContext.settings(true)
|
||||
.apply(Settings::clear)
|
||||
|
||||
// Then
|
||||
|
@ -81,7 +82,7 @@ class SettingsTest {
|
|||
fun isCrashReportingEnabled_disabledInBuild() {
|
||||
// When
|
||||
clearExistingInstance()
|
||||
val settings = Settings.getInstance(testContext, isCrashReportEnabledInBuild = false)
|
||||
val settings = testContext.settings(false)
|
||||
.apply(Settings::clear)
|
||||
|
||||
// Then
|
||||
|
|
Loading…
Reference in New Issue