Browse Source

Catalog visuals update 1155 (#1167)

* adjusted search to be lower in navview

* close drawer on search
moved search and reset to bottom

* switched sort icon to arrow

* allow secondary drawer to swipe open and close

* fixed click to collapse for sortgroup, and group item
updated to rc4 flexibleadapter

* added header to drawer

* changed string to Search filters

* collapsed sort group

* fixed arrow size

* added divider line

* fixed vector size

* add divider id and tools text
Carlos 7 years ago
parent
commit
7f63e318f1

+ 2 - 1
app/build.gradle

@@ -193,7 +193,8 @@ dependencies {
     // UI
     // UI
     implementation 'com.dmitrymalkovich.android:material-design-dimens:1.4'
     implementation 'com.dmitrymalkovich.android:material-design-dimens:1.4'
     implementation 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
     implementation 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
-    implementation 'eu.davidea:flexible-adapter:5.0.0-rc3'
+    implementation 'eu.davidea:flexible-adapter:5.0.0-rc4'
+    implementation 'eu.davidea:flexible-adapter-ui:1.0.0-b1'
     implementation 'com.nononsenseapps:filepicker:2.5.2'
     implementation 'com.nononsenseapps:filepicker:2.5.2'
     implementation 'com.github.amulyakhare:TextDrawable:558677e'
     implementation 'com.github.amulyakhare:TextDrawable:558677e'
     implementation('com.afollestad.material-dialogs:core:0.9.4.7') {
     implementation('com.afollestad.material-dialogs:core:0.9.4.7') {

+ 2 - 12
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/BrowseCatalogueController.kt

@@ -24,7 +24,6 @@ import eu.kanade.tachiyomi.ui.library.ChangeMangaCategoriesDialog
 import eu.kanade.tachiyomi.ui.manga.MangaController
 import eu.kanade.tachiyomi.ui.manga.MangaController
 import eu.kanade.tachiyomi.util.*
 import eu.kanade.tachiyomi.util.*
 import eu.kanade.tachiyomi.widget.AutofitRecyclerView
 import eu.kanade.tachiyomi.widget.AutofitRecyclerView
-import eu.kanade.tachiyomi.widget.DrawerSwipeCloseListener
 import kotlinx.android.synthetic.main.catalogue_controller.*
 import kotlinx.android.synthetic.main.catalogue_controller.*
 import kotlinx.android.synthetic.main.main_activity.*
 import kotlinx.android.synthetic.main.main_activity.*
 import rx.Observable
 import rx.Observable
@@ -75,11 +74,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
      */
      */
     private var recycler: RecyclerView? = null
     private var recycler: RecyclerView? = null
 
 
-    /**
-     * Drawer listener to allow swipe only for closing the drawer.
-     */
-    private var drawerListener: DrawerLayout.DrawerListener? = null
-
     /**
     /**
      * Subscription for the search view.
      * Subscription for the search view.
      */
      */
@@ -138,17 +132,15 @@ open class BrowseCatalogueController(bundle: Bundle) :
         // Inflate and prepare drawer
         // Inflate and prepare drawer
         val navView = drawer.inflate(R.layout.catalogue_drawer) as CatalogueNavigationView
         val navView = drawer.inflate(R.layout.catalogue_drawer) as CatalogueNavigationView
         this.navView = navView
         this.navView = navView
-        drawerListener = DrawerSwipeCloseListener(drawer, navView).also {
-            drawer.addDrawerListener(it)
-        }
         navView.setFilters(presenter.filterItems)
         navView.setFilters(presenter.filterItems)
 
 
-        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.END)
+        drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END)
 
 
         navView.onSearchClicked = {
         navView.onSearchClicked = {
             val allDefault = presenter.sourceFilters == presenter.source.getFilterList()
             val allDefault = presenter.sourceFilters == presenter.source.getFilterList()
             showProgressBar()
             showProgressBar()
             adapter?.clear()
             adapter?.clear()
+            drawer.closeDrawer(Gravity.END)
             presenter.setSourceFilter(if (allDefault) FilterList() else presenter.sourceFilters)
             presenter.setSourceFilter(if (allDefault) FilterList() else presenter.sourceFilters)
         }
         }
 
 
@@ -162,8 +154,6 @@ open class BrowseCatalogueController(bundle: Bundle) :
     }
     }
 
 
     override fun cleanupSecondaryDrawer(drawer: DrawerLayout) {
     override fun cleanupSecondaryDrawer(drawer: DrawerLayout) {
-        drawerListener?.let { drawer.removeDrawerListener(it) }
-        drawerListener = null
         navView = null
         navView = null
     }
     }
 
 

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/browse/CatalogueNavigationView.kt

