Handle more deprecated items
This commit is contained in:
parent
1e55a3f21a
commit
aeaf52cb58
@ -313,6 +313,7 @@ tasks {
|
|||||||
"-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
|
"-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
|
||||||
"-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
|
"-Xuse-experimental=kotlinx.serialization.ExperimentalSerializationApi",
|
||||||
"-Xuse-experimental=coil.annotation.ExperimentalCoilApi",
|
"-Xuse-experimental=coil.annotation.ExperimentalCoilApi",
|
||||||
|
"-Xuse-experimental=kotlin.time.ExperimentalTime",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ import exh.log.XLogTree
|
|||||||
import exh.log.xLogD
|
import exh.log.xLogD
|
||||||
import exh.log.xLogE
|
import exh.log.xLogE
|
||||||
import exh.syDebugVersion
|
import exh.syDebugVersion
|
||||||
|
import exh.util.days
|
||||||
import io.realm.Realm
|
import io.realm.Realm
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
@ -70,8 +71,6 @@ import java.security.Security
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import javax.net.ssl.SSLContext
|
import javax.net.ssl.SSLContext
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.days
|
|
||||||
|
|
||||||
open class App : Application(), LifecycleObserver, ImageLoaderFactory {
|
open class App : Application(), LifecycleObserver, ImageLoaderFactory {
|
||||||
|
|
||||||
@ -231,7 +230,6 @@ open class App : Application(), LifecycleObserver, ImageLoaderFactory {
|
|||||||
|
|
||||||
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
|
val dateFormat = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
printers += EnhancedFilePrinter
|
printers += EnhancedFilePrinter
|
||||||
.Builder(logFolder.absolutePath) {
|
.Builder(logFolder.absolutePath) {
|
||||||
fileNameGenerator = object : DateFileNameGenerator() {
|
fileNameGenerator = object : DateFileNameGenerator() {
|
||||||
@ -245,7 +243,7 @@ open class App : Application(), LifecycleObserver, ImageLoaderFactory {
|
|||||||
flattener { timeMillis, level, tag, message ->
|
flattener { timeMillis, level, tag, message ->
|
||||||
"${dateFormat.format(timeMillis)} ${LogLevel.getShortLevelName(level)}/$tag: $message"
|
"${dateFormat.format(timeMillis)} ${LogLevel.getShortLevelName(level)}/$tag: $message"
|
||||||
}
|
}
|
||||||
cleanStrategy = FileLastModifiedCleanStrategy(7.days.toLongMilliseconds())
|
cleanStrategy = FileLastModifiedCleanStrategy(7.days.inWholeMilliseconds)
|
||||||
backupStrategy = NeverBackupStrategy()
|
backupStrategy = NeverBackupStrategy()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class SourcePresenter(
|
|||||||
// SY -->
|
// SY -->
|
||||||
val categories = mutableListOf<SourceCategory>()
|
val categories = mutableListOf<SourceCategory>()
|
||||||
|
|
||||||
preferences.sourcesTabCategories().get().sortedByDescending { it.toLowerCase() }.forEach {
|
preferences.sourcesTabCategories().get().sortedByDescending { it.lowercase() }.forEach {
|
||||||
categories.add(SourceCategory(it))
|
categories.add(SourceCategory(it))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ class SourcePresenter(
|
|||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
categories.forEach {
|
categories.forEach {
|
||||||
sourceItems = it.sources.sortedBy { sourceItem -> sourceItem.source.name.toLowerCase() } + sourceItems
|
sourceItems = it.sources.sortedBy { sourceItem -> sourceItem.source.name.lowercase() } + sourceItems
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
|
@ -8,16 +8,14 @@ import com.bluelinelabs.conductor.Controller
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
import eu.kanade.tachiyomi.ui.base.controller.DialogController
|
||||||
import exh.log.xLogD
|
import exh.log.xLogD
|
||||||
|
import exh.util.hours
|
||||||
|
import exh.util.minutes
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.hours
|
|
||||||
import kotlin.time.minutes
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog to create a new category for the library.
|
* Dialog to create a new category for the library.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
class BiometricTimesCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
class BiometricTimesCreateDialog<T>(bundle: Bundle? = null) : DialogController(bundle)
|
||||||
where T : Controller, T : BiometricTimesCreateDialog.Listener {
|
where T : Controller, T : BiometricTimesCreateDialog.Listener {
|
||||||
|
|
||||||
|
@ -2,28 +2,24 @@ package eu.kanade.tachiyomi.ui.category.biometric
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
|
import exh.util.hours
|
||||||
|
import exh.util.minutes
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.SimpleTimeZone
|
import java.util.SimpleTimeZone
|
||||||
import kotlin.math.floor
|
|
||||||
import kotlin.math.roundToInt
|
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.hours
|
|
||||||
import kotlin.time.minutes
|
|
||||||
|
|
||||||
@ExperimentalTime
|
|
||||||
data class TimeRange(val startTime: Duration, val endTime: Duration) {
|
data class TimeRange(val startTime: Duration, val endTime: Duration) {
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
val startHour = floor(startTime.inHours).roundToInt()
|
val startHour = startTime.inWholeHours
|
||||||
val startMinute = (startTime - floor(startTime.inHours).hours).inMinutes.roundToInt()
|
val startMinute = (startTime - startHour.hours).inWholeMinutes
|
||||||
val endHour = floor(endTime.inHours).roundToInt()
|
val endHour = endTime.inWholeHours
|
||||||
val endMinute = (endTime - floor(endTime.inHours).hours).inMinutes.roundToInt()
|
val endMinute = (endTime - endHour.hours).inWholeMinutes
|
||||||
return String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)
|
return String.format("%02d:%02d - %02d:%02d", startHour, startMinute, endHour, endMinute)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFormattedString(context: Context): String {
|
fun getFormattedString(context: Context): String {
|
||||||
val startDate = Date(startTime.toLongMilliseconds())
|
val startDate = Date(startTime.inWholeMilliseconds)
|
||||||
val endDate = Date(endTime.toLongMilliseconds())
|
val endDate = Date(endTime.inWholeMilliseconds)
|
||||||
val format = DateFormat.getTimeFormat(context)
|
val format = DateFormat.getTimeFormat(context)
|
||||||
format.timeZone = SimpleTimeZone(0, "UTC")
|
format.timeZone = SimpleTimeZone(0, "UTC")
|
||||||
|
|
||||||
@ -31,7 +27,7 @@ data class TimeRange(val startTime: Duration, val endTime: Duration) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun toPreferenceString(): String {
|
fun toPreferenceString(): String {
|
||||||
return "${startTime.inMinutes},${endTime.inMinutes}"
|
return "${startTime.inWholeMinutes},${endTime.inWholeMinutes}"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun conflictsWith(other: TimeRange): Boolean {
|
fun conflictsWith(other: TimeRange): Boolean {
|
||||||
|
@ -49,6 +49,7 @@ import exh.source.isEhBasedManga
|
|||||||
import exh.source.mangaDexSourceIds
|
import exh.source.mangaDexSourceIds
|
||||||
import exh.source.nHentaiSourceIds
|
import exh.source.nHentaiSourceIds
|
||||||
import exh.ui.LoaderManager
|
import exh.ui.LoaderManager
|
||||||
|
import exh.util.milliseconds
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
@ -59,8 +60,6 @@ import reactivecircus.flowbinding.viewpager.pageSelections
|
|||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.milliseconds
|
|
||||||
|
|
||||||
class LibraryController(
|
class LibraryController(
|
||||||
bundle: Bundle? = null,
|
bundle: Bundle? = null,
|
||||||
@ -674,7 +673,6 @@ class LibraryController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
override fun onAttach(view: View) {
|
override fun onAttach(view: View) {
|
||||||
super.onAttach(view)
|
super.onAttach(view)
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||||
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
|
import eu.kanade.tachiyomi.databinding.TrackSearchItemBinding
|
||||||
import eu.kanade.tachiyomi.util.view.inflate
|
import eu.kanade.tachiyomi.util.view.inflate
|
||||||
|
import exh.util.capitalize
|
||||||
|
|
||||||
class TrackSearchAdapter(context: Context) :
|
class TrackSearchAdapter(context: Context) :
|
||||||
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, mutableListOf<TrackSearch>()) {
|
ArrayAdapter<TrackSearch>(context, R.layout.track_search_item, mutableListOf<TrackSearch>()) {
|
||||||
|
@ -82,6 +82,7 @@ import exh.log.xLogE
|
|||||||
import exh.source.isEhBasedSource
|
import exh.source.isEhBasedSource
|
||||||
import exh.util.defaultReaderType
|
import exh.util.defaultReaderType
|
||||||
import exh.util.mangaType
|
import exh.util.mangaType
|
||||||
|
import exh.util.seconds
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@ -99,9 +100,6 @@ import timber.log.Timber
|
|||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.abs
|
import kotlin.math.abs
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.seconds
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activity containing the reader of Tachiyomi. This activity is mostly a container of the
|
* Activity containing the reader of Tachiyomi. This activity is mostly a container of the
|
||||||
* viewers, to which calls from the presenter or UI events are delegated.
|
* viewers, to which calls from the presenter or UI events are delegated.
|
||||||
@ -236,7 +234,6 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
private fun setupAutoscroll(interval: Double) {
|
private fun setupAutoscroll(interval: Double) {
|
||||||
autoScrollJob?.cancel()
|
autoScrollJob?.cancel()
|
||||||
if (interval == -1.0) return
|
if (interval == -1.0) return
|
||||||
|
@ -7,14 +7,13 @@ import androidx.lifecycle.lifecycleScope
|
|||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.ui.category.biometric.TimeRange
|
import eu.kanade.tachiyomi.ui.category.biometric.TimeRange
|
||||||
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
import eu.kanade.tachiyomi.util.system.AuthenticatorUtil
|
||||||
|
import exh.util.hours
|
||||||
|
import exh.util.minutes
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.hours
|
|
||||||
import kotlin.time.minutes
|
|
||||||
|
|
||||||
class SecureActivityDelegate(private val activity: FragmentActivity) {
|
class SecureActivityDelegate(private val activity: FragmentActivity) {
|
||||||
|
|
||||||
@ -48,7 +47,6 @@ class SecureActivityDelegate(private val activity: FragmentActivity) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
private fun isAppLocked(): Boolean {
|
private fun isAppLocked(): Boolean {
|
||||||
if (!locked) {
|
if (!locked) {
|
||||||
return false
|
return false
|
||||||
|
@ -47,9 +47,13 @@ import exh.metadata.metadata.base.getFlatMetadataForManga
|
|||||||
import exh.source.isEhBasedManga
|
import exh.source.isEhBasedManga
|
||||||
import exh.uconfig.WarnConfigureDialogController
|
import exh.uconfig.WarnConfigureDialogController
|
||||||
import exh.ui.login.EhLoginActivity
|
import exh.ui.login.EhLoginActivity
|
||||||
|
import exh.util.days
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
import exh.util.floor
|
import exh.util.hours
|
||||||
|
import exh.util.milliseconds
|
||||||
|
import exh.util.minutes
|
||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
|
import exh.util.seconds
|
||||||
import exh.util.trans
|
import exh.util.trans
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
@ -61,12 +65,6 @@ import kotlinx.serialization.decodeFromString
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import kotlin.time.Duration
|
import kotlin.time.Duration
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.days
|
|
||||||
import kotlin.time.hours
|
|
||||||
import kotlin.time.milliseconds
|
|
||||||
import kotlin.time.minutes
|
|
||||||
import kotlin.time.seconds
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EH Settings fragment
|
* EH Settings fragment
|
||||||
@ -649,7 +647,6 @@ class SettingsEhController : SettingsController() {
|
|||||||
.cancelable(false)
|
.cancelable(false)
|
||||||
progress.show()
|
progress.show()
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
viewScope.launch(Dispatchers.IO) {
|
viewScope.launch(Dispatchers.IO) {
|
||||||
val updateInfo = try {
|
val updateInfo = try {
|
||||||
val stats =
|
val stats =
|
||||||
@ -669,7 +666,7 @@ class SettingsEhController : SettingsController() {
|
|||||||
}.toList()
|
}.toList()
|
||||||
|
|
||||||
fun metaInRelativeDuration(duration: Duration): Int {
|
fun metaInRelativeDuration(duration: Duration): Int {
|
||||||
val durationMs = duration.toLongMilliseconds()
|
val durationMs = duration.inWholeMilliseconds
|
||||||
return allMeta.asSequence().filter {
|
return allMeta.asSequence().filter {
|
||||||
System.currentTimeMillis() - it.lastUpdateCheck < durationMs
|
System.currentTimeMillis() - it.lastUpdateCheck < durationMs
|
||||||
}.count()
|
}.count()
|
||||||
@ -703,7 +700,6 @@ class SettingsEhController : SettingsController() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
private fun getRelativeTimeFromNow(then: Duration): RelativeTime {
|
private fun getRelativeTimeFromNow(then: Duration): RelativeTime {
|
||||||
val now = System.currentTimeMillis().milliseconds
|
val now = System.currentTimeMillis().milliseconds
|
||||||
var period: Duration = now - then
|
var period: Duration = now - then
|
||||||
@ -711,50 +707,50 @@ class SettingsEhController : SettingsController() {
|
|||||||
while (period > 0.milliseconds) {
|
while (period > 0.milliseconds) {
|
||||||
when {
|
when {
|
||||||
period >= 365.days -> {
|
period >= 365.days -> {
|
||||||
(period.inDays / 365).floor().let {
|
(period.inWholeDays / 365).let {
|
||||||
relativeTime.years = it
|
relativeTime.years = it
|
||||||
period -= (it * 365).days
|
period -= (it * 365).days
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
period >= 30.days -> {
|
period >= 30.days -> {
|
||||||
(period.inDays / 30).floor().let {
|
(period.inWholeDays / 30).let {
|
||||||
relativeTime.months = it
|
relativeTime.months = it
|
||||||
period -= (it * 30).days
|
period -= (it * 30).days
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 7.days -> {
|
period >= 7.days -> {
|
||||||
(period.inDays / 7).floor().let {
|
(period.inWholeDays / 7).let {
|
||||||
relativeTime.weeks = it
|
relativeTime.weeks = it
|
||||||
period -= (it * 7).days
|
period -= (it * 7).days
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 1.days -> {
|
period >= 1.days -> {
|
||||||
period.inDays.floor().let {
|
period.inWholeDays.let {
|
||||||
relativeTime.days = it
|
relativeTime.days = it
|
||||||
period -= it.days
|
period -= it.days
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 1.hours -> {
|
period >= 1.hours -> {
|
||||||
period.inHours.floor().let {
|
period.inWholeHours.let {
|
||||||
relativeTime.hours = it
|
relativeTime.hours = it
|
||||||
period -= it.hours
|
period -= it.hours
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 1.minutes -> {
|
period >= 1.minutes -> {
|
||||||
period.inMinutes.floor().let {
|
period.inWholeMinutes.let {
|
||||||
relativeTime.minutes = it
|
relativeTime.minutes = it
|
||||||
period -= it.minutes
|
period -= it.minutes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 1.seconds -> {
|
period >= 1.seconds -> {
|
||||||
period.inSeconds.floor().let {
|
period.inWholeSeconds.let {
|
||||||
relativeTime.seconds = it
|
relativeTime.seconds = it
|
||||||
period -= it.seconds
|
period -= it.seconds
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
period >= 1.milliseconds -> {
|
period >= 1.milliseconds -> {
|
||||||
period.inMilliseconds.floor().let {
|
period.inWholeMilliseconds.let {
|
||||||
relativeTime.milliseconds = it
|
relativeTime.milliseconds = it
|
||||||
}
|
}
|
||||||
period = 0.milliseconds
|
period = 0.milliseconds
|
||||||
@ -765,17 +761,26 @@ class SettingsEhController : SettingsController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getRelativeTimeString(relativeTime: RelativeTime, context: Context): String {
|
private fun getRelativeTimeString(relativeTime: RelativeTime, context: Context): String {
|
||||||
return relativeTime.years?.let { context.resources.getQuantityString(R.plurals.humanize_year, it, it) }
|
return relativeTime.years?.let { context.resources.getQuantityString(R.plurals.humanize_year, it.toInt(), it) }
|
||||||
?: relativeTime.months?.let { context.resources.getQuantityString(R.plurals.humanize_month, it, it) }
|
?: relativeTime.months?.let { context.resources.getQuantityString(R.plurals.humanize_month, it.toInt(), it) }
|
||||||
?: relativeTime.weeks?.let { context.resources.getQuantityString(R.plurals.humanize_week, it, it) }
|
?: relativeTime.weeks?.let { context.resources.getQuantityString(R.plurals.humanize_week, it.toInt(), it) }
|
||||||
?: relativeTime.days?.let { context.resources.getQuantityString(R.plurals.humanize_day, it, it) }
|
?: relativeTime.days?.let { context.resources.getQuantityString(R.plurals.humanize_day, it.toInt(), it) }
|
||||||
?: relativeTime.hours?.let { context.resources.getQuantityString(R.plurals.humanize_hour, it, it) }
|
?: relativeTime.hours?.let { context.resources.getQuantityString(R.plurals.humanize_hour, it.toInt(), it) }
|
||||||
?: relativeTime.minutes?.let { context.resources.getQuantityString(R.plurals.humanize_minute, it, it) }
|
?: relativeTime.minutes?.let { context.resources.getQuantityString(R.plurals.humanize_minute, it.toInt(), it) }
|
||||||
?: relativeTime.seconds?.let { context.resources.getQuantityString(R.plurals.humanize_second, it, it) }
|
?: relativeTime.seconds?.let { context.resources.getQuantityString(R.plurals.humanize_second, it.toInt(), it) }
|
||||||
?: context.getString(R.string.humanize_fallback)
|
?: context.getString(R.string.humanize_fallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
data class RelativeTime(var years: Int? = null, var months: Int? = null, var weeks: Int? = null, var days: Int? = null, var hours: Int? = null, var minutes: Int? = null, var seconds: Int? = null, var milliseconds: Int? = null)
|
data class RelativeTime(
|
||||||
|
var years: Long? = null,
|
||||||
|
var months: Long? = null,
|
||||||
|
var weeks: Long? = null,
|
||||||
|
var days: Long? = null,
|
||||||
|
var hours: Long? = null,
|
||||||
|
var minutes: Long? = null,
|
||||||
|
var seconds: Long? = null,
|
||||||
|
var milliseconds: Long? = null
|
||||||
|
)
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
if (resultCode == Activity.RESULT_OK) {
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
@ -20,7 +20,7 @@ enum class DebugToggles(val default: Boolean) {
|
|||||||
// Pretend that all galleries only have a single version
|
// Pretend that all galleries only have a single version
|
||||||
INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS(false);
|
INCLUDE_ONLY_ROOT_WHEN_LOADING_EXH_VERSIONS(false);
|
||||||
|
|
||||||
val prefKey = "eh_debug_toggle_${name.toLowerCase(Locale.getDefault())}"
|
val prefKey = "eh_debug_toggle_${name.lowercase(Locale.US)}"
|
||||||
|
|
||||||
var enabled: Boolean
|
var enabled: Boolean
|
||||||
get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
|
get() = prefs.flowPrefs.getBoolean(prefKey, default).get()
|
||||||
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.util.preference.onClick
|
|||||||
import eu.kanade.tachiyomi.util.preference.preference
|
import eu.kanade.tachiyomi.util.preference.preference
|
||||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||||
|
import exh.util.capitalize
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlin.reflect.KVisibility
|
import kotlin.reflect.KVisibility
|
||||||
import kotlin.reflect.full.declaredFunctions
|
import kotlin.reflect.full.declaredFunctions
|
||||||
|
@ -28,7 +28,9 @@ import exh.metadata.metadata.base.getFlatMetadataForManga
|
|||||||
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
import exh.metadata.metadata.base.insertFlatMetadataAsync
|
||||||
import exh.source.isEhBasedManga
|
import exh.source.isEhBasedManga
|
||||||
import exh.util.cancellable
|
import exh.util.cancellable
|
||||||
|
import exh.util.days
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
|
import exh.util.hours
|
||||||
import exh.util.jobScheduler
|
import exh.util.jobScheduler
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
@ -46,9 +48,6 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
import kotlin.time.ExperimentalTime
|
|
||||||
import kotlin.time.days
|
|
||||||
import kotlin.time.hours
|
|
||||||
|
|
||||||
class EHentaiUpdateWorker : JobService() {
|
class EHentaiUpdateWorker : JobService() {
|
||||||
private val scope = CoroutineScope(Dispatchers.Default + Job())
|
private val scope = CoroutineScope(Dispatchers.Default + Job())
|
||||||
@ -289,8 +288,7 @@ class EHentaiUpdateWorker : JobService() {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val MAX_UPDATE_FAILURES = 5
|
private const val MAX_UPDATE_FAILURES = 5
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
private val MIN_BACKGROUND_UPDATE_FREQ = 1.days.inWholeMilliseconds
|
||||||
private val MIN_BACKGROUND_UPDATE_FREQ = 1.days.toLongMilliseconds()
|
|
||||||
|
|
||||||
private const val JOB_ID_UPDATE_BACKGROUND = 700000
|
private const val JOB_ID_UPDATE_BACKGROUND = 700000
|
||||||
private const val JOB_ID_UPDATE_BACKGROUND_TEST = 700001
|
private const val JOB_ID_UPDATE_BACKGROUND_TEST = 700001
|
||||||
@ -356,9 +354,8 @@ class EHentaiUpdateWorker : JobService() {
|
|||||||
val acRestriction = "ac" in restrictions
|
val acRestriction = "ac" in restrictions
|
||||||
val wifiRestriction = "wifi" in restrictions
|
val wifiRestriction = "wifi" in restrictions
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
|
||||||
val jobInfo = context.periodicBackgroundJobInfo(
|
val jobInfo = context.periodicBackgroundJobInfo(
|
||||||
duration.hours.toLongMilliseconds(),
|
duration.hours.inWholeMilliseconds,
|
||||||
acRestriction,
|
acRestriction,
|
||||||
wifiRestriction
|
wifiRestriction
|
||||||
)
|
)
|
||||||
@ -382,6 +379,5 @@ data class UpdateEntry(val manga: Manga, val meta: EHentaiSearchMetadata, val ro
|
|||||||
object EHentaiUpdateWorkerConstants {
|
object EHentaiUpdateWorkerConstants {
|
||||||
const val UPDATES_PER_ITERATION = 50
|
const val UPDATES_PER_ITERATION = 50
|
||||||
|
|
||||||
@OptIn(ExperimentalTime::class)
|
val GALLERY_AGE_TIME = 365.days.inWholeMilliseconds
|
||||||
val GALLERY_AGE_TIME = 365.days.toLongMilliseconds()
|
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import exh.metadata.metadata.MangaDexSearchMetadata
|
|||||||
import exh.metadata.metadata.base.RaisedTag
|
import exh.metadata.metadata.base.RaisedTag
|
||||||
import exh.metadata.metadata.base.getFlatMetadataForManga
|
import exh.metadata.metadata.base.getFlatMetadataForManga
|
||||||
import exh.metadata.metadata.base.insertFlatMetadata
|
import exh.metadata.metadata.base.insertFlatMetadata
|
||||||
|
import exh.util.capitalize
|
||||||
import exh.util.dropEmpty
|
import exh.util.dropEmpty
|
||||||
import exh.util.executeOnIO
|
import exh.util.executeOnIO
|
||||||
import exh.util.floor
|
import exh.util.floor
|
||||||
|
@ -13,6 +13,7 @@ import rx.Observable
|
|||||||
import tachiyomi.source.model.ChapterInfo
|
import tachiyomi.source.model.ChapterInfo
|
||||||
import tachiyomi.source.model.MangaInfo
|
import tachiyomi.source.model.MangaInfo
|
||||||
|
|
||||||
|
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
|
||||||
abstract class DelegatedHttpSource(val delegate: HttpSource) : HttpSource() {
|
abstract class DelegatedHttpSource(val delegate: HttpSource) : HttpSource() {
|
||||||
/**
|
/**
|
||||||
* Returns the request for the popular manga given the page.
|
* Returns the request for the popular manga given the page.
|
||||||
|
@ -12,6 +12,7 @@ import tachiyomi.source.model.ChapterInfo
|
|||||||
import tachiyomi.source.model.MangaInfo
|
import tachiyomi.source.model.MangaInfo
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
|
@Suppress("OverridingDeprecatedMember", "DEPRECATION")
|
||||||
class EnhancedHttpSource(
|
class EnhancedHttpSource(
|
||||||
val originalSource: HttpSource,
|
val originalSource: HttpSource,
|
||||||
val enhancedSource: HttpSource
|
val enhancedSource: HttpSource
|
||||||
|
32
app/src/main/java/exh/util/Duration.kt
Normal file
32
app/src/main/java/exh/util/Duration.kt
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package exh.util
|
||||||
|
|
||||||
|
import kotlin.time.DurationUnit
|
||||||
|
import kotlin.time.toDuration
|
||||||
|
|
||||||
|
val Int.nanoseconds get() = toDuration(DurationUnit.NANOSECONDS)
|
||||||
|
val Long.nanoseconds get() = toDuration(DurationUnit.NANOSECONDS)
|
||||||
|
val Double.nanoseconds get() = toDuration(DurationUnit.NANOSECONDS)
|
||||||
|
val Int.microseconds get() = toDuration(DurationUnit.MICROSECONDS)
|
||||||
|
val Long.microseconds get() = toDuration(DurationUnit.MICROSECONDS)
|
||||||
|
val Double.microseconds get() = toDuration(DurationUnit.MICROSECONDS)
|
||||||
|
val Int.milliseconds get() = toDuration(DurationUnit.MILLISECONDS)
|
||||||
|
val Long.milliseconds get() = toDuration(DurationUnit.MILLISECONDS)
|
||||||
|
val Double.milliseconds get() = toDuration(DurationUnit.MILLISECONDS)
|
||||||
|
val Int.seconds get() = toDuration(DurationUnit.SECONDS)
|
||||||
|
val Long.seconds get() = toDuration(DurationUnit.SECONDS)
|
||||||
|
val Double.seconds get() = toDuration(DurationUnit.SECONDS)
|
||||||
|
val Int.minutes get() = toDuration(DurationUnit.MINUTES)
|
||||||
|
val Long.minutes get() = toDuration(DurationUnit.MINUTES)
|
||||||
|
val Double.minutes get() = toDuration(DurationUnit.MINUTES)
|
||||||
|
val Int.hours get() = toDuration(DurationUnit.HOURS)
|
||||||
|
val Long.hours get() = toDuration(DurationUnit.HOURS)
|
||||||
|
val Double.hours get() = toDuration(DurationUnit.HOURS)
|
||||||
|
val Int.days get() = toDuration(DurationUnit.DAYS)
|
||||||
|
val Long.days get() = toDuration(DurationUnit.DAYS)
|
||||||
|
val Double.days get() = toDuration(DurationUnit.DAYS)
|
12
app/src/main/java/exh/util/String.kt
Normal file
12
app/src/main/java/exh/util/String.kt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package exh.util
|
||||||
|
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
|
fun String.capitalize(locale: Locale = Locale.getDefault()) =
|
||||||
|
replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }
|
Loading…
x
Reference in New Issue
Block a user