feat: something

This commit is contained in:
aayush262
2024-07-05 19:03:00 +05:30
parent c259dce97c
commit df36adba54
5 changed files with 106 additions and 86 deletions

View File

@@ -22,7 +22,7 @@ object Anilist {
var token: String? = null
var username: String? = null
var adult: Boolean = false
var userid: Int? = null
var avatar: String? = null
var bg: String? = null
@@ -36,6 +36,11 @@ object Anilist {
var rateLimitReset: Long = 0
var initialized = false
var adult: Boolean = false
var titleLanguage: String? = null
var staffNameLanguage: String? = null
var airingNotifications: Boolean = false
var restrictMessagesToFollowing: Boolean = false
val sortBy = listOf(
"SCORE_DESC",

View File

@@ -88,11 +88,10 @@ class AnilistQueries {
Anilist.initialized = true
user.options?.let {
PrefManager.setVal(PrefName.AnilistTitleLanguage, it.titleLanguage)
PrefManager.setVal(PrefName.AnilistStaffNameLanguage, it.staffNameLanguage)
PrefManager.setVal(PrefName.AnilistDisplayAdultContent, it.displayAdultContent)
PrefManager.setVal(PrefName.AnilistAiringNotifications, it.airingNotifications)
PrefManager.setVal(PrefName.AnilistRestrictMessagesToFollowing, it.restrictMessagesToFollowing)
Anilist.titleLanguage = it.titleLanguage.toString()
Anilist.staffNameLanguage = it.staffNameLanguage.toString()
Anilist.airingNotifications = it.airingNotifications ?: false
Anilist.restrictMessagesToFollowing = it.restrictMessagesToFollowing ?: false
}
return true
}

View File

@@ -8,12 +8,14 @@ import androidx.core.view.updateLayoutParams
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import ani.dantotsu.R
import ani.dantotsu.connections.anilist.Anilist
import ani.dantotsu.databinding.ActivitySettingsAnilistBinding
import ani.dantotsu.initActivity
import ani.dantotsu.navBarHeight
import ani.dantotsu.statusBarHeight
import ani.dantotsu.themes.ThemeManager
import ani.dantotsu.connections.anilist.AnilistMutations
import ani.dantotsu.restartApp
import ani.dantotsu.settings.saving.PrefManager
import ani.dantotsu.settings.saving.PrefName
import kotlinx.coroutines.launch
@@ -24,7 +26,7 @@ class SettingsAnilistActivity : AppCompatActivity() {
enum class Format {
ENGLISH,
ROMANJI,
ROMAJI,
NATIVE
}
@@ -67,7 +69,7 @@ class SettingsAnilistActivity : AppCompatActivity() {
"Native (進撃の巨人)"
)
val currentTitleLang = PrefManager.getVal<String>(PrefName.AnilistTitleLanguage)
val currentTitleLang = Anilist.titleLanguage
val titleFormat = Format.entries.firstOrNull { it.name == currentTitleLang } ?: Format.ENGLISH
settingsAnilistTitleLanguage.setText(titleLang[titleFormat.ordinal])
@@ -83,7 +85,8 @@ class SettingsAnilistActivity : AppCompatActivity() {
}
lifecycleScope.launch {
anilistMutations.updateSettings(titleLanguage = selectedLanguage)
PrefManager.setVal(PrefName.AnilistTitleLanguage, selectedLanguage)
Anilist.titleLanguage = selectedLanguage
restartApp()
}
settingsAnilistTitleLanguage.clearFocus()
}
@@ -95,7 +98,7 @@ class SettingsAnilistActivity : AppCompatActivity() {
"Native (キルア=ゾルディック)"
)
val currentStaffNameLang = PrefManager.getVal<String>(PrefName.AnilistStaffNameLanguage)
val currentStaffNameLang = Anilist.staffNameLanguage
val staffNameFormat = Format.entries.firstOrNull { it.name == currentStaffNameLang } ?: Format.ENGLISH
settingsAnilistStaffLanguage.setText(staffNameLang[staffNameFormat.ordinal])
@@ -111,14 +114,15 @@ class SettingsAnilistActivity : AppCompatActivity() {
}
lifecycleScope.launch {
anilistMutations.updateSettings(staffNameLanguage = selectedLanguage)
PrefManager.setVal(PrefName.AnilistStaffNameLanguage, selectedLanguage)
Anilist.staffNameLanguage = selectedLanguage
restartApp()
}
settingsAnilistStaffLanguage.clearFocus()
}
val displayAdultContent = PrefManager.getVal(PrefName.AnilistDisplayAdultContent, false)
val airingNotifications = PrefManager.getVal(PrefName.AnilistAiringNotifications, false)
val restrictMessagesToFollowing = PrefManager.getVal(PrefName.AnilistRestrictMessagesToFollowing, false)
val displayAdultContent = Anilist.adult
val airingNotifications = Anilist.airingNotifications
val restrictMessagesToFollowing = Anilist.restrictMessagesToFollowing
binding.settingsRecyclerView.adapter = SettingsAdapter(
arrayListOf(
@@ -131,7 +135,8 @@ class SettingsAnilistActivity : AppCompatActivity() {
switch = { isChecked, _ ->
lifecycleScope.launch {
anilistMutations.updateSettings(airingNotifications = isChecked)
PrefManager.setVal(PrefName.AnilistAiringNotifications, isChecked)
Anilist.airingNotifications = isChecked
restartApp()
}
}
),
@@ -144,7 +149,8 @@ class SettingsAnilistActivity : AppCompatActivity() {
switch = { isChecked, _ ->
lifecycleScope.launch {
anilistMutations.updateSettings(displayAdultContent = isChecked)
PrefManager.setVal(PrefName.AnilistDisplayAdultContent, isChecked)
Anilist.adult = isChecked
restartApp()
}
}
),
@@ -157,7 +163,8 @@ class SettingsAnilistActivity : AppCompatActivity() {
switch = { isChecked, _ ->
lifecycleScope.launch {
anilistMutations.updateSettings(restrictMessagesToFollowing = isChecked)
PrefManager.setVal(PrefName.AnilistRestrictMessagesToFollowing, isChecked)
Anilist.restrictMessagesToFollowing = isChecked
restartApp()
}
}
),

View File

@@ -48,13 +48,8 @@ enum class PrefName(val data: Pref) { //TODO: Split this into multiple files
AdultOnly(Pref(Location.General, Boolean::class, false)),
// Anilist Settings
AnilistTitleLanguage(Pref(Location.General, String::class, "ENGLISH")),
AnilistDisplayAdultContent(Pref(Location.General, Boolean::class, false)),
AnilistAiringNotifications(Pref(Location.General, Boolean::class, false)),
AnilistTimezone(Pref(Location.General, String::class, "(GMT+00:00) London")),
AnilistActivityMergeTime(Pref(Location.General, Int::class, 0)),
AnilistStaffNameLanguage(Pref(Location.General, String::class, "ROMAJI")),
AnilistRestrictMessagesToFollowing(Pref(Location.General, Boolean::class, false)),
AnilistDisabledListActivity(Pref(Location.General, Set::class, setOf<String>())),
//User Interface

View File

@@ -42,8 +42,8 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginEnd="10dp"
android:layout_marginTop="32dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="32dp"
android:layout_weight="1"
android:fontFamily="@font/poppins_bold"
@@ -62,79 +62,93 @@
</LinearLayout>
<TextView
<ani.dantotsu.others.Xpandable
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:alpha="0.58"
android:fontFamily="@font/poppins_bold"
android:text="@string/selected_title_language" />
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="8dp"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:hintAnimationEnabled="true"
app:startIconDrawable="@drawable/ic_round_dns_24">
<AutoCompleteTextView
android:id="@+id/settingsAnilistTitleLanguage"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginHorizontal="16dp"
android:alpha="0.58"
android:fontFamily="@font/poppins_bold"
android:freezesText="false"
android:inputType="none"
android:padding="8dp"
android:text="@string/placeholder"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
</com.google.android.material.textfield.TextInputLayout>
android:text="something" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:alpha="0.58"
android:fontFamily="@font/poppins_bold"
android:text="@string/selected_staff_language" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="8dp"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:hintAnimationEnabled="true"
app:startIconDrawable="@drawable/ic_round_dns_24">
<AutoCompleteTextView
android:id="@+id/settingsAnilistStaffLanguage"
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginHorizontal="16dp"
android:alpha="0.58"
android:fontFamily="@font/poppins_bold"
android:freezesText="false"
android:inputType="none"
android:padding="8dp"
android:text="@string/placeholder"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
</com.google.android.material.textfield.TextInputLayout>
android:text="@string/selected_title_language" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="8dp"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:hintAnimationEnabled="true"
app:startIconDrawable="@drawable/ic_round_dns_24">
<AutoCompleteTextView
android:id="@+id/settingsAnilistTitleLanguage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="@font/poppins_bold"
android:freezesText="false"
android:inputType="none"
android:padding="8dp"
android:text="@string/placeholder"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
</com.google.android.material.textfield.TextInputLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:alpha="0.58"
android:fontFamily="@font/poppins_bold"
android:text="@string/selected_staff_language" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="16dp"
android:layout_marginBottom="8dp"
app:boxCornerRadiusBottomEnd="8dp"
app:boxCornerRadiusBottomStart="8dp"
app:boxCornerRadiusTopEnd="8dp"
app:boxCornerRadiusTopStart="8dp"
app:hintAnimationEnabled="true"
app:startIconDrawable="@drawable/ic_round_dns_24">
<AutoCompleteTextView
android:id="@+id/settingsAnilistStaffLanguage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="@font/poppins_bold"
android:freezesText="false"
android:inputType="none"
android:padding="8dp"
android:text="@string/placeholder"
android:textAllCaps="true"
android:textColor="?android:attr/textColorSecondary"
android:textSize="14sp"
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
</com.google.android.material.textfield.TextInputLayout>
</ani.dantotsu.others.Xpandable>
<ani.dantotsu.FadingEdgeRecyclerView
android:id="@+id/settingsRecyclerView"