imported more settings

This commit is contained in:
aayush262 2024-01-30 17:34:01 +05:30
parent 922ccdfb27
commit c242fedfee
21 changed files with 90 additions and 52 deletions

View file

@ -7,8 +7,9 @@ import android.content.Context
import android.content.Intent
import ani.dantotsu.currContext
import ani.dantotsu.isOnline
import ani.dantotsu.loadData
import ani.dantotsu.logger
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
import ani.dantotsu.subcriptions.Subscription.Companion.startSubscription
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
@ -43,7 +44,7 @@ class AlarmReceiver : BroadcastReceiver() {
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
val alarmManager = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager
val curTime = loadData<Int>("subscriptions_time_s", context) ?: defaultTime
val curTime = PrefWrapper.getVal(PrefName.SubscriptionsTimeS, defaultTime)
if (timeMinutes[curTime] > 0)
alarmManager.setRepeating(

View file

@ -8,6 +8,8 @@ import androidx.core.app.NotificationManagerCompat
import ani.dantotsu.*
import ani.dantotsu.parsers.Episode
import ani.dantotsu.parsers.MangaChapter
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
@ -41,7 +43,7 @@ class Subscription {
val notificationManager = NotificationManagerCompat.from(context)
val progressEnabled =
loadData("subscription_checking_notifications", context) ?: true
PrefWrapper.getVal(PrefName.SubscriptionCheckingNotifications, true)
val progressNotification = if (progressEnabled) getProgressNotification(
context,
subscriptions.size

View file

@ -16,6 +16,8 @@ import ani.dantotsu.parsers.MangaChapter
import ani.dantotsu.parsers.MangaParser
import ani.dantotsu.parsers.MangaSources
import ani.dantotsu.saveData
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.tryWithSuspend
import kotlinx.coroutines.withTimeoutOrNull
@ -29,7 +31,7 @@ class SubscriptionHelper {
): Selected {
val data = loadData<Selected>("${mediaId}-select", context) ?: Selected().let {
it.sourceIndex = 0
it.preferDub = loadData("settings_prefer_dub", context) ?: false
it.preferDub = PrefWrapper.getVal(PrefName.SettingsPreferDub, false)
it
}
return data

View file

@ -9,6 +9,8 @@ import androidx.work.PeriodicWorkRequest
import androidx.work.WorkManager
import androidx.work.WorkerParameters
import ani.dantotsu.loadData
import ani.dantotsu.settings.saving.PrefName
import ani.dantotsu.settings.saving.PrefWrapper
import ani.dantotsu.subcriptions.Subscription.Companion.defaultTime
import ani.dantotsu.subcriptions.Subscription.Companion.timeMinutes
import kotlinx.coroutines.Dispatchers
@ -29,7 +31,7 @@ class SubscriptionWorker(val context: Context, params: WorkerParameters) :
private const val SUBSCRIPTION_WORK_NAME = "work_subscription"
fun enqueue(context: Context) {
val curTime = loadData<Int>("subscriptions_time_s") ?: defaultTime
val curTime = PrefWrapper.getVal(PrefName.SubscriptionsTimeS, defaultTime)
if (timeMinutes[curTime] > 0L) {
val constraints =
Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()