diff --git a/modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png new file mode 100644 index 000000000..4828ecdb9 Binary files /dev/null and b/modules/app/src/main/res/drawable-hdpi/icon_preferences_analytics.png differ diff --git a/modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png new file mode 100644 index 000000000..10aa9dc1c Binary files /dev/null and b/modules/app/src/main/res/drawable-hdpi/icon_preferences_feedback.png differ diff --git a/modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png new file mode 100644 index 000000000..d28ea3b5a Binary files /dev/null and b/modules/app/src/main/res/drawable-mdpi/icon_preferences_analytics.png differ diff --git a/modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png new file mode 100644 index 000000000..f9a92f8a1 Binary files /dev/null and b/modules/app/src/main/res/drawable-mdpi/icon_preferences_feedback.png differ diff --git a/modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png new file mode 100644 index 000000000..d4b216f9a Binary files /dev/null and b/modules/app/src/main/res/drawable-xhdpi/icon_preferences_analytics.png differ diff --git a/modules/app/src/main/res/drawable-xhdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-xhdpi/icon_preferences_feedback.png new file mode 100644 index 000000000..d17999bf4 Binary files /dev/null and b/modules/app/src/main/res/drawable-xhdpi/icon_preferences_feedback.png differ diff --git a/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png new file mode 100644 index 000000000..daa4be532 Binary files /dev/null and b/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_analytics.png differ diff --git a/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_feedback.png new file mode 100644 index 000000000..37febe7ec Binary files /dev/null and b/modules/app/src/main/res/drawable-xxhdpi/icon_preferences_feedback.png differ diff --git a/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png new file mode 100644 index 000000000..9c28ef300 Binary files /dev/null and b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_analytics.png differ diff --git a/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png new file mode 100644 index 000000000..f8a98d28e Binary files /dev/null and b/modules/app/src/main/res/drawable-xxxhdpi/icon_preferences_feedback.png differ diff --git a/modules/app/src/main/res/values-es/strings.xml b/modules/app/src/main/res/values-es/strings.xml index 1198bcfc6..70c902316 100644 --- a/modules/app/src/main/res/values-es/strings.xml +++ b/modules/app/src/main/res/values-es/strings.xml @@ -618,6 +618,16 @@ Movimiento Fondo de Pantalla La imagen de fondo se mueve en el desplazamiento entre pantallas en el launcher + + + Analítica + Aprende más sobre nuestra política de analítica + + Habilitar analítica + 9 Cards usa Google Analytics para trackear el comportamiento independientemente de como ellos usas las apps. La información es anónima y es usada con el propósito de la generación de estadísticas de las apps más populares, mejores colecciones y mejor experiencia del usuario. Los datos son sólo usados con este propósito y no son vendidos, publicados ni usados de otra manera que para mejorar la experiencia en el Launcher. Si prefieres que tus datos anónimos no sean usados tu puedes deshabilitarlo + + + Opciones para Desarrolladores Activada diff --git a/modules/app/src/main/res/values/strings.xml b/modules/app/src/main/res/values/strings.xml index 864296ddd..e4396cb2e 100644 --- a/modules/app/src/main/res/values/strings.xml +++ b/modules/app/src/main/res/values/strings.xml @@ -630,6 +630,14 @@ Wallpaper movement The background image will move along with you as you swipe left or right through your home screens + + + Analytics + Learn more about our analytics + + Analytics Enable + 9 Cards uses Google Analytics to track user behavior regarding how they open and use apps. This user data is anonymous and is collected for the purpose of generating statistics on popular apps, best collections, and improving your user experience. The data is only used for this purpose and will not be sold, published, or used in any other manner, other than to improve the functionality of this launcher. If you prefer that your anonymous data is not used, you may opt-out here + Developer options activated diff --git a/modules/app/src/main/res/xml/preferences_analytics.xml b/modules/app/src/main/res/xml/preferences_analytics.xml new file mode 100644 index 000000000..bfa2a3840 --- /dev/null +++ b/modules/app/src/main/res/xml/preferences_analytics.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/modules/app/src/main/res/xml/preferences_devs_headers.xml b/modules/app/src/main/res/xml/preferences_devs_headers.xml index 156e2a749..e2d8bf9ed 100644 --- a/modules/app/src/main/res/xml/preferences_devs_headers.xml +++ b/modules/app/src/main/res/xml/preferences_devs_headers.xml @@ -28,6 +28,12 @@ android:key="animationsKey" android:summary="@string/animationsPrefSummary"/> + + diff --git a/modules/app/src/main/res/xml/preferences_headers.xml b/modules/app/src/main/res/xml/preferences_headers.xml index 17c569d78..eae297d64 100644 --- a/modules/app/src/main/res/xml/preferences_headers.xml +++ b/modules/app/src/main/res/xml/preferences_headers.xml @@ -28,6 +28,12 @@ android:key="animationsKey" android:summary="@string/animationsPrefSummary"/> + + @@ -45,7 +51,7 @@ android:summary="@string/aboutSummary"/> diff --git a/modules/app/src/main/scala/cards/nine/app/di/Injector.scala b/modules/app/src/main/scala/cards/nine/app/di/Injector.scala index 1015dbd78..bc6052a95 100644 --- a/modules/app/src/main/scala/cards/nine/app/di/Injector.scala +++ b/modules/app/src/main/scala/cards/nine/app/di/Injector.scala @@ -4,7 +4,12 @@ import android.content.res.Resources import cards.nine.api.rest.client.ServiceClient import cards.nine.api.rest.client.http.OkHttpClient import cards.nine.app.observers.ObserverRegister -import cards.nine.app.ui.preferences.commons.{BackendV2Url, IsStethoActive, OverrideBackendV2Url} +import cards.nine.app.ui.preferences.commons.{ + AnalyticsEnabled, + BackendV2Url, + IsStethoActive, + OverrideBackendV2Url +} import cards.nine.commons.contentresolver.{ContentResolverWrapperImpl, UriCreator} import cards.nine.commons.contexts.ContextSupport import cards.nine.models.types.NineCardsCategory @@ -55,7 +60,7 @@ import cards.nine.services.permissions.impl.AndroidSupportPermissionsServices import cards.nine.services.persistence.impl.PersistenceServicesImpl import cards.nine.services.plus.impl.GooglePlusServicesImpl import cards.nine.services.shortcuts.impl.ShortcutsServicesImpl -import cards.nine.services.track.impl.ConsoleTrackServices +import cards.nine.services.track.impl.{ConsoleTrackServices, DisableTrackServices} import cards.nine.services.widgets.impl.WidgetsServicesImpl import cards.nine.services.connectivity.impl.ConnectivityServicesImpl import com.facebook.stetho.okhttp3.StethoInterceptor @@ -249,7 +254,9 @@ class InjectorImpl(implicit contextSupport: ContextSupport) extends Injector { override def trackEventProcess: TrackEventProcess = { def createService() = { val resources = contextSupport.getResources - if (resources.getString(R.string.analytics_enabled).equalsIgnoreCase("true")) { + if (!AnalyticsEnabled.readValueWith(contextSupport.context)) { + new DisableTrackServices + } else if (resources.getString(R.string.analytics_enabled).equalsIgnoreCase("true")) { val track = GoogleAnalytics .getInstance(contextSupport.context) .newTracker(resources.getString(R.string.ga_trackingId)) diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala index 8199efd8f..b027fd4f8 100644 --- a/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/NineCardsPreferencesActivity.scala @@ -7,6 +7,7 @@ import android.preference.{Preference, PreferenceActivity, PreferenceFragment} import android.view.MenuItem import cards.nine.app.ui.commons.ops.TaskServiceOps._ import cards.nine.app.ui.preferences.about.AboutFragment +import cards.nine.app.ui.preferences.analytics.AnalyticsFragment import cards.nine.app.ui.preferences.animations.AnimationsFragment import cards.nine.app.ui.preferences.appdrawer.AppDrawerFragment import cards.nine.app.ui.preferences.commons._ @@ -79,6 +80,9 @@ class NineCardsPreferencesActivity findPreference(AnimationsPreferences.name).setOnPreferenceClickListener( preferenceClick(AnimationsPreferences.name, new AnimationsFragment())) + findPreference(AnalyticsPreferences.name).setOnPreferenceClickListener( + preferenceClick(AnalyticsPreferences.name, new AnalyticsFragment())) + findPreference(WizardInlinePreferences.name).setOnPreferenceClickListener( preferenceActionClick(() => jobs.cleanWizardInlinePreferences().resolveAsync())) diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala new file mode 100644 index 000000000..2c3823dfc --- /dev/null +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/analytics/AnalyticsFragment.scala @@ -0,0 +1,17 @@ +package cards.nine.app.ui.preferences.analytics + +import android.os.Bundle +import cards.nine.app.ui.preferences.commons.PreferenceChangeListenerFragment +import com.fortysevendeg.ninecardslauncher.R + +class AnalyticsFragment extends PreferenceChangeListenerFragment { + + override def onCreate(savedInstanceState: Bundle): Unit = { + super.onCreate(savedInstanceState) + withActivity { activity => + Option(activity.getActionBar) foreach (_.setTitle(getString(R.string.analyticsPrefTitle))) + } + addPreferencesFromResource(R.xml.preferences_analytics) + } + +} diff --git a/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala b/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala index 5420447aa..99244e0ad 100644 --- a/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala +++ b/modules/app/src/main/scala/cards/nine/app/ui/preferences/commons/NineCardsPreferences.scala @@ -31,6 +31,10 @@ case object AnimationsPreferences extends NineCardsPreferences { override val name: String = "animationsKey" } +case object AnalyticsPreferences extends NineCardsPreferences { + override val name: String = "analyticsKey" +} + case object DeveloperPreferences extends NineCardsPreferences { override val name: String = "developerKey" } @@ -258,6 +262,16 @@ case object CardPadding extends NineCardsPreferenceValue[IconsSizeValue] { } } +// Analytics + +case object AnalyticsEnabled extends NineCardsPreferenceValue[Boolean] { + override val name: String = "analyticsEnabled" + override val default: Boolean = true + + override def readValueWith(context: Context): Boolean = + getBoolean(context, name, default) +} + // Developer Preferences case object IsDeveloper extends NineCardsPreferenceValue[Boolean] { diff --git a/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala b/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala new file mode 100644 index 000000000..b0b777390 --- /dev/null +++ b/modules/services/src/main/scala/cards/nine/services/track/impl/DisableTrackServices.scala @@ -0,0 +1,25 @@ +package cards.nine.services.track.impl + +import cards.nine.commons.services.TaskService +import cards.nine.commons.services.TaskService._ +import cards.nine.models.TrackEvent +import cards.nine.models.types.MomentCategory +import cards.nine.services.track.TrackServices +import monix.eval.Task + +class DisableTrackServices extends TrackServices { + + override def trackEvent(event: TrackEvent): TaskService[Unit] = TaskService { + val categoryName = event.category match { + case MomentCategory(moment) => s"WIDGET_${moment.name}" + case _ => event.category.name + } + + Task(Right(println(s"""Event no tracked + | Action ${event.action.name} + | Category $categoryName + | Label ${event.label.getOrElse("")} + | Screen ${event.screen.name} + | Value ${event.value.map(_.value).getOrElse(0)}""".stripMargin))) + } +}