feat(Settings): Toggleable RPC (#513)
This commit is contained in:
parent
3071f88681
commit
b703337a16
7 changed files with 29 additions and 3 deletions
|
@ -1309,7 +1309,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
|
||||||
val ep = episode
|
val ep = episode
|
||||||
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
||||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||||
if ((isOnline(context) && !offline) && Discord.token != null && !incognito) {
|
val rpcenabled: Boolean = PrefManager.getVal(PrefName.rpcEnabled)
|
||||||
|
if ((isOnline(context) && !offline) && Discord.token != null && !incognito && rpcenabled) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
|
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
|
||||||
val buttons = when (discordMode) {
|
val buttons = when (discordMode) {
|
||||||
|
|
|
@ -414,7 +414,8 @@ class MangaReaderActivity : AppCompatActivity() {
|
||||||
val context = this
|
val context = this
|
||||||
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
|
||||||
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
val incognito: Boolean = PrefManager.getVal(PrefName.Incognito)
|
||||||
if ((isOnline(context) && !offline) && Discord.token != null && !incognito) {
|
val rpcenabled: Boolean = PrefManager.getVal(PrefName.rpcEnabled)
|
||||||
|
if ((isOnline(context) && !offline) && Discord.token != null && !incognito && rpcenabled) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
|
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
|
||||||
val buttons = when (discordMode) {
|
val buttons = when (discordMode) {
|
||||||
|
|
|
@ -209,6 +209,17 @@ class SettingsAccountActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
binding.settingsRecyclerView.adapter = SettingsAdapter(
|
binding.settingsRecyclerView.adapter = SettingsAdapter(
|
||||||
arrayListOf(
|
arrayListOf(
|
||||||
|
Settings(
|
||||||
|
type = 2,
|
||||||
|
name = getString(R.string.enable_rpc),
|
||||||
|
desc = getString(R.string.enable_rpc_desc),
|
||||||
|
icon = R.drawable.interests_24,
|
||||||
|
isChecked = PrefManager.getVal(PrefName.rpcEnabled),
|
||||||
|
switch = { isChecked, _ ->
|
||||||
|
PrefManager.setVal(PrefName.rpcEnabled, isChecked)
|
||||||
|
},
|
||||||
|
isVisible = Discord.token != null
|
||||||
|
),
|
||||||
Settings(
|
Settings(
|
||||||
type = 1,
|
type = 1,
|
||||||
name = getString(R.string.anilist_settings),
|
name = getString(R.string.anilist_settings),
|
||||||
|
|
|
@ -193,6 +193,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
|
||||||
DownloadsDir(Pref(Location.Irrelevant, String::class, "")),
|
DownloadsDir(Pref(Location.Irrelevant, String::class, "")),
|
||||||
OC(Pref(Location.Irrelevant, Boolean::class, false)),
|
OC(Pref(Location.Irrelevant, Boolean::class, false)),
|
||||||
RefreshStatus(Pref(Location.Irrelevant, Boolean::class, false)),
|
RefreshStatus(Pref(Location.Irrelevant, Boolean::class, false)),
|
||||||
|
rpcEnabled(Pref(Location.Irrelevant, Boolean::class, true)),
|
||||||
|
|
||||||
//Protected
|
//Protected
|
||||||
DiscordToken(Pref(Location.Protected, String::class, "")),
|
DiscordToken(Pref(Location.Protected, String::class, "")),
|
||||||
|
|
10
app/src/main/res/drawable/interests_24.xml
Normal file
10
app/src/main/res/drawable/interests_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="960"
|
||||||
|
android:viewportHeight="960"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M80,440L280,80L480,440L80,440ZM280,840Q214,840 167,793Q120,746 120,680Q120,613 167,566.5Q214,520 280,520Q346,520 393,567Q440,614 440,680Q440,746 393,793Q346,840 280,840ZM280,760Q313,760 336.5,736.5Q360,713 360,680Q360,647 336.5,623.5Q313,600 280,600Q247,600 223.5,623.5Q200,647 200,680Q200,713 223.5,736.5Q247,760 280,760ZM216,360L344,360L280,245L216,360ZM520,840L520,520L840,520L840,840L520,840ZM600,760L760,760L760,600L600,600L600,760ZM680,440Q623,392 584.5,359Q546,326 523,301Q500,276 490,254Q480,232 480,207Q480,162 511.5,131Q543,100 590,100Q617,100 640.5,112.5Q664,125 680,147Q696,125 719.5,112.5Q743,100 770,100Q817,100 848.5,131Q880,162 880,207Q880,232 870,254Q860,276 837,301Q814,326 775.5,359Q737,392 680,440ZM680,335Q752,275 776,250Q800,225 800,209Q800,196 792.5,188Q785,180 772,180Q762,180 752.5,185.5Q743,191 729,205L680,252L631,205Q617,191 607.5,185.5Q598,180 588,180Q575,180 567.5,188Q560,196 560,209Q560,225 584,250Q608,275 680,335ZM680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257L680,257L680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257Q680,257 680,257ZM280,302L280,302L280,302ZM280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680Q280,680 280,680ZM680,680L680,680L680,680L680,680Z"/>
|
||||||
|
</vector>
|
|
@ -820,6 +820,8 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||||
<string name="anilist_notifications_checking_time">Anilist notifications update frequency : %1$s</string>
|
<string name="anilist_notifications_checking_time">Anilist notifications update frequency : %1$s</string>
|
||||||
<string name="comment_notification_checking_time">Comment notifications update frequency : %1$s</string>
|
<string name="comment_notification_checking_time">Comment notifications update frequency : %1$s</string>
|
||||||
<string name="activities">Activities</string>
|
<string name="activities">Activities</string>
|
||||||
|
<string name="enable_rpc">Enable Discord RPC</string>
|
||||||
|
<string name="enable_rpc_desc">Display your taste to plebs on Discord!</string>
|
||||||
|
|
||||||
<string name="incorrect_password">Incorrect password</string>
|
<string name="incorrect_password">Incorrect password</string>
|
||||||
<string name="password_cannot_be_empty">Password cannot be empty</string>
|
<string name="password_cannot_be_empty">Password cannot be empty</string>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue