1
0
Fork 0

Fixes feedback

master
Sawyer Blatz 2019-08-07 15:06:44 -07:00 committed by Jeff Boek
parent 4d14735935
commit 4566bd6fba
6 changed files with 47 additions and 9 deletions

View File

@ -38,6 +38,7 @@ import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
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
@ -76,7 +77,7 @@ class BackgroundServices(
}
)
// If sync has been turned off on the server then disable syncing.
val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
private val syncConfig = if (context.isInExperiment(Experiments.asFeatureSyncDisabled)) {
null
} else {
SyncConfig(setOf("history", "bookmarks"), syncPeriodInMinutes = 240L) // four hours
@ -137,6 +138,8 @@ class BackgroundServices(
pushService.stop()
push.unsubscribeForType(PushType.Services)
Settings.instance?.setFxaSignedIn(false)
}
override fun onAuthenticated(account: OAuthAccount, newAccount: Boolean) {
@ -145,6 +148,7 @@ class BackgroundServices(
if (newAccount) {
push.subscribeForType(PushType.Services)
}
Settings.instance?.setFxaSignedIn(true)
}
}
@ -166,6 +170,8 @@ class BackgroundServices(
// See https://github.com/mozilla-mobile/android-components/issues/3732
setOf("https://identity.mozilla.com/apps/oldsync")
).also {
Settings.instance?.setFxaHasSyncedItems(syncConfig?.syncableStores?.isNotEmpty() ?: false)
if (FeatureFlags.sendTabEnabled) {
it.registerForDeviceEvents(deviceEventObserver, ProcessLifecycleOwner.get(), false)

View File

@ -66,17 +66,14 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
LeanplumActivityHelper.enableLifecycleCallbacks(application)
val installedApps = MozillaProductDetector.getInstalledMozillaProducts(application)
val backgroundServices = application.applicationContext.components.backgroundServices
val fxaLoggedIn = backgroundServices.accountManager.accountProfile() != null
val syncedItems = backgroundServices.syncConfig?.syncableStores?.isNotEmpty() ?: false
Leanplum.start(application, hashMapOf(
"default_browser" to (MozillaProductDetector.getMozillaBrowserDefault(application) ?: ""),
"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_logged_in" to fxaLoggedIn,
"fxa_synced_items" to syncedItems
"fxa_signed_in" to (Settings.instance?.fxaSignedIn ?: false),
"fxa_has_synced_items" to (Settings.instance?.fxaHasSyncedItems ?: false)
))
}

View File

@ -204,6 +204,7 @@ class HomeFragment : Fragment(), AccountObserver {
val homeViewModel = activity?.run {
ViewModelProvider(this).get(HomeScreenViewModel::class.java)
}
homeViewModel?.layoutManagerState?.also { parcelable ->
sessionControlComponent.view.layoutManager?.onRestoreInstanceState(parcelable)
}

View File

@ -235,6 +235,28 @@ class Settings private constructor(
)
}
fun setFxaSignedIn(isSignedIn: Boolean) {
preferences.edit()
.putBoolean(appContext.getPreferenceKey(R.string.pref_key_fxa_signed_in), isSignedIn)
.apply()
}
val fxaSignedIn: Boolean
get() = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_fxa_signed_in), true
)
fun setFxaHasSyncedItems(hasSyncedItems: Boolean) {
preferences.edit()
.putBoolean(appContext.getPreferenceKey(R.string.pref_key_fxa_has_synced_items), hasSyncedItems)
.apply()
}
val fxaHasSyncedItems: Boolean
get() = preferences.getBoolean(
appContext.getPreferenceKey(R.string.pref_key_fxa_has_synced_items), true
)
private val SitePermissionsRules.Action.id: Int
get() {
return when (this) {

View File

@ -47,6 +47,8 @@
<string name="pref_key_sync_create_account" translatable="false">pref_key_sync_create_account</string>
<string name="pref_key_sync_problem" translatable="false">pref_key_sync_problem</string>
<string name="pref_key_push_project_id" translatable="false">project_id</string>
<string name="pref_key_fxa_signed_in" translatable="false">pref_key_fxa_signed_in</string>
<string name="pref_key_fxa_has_synced_items" translatable="false">pref_key_fxa_has_synced_items</string>
<!-- Search Settings -->
<string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string>

View File

@ -116,19 +116,29 @@ User Attributes
</tr>
<tr>
<td>`focus_installed`</td>
<td>A boolean indicated that Firefox Focus is installed</td>
<td>A boolean indicating that Firefox Focus is installed</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3459#issuecomment-502252010">#3459</a></td>
</tr>
<tr>
<td>`klar_installed`</td>
<td>A boolean indicated that Firefox Klar is installed</td>
<td>A boolean indicating that Firefox Klar is installed</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3459#issuecomment-502252010">#3459</a></td>
</tr>
<tr>
<td>`fennec_installed`</td>
<td>A boolean indicated that Fennec is installed</td>
<td>A boolean indicating that Fennec is installed</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/3459#issuecomment-502252010">#3459</a></td>
</tr>
<tr>
<td>`fxa_signed_in`</td>
<td>A boolean indicating that the user is signed in to FxA</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4568#issuecomment-519159545">#4568</a></td>
</tr>
<tr>
<td>`fxa_has_synced_items`</td>
<td>A boolean indicating that the user has opted to sync at least one category of items with FxA</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4568#issuecomment-519159545">#4568</a></td>
</tr>
</table>
Events