mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-28 04:01:03 +00:00
feat(ALsettings): activityMergeTime done
This commit is contained in:
@@ -160,7 +160,7 @@ object Anilist {
|
||||
"10 Point Decimal (5.5/10)",
|
||||
"10 Point (5/10)",
|
||||
"5 Star (3/5)",
|
||||
"3 Point Smiley :)",
|
||||
"3 Point Smiley :)"
|
||||
)
|
||||
|
||||
val rowOrderMap = mapOf(
|
||||
@@ -170,6 +170,22 @@ object Anilist {
|
||||
"Last Added" to "id"
|
||||
)
|
||||
|
||||
val activityMergeTimeMap = mapOf(
|
||||
"Never" to 0,
|
||||
"30 mins" to 30,
|
||||
"69 mins" to 69,
|
||||
"1 hour" to 60,
|
||||
"2 hours" to 120,
|
||||
"3 hours" to 180,
|
||||
"6 hours" to 360,
|
||||
"12 hours" to 720,
|
||||
"1 day" to 1440,
|
||||
"2 days" to 2880,
|
||||
"3 days" to 4320,
|
||||
"1 week" to 10080,
|
||||
"Always" to 20160
|
||||
)
|
||||
|
||||
private val cal: Calendar = Calendar.getInstance()
|
||||
private val currentYear = cal.get(Calendar.YEAR)
|
||||
private val currentSeason: Int = when (cal.get(Calendar.MONTH)) {
|
||||
|
||||
@@ -47,12 +47,13 @@ class AnilistQueries {
|
||||
Viewer {
|
||||
name
|
||||
options {
|
||||
restrictMessagesToFollowing
|
||||
displayAdultContent
|
||||
airingNotifications
|
||||
staffNameLanguage
|
||||
titleLanguage
|
||||
timezone
|
||||
titleLanguage
|
||||
staffNameLanguage
|
||||
activityMergeTime
|
||||
airingNotifications
|
||||
displayAdultContent
|
||||
restrictMessagesToFollowing
|
||||
}
|
||||
avatar { medium }
|
||||
bannerImage
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import ani.dantotsu.R
|
||||
import ani.dantotsu.connections.anilist.Anilist
|
||||
import ani.dantotsu.connections.anilist.Anilist.ScoreFormat
|
||||
import ani.dantotsu.connections.anilist.Anilist.activityMergeTimeMap
|
||||
import ani.dantotsu.connections.anilist.Anilist.rowOrderMap
|
||||
import ani.dantotsu.connections.anilist.Anilist.staffNameLang
|
||||
import ani.dantotsu.connections.anilist.Anilist.titleLang
|
||||
@@ -103,6 +104,23 @@ class SettingsAnilistActivity : AppCompatActivity() {
|
||||
settingsAnilistStaffLanguage.clearFocus()
|
||||
}
|
||||
|
||||
val currentMergeTimeDisplay = activityMergeTimeMap.entries.firstOrNull { it.value == Anilist.activityMergeTime }?.key
|
||||
?: "${Anilist.activityMergeTime} mins"
|
||||
settingsAnilistActivityMergeTime.setText(currentMergeTimeDisplay)
|
||||
settingsAnilistActivityMergeTime.setAdapter(
|
||||
ArrayAdapter(context, R.layout.item_dropdown, activityMergeTimeMap.keys.toList())
|
||||
)
|
||||
settingsAnilistActivityMergeTime.setOnItemClickListener { _, _, i, _ ->
|
||||
val selectedDisplayTime = activityMergeTimeMap.keys.toList()[i]
|
||||
val selectedApiTime = activityMergeTimeMap[selectedDisplayTime] ?: 0
|
||||
lifecycleScope.launch {
|
||||
anilistMutations.updateSettings(activityMergeTime = selectedApiTime)
|
||||
Anilist.activityMergeTime = selectedApiTime
|
||||
restartApp()
|
||||
}
|
||||
settingsAnilistActivityMergeTime.clearFocus()
|
||||
}
|
||||
|
||||
val currentScoreFormat = Anilist.scoreFormat
|
||||
val scoreFormat = FormatScore.entries.firstOrNull{ it.name == currentScoreFormat } ?: FormatScore.POINT_100
|
||||
settingsAnilistScoreFormat.setText(ScoreFormat[scoreFormat.ordinal])
|
||||
|
||||
@@ -175,7 +175,7 @@
|
||||
app:startIconDrawable="@drawable/ic_round_dns_24">
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/settingsAnilistMergeTime"
|
||||
android:id="@+id/settingsAnilistActivityMergeTime"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
||||
Reference in New Issue
Block a user