Skip to content

Commit

Permalink
feat(Settings): Toggleable RPC (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sadwhy authored Nov 7, 2024
1 parent 3071f88 commit b703337
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -379,4 +379,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: commit-log
path: commit_log.txt
path: commit_log.txt
3 changes: 2 additions & 1 deletion app/src/main/java/ani/dantotsu/media/anime/ExoplayerView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,8 @@ class ExoplayerView : AppCompatActivity(), Player.Listener, SessionAvailabilityL
val ep = episode
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
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 {
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
val buttons = when (discordMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ class MangaReaderActivity : AppCompatActivity() {
val context = this
val offline: Boolean = PrefManager.getVal(PrefName.OfflineMode)
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 {
val discordMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
val buttons = when (discordMode) {
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/ani/dantotsu/settings/SettingsAccountActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,17 @@ class SettingsAccountActivity : AppCompatActivity() {
}
binding.settingsRecyclerView.adapter = SettingsAdapter(
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(
type = 1,
name = getString(R.string.anilist_settings),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
DownloadsDir(Pref(Location.Irrelevant, String::class, "")),
OC(Pref(Location.Irrelevant, Boolean::class, false)),
RefreshStatus(Pref(Location.Irrelevant, Boolean::class, false)),
rpcEnabled(Pref(Location.Irrelevant, Boolean::class, true)),

//Protected
DiscordToken(Pref(Location.Protected, String::class, "")),
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/interests_24.xml
Original file line number Diff line number Diff line change
@@ -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>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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="comment_notification_checking_time">Comment notifications update frequency : %1$s</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="password_cannot_be_empty">Password cannot be empty</string>
Expand Down

0 comments on commit b703337

Please sign in to comment.