diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt index 8a01bcacf3..44d295b765 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/category/CategoryActivity.kt @@ -55,9 +55,9 @@ class CategoryActivity : BaseRxActivity(), 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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt index 1085df828e..814dec25a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryCategoryFragment.kt +++ b/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() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt index 9e455a0296..0916dfd2e1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryFragment.kt @@ -138,7 +138,7 @@ class LibraryFragment : BaseRxFragment(), 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(), 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(), 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)) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt index 07f5add56c..a9f2cfb237 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryHolder.kt +++ b/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. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt index 78d9accee6..2e561d38cf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryListHolder.kt +++ b/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) } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt index 26650cd04c..39efd36d64 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryPresenter.kt @@ -39,12 +39,12 @@ class LibraryPresenter : BasePresenter() { /** * Search query of the library. */ - val searchSubject = BehaviorSubject.create() + val searchSubject: BehaviorSubject? = BehaviorSubject.create() /** * Subject to notify the library's viewpager for updates. */ - val libraryMangaSubject = BehaviorSubject.create() + val libraryMangaSubject: BehaviorSubject? = BehaviorSubject.create() /** * Database. @@ -247,7 +247,7 @@ class LibraryPresenter : BasePresenter() { * * @param mangas the list of manga. */ - fun getCommonCategories(mangas: List) = mangas.toSet() + fun getCommonCategories(mangas: List): Collection = mangas.toSet() .map { db.getCategoriesForManga(it).executeAsBlocking() } .reduce { set1: Iterable, set2 -> set1.intersect(set2) } @@ -307,7 +307,6 @@ class LibraryPresenter : BasePresenter() { * Changes the active display mode. */ fun swapDisplayMode() { - var currentMode: Boolean = displayAsList preferences.libraryAsList().set(!displayAsList) } diff --git a/app/src/main/res/layout/fragment_library_category.xml b/app/src/main/res/layout/fragment_library_category.xml index 77fd57c33c..bc31c39c8e 100644 --- a/app/src/main/res/layout/fragment_library_category.xml +++ b/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"/> diff --git a/app/src/main/res/layout/item_library_list.xml b/app/src/main/res/layout/item_library_list.xml index 7142650f4a..cad62cfd05 100644 --- a/app/src/main/res/layout/item_library_list.xml +++ b/app/src/main/res/layout/item_library_list.xml @@ -2,34 +2,41 @@ + 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"/> + 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"/> + 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"/> \ No newline at end of file diff --git a/app/src/main/res/menu/library.xml b/app/src/main/res/menu/library.xml index 0af3d8b000..27fabce9be 100644 --- a/app/src/main/res/menu/library.xml +++ b/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"> + + + android:id="@+id/action_update_library" + android:icon="@drawable/ic_refresh_white_24dp" + android:title="@string/action_update_library" + app:showAsAction="ifRoom" /> - - + android:title="@string/action_display_mode" + app:showAsAction="never"/>