diff --git a/app/src/main/java/ani/dantotsu/connections/discord/RPC.kt b/app/src/main/java/ani/dantotsu/connections/discord/RPC.kt index 822218c533..8a4f314bef 100644 --- a/app/src/main/java/ani/dantotsu/connections/discord/RPC.kt +++ b/app/src/main/java/ani/dantotsu/connections/discord/RPC.kt @@ -2,6 +2,8 @@ package ani.dantotsu.connections.discord import ani.dantotsu.connections.discord.serializers.Activity import ani.dantotsu.connections.discord.serializers.Presence +import ani.dantotsu.settings.saving.PrefManager +import ani.dantotsu.settings.saving.PrefName import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json @@ -81,7 +83,7 @@ open class RPC(val token: String, val coroutineContext: CoroutineContext) { ), afk = true, since = data.startTimestamp, - status = data.status + status = PrefManager.getVal(PrefName.DiscordStatus) ) )) } diff --git a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt index 5a6be7ea85..059e885559 100644 --- a/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt +++ b/app/src/main/java/ani/dantotsu/settings/SettingsActivity.kt @@ -14,8 +14,10 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.animation.AnimationUtils import android.view.inputmethod.EditorInfo import android.widget.ArrayAdapter +import android.widget.ImageView import android.widget.TextView import android.widget.Toast import androidx.activity.OnBackPressedCallback @@ -805,7 +807,41 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene restartMainActivity.isEnabled = true reload() } + + val imageSwitcher: ImageView = findViewById(R.id.imageSwitcher) + imageSwitcher.visibility = View.VISIBLE + val temp3: String = PrefManager.getVal(PrefName.DiscordStatus) + var temp5 = when (temp3) { + "online" -> R.drawable.discord_status_online + "idle" -> R.drawable.discord_status_idle + "dnd" -> R.drawable.discord_status_dnd + else -> R.drawable.discord_status_online + } + imageSwitcher.setImageResource(temp5) + + val zoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.bounce_zoom) + imageSwitcher.setOnClickListener { + temp5 = when (temp5) { + R.drawable.discord_status_online -> R.drawable.discord_status_idle + R.drawable.discord_status_idle -> R.drawable.discord_status_dnd + R.drawable.discord_status_dnd -> R.drawable.discord_status_online + else -> R.drawable.discord_status_online + } + + val status = when (temp5) { + R.drawable.discord_status_online -> "online" + R.drawable.discord_status_idle -> "idle" + R.drawable.discord_status_dnd -> "dnd" + else -> "online" + } + + PrefManager.setVal(PrefName.DiscordStatus, status) + imageSwitcher.setImageResource(temp5) + imageSwitcher.startAnimation(zoomInAnimation) + } } else { + val imageSwitcher: ImageView = findViewById(R.id.imageSwitcher) + imageSwitcher.visibility = View.GONE binding.settingsDiscordAvatar.setImageResource(R.drawable.ic_round_person_24) binding.settingsDiscordUsername.visibility = View.GONE binding.settingsDiscordLogin.setText(R.string.login) @@ -950,4 +986,4 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene ?: "Unknown Architecture" } } -} +} \ No newline at end of file diff --git a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt index dfa0c0b7f3..af7e005bd6 100644 --- a/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt +++ b/app/src/main/java/ani/dantotsu/settings/saving/Preferences.kt @@ -144,6 +144,7 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files //Irrelevant Incognito(Pref(Location.Irrelevant, Boolean::class, false)), OfflineMode(Pref(Location.Irrelevant, Boolean::class, false)), + DiscordStatus(Pref(Location.Irrelevant, String::class, "online")), DownloadsKeys(Pref(Location.Irrelevant, String::class, "")), NovelLastExtCheck(Pref(Location.Irrelevant, Long::class, 0L)), SomethingSpecial(Pref(Location.Irrelevant, Boolean::class, false)), diff --git a/app/src/main/res/anim/bounce_zoom.xml b/app/src/main/res/anim/bounce_zoom.xml new file mode 100644 index 0000000000..c19927cf20 --- /dev/null +++ b/app/src/main/res/anim/bounce_zoom.xml @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/app/src/main/res/drawable/discord_status_dnd.xml b/app/src/main/res/drawable/discord_status_dnd.xml new file mode 100644 index 0000000000..db4153065e --- /dev/null +++ b/app/src/main/res/drawable/discord_status_dnd.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/discord_status_idle.xml b/app/src/main/res/drawable/discord_status_idle.xml new file mode 100644 index 0000000000..ed0e0880dd --- /dev/null +++ b/app/src/main/res/drawable/discord_status_idle.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/discord_status_online.xml b/app/src/main/res/drawable/discord_status_online.xml new file mode 100644 index 0000000000..cc81654fb3 --- /dev/null +++ b/app/src/main/res/drawable/discord_status_online.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1742313fe6..69130dbf45 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -238,7 +238,8 @@ android:id="@+id/settingsDiscordLoginContainer" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal"> + android:orientation="horizontal" + tools:ignore="ExtraText"> + + - \ No newline at end of file +