From 50a7b483b9169ed435839ffc6c4b1953e2d034e5 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Wed, 21 Jun 2017 00:17:11 -0700 Subject: Clean up and add event logging --- app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt | 2 ++ app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt | 3 ++- .../kotlin/com/pitchedapps/frost/services/NotificationService.kt | 5 +++-- app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt | 7 +++++++ 4 files changed, 14 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt index 2e87d141..d6583a50 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt @@ -239,6 +239,8 @@ class MainActivity : BaseActivity() { primaryItem(FbTab.GROUPS) primaryItem(FbTab.PAGES) primaryItem(FbTab.SAVED) + divider() + } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt index 1fcdf798..ef8345d0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt @@ -24,12 +24,13 @@ class SettingsActivity : KPrefActivity() { items(Theme.values().map { this@SettingsActivity.string(it.textRes) }) itemsDisabledIndices(Theme.CUSTOM.ordinal) itemsCallbackSingleChoice(item.pref, { - _, _, which, _ -> + _, _, which, text -> if (item.pref != which) { item.pref = which reload() setFrostTheme(true) themeExterior() + frostAnswersCustom("Theme") { putCustomAttribute("Count", text.toString()) } } true }) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt index 9c8bf2e6..03dd21a4 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/services/NotificationService.kt @@ -18,6 +18,7 @@ import com.pitchedapps.frost.facebook.FACEBOOK_COM import com.pitchedapps.frost.facebook.FB_URL_BASE import com.pitchedapps.frost.facebook.FbTab import com.pitchedapps.frost.utils.L +import com.pitchedapps.frost.utils.frostAnswersCustom import com.pitchedapps.frost.utils.frostNotification import org.jetbrains.anko.doAsync import org.jsoup.Jsoup @@ -39,7 +40,7 @@ class NotificationService : JobService() { override fun onStartJob(params: JobParameters?): Boolean { future = doAsync { - debugNotification("Load notifs") + // debugNotification("Load notifs") loadFbCookiesSync().forEach { data -> L.i("Handle notifications for $data") @@ -59,6 +60,7 @@ class NotificationService : JobService() { } } if (notifCount > 0) saveNotificationTime(NotificationModel(data.id, latestEpoch)) + frostAnswersCustom("Notifications") { putCustomAttribute("Count", notifCount) } summaryNotification(data.id, notifCount) } L.d("Finished notifications") @@ -69,7 +71,6 @@ class NotificationService : JobService() { } companion object { - const val ARG_ID = "arg_id" val epochMatcher: Regex by lazy { Regex(":([0-9]*),") } val notifIdMatcher: Regex by lazy { Regex("notif_id\":([0-9]*),") } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt index 3e0e6924..b9de13af 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt @@ -16,6 +16,7 @@ import android.widget.TextView import ca.allanwang.kau.utils.* import com.afollestad.materialdialogs.MaterialDialog import com.crashlytics.android.answers.Answers +import com.crashlytics.android.answers.CustomEvent import com.pitchedapps.frost.* import com.pitchedapps.frost.dbflow.CookieModel import com.pitchedapps.frost.facebook.FB_URL_BASE @@ -141,4 +142,10 @@ fun frostAnswers(action: Answers.() -> Unit) { if (BuildConfig.DEBUG) return //TODO add opt out toggle Answers.getInstance().action() +} + +fun frostAnswersCustom(name: String, action: CustomEvent.() -> Unit = {}) { + frostAnswers { + logCustom(CustomEvent("Frost $name").apply { action() }) + } } \ No newline at end of file -- cgit v1.2.3