move anilist to protected
This commit is contained in:
parent
cd96b6ab06
commit
025d31102e
4 changed files with 12 additions and 15 deletions
|
@ -8,6 +8,8 @@ import ani.dantotsu.R
|
|||
import ani.dantotsu.client
|
||||
import ani.dantotsu.currContext
|
||||
import ani.dantotsu.openLinkInBrowser
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.tryWithSuspend
|
||||
import java.io.File
|
||||
import java.util.Calendar
|
||||
|
@ -94,15 +96,12 @@ object Anilist {
|
|||
}
|
||||
}
|
||||
|
||||
fun getSavedToken(context: Context): Boolean {
|
||||
if ("anilistToken" in context.fileList()) {
|
||||
token = File(context.filesDir, "anilistToken").readText()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
fun getSavedToken(): Boolean {
|
||||
token = PrefManager.getVal(PrefName.AnilistToken, null as String?)
|
||||
return !token.isNullOrEmpty()
|
||||
}
|
||||
|
||||
fun removeSavedToken(context: Context) {
|
||||
fun removeSavedToken() {
|
||||
token = null
|
||||
username = null
|
||||
adult = false
|
||||
|
@ -111,9 +110,7 @@ object Anilist {
|
|||
bg = null
|
||||
episodesWatched = null
|
||||
chapterRead = null
|
||||
if ("anilistToken" in context.fileList()) {
|
||||
File(context.filesDir, "anilistToken").delete()
|
||||
}
|
||||
PrefManager.removeVal(PrefName.AnilistToken)
|
||||
}
|
||||
|
||||
suspend inline fun <reified T : Any> executeQuery(
|
||||
|
|
|
@ -6,6 +6,8 @@ import android.os.Bundle
|
|||
import androidx.appcompat.app.AppCompatActivity
|
||||
import ani.dantotsu.logError
|
||||
import ani.dantotsu.logger
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import ani.dantotsu.startMainActivity
|
||||
import ani.dantotsu.themes.ThemeManager
|
||||
|
||||
|
@ -19,10 +21,7 @@ class Login : AppCompatActivity() {
|
|||
try {
|
||||
Anilist.token =
|
||||
Regex("""(?<=access_token=).+(?=&token_type)""").find(data.toString())!!.value
|
||||
val filename = "anilistToken"
|
||||
this.openFileOutput(filename, Context.MODE_PRIVATE).use {
|
||||
it.write(Anilist.token!!.toByteArray())
|
||||
}
|
||||
PrefManager.setVal(PrefName.AnilistToken, Anilist.token?:"")
|
||||
} catch (e: Exception) {
|
||||
logError(e)
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
|||
DiscordId(Pref(Location.Protected, String::class, "")),
|
||||
DiscordUserName(Pref(Location.Protected, String::class, "")),
|
||||
DiscordAvatar(Pref(Location.Protected, String::class, "")),
|
||||
AnilistToken(Pref(Location.Protected, String::class, "")),
|
||||
AnilistUserName(Pref(Location.Protected, String::class, "")),
|
||||
MALCodeChallenge(Pref(Location.Protected, String::class, "")),
|
||||
MALToken(Pref(Location.Protected, MAL.ResponseToken::class, "")),
|
||||
|
|
|
@ -18,5 +18,5 @@ enum class Location(val location: String, val exportable: Boolean) {
|
|||
NovelReader("ani.dantotsu.novelReader", true),
|
||||
Irrelevant("ani.dantotsu.irrelevant", false),
|
||||
AnimeDownloads("animeDownloads", false), //different for legacy reasons
|
||||
Protected("ani.dantotsu.protected", false),
|
||||
Protected("ani.dantotsu.protected", true),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue