From 6c1453eb547a6e468c0a837ebe6509248bf02e18 Mon Sep 17 00:00:00 2001 From: Carlos Date: Fri, 16 Feb 2018 09:23:15 -0500 Subject: [PATCH] Library filter UI change (#1211) * similar library filter to catalog filter * removed some commented out code * code review changes * fixed accidentally removing title --- .../kanade/tachiyomi/ui/catalogue/filter/SortItem.kt | 4 ++-- .../kanade/tachiyomi/ui/library/LibraryController.kt | 10 ++-------- .../tachiyomi/ui/library/LibraryNavigationView.kt | 10 +++------- .../kanade/tachiyomi/widget/ExtendedNavigationView.kt | 10 ++++------ .../eu/kanade/tachiyomi/widget/SimpleNavigationView.kt | 8 ++++++-- ...rrow_down_32dp.xml => ic_arrow_down_white_32dp.xml} | 0 ...ic_arrow_up_32dp.xml => ic_arrow_up_white_32dp.xml} | 0 7 files changed, 17 insertions(+), 25 deletions(-) rename app/src/main/res/drawable/{ic_arrow_down_32dp.xml => ic_arrow_down_white_32dp.xml} (100%) rename app/src/main/res/drawable/{ic_arrow_up_32dp.xml => ic_arrow_up_white_32dp.xml} (100%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SortItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SortItem.kt index a23a7980d7..87d0a501bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SortItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SortItem.kt @@ -33,9 +33,9 @@ class SortItem(val name: String, val group: SortGroup) : AbstractSectionableItem val i = filter.values.indexOf(name) fun getIcon() = when (filter.state) { - Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_down_32dp, null) + Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_down_white_32dp, null) ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) } - Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_up_32dp, null) + Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_up_white_32dp, null) ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) } else -> ContextCompat.getDrawable(view.context, R.drawable.empty_drawable_32dp) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index 813f8b1e05..169df75ba9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -35,7 +35,6 @@ import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.ui.migration.MigrationController import eu.kanade.tachiyomi.util.inflate import eu.kanade.tachiyomi.util.toast -import eu.kanade.tachiyomi.widget.DrawerSwipeCloseListener import kotlinx.android.synthetic.main.library_controller.* import kotlinx.android.synthetic.main.main_activity.* import rx.Subscription @@ -177,11 +176,8 @@ class LibraryController( override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup { val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView - drawerListener = DrawerSwipeCloseListener(drawer, view).also { - drawer.addDrawerListener(it) - } navView = view - drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END) + drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END) navView?.onGroupClicked = { group -> when (group) { @@ -196,8 +192,6 @@ class LibraryController( } override fun cleanupSecondaryDrawer(drawer: DrawerLayout) { - drawerListener?.let { drawer.removeDrawerListener(it) } - drawerListener = null navView = null } @@ -278,7 +272,7 @@ class LibraryController( activity?.invalidateOptionsMenu() } - private fun onDownloadBadgeChanged(){ + private fun onDownloadBadgeChanged() { presenter.requestDownloadBadgesUpdate() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt index e79503a7d0..aa9f0b666c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryNavigationView.kt @@ -15,7 +15,7 @@ import uy.kohesive.injekt.injectLazy * The navigation view shown in a drawer with the different options to show the library. */ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) -: ExtendedNavigationView(context, attrs) { + : ExtendedNavigationView(context, attrs) { /** * Preferences helper. @@ -25,7 +25,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A /** * List of groups shown in the view. */ - private val groups = listOf(FilterGroup(), SortGroup(), DisplayGroup(), BadgeGroup()) + private val groups = listOf(FilterGroup(), SortGroup(), DisplayGroup(), BadgeGroup()) /** * Adapter instance. @@ -62,7 +62,6 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A onGroupClicked(item.group) } } - } /** @@ -99,7 +98,6 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A adapter.notifyItemChanged(item) } - } /** @@ -169,7 +167,7 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A inner class BadgeGroup : Group { private val downloadBadge = Item.CheckboxGroup(R.string.action_display_download_badge, this) override val header = null - override val footer= null + override val footer = null override val items = listOf(downloadBadge) override fun initModels() { downloadBadge.checked = preferences.downloadBadge().getOrDefault() @@ -215,7 +213,5 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A item.group.items.forEach { adapter.notifyItemChanged(it) } } - } - } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/ExtendedNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/ExtendedNavigationView.kt index baa26946c8..27db7bfbb6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/ExtendedNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/ExtendedNavigationView.kt @@ -9,7 +9,6 @@ import android.support.v7.widget.RecyclerView import android.util.AttributeSet import android.view.View import android.view.ViewGroup -import android.widget.TextView import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.getResourceColor @@ -21,7 +20,7 @@ open class ExtendedNavigationView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) -: SimpleNavigationView(context, attrs, defStyleAttr) { + : SimpleNavigationView(context, attrs, defStyleAttr) { /** * Every item of the nav view. Generic items must belong to this list, custom items could be @@ -100,8 +99,8 @@ open class ExtendedNavigationView @JvmOverloads constructor( override fun getStateDrawable(context: Context): Drawable? { return when (state) { - SORT_ASC -> tintVector(context, R.drawable.ic_keyboard_arrow_up_black_32dp) - SORT_DESC -> tintVector(context, R.drawable.ic_keyboard_arrow_down_black_32dp) + SORT_ASC -> tintVector(context, R.drawable.ic_arrow_up_white_32dp) + SORT_DESC -> tintVector(context, R.drawable.ic_arrow_down_white_32dp) SORT_NONE -> ContextCompat.getDrawable(context, R.drawable.empty_drawable_32dp) else -> null } @@ -206,9 +205,8 @@ open class ExtendedNavigationView @JvmOverloads constructor( override fun onBindViewHolder(holder: Holder, position: Int) { when (holder) { is HeaderHolder -> { - val view = holder.itemView as TextView val item = items[position] as Item.Header - view.setText(item.resTitle) + holder.title.setText(item.resTitle) } is SeparatorHolder -> { val view = holder.itemView diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt index efae6f62f6..31fcec901c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt @@ -22,7 +22,7 @@ open class SimpleNavigationView @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) -: ScrimInsetsFrameLayout(context, attrs, defStyleAttr) { + : ScrimInsetsFrameLayout(context, attrs, defStyleAttr) { /** * Max width of the navigation view. @@ -89,7 +89,11 @@ open class SimpleNavigationView @JvmOverloads constructor( * Header view holder. */ class HeaderHolder(parent: ViewGroup) - : Holder(parent.inflate(R.layout.design_navigation_item_subheader)) + : Holder(parent.inflate(TR.layout.navigation_view_group)){ + + val title: TextView = itemView.findViewById(TR.id.title) + } + /** * Clickable view holder. diff --git a/app/src/main/res/drawable/ic_arrow_down_32dp.xml b/app/src/main/res/drawable/ic_arrow_down_white_32dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_arrow_down_32dp.xml rename to app/src/main/res/drawable/ic_arrow_down_white_32dp.xml diff --git a/app/src/main/res/drawable/ic_arrow_up_32dp.xml b/app/src/main/res/drawable/ic_arrow_up_white_32dp.xml similarity index 100% rename from app/src/main/res/drawable/ic_arrow_up_32dp.xml rename to app/src/main/res/drawable/ic_arrow_up_white_32dp.xml