mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
parent
dd327bdb48
commit
0809a7b7ff
5 changed files with 80 additions and 57 deletions
|
@ -108,7 +108,7 @@ interface Manga : SManga {
|
||||||
{ tag ->
|
{ tag ->
|
||||||
tag == "chinese" || tag == "manhua" ||
|
tag == "chinese" || tag == "manhua" ||
|
||||||
tag.startsWith("english") || tag == "comic"
|
tag.startsWith("english") || tag == "comic"
|
||||||
} == true || (isComicSource(sourceName) && !sourceName.contains("tapastic", true)) ||
|
} == true || (isComicSource(sourceName) && !sourceName.contains("tapas", true)) ||
|
||||||
sourceName.contains("manhua", true)
|
sourceName.contains("manhua", true)
|
||||||
)
|
)
|
||||||
ReaderActivity.LEFT_TO_RIGHT
|
ReaderActivity.LEFT_TO_RIGHT
|
||||||
|
@ -142,7 +142,7 @@ interface Manga : SManga {
|
||||||
sourceName.contains("dilbert", true) ||
|
sourceName.contains("dilbert", true) ||
|
||||||
sourceName.contains("cyanide", true) ||
|
sourceName.contains("cyanide", true) ||
|
||||||
sourceName.contains("xkcd", true) ||
|
sourceName.contains("xkcd", true) ||
|
||||||
sourceName.contains("tapastic", true)
|
sourceName.contains("tapas", true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun key(): String {
|
fun key(): String {
|
||||||
|
@ -212,11 +212,11 @@ interface Manga : SManga {
|
||||||
const val DISPLAY_NUMBER = 0x00100000
|
const val DISPLAY_NUMBER = 0x00100000
|
||||||
const val DISPLAY_MASK = 0x00100000
|
const val DISPLAY_MASK = 0x00100000
|
||||||
|
|
||||||
const val TYPE_MANGA = 0
|
const val TYPE_MANGA = 1
|
||||||
const val TYPE_MANHWA = 1
|
const val TYPE_MANHWA = 2
|
||||||
const val TYPE_MANHUA = 2
|
const val TYPE_MANHUA = 3
|
||||||
const val TYPE_COMIC = 3
|
const val TYPE_COMIC = 4
|
||||||
const val TYPE_WEBTOON = 4
|
const val TYPE_WEBTOON = 5
|
||||||
|
|
||||||
fun create(source: Long): Manga = MangaImpl().apply {
|
fun create(source: Long): Manga = MangaImpl().apply {
|
||||||
this.source = source
|
this.source = source
|
||||||
|
|
|
@ -242,8 +242,11 @@ class LibraryPresenter(
|
||||||
if (filterUnread == 4 && !(item.manga.unread > 0 && item.manga.hasRead)) return false
|
if (filterUnread == 4 && !(item.manga.unread > 0 && item.manga.hasRead)) return false
|
||||||
|
|
||||||
if (filterMangaType > 0) {
|
if (filterMangaType > 0) {
|
||||||
if (if (filterMangaType == Manga.TYPE_MANHWA) (filterMangaType != item.manga.mangaType() && filterMangaType != Manga.TYPE_WEBTOON)
|
if (if (filterMangaType == Manga.TYPE_MANHWA) {
|
||||||
else filterMangaType != item.manga.mangaType()
|
(filterMangaType != item.manga.mangaType() && filterMangaType != Manga.TYPE_WEBTOON)
|
||||||
|
} else {
|
||||||
|
filterMangaType != item.manga.mangaType()
|
||||||
|
}
|
||||||
) return false
|
) return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||||
|
|
||||||
private val trackManager: TrackManager by injectLazy()
|
private val trackManager: TrackManager by injectLazy()
|
||||||
|
|
||||||
val hasTracking
|
private val hasTracking
|
||||||
get() = trackManager.hasLoggedServices()
|
get() = trackManager.hasLoggedServices()
|
||||||
|
|
||||||
private lateinit var downloaded: FilterTagGroup
|
private lateinit var downloaded: FilterTagGroup
|
||||||
|
@ -264,6 +264,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||||
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
|
val mangaType = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||||
mangaType.setup(
|
mangaType.setup(
|
||||||
this@FilterBottomSheet,
|
this@FilterBottomSheet,
|
||||||
|
R.string.manga,
|
||||||
types.first(),
|
types.first(),
|
||||||
types.getOrNull(1),
|
types.getOrNull(1),
|
||||||
types.getOrNull(2)
|
types.getOrNull(2)
|
||||||
|
@ -283,7 +284,13 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||||
unreadProgress.state = unreadP - 3
|
unreadProgress.state = unreadP - 3
|
||||||
}
|
}
|
||||||
tracked?.setState(preferences.filterTracked())
|
tracked?.setState(preferences.filterTracked())
|
||||||
mangaType?.setState(preferences.filterMangaType())
|
mangaType?.setState(when (preferences.filterMangaType().getOrDefault()) {
|
||||||
|
Manga.TYPE_MANGA -> context.getString(R.string.manga)
|
||||||
|
Manga.TYPE_MANHUA -> context.getString(R.string.manhua)
|
||||||
|
Manga.TYPE_MANHWA -> context.getString(R.string.manhwa)
|
||||||
|
Manga.TYPE_COMIC -> context.getString(R.string.comic)
|
||||||
|
else -> ""
|
||||||
|
})
|
||||||
reorderFilters()
|
reorderFilters()
|
||||||
reSortViews()
|
reSortViews()
|
||||||
}
|
}
|
||||||
|
@ -409,7 +416,17 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
||||||
downloaded -> preferences.filterDownloaded()
|
downloaded -> preferences.filterDownloaded()
|
||||||
completed -> preferences.filterCompleted()
|
completed -> preferences.filterCompleted()
|
||||||
tracked -> preferences.filterTracked()
|
tracked -> preferences.filterTracked()
|
||||||
mangaType -> preferences.filterMangaType()
|
mangaType -> {
|
||||||
|
val newIndex = when (view.nameOf(index)) {
|
||||||
|
context.getString(R.string.manga) -> Manga.TYPE_MANGA
|
||||||
|
context.getString(R.string.manhua) -> Manga.TYPE_MANHUA
|
||||||
|
context.getString(R.string.manhwa) -> Manga.TYPE_MANHWA
|
||||||
|
context.getString(R.string.comic) -> Manga.TYPE_COMIC
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
preferences.filterMangaType().set(newIndex)
|
||||||
|
null
|
||||||
|
}
|
||||||
else -> null
|
else -> null
|
||||||
}?.set(index + 1)
|
}?.set(index + 1)
|
||||||
onGroupClicked(ACTION_FILTER)
|
onGroupClicked(ACTION_FILTER)
|
||||||
|
|
|
@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import kotlinx.android.synthetic.main.filter_buttons.view.*
|
import kotlinx.android.synthetic.main.filter_buttons.view.*
|
||||||
|
|
||||||
class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout
|
class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : LinearLayout
|
||||||
|
@ -24,8 +25,8 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
||||||
|
|
||||||
private var root: ViewGroup? = null
|
private var root: ViewGroup? = null
|
||||||
|
|
||||||
private val buttons by lazy { arrayOf(firstButton, secondButton, thirdButton) }
|
private val buttons by lazy { arrayOf(firstButton, secondButton, thirdButton, fourthButton) }
|
||||||
private val separators by lazy { arrayOf(separator1, separator2) }
|
private val separators by lazy { arrayOf(separator1, separator2, separator3) }
|
||||||
|
|
||||||
override fun isActivated(): Boolean {
|
override fun isActivated(): Boolean {
|
||||||
return buttons.any { it.isActivated }
|
return buttons.any { it.isActivated }
|
||||||
|
@ -33,45 +34,28 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
||||||
|
|
||||||
fun nameOf(index: Int): String? = buttons.getOrNull(index)?.text as? String
|
fun nameOf(index: Int): String? = buttons.getOrNull(index)?.text as? String
|
||||||
|
|
||||||
fun setup(root: ViewGroup, firstText: Int, secondText: Int? = null, thirdText: Int? = null) {
|
fun setup(root: ViewGroup, firstText: Int, vararg extra: Int?) {
|
||||||
val text1 = context.getString(firstText)
|
val text1 = context.getString(firstText)
|
||||||
val text2 = if (secondText != null) context.getString(secondText) else null
|
val strings = extra.mapNotNull { if (it != null) context.getString(it) else null }
|
||||||
val text3 = if (thirdText != null) context.getString(thirdText) else null
|
setup(root, text1, extra = *strings.toTypedArray())
|
||||||
setup(root, text1, text2, text3)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setup(
|
fun setup(root: ViewGroup, firstText: String, vararg extra: String?) {
|
||||||
root: ViewGroup,
|
|
||||||
firstText: String,
|
|
||||||
secondText: String? = null,
|
|
||||||
thirdText: String? =
|
|
||||||
null
|
|
||||||
) {
|
|
||||||
listener = root as? FilterTagGroupListener
|
listener = root as? FilterTagGroupListener
|
||||||
(layoutParams as? MarginLayoutParams)?.rightMargin = 5.dpToPx
|
(layoutParams as? MarginLayoutParams)?.rightMargin = 5.dpToPx
|
||||||
(layoutParams as? MarginLayoutParams)?.leftMargin = 5.dpToPx
|
(layoutParams as? MarginLayoutParams)?.leftMargin = 5.dpToPx
|
||||||
firstButton.text = firstText
|
firstButton.text = firstText
|
||||||
if (secondText != null) {
|
val extras = (extra.toList() + listOf<String?>(null, null, null)).take(separators.size)
|
||||||
secondButton.text = secondText
|
extras.forEachIndexed { index, text ->
|
||||||
itemCount = 2
|
buttons[index + 1].text = text
|
||||||
if (thirdText != null) {
|
separators[index].visibleIf(text != null)
|
||||||
thirdButton.text = thirdText
|
buttons[index + 1].visibleIf(text != null)
|
||||||
itemCount = 3
|
|
||||||
} else {
|
|
||||||
thirdButton.gone()
|
|
||||||
separator2.gone()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
itemCount = 1
|
|
||||||
secondButton.gone()
|
|
||||||
separator1.gone()
|
|
||||||
thirdButton.gone()
|
|
||||||
separator2.gone()
|
|
||||||
}
|
}
|
||||||
|
itemCount = buttons.count { !it.text.isNullOrBlank() }
|
||||||
this.root = root
|
this.root = root
|
||||||
firstButton.setOnClickListener { toggleButton(0) }
|
buttons.forEachIndexed { index, textView ->
|
||||||
secondButton.setOnClickListener { toggleButton(1) }
|
textView.setOnClickListener { toggleButton(index) }
|
||||||
thirdButton.setOnClickListener { toggleButton(2) }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var state: Int
|
var state: Int
|
||||||
|
@ -115,27 +99,24 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
||||||
listener?.onFilterClicked(this, if (firstButton.isActivated) index else -1, callBack)
|
listener?.onFilterClicked(this, if (firstButton.isActivated) index else -1, callBack)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
val buttons = mutableListOf(firstButton, secondButton)
|
|
||||||
if (itemCount >= 3)
|
|
||||||
buttons.add(thirdButton)
|
|
||||||
val mainButton = buttons[index]
|
val mainButton = buttons[index]
|
||||||
buttons.remove(mainButton)
|
|
||||||
|
|
||||||
if (mainButton.isActivated) {
|
if (mainButton.isActivated) {
|
||||||
mainButton.isActivated = false
|
mainButton.isActivated = false
|
||||||
separator1.visible()
|
|
||||||
listener?.onFilterClicked(this, -1, callBack)
|
listener?.onFilterClicked(this, -1, callBack)
|
||||||
if (itemCount >= 3)
|
buttons.forEachIndexed { viewIndex, textView ->
|
||||||
separator2.visible()
|
if (!textView.text.isNullOrBlank()) {
|
||||||
buttons.forEach { it.visible() }
|
textView.visible()
|
||||||
|
if (viewIndex > 0) {
|
||||||
|
separators[viewIndex - 1].visible()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mainButton.isActivated = true
|
mainButton.isActivated = true
|
||||||
listener?.onFilterClicked(this, index, callBack)
|
listener?.onFilterClicked(this, index, callBack)
|
||||||
buttons.forEach { it.gone() }
|
buttons.forEach { if (it != mainButton) it.gone() }
|
||||||
separator1.gone()
|
separators.forEach { it.gone() }
|
||||||
if (itemCount >= 3) {
|
|
||||||
separator2.gone()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
mainButton.setTextColor(if (mainButton.isActivated) Color.WHITE else context
|
mainButton.setTextColor(if (mainButton.isActivated) Color.WHITE else context
|
||||||
.getResourceColor(android.R.attr.textColorPrimary))
|
.getResourceColor(android.R.attr.textColorPrimary))
|
||||||
|
|
|
@ -64,4 +64,26 @@
|
||||||
tools:text="Item 3"
|
tools:text="Item 3"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="20dp"
|
||||||
android:paddingEnd="20dp"/>
|
android:paddingEnd="20dp"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/separator3"
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:background="@color/strong_divider"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/fourthButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body2"
|
||||||
|
android:textSize="15sp"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:background="@drawable/oval_ripple"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:textStyle="normal"
|
||||||
|
tools:text="Item 4"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"/>
|
||||||
</eu.kanade.tachiyomi.ui.library.filter.FilterTagGroup>
|
</eu.kanade.tachiyomi.ui.library.filter.FilterTagGroup>
|
Loading…
Add table
Add a link
Reference in a new issue