From 3a1633951605d9231c6d768bdf818dc4e2204c9f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 15 Oct 2019 23:50:09 +0200 Subject: [PATCH] time spent --- .../info/nightscout/androidaps/MainApp.java | 5 ++- .../plugins/general/timeSpent/TS.kt | 38 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/general/timeSpent/TS.kt diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index a1300f59bc..97c5d49c0c 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -51,6 +51,7 @@ import info.nightscout.androidaps.plugins.general.overview.OverviewPlugin; import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin; import info.nightscout.androidaps.plugins.general.signatureVerifier.SignatureVerifier; import info.nightscout.androidaps.plugins.general.smsCommunicator.SmsCommunicatorPlugin; +import info.nightscout.androidaps.plugins.general.timeSpent.TS; import info.nightscout.androidaps.plugins.general.versionChecker.VersionCheckerPlugin; import info.nightscout.androidaps.plugins.general.wear.WearPlugin; import info.nightscout.androidaps.plugins.general.xdripStatusline.StatuslinePlugin; @@ -138,6 +139,8 @@ public class MainApp extends Application { log.error("Error with Fabric init! " + e); } + registerActivityLifecycleCallbacks(TS.INSTANCE); + mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); mFirebaseAnalytics.setAnalyticsCollectionEnabled(!Boolean.getBoolean("disableFirebase")); @@ -438,7 +441,7 @@ public class MainApp extends Application { if (timeDateOrTZChangeReceiver != null) { unregisterReceiver(timeDateOrTZChangeReceiver); } - + unregisterActivityLifecycleCallbacks(TS.INSTANCE); } public static int dpToPx(int dp) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/timeSpent/TS.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/timeSpent/TS.kt new file mode 100644 index 0000000000..e00a8a1599 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/timeSpent/TS.kt @@ -0,0 +1,38 @@ +package info.nightscout.androidaps.plugins.general.timeSpent + +import android.app.Activity +import android.app.Application +import android.os.Bundle +import info.nightscout.androidaps.logging.L +import org.slf4j.LoggerFactory + +object TS : Application.ActivityLifecycleCallbacks { + private val log = LoggerFactory.getLogger(L.CORE) + override fun onActivityPaused(activity: Activity?) { + log.debug("onActivityPaused " + activity?.localClassName) + } + + override fun onActivityResumed(activity: Activity?) { + log.debug("onActivityResumed " + activity?.localClassName) + } + + override fun onActivityStarted(activity: Activity?) { + log.debug("onActivityStarted " + activity?.localClassName) + } + + override fun onActivityDestroyed(activity: Activity?) { + log.debug("onActivityDestroyed " + activity?.localClassName) + } + + override fun onActivitySaveInstanceState(activity: Activity?, outState: Bundle?) { + log.debug("onActivitySaveInstanceState " + activity?.localClassName) + } + + override fun onActivityStopped(activity: Activity?) { + log.debug("onActivityStopped " + activity?.localClassName) + } + + override fun onActivityCreated(activity: Activity?, savedInstanceState: Bundle?) { + log.debug("onActivityCreated " + activity?.localClassName) + } +} \ No newline at end of file