mirror of
https://github.com/rebelonion/Dantotsu.git
synced 2026-01-20 23:33:56 +00:00
feat: source filter fully functional
This commit is contained in:
@@ -45,6 +45,24 @@ object Anilist {
|
||||
"SCORE"
|
||||
)
|
||||
|
||||
val source = listOf(
|
||||
"ORIGINAL",
|
||||
"MANGA",
|
||||
"LIGHT_NOVEL",
|
||||
"VISUAL_NOVEL",
|
||||
"VIDEO_GAME",
|
||||
"OTHER",
|
||||
"NOVEL",
|
||||
"DOUJINSHI",
|
||||
"ANIME",
|
||||
"WEB_NOVEL",
|
||||
"LIVE_ACTION",
|
||||
"GAME",
|
||||
"COMIC",
|
||||
"MULTIMEDIA_PROJECT",
|
||||
"PICTURE_BOOK"
|
||||
)
|
||||
|
||||
val animeStatus = listOf(
|
||||
"FINISHED",
|
||||
"RELEASING",
|
||||
|
||||
@@ -882,6 +882,7 @@ class AnilistQueries {
|
||||
genres: MutableList<String>? = null,
|
||||
tags: MutableList<String>? = null,
|
||||
status: String? = null,
|
||||
source: String? = null,
|
||||
format: String? = null,
|
||||
countryOfOrigin: String? = null,
|
||||
isAdult: Boolean = false,
|
||||
@@ -945,6 +946,7 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult:
|
||||
${if (seasonYear != null) ""","seasonYear":"$seasonYear"""" else ""}
|
||||
${if (season != null) ""","season":"$season"""" else ""}
|
||||
${if (search != null) ""","search":"$search"""" else ""}
|
||||
${if (source != null) ""","source":"$source"""" else ""}
|
||||
${if (sort != null) ""","sort":"$sort"""" else ""}
|
||||
${if (status != null) ""","status":"$status"""" else ""}
|
||||
${if (format != null) ""","format":"${format.replace(" ", "_")}"""" else ""}
|
||||
@@ -1013,6 +1015,7 @@ query (${"$"}page: Int = 1, ${"$"}id: Int, ${"$"}type: MediaType, ${"$"}isAdult:
|
||||
tags = tags,
|
||||
excludedTags = excludedTags,
|
||||
status = status,
|
||||
source = source,
|
||||
format = format,
|
||||
countryOfOrigin = countryOfOrigin,
|
||||
seasonYear = seasonYear,
|
||||
|
||||
@@ -186,6 +186,7 @@ class AnilistAnimeViewModel : ViewModel() {
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
@@ -260,6 +261,7 @@ class AnilistMangaViewModel : ViewModel() {
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
@@ -291,6 +293,7 @@ class AnilistSearch : ViewModel() {
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
@@ -312,6 +315,7 @@ class AnilistSearch : ViewModel() {
|
||||
r.genres,
|
||||
r.tags,
|
||||
r.status,
|
||||
r.source,
|
||||
r.format,
|
||||
r.countryOfOrigin,
|
||||
r.isAdult,
|
||||
|
||||
@@ -18,6 +18,7 @@ data class SearchResults(
|
||||
var tags: MutableList<String>? = null,
|
||||
var excludedTags: MutableList<String>? = null,
|
||||
var status: String? = null,
|
||||
var source: String? = null,
|
||||
var format: String? = null,
|
||||
var seasonYear: Int? = null,
|
||||
var season: String? = null,
|
||||
@@ -42,6 +43,9 @@ data class SearchResults(
|
||||
status?.let {
|
||||
list.add(SearchChip("STATUS", currContext()!!.getString(R.string.filter_status, it)))
|
||||
}
|
||||
source?.let {
|
||||
list.add(SearchChip("SOURCE", currContext()!!.getString(R.string.filter_source, it)))
|
||||
}
|
||||
format?.let {
|
||||
list.add(SearchChip("FORMAT", currContext()!!.getString(R.string.filter_format, it)))
|
||||
}
|
||||
@@ -83,6 +87,7 @@ data class SearchResults(
|
||||
when (chip.type) {
|
||||
"SORT" -> sort = null
|
||||
"STATUS" -> status = null
|
||||
"SOURCE" -> source = null
|
||||
"FORMAT" -> format = null
|
||||
"COUNTRY" -> countryOfOrigin = null
|
||||
"SEASON" -> season = null
|
||||
|
||||
@@ -68,6 +68,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
tags = intent.getStringExtra("tag")?.let { mutableListOf(it) },
|
||||
sort = intent.getStringExtra("sortBy"),
|
||||
status = intent.getStringExtra("status"),
|
||||
source = intent.getStringExtra("source"),
|
||||
countryOfOrigin = intent.getStringExtra("country"),
|
||||
season = intent.getStringExtra("season"),
|
||||
seasonYear = intent.getStringExtra("seasonYear")?.toIntOrNull(),
|
||||
@@ -131,6 +132,7 @@ class SearchActivity : AppCompatActivity() {
|
||||
season = it.season
|
||||
seasonYear = it.seasonYear
|
||||
status = it.status
|
||||
source = it.source
|
||||
format = it.format
|
||||
countryOfOrigin = it.countryOfOrigin
|
||||
page = it.page
|
||||
|
||||
@@ -124,6 +124,7 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
activity.result.apply {
|
||||
status = binding.searchStatus.text.toString().replace(" ", "_").ifBlank { null }
|
||||
source = binding.searchSource.text.toString().replace(" ", "_").ifBlank { null }
|
||||
format = binding.searchFormat.text.toString().ifBlank { null }
|
||||
season = binding.searchSeason.text.toString().ifBlank { null }
|
||||
seasonYear = binding.searchYear.text.toString().toIntOrNull()
|
||||
@@ -221,6 +222,7 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
binding.searchFilterApply.setOnClickListener {
|
||||
activity.result.apply {
|
||||
status = binding.searchStatus.text.toString().replace(" ", "_").ifBlank { null }
|
||||
source = binding.searchSource.text.toString().replace(" ", "_").ifBlank { null }
|
||||
format = binding.searchFormat.text.toString().ifBlank { null }
|
||||
season = binding.searchSeason.text.toString().ifBlank { null }
|
||||
seasonYear = binding.searchYear.text.toString().toIntOrNull()
|
||||
@@ -248,6 +250,15 @@ class SearchFilterBottomDialog : BottomSheetDialogFragment() {
|
||||
)
|
||||
)
|
||||
|
||||
binding.searchSource.setText(activity.result.source)
|
||||
binding.searchSource.setAdapter(
|
||||
ArrayAdapter(
|
||||
binding.root.context,
|
||||
R.layout.item_dropdown,
|
||||
Anilist.source.toTypedArray()
|
||||
)
|
||||
)
|
||||
|
||||
binding.searchFormat.setText(activity.result.format)
|
||||
binding.searchFormat.setAdapter(
|
||||
ArrayAdapter(
|
||||
|
||||
@@ -143,6 +143,38 @@
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/source"
|
||||
app:boxCornerRadiusBottomEnd="16dp"
|
||||
app:boxCornerRadiusBottomStart="16dp"
|
||||
app:boxCornerRadiusTopEnd="16dp"
|
||||
app:boxCornerRadiusTopStart="16dp"
|
||||
app:boxStrokeColor="@color/text_input_layout_stroke_color"
|
||||
app:hintAnimationEnabled="true">
|
||||
|
||||
<AutoCompleteTextView
|
||||
android:id="@+id/searchSource"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
android:layout_weight="1"
|
||||
android:fontFamily="@font/poppins_bold"
|
||||
android:freezesText="false"
|
||||
android:inputType="none"
|
||||
android:padding="8dp"
|
||||
android:singleLine="true"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="14sp"
|
||||
tools:ignore="LabelFor,TextContrastCheck,DuplicateSpeakableTextCheck" />
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -614,6 +614,7 @@
|
||||
<string name="chapter_plural">Chapters</string>
|
||||
|
||||
<string name="filter_status">"Status : %1$s"</string>
|
||||
<string name="filter_source">"Source : %1$s"</string>
|
||||
<string name="filter_format">"Format : %1$s"</string>
|
||||
<string name="filter_country">"Country : %1$s"</string>
|
||||
<string name="filter_sort">"Sort : %1$s"</string>
|
||||
|
||||
Reference in New Issue
Block a user