last selected comment section option and default

This commit is contained in:
Kelvin 2024-09-06 17:21:50 +02:00
parent d42f104884
commit cf3587f504
6 changed files with 31 additions and 6 deletions

View file

@ -489,7 +489,7 @@ class Settings : FragmentedStorageFileJson() {
@FormField(R.string.default_comment_section, FieldForm.DROPDOWN, -1, 0)
@DropdownFieldOptionsId(R.array.comment_sections)
var defaultCommentSection: Int = 1;
var defaultCommentSection: Int = 2;
@FormField(R.string.default_recommendations, FieldForm.TOGGLE, R.string.default_recommendations_description, 0)
var recommendationsDefault: Boolean = false;

View file

@ -104,6 +104,7 @@ import com.futo.platformplayer.states.StateApp
import com.futo.platformplayer.states.StateDeveloper
import com.futo.platformplayer.states.StateDownloads
import com.futo.platformplayer.states.StateHistory
import com.futo.platformplayer.states.StateMeta
import com.futo.platformplayer.states.StatePlatform
import com.futo.platformplayer.states.StatePlayer
import com.futo.platformplayer.states.StatePlaylists
@ -444,7 +445,8 @@ class VideoDetailView : ConstraintLayout {
if (StatePolycentric.instance.enabled) {
_buttonPolycentric.setOnClickListener {
setTabIndex(0)
setTabIndex(0);
StateMeta.instance.setLastCommentSection(0);
}
} else {
_buttonPolycentric.visibility = View.GONE
@ -456,6 +458,7 @@ class VideoDetailView : ConstraintLayout {
_buttonPlatform.setOnClickListener {
setTabIndex(1)
StateMeta.instance.setLastCommentSection(1);
}
val layoutTop: LinearLayout = findViewById(R.id.layout_top);
@ -1297,8 +1300,11 @@ class VideoDetailView : ConstraintLayout {
if (Settings.instance.comments.recommendationsDefault) {
setTabIndex(2)
} else {
val commentType = !Settings.instance.other.polycentricEnabled || Settings.instance.comments.defaultCommentSection == 1
setTabIndex(if (commentType) 1 else 0, true)
when(Settings.instance.comments.defaultCommentSection) {
0 -> if(Settings.instance.other.polycentricEnabled) setTabIndex(0) else setTabIndex(1);
1 -> setTabIndex(1);
2 -> setTabIndex(StateMeta.instance.getLastCommentSection())
}
}
}

View file

@ -2,11 +2,29 @@ package com.futo.platformplayer.states
import com.futo.platformplayer.stores.FragmentedStorage
import com.futo.platformplayer.stores.StringHashSetStorage
import com.futo.platformplayer.stores.StringStorage
class StateMeta {
val hiddenVideos = FragmentedStorage.get<StringHashSetStorage>("hiddenVideos");
val hiddenCreators = FragmentedStorage.get<StringHashSetStorage>("hiddenCreators");
val lastCommentSection = FragmentedStorage.get<StringStorage>("defaultCommentSection");
fun getLastCommentSection(): Int{
return when(lastCommentSection.value){
"Polycentric" -> 0;
"Platform" -> 1;
else -> 1
}
}
fun setLastCommentSection(value: Int) {
when(value) {
0 -> lastCommentSection.setAndSave("Polycentric");
1 -> lastCommentSection.setAndSave("Platform");
else -> lastCommentSection.setAndSave("");
}
}
fun isVideoHidden(videoUrl: String) : Boolean {
return hiddenVideos.contains(videoUrl);
}

View file

@ -916,6 +916,7 @@
<string-array name="comment_sections">
<item>Polycentric</item>
<item>Platform</item>
<item>Last Selected</item>
</string-array>
<string-array name="audio_languages">
<item>English</item>

@ -1 +1 @@
Subproject commit 0c11c566918647fb6d3d010deeeb8312c94d3437
Subproject commit fe6c3bdf3b454046987341327289086e9fb357e0

@ -1 +1 @@
Subproject commit 3b1301572d3960a1fee8b2e5083aae9d52c13d14
Subproject commit c0a601817d0840151fbca8fdfd8a41cab8ca9339