Flipped long press and tap for tapping a category, shrunk distance between collapsed chapters
Added an arrow to show show collasped status
This commit is contained in:
parent
e2152e7f72
commit
9078500b7c
@ -31,6 +31,7 @@ import eu.kanade.tachiyomi.util.view.invisible
|
|||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
import eu.kanade.tachiyomi.util.view.visInvisIf
|
import eu.kanade.tachiyomi.util.view.visInvisIf
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
import eu.kanade.tachiyomi.util.view.visible
|
||||||
|
import kotlinx.android.synthetic.main.library_category_header_item.*
|
||||||
|
|
||||||
class LibraryHeaderItem(
|
class LibraryHeaderItem(
|
||||||
private val categoryF: (Int) -> Category,
|
private val categoryF: (Int) -> Category,
|
||||||
@ -56,7 +57,7 @@ class LibraryHeaderItem(
|
|||||||
position: Int,
|
position: Int,
|
||||||
payloads: MutableList<Any?>?
|
payloads: MutableList<Any?>?
|
||||||
) {
|
) {
|
||||||
holder.bind(categoryF(catId))
|
holder.bind(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
val category: Category
|
val category: Category
|
||||||
@ -89,69 +90,89 @@ class LibraryHeaderItem(
|
|||||||
private val sortText: TextView = view.findViewById(R.id.category_sort)
|
private val sortText: TextView = view.findViewById(R.id.category_sort)
|
||||||
private val updateButton: ImageView = view.findViewById(R.id.update_button)
|
private val updateButton: ImageView = view.findViewById(R.id.update_button)
|
||||||
private val checkboxImage: ImageView = view.findViewById(R.id.checkbox)
|
private val checkboxImage: ImageView = view.findViewById(R.id.checkbox)
|
||||||
|
private val expandImage: ImageView = view.findViewById(R.id.collapse_arrow)
|
||||||
private val catProgress: ProgressBar = view.findViewById(R.id.cat_progress)
|
private val catProgress: ProgressBar = view.findViewById(R.id.cat_progress)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
sortText.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
sortText.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
marginEnd = (if (padEnd && adapter.recyclerView.paddingEnd == 0) 12 else 2).dpToPx
|
marginEnd = (if (padEnd && adapter.recyclerView.paddingEnd == 0) 12 else 2).dpToPx
|
||||||
}
|
}
|
||||||
updateButton.setOnClickListener { addCategoryToUpdate() }
|
category_header_layout.setOnClickListener {
|
||||||
sectionText.setOnClickListener { adapter.libraryListener.manageCategory(adapterPosition) }
|
|
||||||
sectionText.setOnLongClickListener {
|
|
||||||
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
||||||
|
}
|
||||||
|
updateButton.setOnClickListener { addCategoryToUpdate() }
|
||||||
|
sectionText.setOnLongClickListener {
|
||||||
|
adapter.libraryListener.manageCategory(adapterPosition)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
sectionText.setOnClickListener {
|
||||||
|
adapter.libraryListener.toggleCategoryVisibility(adapterPosition)
|
||||||
|
}
|
||||||
sortText.setOnClickListener { it.post { showCatSortOptions() } }
|
sortText.setOnClickListener { it.post { showCatSortOptions() } }
|
||||||
checkboxImage.setOnClickListener { selectAll() }
|
checkboxImage.setOnClickListener { selectAll() }
|
||||||
updateButton.drawable.mutate()
|
updateButton.drawable.mutate()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bind(category: Category) {
|
fun bind(item: LibraryHeaderItem) {
|
||||||
sectionText.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
val index = adapter.headerItems.indexOf(item)
|
||||||
topMargin =
|
val previousIsCollapsed =
|
||||||
(if ((adapter.headerItems.firstOrNull() as? LibraryHeaderItem)?.catId == category.id) 2 else 44).dpToPx
|
if (index > 0) {
|
||||||
|
(adapter.headerItems[index - 1] as? LibraryHeaderItem)?.category?.isHidden
|
||||||
|
?: false
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
val shorterMargin = adapter.headerItems.firstOrNull() == item
|
||||||
|
sectionText.updateLayoutParams<ConstraintLayout.LayoutParams> {
|
||||||
|
topMargin = (when {
|
||||||
|
shorterMargin -> 2
|
||||||
|
previousIsCollapsed -> 5
|
||||||
|
else -> 32
|
||||||
|
}).dpToPx
|
||||||
|
}
|
||||||
|
val category = item.category
|
||||||
|
|
||||||
if (category.isFirst == true && category.isLast == true) sectionText.text = ""
|
if (category.isFirst == true && category.isLast == true) sectionText.text = ""
|
||||||
else sectionText.text = category.name
|
else sectionText.text = category.name
|
||||||
sortText.text = itemView.context.getString(R.string.sort_by_,
|
sortText.text = itemView.context.getString(
|
||||||
itemView.context.getString(category.sortRes())
|
R.string.sort_by_, itemView.context.getString(category.sortRes())
|
||||||
)
|
)
|
||||||
|
|
||||||
val isAscending = category.isAscending()
|
val isAscending = category.isAscending()
|
||||||
val sortingMode = category.sortingMode()
|
val sortingMode = category.sortingMode()
|
||||||
val sortDrawable = if (category.isHidden) R.drawable.ic_expand_more_white_24dp
|
val sortDrawable = if (category.isHidden) R.drawable.ic_expand_more_24dp
|
||||||
else
|
else when {
|
||||||
when {
|
sortingMode == LibrarySort.DRAG_AND_DROP || sortingMode == null -> R.drawable.ic_sort_white_24dp
|
||||||
sortingMode == LibrarySort.DRAG_AND_DROP || sortingMode == null -> R.drawable
|
if (sortingMode == LibrarySort.DATE_ADDED || sortingMode == LibrarySort.LATEST_CHAPTER || sortingMode == LibrarySort.LAST_READ) !isAscending else isAscending -> R.drawable.ic_arrow_down_white_24dp
|
||||||
.ic_sort_white_24dp
|
|
||||||
if (sortingMode == LibrarySort.DATE_ADDED ||
|
|
||||||
sortingMode == LibrarySort.LATEST_CHAPTER ||
|
|
||||||
sortingMode == LibrarySort.LAST_READ) !isAscending else isAscending ->
|
|
||||||
R.drawable.ic_arrow_down_white_24dp
|
|
||||||
else -> R.drawable.ic_arrow_up_white_24dp
|
else -> R.drawable.ic_arrow_up_white_24dp
|
||||||
}
|
}
|
||||||
|
|
||||||
sortText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, sortDrawable, 0)
|
sortText.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, sortDrawable, 0)
|
||||||
sortText.setText(if (category.isHidden) R.string.collasped else category.sortRes())
|
sortText.setText(if (category.isHidden) R.string.collasped else category.sortRes())
|
||||||
|
expandImage.setImageResource(
|
||||||
|
if (category.isHidden) R.drawable.ic_expand_more_24dp
|
||||||
|
else R.drawable.ic_expand_less_24dp)
|
||||||
when {
|
when {
|
||||||
adapter.mode == SelectableAdapter.Mode.MULTI -> {
|
adapter.mode == SelectableAdapter.Mode.MULTI -> {
|
||||||
checkboxImage.visible()
|
checkboxImage.visible()
|
||||||
|
expandImage.invisible()
|
||||||
updateButton.gone()
|
updateButton.gone()
|
||||||
catProgress.gone()
|
catProgress.gone()
|
||||||
setSelection()
|
setSelection()
|
||||||
}
|
}
|
||||||
category.id == -1 -> {
|
category.id == -1 -> {
|
||||||
|
expandImage.gone()
|
||||||
checkboxImage.gone()
|
checkboxImage.gone()
|
||||||
updateButton.gone()
|
updateButton.gone()
|
||||||
}
|
}
|
||||||
LibraryUpdateService.categoryInQueue(category.id) -> {
|
LibraryUpdateService.categoryInQueue(category.id) -> {
|
||||||
|
expandImage.visible()
|
||||||
checkboxImage.gone()
|
checkboxImage.gone()
|
||||||
catProgress.visible()
|
catProgress.visible()
|
||||||
updateButton.invisible()
|
updateButton.invisible()
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
expandImage.visible()
|
||||||
catProgress.gone()
|
catProgress.gone()
|
||||||
checkboxImage.gone()
|
checkboxImage.gone()
|
||||||
updateButton.visInvisIf(category.id ?: 0 > -1)
|
updateButton.visInvisIf(category.id ?: 0 > -1)
|
||||||
|
@ -79,8 +79,10 @@ class LibraryListHolder(
|
|||||||
|
|
||||||
subtitle.text = item.manga.author?.trim()
|
subtitle.text = item.manga.author?.trim()
|
||||||
title.post {
|
title.post {
|
||||||
|
if (title.text == item.manga.title) {
|
||||||
subtitle.visibleIf(title.lineCount == 1 && !item.manga.author.isNullOrBlank())
|
subtitle.visibleIf(title.lineCount == 1 && !item.manga.author.isNullOrBlank())
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the cover.
|
// Update the cover.
|
||||||
if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail)
|
if (item.manga.thumbnail_url == null) Glide.with(view.context).clear(cover_thumbnail)
|
||||||
|
@ -35,7 +35,7 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
|
|||||||
holder.title.text = filter.name
|
holder.title.text = filter.name
|
||||||
|
|
||||||
holder.icon.setVectorCompat(if (isExpanded)
|
holder.icon.setVectorCompat(if (isExpanded)
|
||||||
R.drawable.ic_expand_more_white_24dp
|
R.drawable.ic_expand_more_24dp
|
||||||
else
|
else
|
||||||
R.drawable.ic_chevron_right_white_24dp)
|
R.drawable.ic_chevron_right_white_24dp)
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGrou
|
|||||||
holder.title.text = filter.name
|
holder.title.text = filter.name
|
||||||
|
|
||||||
holder.icon.setVectorCompat(if (isExpanded)
|
holder.icon.setVectorCompat(if (isExpanded)
|
||||||
R.drawable.ic_expand_more_white_24dp
|
R.drawable.ic_expand_more_24dp
|
||||||
else
|
else
|
||||||
R.drawable.ic_chevron_right_white_24dp)
|
R.drawable.ic_chevron_right_white_24dp)
|
||||||
|
|
||||||
|
5
app/src/main/res/drawable/ic_expand_less_24dp.xml
Normal file
5
app/src/main/res/drawable/ic_expand_less_24dp.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector android:height="24dp" android:tint="#FFFFFF"
|
||||||
|
android:viewportHeight="24.0" android:viewportWidth="24.0"
|
||||||
|
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="#FF000000" android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
|
||||||
|
</vector>
|
@ -2,15 +2,17 @@
|
|||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/category_header_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/list_item_selector"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/checkbox"
|
android:id="@+id/checkbox"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="2dp"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
android:contentDescription="@string/select_all"
|
android:contentDescription="@string/select_all"
|
||||||
android:focusable="true"
|
android:focusable="true"
|
||||||
@ -18,18 +20,38 @@
|
|||||||
android:src="@drawable/ic_check_circle_white_24dp"
|
android:src="@drawable/ic_check_circle_white_24dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/category_title"
|
app:layout_constraintBottom_toBottomOf="@+id/category_title"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/category_title"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/category_title"
|
app:layout_constraintTop_toTopOf="@+id/category_title"
|
||||||
tools:tint="?attr/colorAccent"
|
tools:tint="?attr/colorAccent"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/collapse_arrow"
|
||||||
|
android:layout_width="14dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="2dp"
|
||||||
|
android:contentDescription="@string/select_all"
|
||||||
|
android:src="@drawable/ic_expand_less_24dp"
|
||||||
|
android:tint="?android:textColorPrimary"
|
||||||
|
android:alpha="0.5"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/category_title"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/category_title" />
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.Barrier
|
||||||
|
android:id="@+id/start_barrier"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:barrierDirection="right"
|
||||||
|
app:constraint_referenced_ids="collapse_arrow,checkbox"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/category_title"
|
android:id="@+id/category_title"
|
||||||
style="@style/TextAppearance.MaterialComponents.Headline6"
|
style="@style/TextAppearance.MaterialComponents.Headline6"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingStart="4dp"
|
android:paddingStart="0dp"
|
||||||
android:layout_marginStart="4dp"
|
android:layout_marginStart="4dp"
|
||||||
android:paddingEnd="4dp"
|
android:paddingEnd="4dp"
|
||||||
android:paddingTop="4dp"
|
android:paddingTop="4dp"
|
||||||
@ -46,7 +68,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toStartOf="@id/update_button"
|
app:layout_constraintEnd_toStartOf="@id/update_button"
|
||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintStart_toEndOf="@+id/checkbox"
|
app:layout_constraintStart_toEndOf="@+id/start_barrier"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:text="Title dfdsfsfsfsfsfdsfsfsfs" />
|
tools:text="Title dfdsfsfsfsfsfdsfsfsfs" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user