incognito

This commit is contained in:
Finnley Somdahl 2023-12-05 02:39:59 -06:00
parent c1a0eeb361
commit e77ab2800a
9 changed files with 119 additions and 33 deletions

View file

@ -13,27 +13,33 @@ import kotlinx.coroutines.launch
import kotlin.math.roundToInt
fun updateProgress(media: Media, number: String) {
if (Anilist.userid != null) {
CoroutineScope(Dispatchers.IO).launch {
val a = number.toFloatOrNull()?.toInt()
if ((a ?: 0) > (media.userProgress ?: 0)) {
Anilist.mutation.editList(
media.id,
a,
status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT"
)
MAL.query.editList(
media.idMAL,
media.anime != null,
a, null,
if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT"
)
toast(currContext()?.getString(R.string.setting_progress, a))
val incognito = currContext()?.getSharedPreferences("Dantotsu", 0)
?.getBoolean("incognito", false) ?: false
if (!incognito) {
if (Anilist.userid != null) {
CoroutineScope(Dispatchers.IO).launch {
val a = number.toFloatOrNull()?.toInt()
if ((a ?: 0) > (media.userProgress ?: 0)) {
Anilist.mutation.editList(
media.id,
a,
status = if (media.userStatus == "REPEATING") media.userStatus else "CURRENT"
)
MAL.query.editList(
media.idMAL,
media.anime != null,
a, null,
if (media.userStatus == "REPEATING") media.userStatus!! else "CURRENT"
)
toast(currContext()?.getString(R.string.setting_progress, a))
}
media.userProgress = a
Refresh.all()
}
media.userProgress = a
Refresh.all()
} else {
toast(currContext()?.getString(R.string.login_anilist_account))
}
} else {
toast(currContext()?.getString(R.string.login_anilist_account))
toast("Sneaky sneaky :3")
}
}

View file

@ -998,7 +998,9 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
preloading = false
val context = this
if (isOnline(context) && Discord.token != null) {
val incognito = this.getSharedPreferences("Dantotsu", MODE_PRIVATE)
.getBoolean("incognito", false)
if (isOnline(context) && Discord.token != null && !incognito) {
lifecycleScope.launch {
val presence = RPC.createPresence(RPC.Companion.RPCData(
applicationId = Discord.application_Id,
@ -1158,6 +1160,7 @@ class ExoplayerView : AppCompatActivity(), Player.Listener {
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.auto_update, media.userPreferredName))
.setMessage(getString(R.string.incognito_will_not_update))
.apply {
setOnCancelListener { hideSystemBars() }
setCancelable(false)

View file

@ -12,6 +12,7 @@ import android.view.*
import android.view.KeyEvent.*
import android.view.animation.OvershootInterpolator
import android.widget.AdapterView
import android.widget.CheckBox
import androidx.activity.addCallback
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
@ -253,20 +254,22 @@ class MangaReaderActivity : AppCompatActivity() {
showProgressDialog =
if (settings.askIndividual) loadData<Boolean>("${media.id}_progressDialog") != true else false
progressDialog =
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true)
if (showProgressDialog && Anilist.userid != null && if (media.isAdult) settings.updateForH else true) {
val dialogView = layoutInflater.inflate(R.layout.item_custom_dialog, null)
val checkbox = dialogView.findViewById<CheckBox>(R.id.dialog_checkbox)
checkbox.text = getString(R.string.dont_ask_again, media.userPreferredName)
checkbox.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) progressDialog = null
saveData("${media.id}_progressDialog", isChecked)
showProgressDialog = isChecked
}
AlertDialog.Builder(this, R.style.MyPopup)
.setTitle(getString(R.string.title_update_progress)).apply {
setMultiChoiceItems(
arrayOf(getString(R.string.dont_ask_again, media.userPreferredName)),
booleanArrayOf(false)
) { _, _, isChecked ->
if (isChecked) progressDialog = null
saveData("${media.id}_progressDialog", isChecked)
showProgressDialog = isChecked
}
.setTitle(getString(R.string.title_update_progress))
.setView(dialogView)
.apply {
setOnCancelListener { hideBars() }
}
else null
} else null
//Chapter Change
fun change(index: Int) {
@ -329,7 +332,9 @@ class MangaReaderActivity : AppCompatActivity() {
chaptersTitleArr.getOrNull(currentChapterIndex - 1) ?: ""
applySettings()
val context = this
if (isOnline(context) && Discord.token != null) {
val incognito = context.getSharedPreferences("Dantotsu", 0)
?.getBoolean("incognito", false) ?: false
if (isOnline(context) && Discord.token != null && !incognito) {
lifecycleScope.launch {
val presence = RPC.createPresence(
RPC.Companion.RPCData(

View file

@ -416,6 +416,16 @@ class SettingsActivity : AppCompatActivity() {
uiTheme(true, it)
}
binding.settingsIncognito.isChecked =
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).getBoolean(
"incognito",
false
)
binding.settingsIncognito.setOnCheckedChangeListener { _, isChecked ->
getSharedPreferences("Dantotsu", Context.MODE_PRIVATE).edit()
.putBoolean("incognito", isChecked).apply()
}
var previousStart: View = when (uiSettings.defaultStartUpTab) {
0 -> binding.uiSettingsAnime
1 -> binding.uiSettingsHome