Skip to content

Commit

Permalink
Merge pull request #254 from mhss1/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mhss1 authored Nov 13, 2024
2 parents 4c5ee90 + 1350e31 commit 92bef01
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 97 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand All @@ -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(
Expand Down
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/13.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Bug fixes
18 changes: 9 additions & 9 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
[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"
coreKtx = "1.13.1"
composeBom = "2024.10.01"
coreKtx = "1.15.0"
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"
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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit 92bef01

Please sign in to comment.