Skip to content

Commit a819798

Browse files
committed
Release 1.0.0-RC.9 with several overall improvements
1 parent acdc465 commit a819798

File tree

16 files changed

+237
-86
lines changed

16 files changed

+237
-86
lines changed

pom-application/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ android {
2626
applicationId "net.dzikoysk.presenceofmind"
2727
minSdk 29
2828
targetSdk 32
29-
versionCode 8
30-
versionName "1.0.0-RC.8"
29+
versionCode 9
30+
versionName "1.0.0-RC.9"
3131
archivesBaseName = "presence-of-mind-$versionName"
3232

3333
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

pom-application/app/src/main/AndroidManifest.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.INTERNET" />
66
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
77

8+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
89
<uses-permission android:name="android.permission.WAKE_LOCK" />
910
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
1011
<uses-permission android:name="android.permission.USE_EXACT_ALARM"/>
@@ -18,19 +19,27 @@
1819
android:theme="@style/Theme.LightPresenceOfMind">
1920
<activity
2021
android:name=".PresenceOfMindActivity"
22+
android:enabled="true"
2123
android:exported="true"
2224
android:theme="@style/Theme.LightPresenceOfMind">
2325
<intent-filter>
2426
<action android:name="android.intent.action.MAIN" />
2527
<category android:name="android.intent.category.LAUNCHER" />
2628
</intent-filter>
2729
</activity>
30+
<receiver android:name=".StartUpBroadcastReceiver" android:enabled="true" android:exported="true">
31+
<intent-filter>
32+
<action android:name="android.intent.action.BOOT_COMPLETED" />
33+
</intent-filter>
34+
</receiver>
2835
<receiver
29-
android:name="net.dzikoysk.presenceofmind.model.task.reminder.AlarmReceiver"
36+
android:name="net.dzikoysk.presenceofmind.model.task.reminder.EventReminderReceiver"
37+
android:enabled="true"
3038
android:exported="true">
3139
<intent-filter>
32-
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
3340
<category android:name="android.intent.category.DEFAULT" />
41+
<action android:name="android.media.action.DISPLAY_NOTIFICATION" />
42+
<action android:name="pom-event-reminder-notification-cancelled"/>
3443
</intent-filter>
3544
</receiver>
3645
</application>

pom-application/app/src/main/java/net/dzikoysk/presenceofmind/PresenceOfMind.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import net.dzikoysk.presenceofmind.model.task.attributes.PomodoroAttribute
1313
import net.dzikoysk.presenceofmind.model.task.attributes.RepetitiveAttribute
1414
import net.dzikoysk.presenceofmind.model.task.attributes.date.EventAttribute
1515
import net.dzikoysk.presenceofmind.model.task.attributes.date.EventDateTime
16-
import net.dzikoysk.presenceofmind.model.task.attributes.date.MarkAsWatcher
16+
import net.dzikoysk.presenceofmind.model.task.attributes.date.MarkAsTaskWatcher
1717
import net.dzikoysk.presenceofmind.model.task.category.CategoryService
1818
import net.dzikoysk.presenceofmind.model.task.category.SharedPreferencesCategoryRepository
19-
import net.dzikoysk.presenceofmind.model.task.reminder.ReminderWatcher
19+
import net.dzikoysk.presenceofmind.model.task.reminder.ReminderTaskWatcher
2020

21-
internal class PresenceOfMind constructor(
21+
class PresenceOfMind constructor(
2222
val presenceRepository: PresenceRepository,
2323
val categoryService: CategoryService,
2424
val taskService: TaskService,
@@ -63,9 +63,9 @@ private object PresenceOfMindFactory {
6363
),
6464
version = DATA_VERSION
6565
),
66-
watchers = listOf(
67-
MarkAsWatcher(),
68-
ReminderWatcher(context)
66+
taskWatchers = listOf(
67+
MarkAsTaskWatcher(),
68+
ReminderTaskWatcher(context)
6969
)
7070
)
7171

pom-application/app/src/main/java/net/dzikoysk/presenceofmind/PresenceOfMindActivity.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import androidx.activity.ComponentActivity
77
import androidx.activity.compose.setContent
88
import androidx.compose.runtime.LaunchedEffect
99
import com.google.android.play.core.appupdate.AppUpdateManagerFactory
10-
import com.google.android.play.core.install.model.AppUpdateType.FLEXIBLE
10+
import com.google.android.play.core.install.model.AppUpdateType.IMMEDIATE
1111
import com.google.android.play.core.install.model.UpdateAvailability.UPDATE_AVAILABLE
1212
import kotlinx.coroutines.delay
1313
import net.dzikoysk.presenceofmind.pages.Page
@@ -34,15 +34,16 @@ class PresenceOfMindActivity : ComponentActivity() {
3434

3535
appUpdateInfoTask.addOnSuccessListener {
3636
when {
37-
!it.isUpdateTypeAllowed(FLEXIBLE) -> return@addOnSuccessListener
37+
!it.isUpdateTypeAllowed(IMMEDIATE) -> return@addOnSuccessListener
3838
it.updateAvailability() != UPDATE_AVAILABLE -> return@addOnSuccessListener
3939
it.availableVersionCode() == presenceOfMind.presenceRepository.getLatestVersionCode() -> return@addOnSuccessListener
4040
}
4141
presenceOfMind.presenceRepository.setLatestVersionCode(it.availableVersionCode())
42-
appUpdateManager.startUpdateFlowForResult(it, FLEXIBLE, this, UPDATE_CODE)
42+
appUpdateManager.startUpdateFlowForResult(it, IMMEDIATE, this, UPDATE_CODE)
4343
}
4444
}
4545

46+
presenceOfMind.taskService.initializeWatchers(intent.extras)
4647
presenceOfMind.taskService.refreshTasksState()
4748

4849
setContent {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package net.dzikoysk.presenceofmind
2+
3+
import android.content.BroadcastReceiver
4+
import android.content.Context
5+
import android.content.Intent
6+
import android.content.Intent.ACTION_BOOT_COMPLETED
7+
8+
internal class StartUpBroadcastReceiver : BroadcastReceiver() {
9+
10+
override fun onReceive(context: Context, intent: Intent) {
11+
if (intent.action == ACTION_BOOT_COMPLETED) {
12+
PresenceOfMind.getInstance(context).taskService.refreshTasksState()
13+
}
14+
}
15+
16+
}

pom-application/app/src/main/java/net/dzikoysk/presenceofmind/model/task/TaskService.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.dzikoysk.presenceofmind.model.task
22

3+
import android.os.Bundle
34
import androidx.compose.runtime.mutableStateListOf
45
import androidx.compose.runtime.snapshots.SnapshotStateList
56
import java.util.UUID
@@ -11,7 +12,7 @@ typealias DeleteTask = (Task) -> Unit
1112

1213
class TaskService(
1314
val taskRepository: TaskRepository = InMemoryTaskRepository(),
14-
val watchers: Collection<Watcher> = emptyList()
15+
val taskWatchers: Collection<TaskWatcher> = emptyList()
1516
) {
1617

1718
private val tasks = mutableStateListOf<Task>()
@@ -20,8 +21,11 @@ class TaskService(
2021
tasks.addAll(taskRepository.loadOrderedTasks())
2122
}
2223

24+
fun initializeWatchers(extras: Bundle?) =
25+
taskWatchers.forEach { it.initialize(this, extras) }
26+
2327
fun refreshTasksState() =
24-
watchers.forEach { it.onRefresh(this) }
28+
taskWatchers.forEach { it.onRefresh(this) }
2529

2630
fun saveTask(task: Task) =
2731
saveTasks(listOf(task))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package net.dzikoysk.presenceofmind.model.task
2+
3+
import android.os.Bundle
4+
5+
interface TaskWatcher {
6+
7+
fun initialize(taskService: TaskService, extras: Bundle?) {}
8+
9+
fun onRefresh(taskService: TaskService)
10+
11+
}

pom-application/app/src/main/java/net/dzikoysk/presenceofmind/model/task/Watcher.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.

pom-application/app/src/main/java/net/dzikoysk/presenceofmind/model/task/attributes/date/EventAttribute.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,16 @@ import net.dzikoysk.presenceofmind.model.task.reminder.hasOutdatedSchedule
88
import net.dzikoysk.presenceofmind.shared.OUTDATED
99
import net.dzikoysk.presenceofmind.shared.incomingDurationToHumanReadableFormat
1010
import net.dzikoysk.presenceofmind.shared.plural
11-
import java.time.*
11+
import java.time.Duration
12+
import java.time.Instant
13+
import java.time.LocalDateTime
14+
import java.time.ZoneId
15+
import java.time.ZonedDateTime
16+
import java.time.format.DateTimeFormatter
1217
import kotlin.time.toKotlinDuration
1318

19+
val EVENT_DATE_FORMATTER = DateTimeFormatter.ofPattern("dd.MM HH:mm")
20+
1421
/** One-time events */
1522
data class EventAttribute(
1623
val eventDate: EventDateTime = EventDateTime.now(),
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package net.dzikoysk.presenceofmind.model.task.attributes.date
22

33
import net.dzikoysk.presenceofmind.model.task.Task
44
import net.dzikoysk.presenceofmind.model.task.TaskService
5-
import net.dzikoysk.presenceofmind.model.task.Watcher
5+
import net.dzikoysk.presenceofmind.model.task.TaskWatcher
66
import net.dzikoysk.presenceofmind.model.task.attributes.RepetitiveAttribute
77
import net.dzikoysk.presenceofmind.model.task.isDone
88
import net.dzikoysk.presenceofmind.shared.DefaultTimeProvider
@@ -11,7 +11,7 @@ import java.time.Instant
1111
import java.time.ZoneId
1212
import java.time.temporal.ChronoUnit
1313

14-
class MarkAsWatcher(private val timeProvider: TimeProvider = DefaultTimeProvider()) : Watcher {
14+
class MarkAsTaskWatcher(private val timeProvider: TimeProvider = DefaultTimeProvider()) : TaskWatcher {
1515

1616
override fun onRefresh(taskService: TaskService) {
1717
// marks repetitive tasks as unfinished

0 commit comments

Comments
 (0)