Skip to content

Commit 8979383

Browse files
Remove alarmmanager
1 parent 4bf5959 commit 8979383

6 files changed

Lines changed: 4 additions & 60 deletions

File tree

composeApp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/build
22
/shared.podspec
33
/composeApp.podspec
4+
/release/
5+
/staging/

composeApp/src/androidMain/AndroidManifest.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
<uses-permission android:name="android.permission.WAKE_LOCK" />
1010
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
1111
<uses-permission android:name="android.permission.RECORD_AUDIO" />
12-
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
13-
<uses-permission
14-
android:name="android.permission.SCHEDULE_EXACT_ALARM"
15-
android:maxSdkVersion="32" />
16-
<uses-permission android:name="android.permission.USE_EXACT_ALARM" />
1712

1813
<uses-permission
1914
android:name="android.permission.READ_EXTERNAL_STORAGE"

composeApp/src/androidMain/kotlin/io/middlepoint/morestuff/shared/domain/service/Scheduler.android.kt

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package io.middlepoint.morestuff.shared.domain.service
22

3-
import android.app.AlarmManager
43
import android.content.Context
54
import android.content.Intent
65
import androidx.work.Constraints
@@ -94,51 +93,6 @@ class SchedulerImpl(
9493
workManager.enqueueUniqueWork(PRIORITY_REVIEW_WORK, ExistingWorkPolicy.REPLACE, work)
9594
}
9695

97-
override fun scheduleNextReview(hour: Int, minute: Int, replaceExisting: Boolean) {
98-
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
99-
val reviewIntent = NotificationReceiver.createReviewIntent(context)
100-
val pendingIntent = NotificationReceiver.createCancelReviewPendingIntent(
101-
context,
102-
reviewIntent
103-
)
104-
when {
105-
pendingIntent == null -> {
106-
Logger.d("Review notification does not exist - creating...")
107-
setReviewAlarm(alarmManager, hour, minute, reviewIntent)
108-
}
109-
110-
replaceExisting -> {
111-
alarmManager.cancel(pendingIntent)
112-
setReviewAlarm(alarmManager, hour, minute, reviewIntent)
113-
}
114-
}
115-
}
116-
117-
private fun setReviewAlarm(
118-
alarmManager: AlarmManager,
119-
hour: Int,
120-
minute: Int,
121-
reviewIntent: Intent,
122-
) {
123-
Calendar.getInstance().apply {
124-
val hourOfDay = get(Calendar.HOUR_OF_DAY)
125-
if (hourOfDay > hour) {
126-
add(Calendar.DAY_OF_YEAR, 1)
127-
}
128-
set(Calendar.HOUR_OF_DAY, hour)
129-
set(Calendar.MINUTE, minute)
130-
}.also {
131-
alarmManager.setExact(
132-
AlarmManager.RTC_WAKEUP,
133-
it.timeInMillis,
134-
NotificationReceiver.createReviewPendingIntent(
135-
context,
136-
reviewIntent,
137-
)
138-
)
139-
}
140-
}
141-
14296
override fun cancelSchedule(scheduleId: Long) {
14397
workManager.cancelAllWorkByTag(getScheduleWorkTag(scheduleId))
14498
}

composeApp/src/commonMain/kotlin/io/middlepoint/morestuff/shared/domain/service/Scheduler.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ interface Scheduler {
66
fun scheduleReviewWorker(hour: Int, minute: Int)
77
fun cancelSchedule(scheduleId: Long)
88
fun cancelPlannedPriorityUpdate()
9-
fun scheduleNextReview(hour: Int, minute: Int, replaceExisting: Boolean)
109
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
package io.middlepoint.morestuff.shared.ui.utils
2+

composeApp/src/iosMain/kotlin/io/middlepoint/morestuff/shared/domain/service/Scheduler.ios.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ class SchedulerImpl(
131131
}
132132
}
133133

134-
override fun scheduleNextReview(hour: Int, minute: Int, replaceExisting: Boolean) {
135-
if (replaceExisting) {
136-
cancelPlannedPriorityUpdate()
137-
}
138-
139-
scheduleReviewWorker(hour, minute)
140-
}
141-
142134
override fun cancelSchedule(scheduleId: Long) {
143135
UNUserNotificationCenter.currentNotificationCenter()
144136
.removePendingNotificationRequestsWithIdentifiers(

0 commit comments

Comments
 (0)