mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-21 19:43:56 +00:00
feat: discord rpc menu
This commit is contained in:
@@ -37,7 +37,7 @@ android {
|
||||
|
||||
buildTypes {
|
||||
alpha {
|
||||
applicationIdSuffix ".beta" // keep as beta by popular request
|
||||
applicationIdSuffix ".beta1" // keep as beta by popular request
|
||||
versionNameSuffix "-alpha01"
|
||||
manifestPlaceholders.icon_placeholder = "@mipmap/ic_launcher_alpha"
|
||||
manifestPlaceholders.icon_placeholder_round = "@mipmap/ic_launcher_alpha_round"
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package ani.dantotsu.settings
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.RadioButton
|
||||
import android.widget.RadioGroup
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.BottomSheetDialogFragment
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.databinding.BottomSheetDiscordRpcBinding
|
||||
import ani.dantotsu.profile.activity.UsersAdapter
|
||||
import ani.dantotsu.settings.saving.PrefManager
|
||||
import ani.dantotsu.settings.saving.PrefName
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
|
||||
class DiscordDialogFragment: BottomSheetDialogFragment() {
|
||||
private var _binding: BottomSheetDiscordRpcBinding? = null
|
||||
private val binding get() = _binding!!
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
_binding = BottomSheetDiscordRpcBinding.inflate(inflater, container, false)
|
||||
return binding.root
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
when (PrefManager.getCustomVal("discord_mode", "dantotsu")) {
|
||||
"nothing" -> binding.radioNothing.isChecked= true
|
||||
"dantotsu" -> binding.radioDantotsu.isChecked = true
|
||||
"anilist" -> binding.radioAnilist.isChecked = true
|
||||
else -> binding.radioAnilist.isChecked = true
|
||||
}
|
||||
|
||||
// binding.anilistLinkPreview.text = getString(R.string.anilist_link, Anilist.userid.toString()) if you really want it
|
||||
|
||||
binding.radioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
val mode = when (checkedId) {
|
||||
binding.radioNothing.id -> "nothing"
|
||||
binding.radioDantotsu.id -> "dantotsu"
|
||||
binding.radioAnilist.id -> "anilist"
|
||||
else -> "dantotsu"
|
||||
}
|
||||
PrefManager.setCustomVal("discord_mode", mode)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
_binding = null
|
||||
super.onDestroy()
|
||||
}
|
||||
}
|
||||
@@ -263,18 +263,18 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||
reload()
|
||||
}
|
||||
|
||||
imageSwitcher.visibility = View.VISIBLE
|
||||
settingsImageSwitcher.visibility = View.VISIBLE
|
||||
var initialStatus = when (PrefManager.getVal<String>(PrefName.DiscordStatus)) {
|
||||
"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(initialStatus)
|
||||
settingsImageSwitcher.setImageResource(initialStatus)
|
||||
|
||||
val zoomInAnimation =
|
||||
AnimationUtils.loadAnimation(this@SettingsActivity, R.anim.bounce_zoom)
|
||||
imageSwitcher.setOnClickListener {
|
||||
settingsImageSwitcher.setOnClickListener {
|
||||
var status = "online"
|
||||
initialStatus = when (initialStatus) {
|
||||
R.drawable.discord_status_online -> {
|
||||
@@ -296,50 +296,16 @@ class SettingsActivity : AppCompatActivity(), SimpleDialog.OnDialogResultListene
|
||||
}
|
||||
|
||||
PrefManager.setVal(PrefName.DiscordStatus, status)
|
||||
imageSwitcher.setImageResource(initialStatus)
|
||||
imageSwitcher.startAnimation(zoomInAnimation)
|
||||
settingsImageSwitcher.setImageResource(initialStatus)
|
||||
settingsImageSwitcher.startAnimation(zoomInAnimation)
|
||||
}
|
||||
imageSwitcher.setOnLongClickListener {
|
||||
settingsImageSwitcher.setOnLongClickListener {
|
||||
it.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
|
||||
val dialogView = LayoutInflater.from(this@SettingsActivity).inflate(R.layout.discord_rpc_layout, null)
|
||||
val radioGroup = dialogView.findViewById<RadioGroup>(R.id.radio_group)
|
||||
val radioNothing = dialogView.findViewById<RadioButton>(R.id.radio_nothing)
|
||||
val radioDantotsu = dialogView.findViewById<RadioButton>(R.id.radio_dantotsu)
|
||||
val radioAnilist = dialogView.findViewById<RadioButton>(R.id.radio_anilist)
|
||||
val anilistLinkPreview = dialogView.findViewById<TextView>(R.id.anilistLinkPreview)
|
||||
|
||||
val userId = PrefManager.getVal<String>(PrefName.AnilistUserName)
|
||||
val currentMode = PrefManager.getCustomVal("discord_mode", "dantotsu")
|
||||
|
||||
when (currentMode) {
|
||||
"nothing" -> radioNothing.isChecked= true
|
||||
"dantotsu" -> radioDantotsu.isChecked = true
|
||||
"anilist" -> radioAnilist.isChecked = true
|
||||
}
|
||||
|
||||
anilistLinkPreview.text = getString(R.string.anilist_link, userId)
|
||||
|
||||
val bottomSheetDialog = BottomSheetDialog(this@SettingsActivity)
|
||||
bottomSheetDialog.setContentView(dialogView)
|
||||
|
||||
radioGroup.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.radio_nothing -> {
|
||||
PrefManager.setCustomVal("discord_mode", "nothing")
|
||||
}
|
||||
R.id.radio_dantotsu -> {
|
||||
PrefManager.setCustomVal("discord_mode", "dantotsu")
|
||||
}
|
||||
R.id.radio_anilist -> {
|
||||
PrefManager.setCustomVal("discord_mode", "anilist")
|
||||
}
|
||||
}
|
||||
}
|
||||
bottomSheetDialog.show()
|
||||
DiscordDialogFragment().show(supportFragmentManager, "dialog")
|
||||
true
|
||||
}
|
||||
} else {
|
||||
imageSwitcher.visibility = View.GONE
|
||||
settingsImageSwitcher.visibility = View.GONE
|
||||
settingsDiscordAvatar.setImageResource(R.drawable.ic_round_person_24)
|
||||
settingsDiscordUsername.visibility = View.GONE
|
||||
settingsDiscordLogin.setText(R.string.login)
|
||||
|
||||
@@ -213,11 +213,10 @@
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageSwitcher"
|
||||
android:id="@+id/settingsImageSwitcher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/discord_status_idle"
|
||||
android:onClick="onImageClicked"
|
||||
android:padding="16dp" />
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
|
||||
120
app/src/main/res/layout/bottom_sheet_discord_rpc.xml
Normal file
120
app/src/main/res/layout/bottom_sheet_discord_rpc.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bottom_sheet_background">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="4dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="14dp"
|
||||
app:cardBackgroundColor="?attr/colorPrimary"
|
||||
app:cardCornerRadius="2dp"
|
||||
app:cardElevation="0dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottomSheetCustomTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:fontFamily="@font/poppins"
|
||||
android:gravity="bottom|center_horizontal"
|
||||
android:text="@string/discord_rich_presence"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_nothing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/discord_nothing_button" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_dantotsu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/discord_dantotsu_button" />
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/dantotsuCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:padding="8dp"
|
||||
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||
app:cardBackgroundColor="@color/nav_bg"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:contentPadding="4dp"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingRight="8dp"
|
||||
tools:ignore="ContentDescription,TextContrastCheck">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/stream_on_dantotsu"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_anilist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/discord_anilist_button" />
|
||||
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/anilistCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center"
|
||||
android:padding="8dp"
|
||||
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||
app:cardBackgroundColor="@color/nav_bg"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:contentPadding="4dp"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingRight="8dp"
|
||||
tools:ignore="ContentDescription,TextContrastCheck">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/view_my_anilist"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -21,7 +21,7 @@
|
||||
android:layout_height="48dp"
|
||||
android:fontFamily="@font/poppins"
|
||||
android:gravity="bottom|center_horizontal"
|
||||
android:text="Liked By"
|
||||
android:text="@string/liked_by"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bottom_sheet_background"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/bottomSheetCustomTitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="16dp"
|
||||
android:fontFamily="@font/poppins_semi_bold"
|
||||
android:text="@string/discord_rich_presence"
|
||||
android:textAlignment="center"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/radio_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_nothing"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:text="@string/discord_nothing_button" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_dantotsu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/discord_dantotsu_button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/dantotsuCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="start"
|
||||
android:padding="8dp"
|
||||
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||
app:cardBackgroundColor="@color/nav_bg"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:contentPadding="4dp"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingRight="8dp"
|
||||
tools:ignore="ContentDescription,TextContrastCheck">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/stream_on_dantotsu"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/dantotsu"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
</LinearLayout>
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/radio_anilist"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/discord_anilist_button" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/anilistCard"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="start"
|
||||
android:padding="8dp"
|
||||
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||
app:cardBackgroundColor="@color/nav_bg"
|
||||
app:cardCornerRadius="16dp"
|
||||
app:contentPadding="4dp"
|
||||
app:contentPaddingLeft="8dp"
|
||||
app:contentPaddingRight="8dp"
|
||||
tools:ignore="ContentDescription,TextContrastCheck">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/view_my_anilist"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/anilistLinkPreview"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:drawablePadding="4dp"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:text="@string/anilist_link"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
app:drawableTint="?attr/colorPrimary" />
|
||||
|
||||
</LinearLayout>
|
||||
</RadioGroup>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
@@ -859,4 +859,5 @@ Non quae tempore quo provident laudantium qui illo dolor vel quia dolor et exerc
|
||||
<string name="top_rated">Top rated</string>
|
||||
<string name="most_favourite">Most Favourite</string>
|
||||
<string name="trending_manhwa">Trending Manhwa</string>
|
||||
<string name="liked_by">Liked By</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user