This repository was archived by the owner on Feb 17, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
app/src/main/java/net/squanchy Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ class SquanchyApplication : Application() {
3030 enableExceptionLogging()
3131 initializeStaticUserProperties()
3232 trackFirstStartUserNotLoggedIn()
33+ trackFirstStartNotificationsEnabled()
3334 }
3435
3536 if (BuildConfig .DEBUG ) {
Original file line number Diff line number Diff line change @@ -70,6 +70,22 @@ class Analytics internal constructor(
7070 firstStartDetector.setFirstStartNotLoggedInStatusTracked()
7171 }
7272
73+ fun trackFirstStartNotificationsEnabled () {
74+ if (firstStartDetector.isFirstStartNotificationsEnabledTracked()) {
75+ return
76+ }
77+ trackNotificationsEnabled()
78+ firstStartDetector.setFirstStartNotificationsEnabledTracked()
79+ }
80+
81+ fun trackNotificationsEnabled () {
82+ firebaseAnalytics.setUserProperty(" notifications_status" , " enabled" )
83+ }
84+
85+ fun trackNotificationsDisabled () {
86+ firebaseAnalytics.setUserProperty(" notifications_status" , " disabled" )
87+ }
88+
7389 fun trackUserNotLoggedIn () {
7490 setUserLoginProperty(LoginStatus .NOT_LOGGED_IN )
7591 }
Original file line number Diff line number Diff line change @@ -12,8 +12,17 @@ internal class FirstStartDetector(private val preferences: SharedPreferences) {
1212 .apply ()
1313 }
1414
15+ fun isFirstStartNotificationsEnabledTracked () = preferences.getBoolean(KEY_FIRST_START_NOTIFICATIONS_ENABLED_TRACKED , false )
16+
17+ fun setFirstStartNotificationsEnabledTracked () {
18+ preferences.edit()
19+ .putBoolean(KEY_FIRST_START_NOTIFICATIONS_ENABLED_TRACKED , true )
20+ .apply ()
21+ }
22+
1523 companion object {
1624
1725 private const val KEY_FIRST_START_NOT_LOGGED_IN_TRACKED = " FirstStart.not_logged_in_tracked"
26+ private const val KEY_FIRST_START_NOTIFICATIONS_ENABLED_TRACKED = " FirstStart.notifications_enabled_tracked"
1827 }
1928}
Original file line number Diff line number Diff line change @@ -63,6 +63,16 @@ class SettingsFragment : PreferenceFragment() {
6363 navigator.toAboutSquanchy()
6464 true
6565 }
66+
67+ val notificationsPreference = findPreference(getString(R .string.about_to_start_notification_preference_key))
68+ notificationsPreference.setOnPreferenceChangeListener { _, enabled ->
69+ if (enabled as Boolean ) {
70+ analytics.trackNotificationsEnabled()
71+ } else {
72+ analytics.trackNotificationsDisabled()
73+ }
74+ true
75+ }
6676 }
6777
6878 private fun displayBuildVersion () {
You can’t perform that action at this time.
0 commit comments