mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-11 03:17:49 +01:00
Minor Improvements (#405)
This commit is contained in:
parent
f21a030cf8
commit
9cf5a4cac0
9 changed files with 67 additions and 59 deletions
|
@ -55,9 +55,9 @@ class CategoryActivity : BaseRxActivity<CategoryPresenter>(), ActionMode.Callbac
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
setAppTheme()
|
setAppTheme()
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedState)
|
||||||
|
|
||||||
// Inflate activity_edit_categories.xml.
|
// Inflate activity_edit_categories.xml.
|
||||||
setContentView(R.layout.activity_edit_categories)
|
setContentView(R.layout.activity_edit_categories)
|
||||||
|
|
|
@ -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.base.fragment.BaseFragment
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaActivity
|
import eu.kanade.tachiyomi.ui.manga.MangaActivity
|
||||||
import eu.kanade.tachiyomi.util.toast
|
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 kotlinx.android.synthetic.main.fragment_library_category.*
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
@ -69,7 +67,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
|
||||||
/**
|
/**
|
||||||
* display mode
|
* display mode
|
||||||
*/
|
*/
|
||||||
private var displayAsList: Boolean = false;
|
private var displayAsList: Boolean = false
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
|
@ -109,6 +107,8 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
|
||||||
library_list.adapter = adapter
|
library_list.adapter = adapter
|
||||||
library_list.layoutManager = LinearLayoutManager(activity)
|
library_list.layoutManager = LinearLayoutManager(activity)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (libraryFragment.actionMode != null) {
|
if (libraryFragment.actionMode != null) {
|
||||||
setSelectionMode(FlexibleAdapter.MODE_MULTI)
|
setSelectionMode(FlexibleAdapter.MODE_MULTI)
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
|
||||||
// Set again the adapter to recalculate the covers height
|
// Set again the adapter to recalculate the covers height
|
||||||
.subscribe { recycler.adapter = adapter }
|
.subscribe { recycler.adapter = adapter }
|
||||||
|
|
||||||
searchSubscription = libraryPresenter.searchSubject.subscribe { text ->
|
searchSubscription = libraryPresenter.searchSubject?.subscribe { text ->
|
||||||
adapter.searchText = text
|
adapter.searchText = text
|
||||||
adapter.updateDataSet()
|
adapter.updateDataSet()
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
|
||||||
|
|
||||||
|
|
||||||
libraryMangaSubscription = libraryPresenter.libraryMangaSubject
|
libraryMangaSubscription = libraryPresenter.libraryMangaSubject
|
||||||
.subscribe { onNextLibraryManga(it) }
|
?.subscribe { onNextLibraryManga(it) }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +247,7 @@ class LibraryCategoryFragment : BaseFragment(), FlexibleViewHolder.OnListItemCli
|
||||||
*
|
*
|
||||||
* @param manga the manga to open.
|
* @param manga the manga to open.
|
||||||
*/
|
*/
|
||||||
protected fun openManga(manga: Manga) {
|
private fun openManga(manga: Manga) {
|
||||||
// Notify the presenter a manga is being opened.
|
// Notify the presenter a manga is being opened.
|
||||||
libraryPresenter.onOpenManga()
|
libraryPresenter.onOpenManga()
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||||
if (savedState != null) {
|
if (savedState != null) {
|
||||||
activeCategory = savedState.getInt(CATEGORY_KEY)
|
activeCategory = savedState.getInt(CATEGORY_KEY)
|
||||||
query = savedState.getString(QUERY_KEY)
|
query = savedState.getString(QUERY_KEY)
|
||||||
presenter.searchSubject.onNext(query)
|
presenter.searchSubject?.onNext(query)
|
||||||
} else {
|
} else {
|
||||||
activeCategory = presenter.preferences.lastUsedCategory().getOrDefault()
|
activeCategory = presenter.preferences.lastUsedCategory().getOrDefault()
|
||||||
}
|
}
|
||||||
|
@ -283,7 +283,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||||
|
|
||||||
// Notify the subject the query has changed.
|
// Notify the subject the query has changed.
|
||||||
if (isResumed) {
|
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) }
|
view_pager.post { if (isAdded) tabs.setScrollPosition(view_pager.currentItem, 0f, true) }
|
||||||
|
|
||||||
// Send the manga map to child fragments after the adapter is updated.
|
// Send the manga map to child fragments after the adapter is updated.
|
||||||
presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap))
|
presenter.libraryMangaSubject?.onNext(LibraryMangaEvent(mangaMap))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
package eu.kanade.tachiyomi.ui.library
|
package eu.kanade.tachiyomi.ui.library
|
||||||
|
|
||||||
import android.view.View
|
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.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.ui.base.adapter.FlexibleViewHolder
|
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.
|
* Generic class used to hold the displayed data of a manga in the library.
|
||||||
|
|
|
@ -30,24 +30,28 @@ class LibraryListHolder(private val view: View,
|
||||||
*/
|
*/
|
||||||
override fun onSetValues(manga: Manga) {
|
override fun onSetValues(manga: Manga) {
|
||||||
// Update the title of the manga.
|
// Update the title of the manga.
|
||||||
view.title.text = manga.title
|
itemView.title.text = manga.title
|
||||||
|
|
||||||
// Update the unread count and its visibility.
|
// 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
|
visibility = if (manga.unread > 0) View.VISIBLE else View.GONE
|
||||||
text = manga.unread.toString()
|
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.
|
// Update the cover.
|
||||||
Glide.clear(view.thumbnail)
|
Glide.clear(itemView.thumbnail)
|
||||||
Glide.with(view.context)
|
Glide.with(itemView.context)
|
||||||
.load(manga)
|
.load(manga)
|
||||||
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
.diskCacheStrategy(DiskCacheStrategy.RESULT)
|
||||||
.centerCrop()
|
.centerCrop()
|
||||||
.dontAnimate()
|
.dontAnimate()
|
||||||
.into(view.thumbnail)
|
.into(itemView.thumbnail)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -39,12 +39,12 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
/**
|
/**
|
||||||
* Search query of the library.
|
* 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.
|
* Subject to notify the library's viewpager for updates.
|
||||||
*/
|
*/
|
||||||
val libraryMangaSubject = BehaviorSubject.create<LibraryMangaEvent>()
|
val libraryMangaSubject: BehaviorSubject<LibraryMangaEvent>? = BehaviorSubject.create<LibraryMangaEvent>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database.
|
* Database.
|
||||||
|
@ -247,7 +247,7 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
*
|
*
|
||||||
* @param mangas the list of manga.
|
* @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() }
|
.map { db.getCategoriesForManga(it).executeAsBlocking() }
|
||||||
.reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
|
.reduce { set1: Iterable<Category>, set2 -> set1.intersect(set2) }
|
||||||
|
|
||||||
|
@ -307,7 +307,6 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||||
* Changes the active display mode.
|
* Changes the active display mode.
|
||||||
*/
|
*/
|
||||||
fun swapDisplayMode() {
|
fun swapDisplayMode() {
|
||||||
var currentMode: Boolean = displayAsList
|
|
||||||
preferences.libraryAsList().set(!displayAsList)
|
preferences.libraryAsList().set(!displayAsList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
android:id="@+id/library_list"
|
android:id="@+id/library_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:paddingTop="@dimen/material_component_lists_padding_above_list"
|
||||||
tools:listitem="@layout/item_library_list"/>
|
tools:listitem="@layout/item_library_list"/>
|
||||||
|
|
||||||
</ViewSwitcher>
|
</ViewSwitcher>
|
||||||
|
|
|
@ -2,34 +2,41 @@
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
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">
|
android:background="?attr/selectable_list_drawable">
|
||||||
|
|
||||||
<de.hdodenhof.circleimageview.CircleImageView
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/thumbnail"
|
android:id="@+id/thumbnail"
|
||||||
android:layout_width="32dp"
|
android:layout_width="@dimen/material_component_text_fields_icon_height"
|
||||||
android:layout_height="32dp"
|
android:layout_height="@dimen/material_component_text_fields_icon_height"
|
||||||
android:src="@drawable/icon"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_gravity="center_vertical|left"
|
android:paddingEnd="0dp"
|
||||||
android:paddingLeft="6dp"/>
|
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
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
style="@style/TextAppearance.Regular.Body1"
|
style="@style/TextAppearance.Regular.SubHeading"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:paddingLeft="38dp"
|
android:paddingEnd="0dp"
|
||||||
android:text="Sample name"/>
|
android:paddingLeft="@dimen/material_component_lists_text_left_padding"
|
||||||
|
android:paddingRight="0dp"
|
||||||
|
android:paddingStart="@dimen/material_component_lists_text_left_padding"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/unread_text"
|
android:id="@+id/unread_text"
|
||||||
style="@style/TextAppearance.Regular.Caption"
|
style="@style/TextAppearance.Regular.Caption.Hint"
|
||||||
android:textColor="@color/material_grey_500"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_gravity="center_vertical|right"
|
android:paddingEnd="@dimen/material_component_lists_right_padding"
|
||||||
android:paddingRight="9dp"
|
android:paddingLeft="0dp"
|
||||||
android:visibility="gone"/>
|
android:paddingRight="@dimen/material_component_lists_right_padding"
|
||||||
|
android:paddingStart="0dp"
|
||||||
|
android:visibility="gone"/>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -2,10 +2,17 @@
|
||||||
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" tools:context=".MainActivity">
|
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
|
<item
|
||||||
android:id="@+id/action_filter"
|
android:id="@+id/action_filter"
|
||||||
android:title="@string/action_filter"
|
|
||||||
android:icon="@drawable/ic_filter_list_white_24dp"
|
android:icon="@drawable/ic_filter_list_white_24dp"
|
||||||
|
android:title="@string/action_filter"
|
||||||
app:showAsAction="ifRoom">
|
app:showAsAction="ifRoom">
|
||||||
<menu>
|
<menu>
|
||||||
<item
|
<item
|
||||||
|
@ -23,22 +30,15 @@
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_search"
|
android:id="@+id/action_update_library"
|
||||||
android:title="@string/action_search"
|
android:icon="@drawable/ic_refresh_white_24dp"
|
||||||
android:icon="@drawable/ic_search_white_24dp"
|
android:title="@string/action_update_library"
|
||||||
app:showAsAction="collapseActionView|ifRoom"
|
app:showAsAction="ifRoom" />
|
||||||
app:actionViewClass="android.support.v7.widget.SearchView" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_library_display_mode"
|
android:id="@+id/action_library_display_mode"
|
||||||
android:title="Display Mode"
|
android:title="@string/action_display_mode"
|
||||||
app:showAsAction="always"/>
|
app:showAsAction="never"/>
|
||||||
|
|
||||||
<item
|
|
||||||
android:id="@+id/action_update_library"
|
|
||||||
android:title="@string/action_update_library"
|
|
||||||
android:icon="@drawable/ic_refresh_white_24dp"
|
|
||||||
app:showAsAction="ifRoom" />
|
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_edit_categories"
|
android:id="@+id/action_edit_categories"
|
||||||
|
|
Loading…
Reference in a new issue