Make `Settings.instance` private
parent
f62e295fc6
commit
79e58250fc
|
@ -143,7 +143,7 @@ class BackgroundServices(
|
|||
|
||||
context.components.analytics.metrics.track(Event.SyncAuthSignOut)
|
||||
|
||||
Settings.instance?.fxaSignedIn = false
|
||||
Settings.getInstance(context).fxaSignedIn = false
|
||||
}
|
||||
|
||||
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) {
|
||||
|
@ -156,7 +156,7 @@ class BackgroundServices(
|
|||
|
||||
context.components.analytics.metrics.track(Event.SyncAuthSignIn)
|
||||
|
||||
Settings.instance?.fxaSignedIn = true
|
||||
Settings.getInstance(context).fxaSignedIn = true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ class BackgroundServices(
|
|||
// See https://github.com/mozilla-mobile/android-components/issues/3732
|
||||
setOf("https://identity.mozilla.com/apps/oldsync")
|
||||
).also {
|
||||
Settings.instance?.fxaHasSyncedItems = syncConfig?.syncableStores?.isNotEmpty() ?: false
|
||||
Settings.getInstance(context).fxaHasSyncedItems = syncConfig?.syncableStores?.isNotEmpty() ?: false
|
||||
|
||||
if (FeatureFlags.sendTabEnabled) {
|
||||
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)
|
||||
|
|
|
@ -12,7 +12,7 @@ import com.leanplum.annotations.Parser
|
|||
import com.leanplum.internal.LeanplumInternal
|
||||
import org.mozilla.fenix.BuildConfig
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import java.util.UUID
|
||||
import java.util.UUID.randomUUID
|
||||
|
||||
private val Event.name: String?
|
||||
get() = when (this) {
|
||||
|
@ -66,7 +66,7 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
|||
|
||||
Leanplum.setIsTestModeEnabled(false)
|
||||
Leanplum.setApplicationContext(application)
|
||||
Leanplum.setDeviceId(UUID.randomUUID().toString())
|
||||
Leanplum.setDeviceId(randomUUID().toString())
|
||||
Parser.parseVariables(application)
|
||||
|
||||
LeanplumActivityHelper.enableLifecycleCallbacks(application)
|
||||
|
@ -74,13 +74,13 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
|||
val installedApps = MozillaProductDetector.getInstalledMozillaProducts(application)
|
||||
|
||||
Leanplum.start(application, hashMapOf(
|
||||
"default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: ""),
|
||||
"default_browser" to MozillaProductDetector.getMozillaBrowserDefault(application).orEmpty(),
|
||||
"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.instance?.fxaSignedIn ?: false),
|
||||
"fxa_has_synced_items" to (Settings.instance?.fxaHasSyncedItems ?: false),
|
||||
"search_widget_installed" to (Settings.instance?.searchWidgetInstalled ?: false)
|
||||
"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
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -99,9 +99,9 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
|
|||
}
|
||||
|
||||
override fun track(event: Event) {
|
||||
val leanplumExtras = event.extras?.map {
|
||||
it.key.toString() to it.value
|
||||
}?.toMap()
|
||||
val leanplumExtras = event.extras
|
||||
?.map { (key, value) -> key.toString() to value }
|
||||
?.toMap()
|
||||
|
||||
event.name?.also {
|
||||
Leanplum.track(it, leanplumExtras)
|
||||
|
|
|
@ -44,7 +44,8 @@ class Settings private constructor(
|
|||
else -> throw InvalidParameterException("$action is not a valid SitePermissionsRules.Action")
|
||||
}
|
||||
|
||||
var instance: Settings? = null
|
||||
@VisibleForTesting
|
||||
internal var instance: Settings? = null
|
||||
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
|
|
|
@ -14,6 +14,8 @@ import android.os.Bundle
|
|||
import android.speech.RecognizerIntent
|
||||
import android.view.View
|
||||
import android.widget.RemoteViews
|
||||
import androidx.annotation.Dimension
|
||||
import androidx.annotation.Dimension.DP
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.IntentReceiverActivity
|
||||
import org.mozilla.fenix.R
|
||||
|
@ -22,11 +24,11 @@ import org.mozilla.fenix.utils.Settings
|
|||
class SearchWidgetProvider : AppWidgetProvider() {
|
||||
|
||||
override fun onEnabled(context: Context) {
|
||||
Settings.instance?.addSearchWidgetInstalled(1)
|
||||
Settings.getInstance(context).addSearchWidgetInstalled(1)
|
||||
}
|
||||
|
||||
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
|
||||
Settings.instance?.addSearchWidgetInstalled(-appWidgetIds.size)
|
||||
Settings.getInstance(context).addSearchWidgetInstalled(-appWidgetIds.size)
|
||||
}
|
||||
|
||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||
|
@ -66,7 +68,7 @@ class SearchWidgetProvider : AppWidgetProvider() {
|
|||
appWidgetManager.updateAppWidget(appWidgetId, views)
|
||||
}
|
||||
|
||||
private fun getLayoutSize(dp: Int) = when {
|
||||
private fun getLayoutSize(@Dimension(unit = DP) dp: Int) = when {
|
||||
dp >= DP_LARGE -> SearchWidgetProviderSize.LARGE
|
||||
dp >= DP_MEDIUM -> SearchWidgetProviderSize.MEDIUM
|
||||
dp >= DP_SMALL -> SearchWidgetProviderSize.SMALL
|
||||
|
|
Loading…
Reference in New Issue