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