@@ -28,7 +28,7 @@ class CatalogueNavigationView @JvmOverloads constructor(context: Context, attrs:
         val view = inflate(R.layout.catalogue_drawer_content)
         val view = inflate(R.layout.catalogue_drawer_content)
         ((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
         ((view as ViewGroup).getChildAt(1) as ViewGroup).addView(recycler)
         addView(view)
         addView(view)
-
+        title.text = context?.getString(R.string.source_search_options)
         search_btn.setOnClickListener { onSearchClicked() }
         search_btn.setOnClickListener { onSearchClicked() }
         reset_btn.setOnClickListener { onResetClicked() }
         reset_btn.setOnClickListener { onResetClicked() }
     }
     }

+ 9 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/GroupItem.kt

@@ -13,6 +13,10 @@ import eu.kanade.tachiyomi.util.setVectorCompat
 
 
 class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<GroupItem.Holder, ISectionable<*, *>>() {
 class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<GroupItem.Holder, ISectionable<*, *>>() {
 
 
+    init {
+        isExpanded = false
+    }
+
     override fun getLayoutRes(): Int {
     override fun getLayoutRes(): Int {
         return R.layout.navigation_view_group
         return R.layout.navigation_view_group
     }
     }
@@ -32,6 +36,9 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
             R.drawable.ic_expand_more_white_24dp
             R.drawable.ic_expand_more_white_24dp
         else
         else
             R.drawable.ic_chevron_right_white_24dp)
             R.drawable.ic_chevron_right_white_24dp)
+
+        holder.itemView.setOnClickListener(holder)
+
     }
     }
 
 
     override fun equals(other: Any?): Boolean {
     override fun equals(other: Any?): Boolean {
@@ -44,6 +51,7 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
         return filter.hashCode()
         return filter.hashCode()
     }
     }
 
 
+
     open class Holder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder(view, adapter, true) {
     open class Holder(view: View, adapter: FlexibleAdapter<*>) : ExpandableViewHolder(view, adapter, true) {
 
 
         val title: TextView = itemView.findViewById(R.id.title)
         val title: TextView = itemView.findViewById(R.id.title)
@@ -52,5 +60,6 @@ class GroupItem(val filter: Filter.Group<*>) : AbstractExpandableHeaderItem<Grou
         override fun shouldNotifyParentOnClick(): Boolean {
         override fun shouldNotifyParentOnClick(): Boolean {
             return true
             return true
         }
         }
+
     }
     }
 }
 }

+ 7 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SortGroup.kt

@@ -10,6 +10,10 @@ import eu.kanade.tachiyomi.util.setVectorCompat
 
 
 class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGroup.Holder, ISectionable<*, *>>() {
 class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGroup.Holder, ISectionable<*, *>>() {
 
 
+    init {
+        isExpanded = false
+    }
+
     override fun getLayoutRes(): Int {
     override fun getLayoutRes(): Int {
         return R.layout.navigation_view_group
         return R.layout.navigation_view_group
     }
     }
@@ -29,6 +33,9 @@ class SortGroup(val filter: Filter.Sort) : AbstractExpandableHeaderItem<SortGrou
             R.drawable.ic_expand_more_white_24dp
             R.drawable.ic_expand_more_white_24dp
         else
         else
             R.drawable.ic_chevron_right_white_24dp)
             R.drawable.ic_chevron_right_white_24dp)
+
+        holder.itemView.setOnClickListener(holder)
+
     }
     }
 
 
     override fun equals(other: Any?): Boolean {
     override fun equals(other: Any?): Boolean {

+ 2 - 2
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)
         val i = filter.values.indexOf(name)
 
 
         fun getIcon() = when (filter.state) {
         fun getIcon() = when (filter.state) {
-            Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_keyboard_arrow_down_black_32dp, null)
+            Filter.Sort.Selection(i, false) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_down_32dp, null)
                     ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
                     ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
-            Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_keyboard_arrow_up_black_32dp, null)
+            Filter.Sort.Selection(i, true) -> VectorDrawableCompat.create(view.resources, R.drawable.ic_arrow_up_32dp, null)
                     ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
                     ?.apply { setTint(view.context.getResourceColor(R.attr.colorAccent)) }
             else -> ContextCompat.getDrawable(view.context, R.drawable.empty_drawable_32dp)
             else -> ContextCompat.getDrawable(view.context, R.drawable.empty_drawable_32dp)
         }
         }

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryController.kt

@@ -26,7 +26,7 @@ class CategoryController : NucleusController<CategoryPresenter>(),
         CategoryAdapter.OnItemReleaseListener,
         CategoryAdapter.OnItemReleaseListener,
         CategoryCreateDialog.Listener,
         CategoryCreateDialog.Listener,
         CategoryRenameDialog.Listener,
         CategoryRenameDialog.Listener,
