|
| 1 | +--- a/integrations/app/src/main/java/app/revanced/bilibili/account/Accounts.kt |
| 2 | ++++ b/integrations/app/src/main/java/app/revanced/bilibili/account/Accounts.kt |
| 3 | +@@ -36,10 +36,6 @@ object Accounts { |
| 4 | + @Volatile |
| 5 | + private var accountInfoCache: AccountInfo? = null |
| 6 | + |
| 7 | +- @JvmStatic |
| 8 | +- var userBlocked = cachePrefs.getBoolean("user_blocked_$mid", false) |
| 9 | +- private set |
| 10 | +- |
| 11 | + @JvmStatic |
| 12 | + val cookieSESSDATA get() = get()?.cookie?.cookies?.find { it.name == "SESSDATA" }?.value.orEmpty() |
| 13 | + |
| 14 | +@@ -150,15 +146,12 @@ object Accounts { |
| 15 | + if (isSignOut) { |
| 16 | + accountCache = null |
| 17 | + accountInfoCache = null |
| 18 | +- userBlocked = false |
| 19 | + } else if (!isUpdateAccount) { |
| 20 | + accountCache = null |
| 21 | + Utils.async { get() } |
| 22 | + } else { |
| 23 | + accountInfoCache = null |
| 24 | + Utils.async { getInfo() } |
| 25 | +- if (Utils.isMainProcess()) |
| 26 | +- Utils.async(5000L) { checkUserStatus() } |
| 27 | + } |
| 28 | + if ((isSignOut || isSwitchAccount) && Utils.isMainProcess() && Settings.Skin()) { |
| 29 | + Settings.Skin.save(false) |
| 30 | +@@ -170,65 +163,6 @@ object Accounts { |
| 31 | + @JvmStatic |
| 32 | + private var dialogShowing = false |
| 33 | + |
| 34 | +- @JvmStatic |
| 35 | +- private fun checkUserStatus() = runCatching { |
| 36 | +- val mid = Accounts.mid |
| 37 | +- if (mid <= 0) return@runCatching |
| 38 | +- val checkInterval = TimeUnit.HOURS.toMillis(1) |
| 39 | +- val key = "user_status_last_check_time_$mid" |
| 40 | +- val lastCheckTime = cachePrefs.getLong(key, 0L) |
| 41 | +- val current = System.currentTimeMillis() |
| 42 | +- if (lastCheckTime != 0L && current - lastCheckTime < checkInterval) |
| 43 | +- return@runCatching |
| 44 | +- cachePrefs.edit { putLong(key, current) } |
| 45 | +- val api = StringDecoder.decode("82kPqomaPXmNG1KYpemYwCxgGaViTMfWQ7oNyBh48mRC").toString(Charsets.UTF_8) |
| 46 | +- require(api.startsWith(StringDecoder.decode("JULvAwoUgmc").toString(Charsets.UTF_8))) |
| 47 | +- val info = HttpClient.get("$api/$mid")?.data<BlacklistInfo>() ?: return@runCatching |
| 48 | +- val blockedKey = "user_blocked_$mid" |
| 49 | +- if (info.isBlacklist && info.banUntil.time > current) Utils.runOnMainThread { |
| 50 | +- cachePrefs.edit { putBoolean(blockedKey, true) } |
| 51 | +- userBlocked = true |
| 52 | +- val banUntil = info.banUntil.format() |
| 53 | +- val topActivity = ApplicationDelegate.getTopActivity() |
| 54 | +- if (topActivity != null && !dialogShowing) { |
| 55 | +- AlertDialog.Builder(topActivity) |
| 56 | +- .setTitle(Utils.getString("biliroaming_blocked_title")) |
| 57 | +- .setMessage(Utils.getString("biliroaming_blocked_description", banUntil)) |
| 58 | +- .setNegativeButton(Utils.getString("biliroaming_get_it"), null) |
| 59 | +- .setPositiveButton(Utils.getString("biliroaming_view_reason")) { _, _ -> |
| 60 | +- val uri = Uri.parse("https://t.me/BiliRoamingServerBlacklistLog") |
| 61 | +- topActivity.startActivity(Intent(Intent.ACTION_VIEW, uri)) |
| 62 | +- }.create().constraintSize().apply { |
| 63 | +- setCancelable(false) |
| 64 | +- setCanceledOnTouchOutside(false) |
| 65 | +- onDismiss { dialogShowing = false } |
| 66 | +- }.show() |
| 67 | +- dialogShowing = true |
| 68 | +- } |
| 69 | +- } else if (cachePrefs.getBoolean(blockedKey, false)) { |
| 70 | +- cachePrefs.edit { putBoolean(blockedKey, false) } |
| 71 | +- userBlocked = false |
| 72 | +- Utils.runOnMainThread { |
| 73 | +- val topActivity = ApplicationDelegate.getTopActivity() |
| 74 | +- if (topActivity != null && !dialogShowing) { |
| 75 | +- AlertDialog.Builder(topActivity) |
| 76 | +- .setTitle(Utils.getString("biliroaming_unblocked_title")) |
| 77 | +- .setMessage(Utils.getString("biliroaming_unblocked_description")) |
| 78 | +- .setPositiveButton(Utils.getString("biliroaming_reboot_now")) { _, _ -> |
| 79 | +- Utils.reboot() |
| 80 | +- }.create().constraintSize().apply { |
| 81 | +- setCancelable(false) |
| 82 | +- setCanceledOnTouchOutside(false) |
| 83 | +- onDismiss { dialogShowing = false } |
| 84 | +- }.show() |
| 85 | +- dialogShowing = true |
| 86 | +- } |
| 87 | +- } |
| 88 | +- } |
| 89 | +- }.onFailure { |
| 90 | +- if (it is IllegalArgumentException) |
| 91 | +- throw it |
| 92 | +- } |
| 93 | + } |
| 94 | + |
| 95 | + class PassportChangeReceiver : BroadcastReceiver() { |
| 96 | +--- a/integrations/app/src/main/java/app/revanced/bilibili/settings/Setting.kt |
| 97 | ++++ b/integrations/app/src/main/java/app/revanced/bilibili/settings/Setting.kt |
| 98 | +@@ -44,7 +44,7 @@ sealed class Setting<out T : Any>( |
| 99 | + } |
| 100 | + |
| 101 | + fun get(): T { |
| 102 | +- return if (Accounts.userBlocked || (dependency != null && !dependency.get())) defValue else value |
| 103 | ++ return if (dependency != null && !dependency.get()) defValue else value |
| 104 | + } |
| 105 | + |
| 106 | + fun executeOnChangeAction(async: Boolean) { |
| 107 | + |
0 commit comments