Browse Source

Minor Improvements (#405)

Bram van de Kerkhof 8 years ago
parent
commit
9cf5a4cac0

+ 2 - 2
app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt

@@ -55,9 +55,9 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
         }
     }
 
-    override fun onCreate(savedInstanceState: Bundle?) {
+    override fun onCreate(savedState: Bundle?) {
         setAppTheme()
-        super.onCreate(savedInstanceState)
+        super.onCreate(savedState)
 
         // Inflate activity_edit_categories.xml.
         setContentView(R.layout.activity_edit_categories)

+ 6 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt

@@ -18,8 +18,6 @@ import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
 import eu.kanade.tachiyomi.ui.base.fragment.BaseFragment
 import eu.kanade.tachiyomi.ui.manga.MangaActivity
 import eu.kanade.tachiyomi.util.toast
-import kotlinx.android.synthetic.main.fragment_catalogue.*
-import kotlinx.android.synthetic.main.fragment_library.*
 import kotlinx.android.synthetic.main.fragment_library_category.*
 import rx.Subscription
 import uy.kohesive.injekt.injectLazy
@@ -69,7 +67,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
     /**
      * display mode
      */
-    private var displayAsList: Boolean = false;
+    private var displayAsList: Boolean = false
 
     companion object {
         /**
@@ -109,6 +107,8 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
         library_list.adapter = adapter
         library_list.layoutManager = LinearLayoutManager(activity)
 
+
+
         if (libraryFragment.actionMode != null) {
             setSelectionMode(FlexibleAdapter.MODE_MULTI)
         }
@@ -119,7 +119,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
                 // Set again the adapter to recalculate the covers height
                 .subscribe { recycler.adapter = adapter }
 
-        searchSubscription = libraryPresenter.searchSubject.subscribe { text ->
+        searchSubscription = libraryPresenter.searchSubject?.subscribe { text ->
             adapter.searchText = text
             adapter.updateDataSet()
         }
@@ -179,7 +179,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
 
 
         libraryMangaSubscription = libraryPresenter.libraryMangaSubject
-                .subscribe { onNextLibraryManga(it) }
+                ?.subscribe { onNextLibraryManga(it) }
 
     }
 
@@ -247,7 +247,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
      *
      * @param manga the manga to open.
      */
-    protected fun openManga(manga: Manga) {
+    private fun openManga(manga: Manga) {
         // Notify the presenter a manga is being opened.
         libraryPresenter.onOpenManga()
 

+ 3 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt

@@ -138,7 +138,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
         if (savedState != null) {
             activeCategory = savedState.getInt(CATEGORY_KEY)
             query = savedState.getString(QUERY_KEY)
-            presenter.searchSubject.onNext(query)
+            presenter.searchSubject?.onNext(query)
         } else {
             activeCategory = presenter.preferences.lastUsedCategory().getOrDefault()
         }
@@ -283,7 +283,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
 
         // Notify the subject the query has changed.
         if (isResumed) {
-            presenter.searchSubject.onNext(query)
+            presenter.searchSubject?.onNext(query)
         }
     }
 
@@ -311,7 +311,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
         view_pager.post { if (isAdded) tabs.setScrollPosition(view_pager.currentItem, 0f, true) }
 
         // Send the manga map to child fragments after the adapter is updated.
-        presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap))
+        presenter.libraryMangaSubject?.onNext(LibraryMangaEvent(mangaMap))
     }
 
     /**

+ 0 - 3
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt

@@ -1,11 +1,8 @@
 package eu.kanade.tachiyomi.ui.library
 
 import android.view.View
-import com.bumptech.glide.Glide
-import com.bumptech.glide.load.engine.DiskCacheStrategy
 import eu.kanade.tachiyomi.data.database.models.Manga
 import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
-import kotlinx.android.synthetic.main.item_catalogue_grid.view.*
 
 /**
  * Generic class used to hold the displayed data of a manga in the library.

+ 10 - 6
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt

@@ -30,24 +30,28 @@ class LibraryListHolder(private val view: View,
      */
     override fun onSetValues(manga: Manga) {
         // Update the title of the manga.
-        view.title.text = manga.title
+        itemView.title.text = manga.title
 
         // Update the unread count and its visibility.
-        with(view.unread_text) {
+        with(itemView.unread_text) {
             visibility = if (manga.unread > 0) View.VISIBLE else View.GONE
             text = manga.unread.toString()
         }
 
-
+        // Create thumbnail onclick to simulate long click
+        itemView.thumbnail.setOnClickListener {
+            // Simulate long click on this view to enter selection mode
+            onLongClick(itemView)
+        }
 
         // Update the cover.
-        Glide.clear(view.thumbnail)
-        Glide.with(view.context)
+        Glide.clear(itemView.thumbnail)
+        Glide.with(itemView.context)
                 .load(manga)
                 .diskCacheStrategy(DiskCacheStrategy.RESULT)
                 .centerCrop()
                 .dontAnimate()
-                .into(view.thumbnail)
+                .into(itemView.thumbnail)
     }
 
 }

+ 3 - 4
app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt

@@ -39,12 +39,12 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
     /**
      * Search query of the library.
      */
-    val searchSubject = BehaviorSubject.create<String>()
+    val searchSubject: BehaviorSubject<String>? = BehaviorSubject.create<String>()
 
     /**
      * Subject to notify the library's viewpager for updates.
      */
-    val libraryMangaSubject = BehaviorSubject.create<LibraryMangaEvent>()
+    val libraryMangaSubject: BehaviorSubject<LibraryMangaEvent>? = BehaviorSubject.create<LibraryMangaEvent>()
 
     /**
      * Database.
@@ -247,7 +247,7 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
      *
      * @param mangas the list of manga.
      */
-    fun getCommonCategories(mangas: List<Manga>) = mangas.toSet()
+    fun getCommonCategories(mangas: List<Manga>): Collection<Category> = mangas.toSet()
             .map { db.getCategoriesForManga(it).executeAsBlocking() }
             .reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
 
@@ -307,7 +307,6 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
      * Changes the active display mode.
      */
     fun swapDisplayMode() {
-        var currentMode: Boolean = displayAsList
         preferences.libraryAsList().set(!displayAsList)
     }
 

+ 1 - 0
app/src/main/res/layout/fragment_library_category.xml

@@ -27,6 +27,7 @@
                 android:id="@+id/library_list"
                 android:layout_width="match_parent"
                 android:layout_height="match_parent"
+                android:paddingTop="@dimen/material_component_lists_padding_above_list"
                 tools:listitem="@layout/item_library_list"/>
 
         </ViewSwitcher>

+ 28 - 21
app/src/main/res/layout/item_library_list.xml

@@ -2,34 +2,41 @@
 <FrameLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
-    android:layout_height="?android:listPreferredItemHeightSmall"
+    android:layout_height="@dimen/material_component_lists_single_line_with_avatar_height"
     android:background="?attr/selectable_list_drawable">
 
     <de.hdodenhof.circleimageview.CircleImageView
         android:id="@+id/thumbnail"
-        android:layout_width="32dp"
-        android:layout_height="32dp"
-        android:src="@drawable/icon"
-        android:layout_gravity="center_vertical|left"
-        android:paddingLeft="6dp"/>
+        android:layout_width="@dimen/material_component_text_fields_icon_height"
+        android:layout_height="@dimen/material_component_text_fields_icon_height"
+        android:layout_gravity="center_vertical"
+        android:paddingEnd="0dp"
+        android:paddingLeft="@dimen/material_component_lists_icon_left_padding"
+        android:paddingRight="0dp"
+        android:paddingStart="@dimen/material_component_lists_icon_left_padding"
+        android:src="@drawable/icon"/>
 
     <TextView
-            android:id="@+id/title"
-            style="@style/TextAppearance.Regular.Body1"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical"
-            android:paddingLeft="38dp"
-            android:text="Sample name"/>
+        android:id="@+id/title"
+        style="@style/TextAppearance.Regular.SubHeading"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical"
+        android:paddingEnd="0dp"
+        android:paddingLeft="@dimen/material_component_lists_text_left_padding"
+        android:paddingRight="0dp"
+        android:paddingStart="@dimen/material_component_lists_text_left_padding"/>
 
     <TextView
-            android:id="@+id/unread_text"
-            style="@style/TextAppearance.Regular.Caption"
-            android:textColor="@color/material_grey_500"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_vertical|right"
-            android:paddingRight="9dp"
-            android:visibility="gone"/>
+        android:id="@+id/unread_text"
+        style="@style/TextAppearance.Regular.Caption.Hint"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_gravity="center_vertical|end"
+        android:paddingEnd="@dimen/material_component_lists_right_padding"
+        android:paddingLeft="0dp"
+        android:paddingRight="@dimen/material_component_lists_right_padding"
+        android:paddingStart="0dp"
+        android:visibility="gone"/>
 
 </FrameLayout>

+ 14 - 14
app/src/main/res/menu/library.xml

@@ -2,10 +2,17 @@
     xmlns:app="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
 
+    <item
+        android:id="@+id/action_search"
+        android:icon="@drawable/ic_search_white_24dp"
+        android:title="@string/action_search"
+        app:actionViewClass="android.support.v7.widget.SearchView"
+        app:showAsAction="collapseActionView|ifRoom"/>
+
     <item
         android:id="@+id/action_filter"
-        android:title="@string/action_filter"
         android:icon="@drawable/ic_filter_list_white_24dp"
+        android:title="@string/action_filter"
         app:showAsAction="ifRoom">
         <menu>
             <item
@@ -22,24 +29,17 @@
         </menu>
     </item>
 
-    <item
-        android:id="@+id/action_search"
-        android:title="@string/action_search"
-        android:icon="@drawable/ic_search_white_24dp"
-        app:showAsAction="collapseActionView|ifRoom"
-        app:actionViewClass="android.support.v7.widget.SearchView" />
-
-    <item
-        android:id="@+id/action_library_display_mode"
-        android:title="Display Mode"
-        app:showAsAction="always"/>
-
     <item
         android:id="@+id/action_update_library"
-        android:title="@string/action_update_library"
         android:icon="@drawable/ic_refresh_white_24dp"
+        android:title="@string/action_update_library"
         app:showAsAction="ifRoom" />
 
+    <item
+        android:id="@+id/action_library_display_mode"
+        android:title="@string/action_display_mode"
+        app:showAsAction="never"/>
+
     <item
         android:id="@+id/action_edit_categories"
         android:title="@string/action_edit_categories"