diff --git a/android/app/build.gradle b/android/app/build.gradle index 987709b9..49e10af5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -52,7 +52,7 @@ android { applicationId "com.ccextractor.ultimate_alarm_clock" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion 23 + minSdkVersion 24 targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/android/app/src/main/kotlin/com/ccextractor/ultimate_alarm_clock/ultimate_alarm_clock/GetLatestAlarm.kt b/android/app/src/main/kotlin/com/ccextractor/ultimate_alarm_clock/ultimate_alarm_clock/GetLatestAlarm.kt index e0cf94ab..384950a7 100644 --- a/android/app/src/main/kotlin/com/ccextractor/ultimate_alarm_clock/ultimate_alarm_clock/GetLatestAlarm.kt +++ b/android/app/src/main/kotlin/com/ccextractor/ultimate_alarm_clock/ultimate_alarm_clock/GetLatestAlarm.kt @@ -41,68 +41,68 @@ fun getLatestAlarm(db: SQLiteDatabase, wantNextAlarm: Boolean, profile: String): var alarm = AlarmModel.fromCursor(cursor) var intervaltoAlarm = Long.MAX_VALUE var setAlarm: AlarmModel? =null - do { - alarm = AlarmModel.fromCursor(cursor) - if (alarm.ringOn == 0) { + do { + alarm = AlarmModel.fromCursor(cursor) + if (alarm.ringOn == 0) { - var dayfromToday = 0 - var timeDif = getTimeDifferenceInMillis(alarm.alarmTime) - Log.d("d","timeDiff ${timeDif}") - - if ((alarm.days[currentDay] == '1' || alarm.days=="0000000") && timeDif > -1L) { - if (timeDif < intervaltoAlarm) { - intervaltoAlarm = timeDif - setAlarm = alarm - } - } else { - dayfromToday = getDaysUntilNextAlarm(alarm.days, currentDay) - if (dayfromToday == 0) { - - if(alarm.days=="0000000") - { + var dayfromToday = 0 + var timeDif = getTimeDifferenceInMillis(alarm.alarmTime) + Log.d("d","timeDiff ${timeDif}") + if ((alarm.days[currentDay] == '1' || alarm.days=="0000000") && timeDif > -1L) { + if (timeDif < intervaltoAlarm) { + intervaltoAlarm = timeDif + setAlarm = alarm + } + } else { + dayfromToday = getDaysUntilNextAlarm(alarm.days, currentDay) + if (dayfromToday == 0) { + + if(alarm.days=="0000000") + { + + var timeDif = + getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + if (timeDif < intervaltoAlarm && timeDif > -1L ) { + intervaltoAlarm = timeDif + setAlarm = alarm + } + } + else{ + + var timeDif = + getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * 6 + if (timeDif < intervaltoAlarm && timeDif > -1L ) { + intervaltoAlarm = timeDif + setAlarm = alarm + } + } + } else if (dayfromToday == 1) { var timeDif = getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() - if (timeDif < intervaltoAlarm && timeDif > -1L ) { + Log.d("d","timeDiff ${timeDif}") + + if (timeDif < intervaltoAlarm && timeDif > -1L) { intervaltoAlarm = timeDif setAlarm = alarm } - } - else{ - + } else { var timeDif = - getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * 6 - if (timeDif < intervaltoAlarm && timeDif > -1L ) { + getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * (dayfromToday - 1) + if (timeDif < intervaltoAlarm && timeDif > -1L) { intervaltoAlarm = timeDif setAlarm = alarm } - } - } else if (dayfromToday == 1) { - var timeDif = - getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() - Log.d("d","timeDiff ${timeDif}") - - if (timeDif < intervaltoAlarm && timeDif > -1L) { - intervaltoAlarm = timeDif - setAlarm = alarm - } - } else { - var timeDif = - getTimeDifferenceFromMidnight(alarm.alarmTime) + getMillisecondsUntilMidnight() + 86400000 * (dayfromToday - 1) - if (timeDif < intervaltoAlarm && timeDif > -1L) { - intervaltoAlarm = timeDif - setAlarm = alarm } - } - } - } else { - val dayfromToday = getDaysFromCurrentDate(alarm.alarmDate) - if (dayfromToday == 0L) { - var timeDif = getTimeDifferenceInMillis(alarm.alarmTime) - if (alarm.days[currentDay] == '1' && timeDif > -1L) { - if (timeDif < intervaltoAlarm) { - intervaltoAlarm = timeDif + } + } else { + val dayfromToday = getDaysFromCurrentDate(alarm.alarmDate) + if (dayfromToday == 0L) { + var timeDif = getTimeDifferenceInMillis(alarm.alarmTime) + if (alarm.days[currentDay] == '1' && timeDif > -1L) { + if (timeDif < intervaltoAlarm) { + intervaltoAlarm = timeDif setAlarm = alarm } } diff --git a/android/build.gradle b/android/build.gradle index 29d91518..1bb4e34c 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -11,7 +11,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.0' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.15' }