From 1fd289c4af301629c1c7d0bd9659112c89c8053a Mon Sep 17 00:00:00 2001 From: Mohamed Date: Sun, 20 Oct 2024 08:53:53 +0300 Subject: [PATCH 1/5] Update versions --- gradle/libs.versions.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index bc4fdfc..06d82e2 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,20 +1,20 @@ [versions] -activityCompose = "1.9.2" +activityCompose = "1.9.3" appcompat = "1.7.0" biometric = "1.4.0-alpha02" calf = "0.5.5" -composeBom = "2024.09.03" +composeBom = "2024.10.00" coreKtx = "1.13.1" coroutines = "1.9.0" datastorePreferences = "1.1.1" documentfile = "1.0.1" espressoCore = "3.6.1" -glanceAppwidget = "1.1.0" +glanceAppwidget = "1.1.1" junit = "4.13.2" junitVersion = "1.2.1" kotlinxSerializationJson = "1.7.3" lifecycleVersion = "2.8.6" -navigationCompose = "2.8.2" +navigationCompose = "2.8.3" room = "2.6.1" workManager = "2.9.1" androidGradlePlugin = "8.7.1" From 0c1e1d87c443e091dc2ae1f8f53761555cf8d879 Mon Sep 17 00:00:00 2001 From: Mohamed Date: Sun, 20 Oct 2024 08:55:52 +0300 Subject: [PATCH 2/5] Replace BasicAlertDialog with DatePickerDialog in DateTimeDialog --- .../ui/components/common/DateTimeDialog.kt | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/core/ui/src/main/java/com/mhss/app/ui/components/common/DateTimeDialog.kt b/core/ui/src/main/java/com/mhss/app/ui/components/common/DateTimeDialog.kt index f865534..c131a6b 100644 --- a/core/ui/src/main/java/com/mhss/app/ui/components/common/DateTimeDialog.kt +++ b/core/ui/src/main/java/com/mhss/app/ui/components/common/DateTimeDialog.kt @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material3.BasicAlertDialog import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -14,6 +13,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.res.stringResource import androidx.compose.material3.DatePicker +import androidx.compose.material3.DatePickerDialog import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.material3.TextButton @@ -45,9 +45,25 @@ fun DateTimeDialog( var showTime by remember { mutableStateOf(false) } - BasicAlertDialog( + DatePickerDialog( onDismissRequest = onDismissRequest, - modifier = Modifier.fillMaxWidth().padding(8.dp) + modifier = Modifier.fillMaxWidth(), + confirmButton = { + TextButton( + onClick = { + if (showTime) { + onDatePicked( + datePickerState.selectedDateMillis?.at( + timePickerState.hour, + timePickerState.minute + ) ?: initialDate + ) + } else showTime = true + }, + ) { + Text(stringResource(R.string.okay)) + } + } ) { Surface( shape = RoundedCornerShape(20.dp) @@ -68,20 +84,6 @@ fun DateTimeDialog( ) } } - TextButton( - onClick = { - if (showTime) { - onDatePicked( - datePickerState.selectedDateMillis?.at( - timePickerState.hour, - timePickerState.minute - ) ?: initialDate - ) - } else showTime = true - }, - ) { - Text(stringResource(R.string.okay)) - } } } From 7ec2fc9ffa70f623e675809b7a815325b92d3562 Mon Sep 17 00:00:00 2001 From: Mohamed Date: Mon, 21 Oct 2024 10:02:47 +0300 Subject: [PATCH 3/5] Avoid updating entries when deleted --- .../presentation/BookmarkDetailsViewModel.kt | 39 ++++++++++--------- .../app/presentation/DiaryDetailsViewModel.kt | 36 +++++++++-------- .../app/presentation/NoteDetailsViewModel.kt | 34 ++++++++-------- .../app/presentation/TaskDetailsViewModel.kt | 38 +++++++++--------- 4 files changed, 79 insertions(+), 68 deletions(-) diff --git a/bookmarks/presentation/src/main/java/com/mhss/app/presentation/BookmarkDetailsViewModel.kt b/bookmarks/presentation/src/main/java/com/mhss/app/presentation/BookmarkDetailsViewModel.kt index 1b2485b..a7d87e3 100644 --- a/bookmarks/presentation/src/main/java/com/mhss/app/presentation/BookmarkDetailsViewModel.kt +++ b/bookmarks/presentation/src/main/java/com/mhss/app/presentation/BookmarkDetailsViewModel.kt @@ -46,27 +46,30 @@ class BookmarkDetailsViewModel( // Using applicationScope to avoid cancelling when the user exits the screen // and the view model is cleared before the job finishes is BookmarkDetailsEvent.ScreenOnStop -> applicationScope.launch { - if (bookmarkDetailsUiState.bookmark == null) { - if (event.bookmark.url.isNotBlank() - || event.bookmark.title.isNotBlank() - || event.bookmark.description.isNotBlank() - ) { - val bookmark = event.bookmark.copy( - createdDate = now(), + if (!bookmarkDetailsUiState.navigateUp) { + if (bookmarkDetailsUiState.bookmark == null) { + if (event.bookmark.url.isNotBlank() + || event.bookmark.title.isNotBlank() + || event.bookmark.description.isNotBlank() + ) { + val bookmark = event.bookmark.copy( + createdDate = now(), + updatedDate = now() + ) + val id = addBookmark(bookmark) + bookmarkDetailsUiState = + bookmarkDetailsUiState.copy(bookmark = bookmark.copy(id = id.toInt())) + } + } else if (bookmarkChanged(bookmarkDetailsUiState.bookmark!!, event.bookmark)) { + val newBookmark = bookmarkDetailsUiState.bookmark!!.copy( + title = event.bookmark.title, + description = event.bookmark.description, + url = event.bookmark.url, updatedDate = now() ) - val id = addBookmark(bookmark) - bookmarkDetailsUiState = bookmarkDetailsUiState.copy(bookmark = bookmark.copy(id = id.toInt())) + updateBookmark(newBookmark) + bookmarkDetailsUiState = bookmarkDetailsUiState.copy(bookmark = newBookmark) } - } else if (bookmarkChanged(bookmarkDetailsUiState.bookmark!!, event.bookmark)) { - val newBookmark = bookmarkDetailsUiState.bookmark!!.copy( - title = event.bookmark.title, - description = event.bookmark.description, - url = event.bookmark.url, - updatedDate = now() - ) - updateBookmark(newBookmark) - bookmarkDetailsUiState = bookmarkDetailsUiState.copy(bookmark = newBookmark) } } diff --git a/diary/presentation/src/main/java/com/mhss/app/presentation/DiaryDetailsViewModel.kt b/diary/presentation/src/main/java/com/mhss/app/presentation/DiaryDetailsViewModel.kt index 7ff0078..8047daf 100644 --- a/diary/presentation/src/main/java/com/mhss/app/presentation/DiaryDetailsViewModel.kt +++ b/diary/presentation/src/main/java/com/mhss/app/presentation/DiaryDetailsViewModel.kt @@ -43,30 +43,33 @@ class DiaryDetailsViewModel( deleteEntry(uiState.entry!!) uiState = uiState.copy(navigateUp = true) } + is DiaryDetailsEvent.ToggleReadingMode -> { uiState = uiState.copy(readingMode = !uiState.readingMode) } // Using applicationScope to avoid cancelling when the user exits the screen // and the view model is cleared before the job finishes is DiaryDetailsEvent.ScreenOnStop -> applicationScope.launch { - if (uiState.entry == null) { - if (event.currentEntry.title.isNotBlank() || event.currentEntry.content.isNotBlank()) { - val entry = event.currentEntry.copy( + if (!uiState.navigateUp) { + if (uiState.entry == null) { + if (event.currentEntry.title.isNotBlank() || event.currentEntry.content.isNotBlank()) { + val entry = event.currentEntry.copy( + updatedDate = now() + ) + val id = addEntry(entry) + uiState = uiState.copy(entry = entry.copy(id = id.toInt())) + } + } else if (entryChanged(uiState.entry!!, event.currentEntry)) { + val newEntry = uiState.entry!!.copy( + title = event.currentEntry.title, + content = event.currentEntry.content, + mood = event.currentEntry.mood, + createdDate = event.currentEntry.createdDate, updatedDate = now() ) - val id = addEntry(entry) - uiState = uiState.copy(entry = entry.copy(id = id.toInt())) + updateEntry(newEntry) + uiState = uiState.copy(entry = newEntry) } - } else if (entryChanged(uiState.entry!!, event.currentEntry)) { - val newEntry = uiState.entry!!.copy( - title = event.currentEntry.title, - content = event.currentEntry.content, - mood = event.currentEntry.mood, - createdDate = event.currentEntry.createdDate, - updatedDate = now() - ) - updateEntry(newEntry) - uiState = uiState.copy(entry = newEntry) } } } @@ -75,7 +78,8 @@ class DiaryDetailsViewModel( private fun entryChanged(entry: DiaryEntry, newEntry: DiaryEntry): Boolean { return entry.title != newEntry.title || entry.content != newEntry.content || - entry.mood != newEntry.mood + entry.mood != newEntry.mood || + entry.createdDate != newEntry.createdDate } data class UiState( diff --git a/notes/presentation/src/main/java/com/mhss/app/presentation/NoteDetailsViewModel.kt b/notes/presentation/src/main/java/com/mhss/app/presentation/NoteDetailsViewModel.kt index 38d2ed9..2dbcb57 100644 --- a/notes/presentation/src/main/java/com/mhss/app/presentation/NoteDetailsViewModel.kt +++ b/notes/presentation/src/main/java/com/mhss/app/presentation/NoteDetailsViewModel.kt @@ -126,25 +126,27 @@ class NoteDetailsViewModel( // Using applicationScope to avoid cancelling when the user exits the screen // and the view model is cleared before the job finishes is NoteDetailsEvent.ScreenOnStop -> applicationScope.launch { - if (noteUiState.note == null) { - if (event.currentNote.title.isNotBlank() || event.currentNote.content.isNotBlank()) { - val note = event.currentNote.copy( - createdDate = now(), + if (!noteUiState.navigateUp) { + if (noteUiState.note == null) { + if (event.currentNote.title.isNotBlank() || event.currentNote.content.isNotBlank()) { + val note = event.currentNote.copy( + createdDate = now(), + updatedDate = now() + ) + val id = addNote(note) + noteUiState = noteUiState.copy(note = note.copy(id = id.toInt())) + } + } else if (noteChanged(noteUiState.note!!, event.currentNote)) { + val newNote = noteUiState.note!!.copy( + title = event.currentNote.title, + content = event.currentNote.content, + folderId = event.currentNote.folderId, + pinned = event.currentNote.pinned, updatedDate = now() ) - val id = addNote(note) - noteUiState = noteUiState.copy(note = note.copy(id = id.toInt())) + updateNote(newNote) + noteUiState = noteUiState.copy(note = newNote) } - } else if (noteChanged(noteUiState.note!!, event.currentNote)) { - val newNote = noteUiState.note!!.copy( - title = event.currentNote.title, - content = event.currentNote.content, - folderId = event.currentNote.folderId, - pinned = event.currentNote.pinned, - updatedDate = now() - ) - updateNote(newNote) - noteUiState = noteUiState.copy(note = newNote) } } diff --git a/tasks/presentation/src/main/java/com/mhss/app/presentation/TaskDetailsViewModel.kt b/tasks/presentation/src/main/java/com/mhss/app/presentation/TaskDetailsViewModel.kt index 26039c8..955a6c4 100644 --- a/tasks/presentation/src/main/java/com/mhss/app/presentation/TaskDetailsViewModel.kt +++ b/tasks/presentation/src/main/java/com/mhss/app/presentation/TaskDetailsViewModel.kt @@ -45,24 +45,26 @@ class TaskDetailsViewModel( // Using applicationScope to avoid cancelling when the user exits the screen // and the view model is cleared before the job finishes is TaskDetailsEvent.ScreenOnStop -> applicationScope.launch { - if (taskChanged(taskDetailsUiState.task!!, event.task)) { - val newTask = taskDetailsUiState.task!!.copy( - title = event.task.title.ifBlank { "Untitled" }, - description = event.task.description, - dueDate = event.task.dueDate, - priority = event.task.priority, - subTasks = event.task.subTasks, - recurring = event.task.recurring, - frequency = event.task.frequency, - frequencyAmount = event.task.frequencyAmount, - isCompleted = event.task.isCompleted, - updatedDate = now() - ) - updateTask( - newTask, - event.task.dueDate != taskDetailsUiState.task!!.dueDate - ) - taskDetailsUiState = taskDetailsUiState.copy(task = newTask) + if (!taskDetailsUiState.navigateUp) { + if (taskChanged(taskDetailsUiState.task!!, event.task)) { + val newTask = taskDetailsUiState.task!!.copy( + title = event.task.title.ifBlank { "Untitled" }, + description = event.task.description, + dueDate = event.task.dueDate, + priority = event.task.priority, + subTasks = event.task.subTasks, + recurring = event.task.recurring, + frequency = event.task.frequency, + frequencyAmount = event.task.frequencyAmount, + isCompleted = event.task.isCompleted, + updatedDate = now() + ) + updateTask( + newTask, + event.task.dueDate != taskDetailsUiState.task!!.dueDate + ) + taskDetailsUiState = taskDetailsUiState.copy(task = newTask) + } } } From 091efe5200739747cc1dbc09054e12ea42825d21 Mon Sep 17 00:00:00 2001 From: Mohamed Date: Wed, 13 Nov 2024 09:54:13 +0200 Subject: [PATCH 4/5] Update versions --- .idea/kotlinc.xml | 2 +- gradle/libs.versions.toml | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index d4b7acc..c224ad5 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,6 +1,6 @@ - \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 06d82e2..f35cd4f 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -3,8 +3,8 @@ activityCompose = "1.9.3" appcompat = "1.7.0" biometric = "1.4.0-alpha02" calf = "0.5.5" -composeBom = "2024.10.00" -coreKtx = "1.13.1" +composeBom = "2024.10.01" +coreKtx = "1.15.0" coroutines = "1.9.0" datastorePreferences = "1.1.1" documentfile = "1.0.1" @@ -13,12 +13,12 @@ glanceAppwidget = "1.1.1" junit = "4.13.2" junitVersion = "1.2.1" kotlinxSerializationJson = "1.7.3" -lifecycleVersion = "2.8.6" +lifecycleVersion = "2.8.7" navigationCompose = "2.8.3" room = "2.6.1" -workManager = "2.9.1" -androidGradlePlugin = "8.7.1" -kotlin = "2.0.20" +workManager = "2.10.0" +androidGradlePlugin = "8.7.2" +kotlin = "2.0.21" ksp = "2.0.20-1.0.25" koinBOM = "4.0.0" koinKSP = "1.3.1" From 1350e31513fa30e3ef457b3d6b4d1cb5e94a042d Mon Sep 17 00:00:00 2001 From: Mohamed Date: Wed, 13 Nov 2024 13:10:10 +0200 Subject: [PATCH 5/5] Update app versions --- app/build.gradle.kts | 4 ++-- fastlane/metadata/android/en-US/changelogs/13.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/13.txt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 40632b4..c614ade 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,8 +14,8 @@ android { applicationId = "com.mhss.app.mybrain" minSdk = 26 targetSdk = 35 - versionCode = 12 - versionName = "2.0.3" + versionCode = 13 + versionName = "2.0.4" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { diff --git a/fastlane/metadata/android/en-US/changelogs/13.txt b/fastlane/metadata/android/en-US/changelogs/13.txt new file mode 100644 index 0000000..47f5d24 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/13.txt @@ -0,0 +1 @@ +- Bug fixes \ No newline at end of file