Skip to content

Commit

Permalink
Merge branch 'release/1.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
mshabiola committed Dec 14, 2023
2 parents 896381c + c480298 commit 8cd7c26
Show file tree
Hide file tree
Showing 13 changed files with 19,816 additions and 19,435 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.

39,005 changes: 19,669 additions & 19,336 deletions app/src/release/generated/baselineProfiles/baseline-prof.txt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class AndroidApplicationConventionPlugin : Plugin<Project> {
// compileSdkPreview = "UpsideDownCake"
defaultConfig.targetSdk = 34
defaultConfig.minSdk = 24
defaultConfig.versionName = "2023.10.10"
defaultConfig.versionCode = 16
defaultConfig.versionName = "2023.12.14"
defaultConfig.versionCode = 17

defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
defaultConfig.vectorDrawables {
Expand Down
2 changes: 1 addition & 1 deletion build-logic/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-rc-2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
17 changes: 11 additions & 6 deletions core/common/src/main/java/com/mshdabiola/common/ContentManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@ class ContentManager
private val voiceDir = context.filesDir.absolutePath + "/voice"

fun saveImage(uri: Uri, currentTime: Long) {
createImageDir()
val outputStream = FileOutputStream(File(photoDir, "Image_$currentTime.jpg"))

context.contentResolver.openInputStream(uri).use {
it?.copyTo(outputStream)
outputStream.close()
try {
createImageDir()
val outputStream = FileOutputStream(File(photoDir, "Image_$currentTime.jpg"))

context.contentResolver.openInputStream(uri).use {
it?.copyTo(outputStream)
outputStream.close()
}
}catch (e:Exception){
e.printStackTrace()
}

}

fun saveVoice(uri: Uri, currentTime: Long) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ interface NotepadDao {

@Transaction
@Query("SELECT * FROM note_table WHERE id = :noteId")
fun getOneNotePad(noteId: Long): Flow<NotePadEntity>
fun getOneNotePad(noteId: Long): Flow<NotePadEntity?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class NotePadRepository
suspend fun insertNote(note: Note) = noteDao.upsert(note.toNoteEntity())

suspend fun insertNotepad(notePad: NotePad): Long {



val id = noteDao.upsert(notePad.note.toNoteEntity())
if (notePad.checks.isNotEmpty()) {
noteCheckDao.upsert(notePad.checks.map { it.toNoteCheckEntity() })
Expand Down Expand Up @@ -69,8 +72,8 @@ class NotePadRepository

// fun getNote() = generalDao.getNote().map { noteEntities -> noteEntities.map { it.toNote() } }
//
fun getOneNotePad(id: Long): Flow<NotePad> {
return notePadDao.getOneNotePad(id).map { it.toNotePad() }
fun getOneNotePad(id: Long): Flow<NotePad?> {
return notePadDao.getOneNotePad(id).map { it?.toNotePad() }
}

suspend fun deleteTrashType() = withContext(Dispatchers.IO) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class EditViewModel @Inject constructor(
val notePad = notePadRepository
.getOneNotePad(editArg.id)
.first()
.toNotePadUiState(labels, getTime = dateShortStringUsercase::invoke,contentManager::getImagePath)
?.toNotePadUiState(labels, getTime = dateShortStringUsercase::invoke,contentManager::getImagePath)
?:getNewNotepad()
val voices =
notePad.voices.map { it.copy(length = getAudioLength(it.voiceName)) }
val data = editArg.content
Expand Down Expand Up @@ -203,11 +204,15 @@ class EditViewModel @Inject constructor(
}
.map { it.note.id }
.distinctUntilChanged { old, new -> old == new }
.collectLatest {
if (it>-1){

notePadRepository.getOneNotePad(it)
.mapNotNull { it.images to it.labels }
.collectLatest { id ->
if (id>-1){

notePadRepository.getOneNotePad(id)
.mapNotNull {
if (it!=null)
it.images to it.labels
else null
}
.distinctUntilChanged()
.collectLatest { pair ->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ class MainViewModel
NoteType.LABEL -> {
notepadRepository.getNotePads().map { notes ->
notes.filter { it -> it.labels.any { it.labelId == (pair.second).id } }
.map { it.toNotePadUiState(pair.first, getTime = dateShortStringUsercase::invoke, toPath = contentManager::getImagePath) }
.map {
it.toNotePadUiState(
pair.first,
getTime = dateShortStringUsercase::invoke,
toPath = contentManager::getImagePath
)
}
}.collect { padUiStateList ->
val list = padUiStateList.map {
val labels = it.labels
Expand All @@ -110,7 +116,13 @@ class MainViewModel

NoteType.REMAINDER -> {
notepadRepository.getNotePads().map { notes ->
notes.map { it.toNotePadUiState(pair.first,getTime = dateShortStringUsercase::invoke, toPath = contentManager::getImagePath) }
notes.map {
it.toNotePadUiState(
pair.first,
getTime = dateShortStringUsercase::invoke,
toPath = contentManager::getImagePath
)
}
}.collect { padUiStateList ->
val list = padUiStateList.filter { it.note.reminder > 0 }.map {
val labels = it.labels
Expand All @@ -128,7 +140,13 @@ class MainViewModel

else -> {
notepadRepository.getNotePads(pair.second.type).map { notes ->
notes.map { it.toNotePadUiState(pair.first, getTime = dateShortStringUsercase::invoke, toPath = contentManager::getImagePath) }
notes.map {
it.toNotePadUiState(
pair.first,
getTime = dateShortStringUsercase::invoke,
toPath = contentManager::getImagePath
)
}
}.collect { padUiStateList ->
val list = padUiStateList.map {
val labels = it.labels
Expand All @@ -148,7 +166,12 @@ class MainViewModel
}
}
viewModelScope.launch(Dispatchers.IO) {
initDate()
try {
initDate()

}catch (e:Exception){
e.printStackTrace()
}
}
}

Expand Down Expand Up @@ -300,19 +323,22 @@ class MainViewModel
val id = mainState.value.notePads.single { it.note.selected }.note.id
val notepads = notepadRepository.getOneNotePad(id).first()

var copy = notepads.copy(note = notepads.note.copy(id = null))
if (notepads != null) {
var copy = notepads.copy(note = notepads.note.copy(id = null))

val newId = notepadRepository.insertNotepad(copy)
val newId = notepadRepository.insertNotepad(copy)

copy = copy.copy(
note = copy.note.copy(id = newId),
images = copy.images.map { it.copy(noteId = newId) },
voices = copy.voices.map { it.copy(noteId = newId) },
labels = copy.labels.map { it.copy(noteId = newId) },
checks = copy.checks.map { it.copy(noteId = newId) },
)
copy = copy.copy(
note = copy.note.copy(id = newId),
images = copy.images.map { it.copy(noteId = newId) },
voices = copy.voices.map { it.copy(noteId = newId) },
labels = copy.labels.map { it.copy(noteId = newId) },
checks = copy.checks.map { it.copy(noteId = newId) },
)

notepadRepository.insertNotepad(copy)
}

notepadRepository.insertNotepad(copy)
}
}

Expand Down Expand Up @@ -342,13 +368,17 @@ class MainViewModel
}



fun deleteEmptyNote() {
viewModelScope.launch(Dispatchers.IO) {
val emptyList = notepadRepository
.getNotePads()
.first()
.map { it.toNotePadUiState(getTime = dateShortStringUsercase::invoke, toPath = contentManager::getImagePath) }
.map {
it.toNotePadUiState(
getTime = dateShortStringUsercase::invoke,
toPath = contentManager::getImagePath
)
}
.filter { it.isEmpty() }

if (emptyList.isNotEmpty()) {
Expand Down Expand Up @@ -384,19 +414,21 @@ class MainViewModel
DatePickerDefaults.YearRange,
DisplayMode.Picker
)

@OptIn(ExperimentalMaterial3Api::class)
var timePicker: TimePickerState = TimePickerState(12, 4, is24Hour = false)
private lateinit var currentLocalDate :LocalDate
private lateinit var currentLocalDate: LocalDate

//date and time dialog logic

private fun initDate() {
val now = Clock.System.now()
today = now.toLocalDateTime(TimeZone.currentSystemDefault())
val today2=now.plus(10, DateTimeUnit.MINUTE).toLocalDateTime(TimeZone.currentSystemDefault())
val today2 =
now.plus(10, DateTimeUnit.MINUTE).toLocalDateTime(TimeZone.currentSystemDefault())
currentDateTime = today2
currentLocalDate=currentDateTime.date
Log.e("current date",currentLocalDate.toString())
currentLocalDate = currentDateTime.date
Timber.tag("current date").e(currentLocalDate.toString())


val timeList = mutableListOf(
Expand Down Expand Up @@ -446,13 +478,13 @@ class MainViewModel
trail = time12UserCase(timeListDefault[index])
)
} else {
timeListDefault[timeListDefault.lastIndex]=currentDateTime.time
dateListUiState.copy( value = time12UserCase(currentDateTime.time))
timeListDefault[timeListDefault.lastIndex] = currentDateTime.time
dateListUiState.copy(value = time12UserCase(currentDateTime.time))

}
}
.toImmutableList()
val datelist=listOf(
val datelist = listOf(
DateListUiState(
title = "Today",
value = "Today",
Expand Down Expand Up @@ -480,10 +512,10 @@ class MainViewModel
_dateTimeState.update {
it.copy(
isEdit = false,
currentTime = timeList.lastIndex ,
currentTime = timeList.lastIndex,
timeData = timeList,
timeError = today>currentDateTime,
currentDate = 0,
timeError = today > currentDateTime,
currentDate = 0,
dateData = datelist,
currentInterval = interval,
interval = listOf(
Expand Down Expand Up @@ -537,14 +569,14 @@ class MainViewModel
)
}
} else {
val date2=if (index==0)today.date else today.date.plus(1,DateTimeUnit.DAY)
val time=timeListDefault[dateTimeState.value.currentTime]
val localtimedate=LocalDateTime(date2,time)
val date2 = if (index == 0) today.date else today.date.plus(1, DateTimeUnit.DAY)
val time = timeListDefault[dateTimeState.value.currentTime]
val localtimedate = LocalDateTime(date2, time)
_dateTimeState.update {

it.copy(
currentDate = index,
timeError = today>localtimedate
timeError = today > localtimedate
)
}
val date = if (index == 0)
Expand All @@ -557,7 +589,6 @@ class MainViewModel
}



@OptIn(ExperimentalMaterial3Api::class)
fun setDatePicker(date: Long) {
datePicker = DatePickerState(
Expand Down Expand Up @@ -619,12 +650,14 @@ class MainViewModel

val setime = LocalDateTime(date, time)
if (setime > today) {
setAlarm(setime
.toInstant(TimeZone.currentSystemDefault())
.toEpochMilliseconds(), interval)
Log.e("editv","Set Alarm")
}else{
Log.e("editv","Alarm not set $today time $time date$date")
setAlarm(
setime
.toInstant(TimeZone.currentSystemDefault())
.toEpochMilliseconds(), interval
)
Log.e("editv", "Set Alarm")
} else {
Log.e("editv", "Alarm not set $today time $time date$date")
}

}
Expand All @@ -648,8 +681,8 @@ class MainViewModel
val date = Instant.fromEpochMilliseconds(timee)
.toLocalDateTime(TimeZone.currentSystemDefault())
currentLocalDate = date.date
val time=timeListDefault[dateTimeState.value.currentTime]
val localtimedate=LocalDateTime(currentLocalDate,time)
val time = timeListDefault[dateTimeState.value.currentTime]
val localtimedate = LocalDateTime(currentLocalDate, time)

_dateTimeState.update {
val im = it.dateData.toMutableList()
Expand All @@ -658,7 +691,7 @@ class MainViewModel
it.copy(
dateData = im.toImmutableList(),
currentDate = im.lastIndex,
timeError = today>localtimedate
timeError = today > localtimedate
)
}

Expand All @@ -676,9 +709,9 @@ class MainViewModel
1 -> today.date.plus(1, DateTimeUnit.DAY)
else -> currentLocalDate
}
val datetime=LocalDateTime(date,time)
val datetime = LocalDateTime(date, time)

Log.e("onSettime","current $today date $datetime")
Log.e("onSettime", "current $today date $datetime")


_dateTimeState.update {
Expand All @@ -687,7 +720,7 @@ class MainViewModel
it.copy(
timeData = im.toImmutableList(),
currentTime = im.lastIndex,
timeError = datetime<today
timeError = datetime < today
)
}
}
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ kotlin.code.style=official
android.nonTransitiveRClass=true
org.gradle.unsafe.configuration-cache=true

android.enableVcsInfo=true
Loading

0 comments on commit 8cd7c26

Please sign in to comment.