diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 432e7ab..19a171c 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -50,9 +50,9 @@
android:name=".gms.activity.ActivityReceiver"
android:enabled="true"
android:exported="true">
-
-
-
+
+
+
(
ActivityTransition.Builder()
.setActivityType(DetectedActivity.IN_VEHICLE)
@@ -53,7 +53,8 @@ internal val TRANSITIONS = listOf(
)
class ActivityHandler private constructor(private val context: Context) {
- private var pendingIntent: PendingIntent = createPendingIntent()
+ private val pendingIntent: PendingIntent
+ get() = createPendingIntent()
private var activityRegistered = false
companion object {
@@ -95,7 +96,7 @@ class ActivityHandler private constructor(private val context: Context) {
private fun createPendingIntent(): PendingIntent =
with(Intent(context, ActivityReceiver::class.java)) {
-// action = TRANSITIONS_RECEIVER_ACTION
+ action = TRANSITIONS_RECEIVER_ACTION
PendingIntent.getBroadcast(
context,
ACTIVITY_REQUEST_CODE,
diff --git a/app/src/main/java/com/javinator9889/handwashingreminder/gms/activity/ActivityReceiver.kt b/app/src/main/java/com/javinator9889/handwashingreminder/gms/activity/ActivityReceiver.kt
index 8c449ec..cd52308 100644
--- a/app/src/main/java/com/javinator9889/handwashingreminder/gms/activity/ActivityReceiver.kt
+++ b/app/src/main/java/com/javinator9889/handwashingreminder/gms/activity/ActivityReceiver.kt
@@ -88,9 +88,9 @@ class ActivityReceiver : BroadcastReceiver() {
detectedActivity: Int,
context: Context
) {
- val preferences = PreferenceManager.getDefaultSharedPreferences(context)
+ val prefs = PreferenceManager.getDefaultSharedPreferences(context)
val timeInBetweenNotifications =
- preferences.getInt(Preferences.ACTIVITY_MINIMUM_TIME, 15)
+ prefs.getString(Preferences.ACTIVITY_MINIMUM_TIME, "15")!!.toInt()
val timeFile = File(context.cacheDir, "activity.time")
var latestNotificationTime = 0L
withContext(Dispatchers.IO) {
@@ -104,6 +104,7 @@ class ActivityReceiver : BroadcastReceiver() {
TimeUnit.MINUTES,
latestNotificationTime
)
+ Timber.d("$timeDifference - $timeInBetweenNotifications")
if (timeDifference <= timeInBetweenNotifications)
return
val notificationContent = when (detectedActivity) {
diff --git a/app/src/main/java/com/javinator9889/handwashingreminder/utils/LogReportTree.kt b/app/src/main/java/com/javinator9889/handwashingreminder/utils/LogReportTree.kt
index f7aa96f..ca54fee 100644
--- a/app/src/main/java/com/javinator9889/handwashingreminder/utils/LogReportTree.kt
+++ b/app/src/main/java/com/javinator9889/handwashingreminder/utils/LogReportTree.kt
@@ -36,8 +36,11 @@ class LogReportTree : Timber.Tree() {
t: Throwable?
) {
when (priority) {
- Log.DEBUG, Log.VERBOSE -> return
- Log.WARN -> crashlytics.log("W: $tag: $message")
+ Log.DEBUG, Log.VERBOSE, Log.INFO -> return
+ Log.WARN -> {
+ crashlytics.log("W: $tag: $message")
+ t?.let { crashlytics.recordException(it) }
+ }
Log.ERROR -> {
crashlytics.log("E/$tag: $message")
t?.let { crashlytics.recordException(t) }
diff --git a/app/src/main/java/com/javinator9889/handwashingreminder/utils/calendar/Calendar.kt b/app/src/main/java/com/javinator9889/handwashingreminder/utils/calendar/Calendar.kt
index a58c7c4..11275ed 100644
--- a/app/src/main/java/com/javinator9889/handwashingreminder/utils/calendar/Calendar.kt
+++ b/app/src/main/java/com/javinator9889/handwashingreminder/utils/calendar/Calendar.kt
@@ -47,7 +47,7 @@ object CalendarUtils {
unit: TimeUnit,
to: Long,
from: Long = Calendar.getInstance().timeInMillis
- ): Long = unit.convert(timeBetween(from, to), TimeUnit.MILLISECONDS)
+ ): Long = unit.convert(timeBetween(to, from), TimeUnit.MILLISECONDS)
fun timeBetween(
to: Long,