-        UndoHelper.OnUndoListener {
+        UndoHelper.OnActionListener {
 
 
     /**
     /**
      * Object used to show ActionMode toolbar.
      * Object used to show ActionMode toolbar.
@@ -168,7 +168,7 @@ class CategoryController : NucleusController<CategoryPresenter>(),
             R.id.action_delete -> {
             R.id.action_delete -> {
                 undoHelper = UndoHelper(adapter, this)
                 undoHelper = UndoHelper(adapter, this)
                 undoHelper?.start(adapter.selectedPositions, view!!,
                 undoHelper?.start(adapter.selectedPositions, view!!,
-                                R.string.snack_categories_deleted, R.string.action_undo, 3000)
+                        R.string.snack_categories_deleted, R.string.action_undo, 3000)
 
 
                 mode.finish()
                 mode.finish()
             }
             }
@@ -268,7 +268,7 @@ class CategoryController : NucleusController<CategoryPresenter>(),
      *
      *
      * @param action The action performed.
      * @param action The action performed.
      */
      */
-    override fun onActionCanceled(action: Int) {
+    override fun onActionCanceled(action: Int, positions: MutableList<Int>?) {
         adapter?.restoreDeletedItems()
         adapter?.restoreDeletedItems()
         undoHelper = null
         undoHelper = null
     }
     }

+ 16 - 0
app/src/main/res/drawable/ic_arrow_down_32dp.xml

@@ -0,0 +1,16 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="32dp"
+        android:height="32dp"
+        android:viewportHeight="32"
+        android:viewportWidth="32">
+    <group
+        android:scaleX="0.8"
+        android:scaleY="0.8"
+        android:pivotX="32"
+        android:pivotY="32"
+        >
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z"/>
+    </group>
+</vector>

+ 16 - 0
app/src/main/res/drawable/ic_arrow_up_32dp.xml

@@ -0,0 +1,16 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:width="32dp"
+        android:height="32dp"
+        android:viewportHeight="32"
+        android:viewportWidth="32">
+    <group
+        android:scaleX="0.8"
+        android:scaleY="0.8"
+        android:pivotX="32"
+        android:pivotY="32"
+        >
+    <path
+        android:fillColor="#FFFFFF"
+        android:pathData="M13,20H11V8L5.5,13.5L4.08,12.08L12,4.16L19.92,12.08L18.5,13.5L13,8V20Z"/>
+</group>
+</vector>

+ 44 - 14
app/src/main/res/layout/catalogue_drawer_content.xml

@@ -1,36 +1,66 @@
 <?xml version="1.0" encoding="utf-8"?>
 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:layout_height="match_parent"
-    android:clickable="true">
+    android:clickable="true"
+    android:orientation="vertical">
+    <LinearLayout
+        android:id="@+id/title_background"
+        android:layout_width="match_parent"
+        android:layout_height="?attr/listPreferredItemHeightSmall"
+        android:background="?colorPrimary"
+        android:elevation="2dp"
+        android:gravity="center_vertical"
+        android:orientation="horizontal"
+        android:paddingLeft="?attr/listPreferredItemPaddingLeft"
+        android:paddingRight="?attr/listPreferredItemPaddingRight"
+        >
+
+        <TextView
+            android:id="@+id/title"
+            android:layout_width="0dp"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:ellipsize="end"
+            android:maxLines="1"
+            tools:text="Title"
+            android:textAppearance="@style/TextAppearance.AppCompat.Body2"
+            android:textColor="@color/textColorPrimaryDark"/>
+
+    </LinearLayout>
 
 
+    <FrameLayout
+        android:layout_width="match_parent"
+        android:layout_height="0dp"
+        android:layout_weight="3"
+        android:layout_gravity="top"/>
+    <View
+        android:id="@+id/divider"
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:background="?android:attr/divider"/>
     <LinearLayout
     <LinearLayout
         android:layout_width="match_parent"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_height="wrap_content"
+        android:layout_weight="0"
         android:padding="8dp">
         android:padding="8dp">
 
 
         <Button
         <Button
-            style="@style/Theme.Widget.Button.Colored"
-            android:id="@+id/search_btn"
+            android:id="@+id/reset_btn"
+            style="@style/Theme.Widget.Button.Borderless"
             android:layout_width="0dp"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:layout_weight="1"
-            android:text="@string/action_search"/>
+            android:text="@string/action_reset"/>
 
 
         <Button
         <Button
-            style="@style/Theme.Widget.Button.Borderless"
-            android:id="@+id/reset_btn"
+            android:id="@+id/search_btn"
+            style="@style/Theme.Widget.Button.Colored"
             android:layout_width="0dp"
             android:layout_width="0dp"
             android:layout_height="wrap_content"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:layout_weight="1"
-            android:text="@string/action_reset"/>
-
+            android:text="@string/action_search"/>
     </LinearLayout>
     </LinearLayout>
-
-    <FrameLayout
-        android:layout_width="match_parent"
-        android:layout_height="match_parent" />
-
 </LinearLayout>
 </LinearLayout>

+ 1 - 0
app/src/main/res/values/strings.xml

@@ -277,6 +277,7 @@
     <string name="also_delete_chapters">Also delete downloaded chapters</string>
     <string name="also_delete_chapters">Also delete downloaded chapters</string>
 
 
     <!-- Catalogue fragment -->
     <!-- Catalogue fragment -->
+    <string name="source_search_options">Search filters</string>
     <string name="source_requires_login">This source requires you to log in</string>
     <string name="source_requires_login">This source requires you to log in</string>
     <string name="select_source">Select a source</string>
     <string name="select_source">Select a source</string>
     <string name="no_valid_sources">Please enable at least one valid source</string>
     <string name="no_valid_sources">Please enable at least one valid source</string>