mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
idk
This commit is contained in:
parent
978e207096
commit
ff24cd8d18
6 changed files with 65 additions and 5 deletions
|
|
@ -19,7 +19,15 @@ import io.realm.annotations.Ignore
|
|||
import io.realm.annotations.PrimaryKey
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.format.DateTimeFormatterBuilder
|
||||
import java.time.temporal.TemporalAccessor
|
||||
import java.util.Calendar
|
||||
import java.util.Date
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
|
||||
override val realmClass: Class<Task>
|
||||
|
|
@ -194,6 +202,46 @@ open class Task : RealmObject, BaseMainObject, Parcelable, BaseTask {
|
|||
|
||||
fun checkIfDue(): Boolean = isDue == true
|
||||
|
||||
fun getNextReminderOccurence(oldTime: String?): ZonedDateTime? {
|
||||
if (oldTime == null) {
|
||||
return null
|
||||
}
|
||||
val nextDate = nextDue?.firstOrNull()
|
||||
|
||||
return if (nextDate != null && !isDisplayedActive) {
|
||||
val nextDueCalendar = GregorianCalendar()
|
||||
nextDueCalendar.time = nextDate
|
||||
parse(oldTime)
|
||||
?.withYear(nextDueCalendar.get(Calendar.YEAR))
|
||||
?.withMonth(nextDueCalendar.get(Calendar.MONTH))
|
||||
?.withDayOfMonth(nextDueCalendar.get(Calendar.DAY_OF_MONTH))
|
||||
} else if (isDisplayedActive) {
|
||||
parse(oldTime)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
fun formatter(): DateTimeFormatter =
|
||||
DateTimeFormatterBuilder().append(DateTimeFormatter.ISO_LOCAL_DATE)
|
||||
.appendPattern("['T'][' ']")
|
||||
.append(DateTimeFormatter.ISO_LOCAL_TIME)
|
||||
.appendPattern("[XX]")
|
||||
.toFormatter()
|
||||
|
||||
fun parse(dateTime: String): ZonedDateTime? {
|
||||
val parsed: TemporalAccessor = formatter().parseBest(
|
||||
dateTime,
|
||||
ZonedDateTime::from, LocalDateTime::from
|
||||
)
|
||||
return if (parsed is ZonedDateTime) {
|
||||
parsed
|
||||
} else {
|
||||
val defaultZone: ZoneId = ZoneId.of("UTC")
|
||||
(parsed as LocalDateTime).atZone(defaultZone)
|
||||
}
|
||||
}
|
||||
|
||||
fun parseMarkdown() {
|
||||
parsedText = MarkdownParser.parseMarkdown(text)
|
||||
parsedNotes = MarkdownParser.parseMarkdown(notes)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="white">#ffffff</color>
|
||||
<color name="black">#000000</color>
|
||||
<color name="watch_white">#ffffff</color>
|
||||
<color name="watch_black">#000000</color>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
NAME=4.0
|
||||
CODE=4040
|
||||
CODE=4050
|
||||
|
|
@ -4,6 +4,7 @@ import android.app.Application
|
|||
import android.content.Intent
|
||||
import com.habitrpg.common.habitica.extensions.setupCoil
|
||||
import com.habitrpg.common.habitica.helpers.MarkdownParser
|
||||
import com.habitrpg.common.habitica.models.tasks.TaskType
|
||||
import com.habitrpg.wearos.habitica.data.repositories.TaskRepository
|
||||
import com.habitrpg.wearos.habitica.data.repositories.UserRepository
|
||||
import com.habitrpg.wearos.habitica.ui.activities.BaseActivity
|
||||
|
|
@ -13,6 +14,8 @@ import dagger.hilt.android.HiltAndroidApp
|
|||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
|
@ -35,6 +38,13 @@ class MainApplication : Application() {
|
|||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
} else if (it.needsCron && BaseActivity.currentActivityClassName != RYAActivity::class.java.name) {
|
||||
val dueDailies = taskRepository.getTasks(TaskType.DAILY)
|
||||
.map { it.filter { task -> task.isDisplayedActive } }
|
||||
.first()
|
||||
if (dueDailies.isEmpty()) {
|
||||
userRepository.runCron()
|
||||
return@onEach
|
||||
}
|
||||
val intent = Intent(this@MainApplication, RYAActivity::class.java)
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
startActivity(intent)
|
||||
|
|
|
|||
|
|
@ -123,10 +123,6 @@ open class Task constructor(): Parcelable, BaseTask {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other == null) {
|
||||
return false
|
||||
|
|
|
|||
4
wearos/src/main/res/values-w450dp/dimens.xml
Normal file
4
wearos/src/main/res/values-w450dp/dimens.xml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="row_padding_horizontal">12dp</dimen>
|
||||
</resources>
|
||||
Loading…
Reference in a new issue