For #4421: Add search widget attribute to Leanplum (#4694)

This commit is contained in:
Yeon Taek Jeong 2019-08-14 12:00:29 -07:00 committed by GitHub
parent f5ffe3734c
commit 67f3b63ae5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 1 deletions

View File

@ -12,9 +12,18 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.widget.RemoteViews
import org.mozilla.fenix.utils.Settings
class SearchWidgetProvider : AppWidgetProvider() {
override fun onEnabled(context: Context) {
Settings.instance?.addSearchWidgetInstalled(1)
}
override fun onDeleted(context: Context, appWidgetIds: IntArray) {
Settings.instance?.addSearchWidgetInstalled(-appWidgetIds.size)
}
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
val textSearchIntent = createTextSearchIntent(context)
val voiceSearchIntent = createVoiceSearchIntent(context)

View File

@ -73,7 +73,8 @@ class LeanplumMetricsService(private val application: Application) : MetricsServ
"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)
"fxa_has_synced_items" to (Settings.instance?.fxaHasSyncedItems ?: false),
"search_widget_installed" to (Settings.instance?.searchWidgetInstalled ?: false)
))
}

View File

@ -257,6 +257,19 @@ class Settings private constructor(
appContext.getPreferenceKey(R.string.pref_key_fxa_has_synced_items), true
)
fun addSearchWidgetInstalled(count: Int) {
val key = appContext.getPreferenceKey(R.string.pref_key_search_widget_installed)
val newValue = preferences.getInt(key, 0) + count
preferences.edit()
.putInt(key, newValue)
.apply()
}
val searchWidgetInstalled: Boolean
get() = 0 < preferences.getInt(
appContext.getPreferenceKey(R.string.pref_key_search_widget_installed), 0
)
private val SitePermissionsRules.Action.id: Int
get() {
return when (this) {

View File

@ -49,6 +49,7 @@
<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>
<string name="pref_key_search_widget_installed" translatable="false">pref_key_search_widget_installed</string>
<!-- Search Settings -->
<string name="pref_key_show_search_suggestions" translatable="false">pref_key_show_search_suggestions</string>

View File

@ -139,6 +139,11 @@ User Attributes
<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>
<tr>
<td>`search_widget_installed`</td>
<td>A boolean indicating that the user has at least one search widget placed on the home screen</td>
<td><a href="https://github.com/mozilla-mobile/fenix/pull/4694#issuecomment-520591275">#4694</a></td>
</tr>
</table>
Events