mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:31:51 +01:00
Updates & Fixes
Made manga header in details its own item Pressing the tab icon in library toggles the filters bottom sheet state, no longer just shows it Pressing the tab icon in browse toggles the extensions sheet Better logic in detecting which section of the list library you're in Fixing: • download cache with incorrect casing • "view chapters" from notifcation • Title bar centering • Filtering by tracker
This commit is contained in:
parent
1a9614b5de
commit
93cb8f649e
@ -24,19 +24,10 @@ interface Chapter : SChapter, Serializable {
|
|||||||
val isRecognizedNumber: Boolean
|
val isRecognizedNumber: Boolean
|
||||||
get() = chapter_number >= 0f
|
get() = chapter_number >= 0f
|
||||||
|
|
||||||
val isHeader: Boolean
|
|
||||||
get() = id == Long.MIN_VALUE
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
fun create(): Chapter = ChapterImpl().apply {
|
fun create(): Chapter = ChapterImpl().apply {
|
||||||
chapter_number = -1f
|
chapter_number = -1f
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createHeader(isExpanded: Boolean): Chapter = ChapterImpl().apply {
|
|
||||||
id = Long.MIN_VALUE
|
|
||||||
read = isExpanded
|
|
||||||
manga_id = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,9 @@ class DownloadCache(
|
|||||||
checkRenew()
|
checkRenew()
|
||||||
|
|
||||||
val files = mangaFiles[manga.id] ?: return false
|
val files = mangaFiles[manga.id] ?: return false
|
||||||
return files.any { it in provider.getValidChapterDirNames(chapter) }
|
return files.any { file -> provider.getValidChapterDirNames(chapter).any {
|
||||||
|
it.toLowerCase() == file.toLowerCase()
|
||||||
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -395,7 +395,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns [PendingIntent] that opens the manga info controller.
|
* Returns [PendingIntent] that opens the manga details controller.
|
||||||
*
|
*
|
||||||
* @param context context of application
|
* @param context context of application
|
||||||
* @param manga manga of chapter
|
* @param manga manga of chapter
|
||||||
@ -404,7 +404,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
PendingIntent {
|
PendingIntent {
|
||||||
val newIntent =
|
val newIntent =
|
||||||
Intent(context, MainActivity::class.java).setAction(MainActivity.SHORTCUT_MANGA)
|
Intent(context, MainActivity::class.java).setAction(MainActivity.SHORTCUT_MANGA)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
.putExtra(MangaDetailsController.MANGA_EXTRA, manga.id)
|
.putExtra(MangaDetailsController.MANGA_EXTRA, manga.id)
|
||||||
.putExtra("notificationId", manga.id.hashCode())
|
.putExtra("notificationId", manga.id.hashCode())
|
||||||
.putExtra("groupId", groupId)
|
.putExtra("groupId", groupId)
|
||||||
@ -422,7 +422,7 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
internal fun openExtensionsPendingActivity(context: Context): PendingIntent {
|
internal fun openExtensionsPendingActivity(context: Context): PendingIntent {
|
||||||
val newIntent =
|
val newIntent =
|
||||||
Intent(context, MainActivity::class.java).setAction(MainActivity.SHORTCUT_EXTENSIONS)
|
Intent(context, MainActivity::class.java).setAction(MainActivity.SHORTCUT_EXTENSIONS)
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
||||||
return PendingIntent.getActivity(
|
return PendingIntent.getActivity(
|
||||||
context, 0, newIntent, PendingIntent.FLAG_UPDATE_CURRENT
|
context, 0, newIntent, PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
)
|
)
|
||||||
|
@ -21,8 +21,10 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
else {
|
else {
|
||||||
toolbar_title.text = context.getString(resId)
|
toolbar_title.text = context.getString(resId)
|
||||||
post {
|
post {
|
||||||
toolbar_title.text = context.getString(resId)
|
if (navigationIcon !is DrawerArrowDrawable) {
|
||||||
requestLayout()
|
toolbar_title.text = context.getString(resId)
|
||||||
|
requestLayout()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.setTitle(null)
|
super.setTitle(null)
|
||||||
}
|
}
|
||||||
@ -31,13 +33,15 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
override fun setTitle(title: CharSequence?) {
|
override fun setTitle(title: CharSequence?) {
|
||||||
if (navigationIcon is DrawerArrowDrawable) {
|
if (navigationIcon is DrawerArrowDrawable) {
|
||||||
super.setTitle(title)
|
super.setTitle(title)
|
||||||
toolbar_title.text = null
|
toolbar_title.text = ""
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toolbar_title.text = title
|
toolbar_title.text = title
|
||||||
post {
|
post {
|
||||||
toolbar_title.text = title
|
if (navigationIcon !is DrawerArrowDrawable) {
|
||||||
requestLayout()
|
toolbar_title.text = title
|
||||||
|
requestLayout()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
super.setTitle(null)
|
super.setTitle(null)
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package eu.kanade.tachiyomi.ui.base.controller
|
package eu.kanade.tachiyomi.ui.base.controller
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
|
||||||
import android.view.MenuInflater
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.bluelinelabs.conductor.Controller
|
import com.bluelinelabs.conductor.Controller
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
||||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.*
|
import kotlinx.android.synthetic.*
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
@ -82,7 +79,8 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr
|
|||||||
parentController = parentController.parentController
|
parentController = parentController.parentController
|
||||||
}
|
}
|
||||||
|
|
||||||
(activity as? AppCompatActivity)?.supportActionBar?.title = getTitle()
|
if (router.backstack.lastOrNull()?.controller() == this)
|
||||||
|
(activity as? AppCompatActivity)?.supportActionBar?.title = getTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Controller.instance(): String {
|
private fun Controller.instance(): String {
|
||||||
|
@ -164,6 +164,15 @@ class CatalogueController : NucleusController<CataloguePresenter>(),
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun toggleExtensions() {
|
||||||
|
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
|
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun handleRootBack(): Boolean {
|
override fun handleRootBack(): Boolean {
|
||||||
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
if (ext_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED) {
|
||||||
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
ext_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
@ -514,13 +514,7 @@ open class LibraryController(
|
|||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_search -> expandActionViewFromInteraction = true
|
R.id.action_search -> expandActionViewFromInteraction = true
|
||||||
R.id.action_library_filter -> {
|
R.id.action_library_filter -> {
|
||||||
if (bottom_sheet.sheetBehavior?.isHideable == true &&
|
toggleFilters()
|
||||||
bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED)
|
|
||||||
bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
|
||||||
else if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
&& bottom_sheet.sheetBehavior?.skipCollapsed == false)
|
|
||||||
bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
|
||||||
else bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
|
||||||
}
|
}
|
||||||
R.id.action_library_display -> {
|
R.id.action_library_display -> {
|
||||||
DisplayBottomSheet(this).show()
|
DisplayBottomSheet(this).show()
|
||||||
@ -531,12 +525,14 @@ open class LibraryController(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showFiltersBottomSheet() {
|
fun toggleFilters() {
|
||||||
if (bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN)
|
if (bottom_sheet.sheetBehavior?.isHideable == true &&
|
||||||
bottom_sheet.sheetBehavior?.state =
|
bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED)
|
||||||
if (bottom_sheet.sheetBehavior?.skipCollapsed == false)
|
bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
|
||||||
BottomSheetBehavior.STATE_COLLAPSED
|
else if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_COLLAPSED
|
||||||
else BottomSheetBehavior.STATE_EXPANDED
|
&& bottom_sheet.sheetBehavior?.skipCollapsed == false)
|
||||||
|
bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
|
else bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_EXPANDED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -246,6 +246,9 @@ class LibraryHeaderItem(private val categoryF: (Int) -> Category, val catId: Int
|
|||||||
checkboxImage.setImageDrawable(tintedDrawable)
|
checkboxImage.setImageDrawable(tintedDrawable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onLongClick(view: View?): Boolean {
|
||||||
|
super.onLongClick(view)
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,6 +24,7 @@ import com.afollestad.materialdialogs.checkbox.checkBoxPrompt
|
|||||||
import com.afollestad.materialdialogs.checkbox.isCheckPromptChecked
|
import com.afollestad.materialdialogs.checkbox.isCheckPromptChecked
|
||||||
import com.bluelinelabs.conductor.ControllerChangeHandler
|
import com.bluelinelabs.conductor.ControllerChangeHandler
|
||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
import eu.davidea.flexibleadapter.SelectableAdapter
|
import eu.davidea.flexibleadapter.SelectableAdapter
|
||||||
import eu.davidea.flexibleadapter.items.IFlexible
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
@ -113,13 +114,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
private var scrollListener = object : RecyclerView.OnScrollListener () {
|
private var scrollListener = object : RecyclerView.OnScrollListener () {
|
||||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||||
super.onScrolled(recyclerView, dx, dy)
|
super.onScrolled(recyclerView, dx, dy)
|
||||||
val position =
|
val order = getCategoryOrder()
|
||||||
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
|
||||||
val order = when (val item = adapter.getItem(position)) {
|
|
||||||
is LibraryHeaderItem -> item.category.order
|
|
||||||
is LibraryItem -> presenter.categories.find { it.id == item.manga.category }?.order
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
if (order != null && order != activeCategory) {
|
if (order != null && order != activeCategory) {
|
||||||
preferences.lastUsedCategory().set(order)
|
preferences.lastUsedCategory().set(order)
|
||||||
activeCategory = order
|
activeCategory = order
|
||||||
@ -163,13 +158,9 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
if (startPosX == null) {
|
if (startPosX == null) {
|
||||||
startPosX = event.rawX
|
startPosX = event.rawX
|
||||||
startPosY = event.rawY
|
startPosY = event.rawY
|
||||||
val position =
|
val position = (recycler.layoutManager as LinearLayoutManager)
|
||||||
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
.findFirstVisibleItemPosition()
|
||||||
val order = when (val item = adapter.getItem(position)) {
|
val order = getCategoryOrder()
|
||||||
is LibraryHeaderItem -> item.category.order
|
|
||||||
is LibraryItem -> presenter.categories.find { it.id == item.manga.category }?.order
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
if (order != null) {
|
if (order != null) {
|
||||||
ogCategory = order
|
ogCategory = order
|
||||||
var newOffsetN = order + 1
|
var newOffsetN = order + 1
|
||||||
@ -255,6 +246,26 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getCategoryOrder(): Int? {
|
||||||
|
val position =
|
||||||
|
(recycler.layoutManager as LinearLayoutManager).findFirstCompletelyVisibleItemPosition()
|
||||||
|
var order = when (val item = adapter.getItem(position)) {
|
||||||
|
is LibraryHeaderItem -> item.category.order
|
||||||
|
is LibraryItem -> presenter.categories.find { it.id == item.manga.category }?.order
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
if (order == null) {
|
||||||
|
val fPosition =
|
||||||
|
(recycler.layoutManager as LinearLayoutManager).findFirstVisibleItemPosition()
|
||||||
|
order = when (val item = adapter.getItem(fPosition)) {
|
||||||
|
is LibraryHeaderItem -> item.category.order
|
||||||
|
is LibraryItem -> presenter.categories.find { it.id == item.manga.category }?.order
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return order
|
||||||
|
}
|
||||||
|
|
||||||
private fun resetScrollingValues() {
|
private fun resetScrollingValues() {
|
||||||
startPosX = null
|
startPosX = null
|
||||||
startPosY = null
|
startPosY = null
|
||||||
@ -448,13 +459,11 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
headerPosition, (if (headerPosition == 0) 0 else (-28).dpToPx)
|
headerPosition, (if (headerPosition == 0) 0 else (-28).dpToPx)
|
||||||
+ appbarOffset
|
+ appbarOffset
|
||||||
)
|
)
|
||||||
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
|
|
||||||
this
|
|
||||||
|
|
||||||
val headerItem = adapter.getItem(headerPosition) as? LibraryHeaderItem
|
val headerItem = adapter.getItem(headerPosition) as? LibraryHeaderItem
|
||||||
if (headerItem != null) {
|
if (headerItem != null) {
|
||||||
customTitleSpinner.category_title.text = headerItem.category.name
|
customTitleSpinner.category_title.text = headerItem.category.name
|
||||||
if (isCurrentController) setTitle()
|
setTitle()
|
||||||
}
|
}
|
||||||
recycler.suppressLayout(false)
|
recycler.suppressLayout(false)
|
||||||
}
|
}
|
||||||
@ -590,6 +599,7 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
*/
|
*/
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
if (recyclerIsScrolling()) return
|
if (recyclerIsScrolling()) return
|
||||||
|
if (adapter.getItem(position) is LibraryHeaderItem) return
|
||||||
createActionModeIfNeeded()
|
createActionModeIfNeeded()
|
||||||
when {
|
when {
|
||||||
lastClickPosition == -1 -> setSelection(position)
|
lastClickPosition == -1 -> setSelection(position)
|
||||||
@ -778,8 +788,10 @@ class LibraryListController(bundle: Bundle? = null) : LibraryController(bundle),
|
|||||||
override fun onSwipeTop(x: Float, y: Float) {
|
override fun onSwipeTop(x: Float, y: Float) {
|
||||||
val sheetRect = Rect()
|
val sheetRect = Rect()
|
||||||
activity!!.navigationView.getGlobalVisibleRect(sheetRect)
|
activity!!.navigationView.getGlobalVisibleRect(sheetRect)
|
||||||
if (sheetRect.contains(x.toInt(), y.toInt()))
|
if (sheetRect.contains(x.toInt(), y.toInt())) {
|
||||||
showFiltersBottomSheet()
|
if (bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_EXPANDED)
|
||||||
|
toggleFilters()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override fun onSwipeLeft(x: Float, y: Float) = goToNextCategory(x)
|
override fun onSwipeLeft(x: Float, y: Float) = goToNextCategory(x)
|
||||||
override fun onSwipeRight(x: Float, y: Float) = goToNextCategory(x)
|
override fun onSwipeRight(x: Float, y: Float) = goToNextCategory(x)
|
||||||
|
@ -60,11 +60,9 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
|
|
||||||
private val filterItems:MutableList<FilterTagGroup> by lazy {
|
private val filterItems:MutableList<FilterTagGroup> by lazy {
|
||||||
val list = mutableListOf<FilterTagGroup>()
|
val list = mutableListOf<FilterTagGroup>()
|
||||||
list.add(downloaded)
|
|
||||||
list.add(unread)
|
list.add(unread)
|
||||||
|
list.add(downloaded)
|
||||||
list.add(completed)
|
list.add(completed)
|
||||||
//if (Injekt.get<DatabaseHelper>().getCategories().executeAsBlocking().isNotEmpty())
|
|
||||||
// list.add(categories)
|
|
||||||
if (Injekt.get<TrackManager>().hasLoggedServices())
|
if (Injekt.get<TrackManager>().hasLoggedServices())
|
||||||
list.add(tracked)
|
list.add(tracked)
|
||||||
list
|
list
|
||||||
@ -261,6 +259,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
if (tracked.isActivated) {
|
if (tracked.isActivated) {
|
||||||
filter_layout.addView(trackers)
|
filter_layout.addView(trackers)
|
||||||
filterItems.add(trackers!!)
|
filterItems.add(trackers!!)
|
||||||
|
trackers?.setState(FILTER_TRACKER)
|
||||||
|
reSortViews()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,6 +293,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
else if (preferences.filterTracked().getOrDefault() != 1 &&
|
else if (preferences.filterTracked().getOrDefault() != 1 &&
|
||||||
trackers?.parent != null) {
|
trackers?.parent != null) {
|
||||||
filter_layout.removeView(trackers)
|
filter_layout.removeView(trackers)
|
||||||
|
trackers?.reset()
|
||||||
|
FILTER_TRACKER = ""
|
||||||
filterItems.remove(trackers!!)
|
filterItems.remove(trackers!!)
|
||||||
}
|
}
|
||||||
val hasFilters = hasActiveFilters()
|
val hasFilters = hasActiveFilters()
|
||||||
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.library.filter
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
@ -76,9 +77,10 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
toggleButton(index, false)
|
toggleButton(index, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setState(enabled: Boolean) {
|
fun setState(text: String) {
|
||||||
if (enabled)
|
val index = buttons.indexOfFirst { it.text == text && it.visibility == View.VISIBLE }
|
||||||
toggleButton(0, false)
|
if (index > -1)
|
||||||
|
toggleButton(index, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
fun reset() {
|
||||||
|
@ -36,7 +36,6 @@ import com.google.android.material.snackbar.Snackbar
|
|||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.Migrations
|
import eu.kanade.tachiyomi.Migrations
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadServiceListener
|
import eu.kanade.tachiyomi.data.download.DownloadServiceListener
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
@ -58,6 +57,7 @@ import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
|||||||
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersController
|
||||||
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadController
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
|
import eu.kanade.tachiyomi.ui.setting.SettingsController
|
||||||
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
import eu.kanade.tachiyomi.ui.setting.SettingsMainController
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
@ -71,8 +71,6 @@ import kotlinx.coroutines.GlobalScope
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
@ -169,27 +167,27 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
//R.id.nav_settings -> setRoot(SettingsMainController(), id)
|
//R.id.nav_settings -> setRoot(SettingsMainController(), id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (currentRoot.tag()?.toIntOrNull() == id) {
|
else if (currentRoot.tag()?.toIntOrNull() == id) {
|
||||||
when (id) {
|
if (router.backstackSize == 1) {
|
||||||
R.id.nav_recents -> {
|
when (id) {
|
||||||
if (router.backstack.size > 1) router.popToRoot()
|
R.id.nav_recents -> {
|
||||||
else {
|
|
||||||
val showRecents = preferences.showRecentUpdates().getOrDefault()
|
val showRecents = preferences.showRecentUpdates().getOrDefault()
|
||||||
if (!showRecents) setRoot(RecentChaptersController(), id)
|
if (!showRecents) setRoot(RecentChaptersController(), id)
|
||||||
else setRoot(RecentlyReadController(), id)
|
else setRoot(RecentlyReadController(), id)
|
||||||
preferences.showRecentUpdates().set(!showRecents)
|
preferences.showRecentUpdates().set(!showRecents)
|
||||||
updateRecentsIcon()
|
updateRecentsIcon()
|
||||||
}
|
}
|
||||||
}
|
R.id.nav_library -> {
|
||||||
R.id.nav_library -> {
|
val controller =
|
||||||
if (router.backstack.size > 1) router.popToRoot()
|
router.getControllerWithTag(id.toString()) as? LibraryController
|
||||||
else {
|
controller?.toggleFilters()
|
||||||
val controller = router.getControllerWithTag(id.toString()) as?
|
}
|
||||||
LibraryController
|
R.id.nav_catalogues -> {
|
||||||
controller?.showFiltersBottomSheet()
|
val controller =
|
||||||
|
router.getControllerWithTag(id.toString()) as? CatalogueController
|
||||||
|
controller?.toggleExtensions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.nav_catalogues -> router.popToRoot()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
@ -314,9 +312,6 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toolbar.navigationIcon = if (router.backstackSize > 1) drawerArrow else searchDrawable
|
|
||||||
(router.backstack.lastOrNull()?.controller() as? BaseController)?.setTitle()
|
|
||||||
|
|
||||||
toolbar.setNavigationOnClickListener {
|
toolbar.setNavigationOnClickListener {
|
||||||
val rootSearchController = router.backstack.lastOrNull()?.controller()
|
val rootSearchController = router.backstack.lastOrNull()?.controller()
|
||||||
if (rootSearchController is RootSearchInterface) {
|
if (rootSearchController is RootSearchInterface) {
|
||||||
@ -344,6 +339,10 @@ open class MainActivity : BaseActivity(), DownloadServiceListener {
|
|||||||
|
|
||||||
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
|
syncActivityViewWithController(router.backstack.lastOrNull()?.controller())
|
||||||
|
|
||||||
|
toolbar.navigationIcon = if (router.backstackSize > 1) drawerArrow else searchDrawable
|
||||||
|
(router.backstack.lastOrNull()?.controller() as? BaseController)?.setTitle()
|
||||||
|
(router.backstack.lastOrNull()?.controller() as? SettingsController)?.setTitle()
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
// Show changelog if needed
|
// Show changelog if needed
|
||||||
if (Migrations.upgrade(preferences)) {
|
if (Migrations.upgrade(preferences)) {
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.ui.manga
|
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
||||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter
|
|
||||||
|
|
||||||
abstract class MangaChapterHolder(
|
|
||||||
private val view: View,
|
|
||||||
private val adapter: ChaptersAdapter
|
|
||||||
) : BaseFlexibleViewHolder(view, adapter) {
|
|
||||||
/**
|
|
||||||
* Method called from [ChaptersAdapter.onBindViewHolder]. It updates the data for this
|
|
||||||
* holder with the given manga.
|
|
||||||
*
|
|
||||||
* @param item the manga item to bind.
|
|
||||||
*/
|
|
||||||
abstract fun bind(item: ChapterItem, manga: Manga)
|
|
||||||
}
|
|
@ -105,7 +105,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
open class MangaDetailsController : BaseController,
|
class MangaDetailsController : BaseController,
|
||||||
FlexibleAdapter.OnItemClickListener,
|
FlexibleAdapter.OnItemClickListener,
|
||||||
FlexibleAdapter.OnItemLongClickListener,
|
FlexibleAdapter.OnItemLongClickListener,
|
||||||
ActionMode.Callback,
|
ActionMode.Callback,
|
||||||
@ -126,6 +126,7 @@ open class MangaDetailsController : BaseController,
|
|||||||
if (manga != null) {
|
if (manga != null) {
|
||||||
source = Injekt.get<SourceManager>().getOrStub(manga.source)
|
source = Injekt.get<SourceManager>().getOrStub(manga.source)
|
||||||
}
|
}
|
||||||
|
presenter = MangaDetailsPresenter(this, manga!!, source!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(mangaId: Long) : this(
|
constructor(mangaId: Long) : this(
|
||||||
@ -142,15 +143,15 @@ open class MangaDetailsController : BaseController,
|
|||||||
private var manga: Manga? = null
|
private var manga: Manga? = null
|
||||||
private var source: Source? = null
|
private var source: Source? = null
|
||||||
var colorAnimator:ValueAnimator? = null
|
var colorAnimator:ValueAnimator? = null
|
||||||
lateinit var presenter:MangaDetailsPresenter
|
val presenter:MangaDetailsPresenter
|
||||||
var coverColor:Int? = null
|
var coverColor:Int? = null
|
||||||
var toolbarIsColored = false
|
var toolbarIsColored = false
|
||||||
private var snack: Snackbar? = null
|
private var snack: Snackbar? = null
|
||||||
val fromCatalogue = args.getBoolean(FROM_CATALOGUE_EXTRA, false)
|
val fromCatalogue = args.getBoolean(FROM_CATALOGUE_EXTRA, false)
|
||||||
var coverDrawable:Drawable? = null
|
var coverDrawable:Drawable? = null
|
||||||
var trackingBottomSheet: TrackingBottomSheet? = null
|
private var trackingBottomSheet: TrackingBottomSheet? = null
|
||||||
|
private var startingDLChapterPos:Int? = null
|
||||||
|
|
||||||
var startingDLChapterPos:Int? = null
|
|
||||||
/**
|
/**
|
||||||
* Adapter containing a list of chapters.
|
* Adapter containing a list of chapters.
|
||||||
*/
|
*/
|
||||||
@ -178,7 +179,6 @@ open class MangaDetailsController : BaseController,
|
|||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
coverColor = null
|
coverColor = null
|
||||||
if (!::presenter.isInitialized) presenter = MangaDetailsPresenter(this, manga!!, source!!)
|
|
||||||
|
|
||||||
// Init RecyclerView and adapter
|
// Init RecyclerView and adapter
|
||||||
adapter = ChaptersAdapter(this, view.context)
|
adapter = ChaptersAdapter(this, view.context)
|
||||||
@ -191,7 +191,7 @@ open class MangaDetailsController : BaseController,
|
|||||||
DividerItemDecoration.VERTICAL
|
DividerItemDecoration.VERTICAL
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
recycler.setHasFixedSize(false)
|
recycler.setHasFixedSize(true)
|
||||||
adapter?.fastScroller = fast_scroller
|
adapter?.fastScroller = fast_scroller
|
||||||
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
val attrsArray = intArrayOf(android.R.attr.actionBarSize)
|
||||||
val array = view.context.obtainStyledAttributes(attrsArray)
|
val array = view.context.obtainStyledAttributes(attrsArray)
|
||||||
@ -208,7 +208,6 @@ open class MangaDetailsController : BaseController,
|
|||||||
topMargin = appbarHeight + insets.systemWindowInsetTop
|
topMargin = appbarHeight + insets.systemWindowInsetTop
|
||||||
bottomMargin = insets.systemWindowInsetBottom
|
bottomMargin = insets.systemWindowInsetBottom
|
||||||
}
|
}
|
||||||
// offset the recycler by the fab's inset + some inset on top
|
|
||||||
v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
v.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,6 +305,11 @@ open class MangaDetailsController : BaseController,
|
|||||||
presenter.isLockedFromSearch = SecureActivityDelegate.shouldBeLocked()
|
presenter.isLockedFromSearch = SecureActivityDelegate.shouldBeLocked()
|
||||||
presenter.headerItem.isLocked = presenter.isLockedFromSearch
|
presenter.headerItem.isLocked = presenter.isLockedFromSearch
|
||||||
presenter.fetchChapters()
|
presenter.fetchChapters()
|
||||||
|
val isCurrentController = router?.backstack?.lastOrNull()?.controller() ==
|
||||||
|
this
|
||||||
|
if (isCurrentController) {
|
||||||
|
setStatusBarAndToolbar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showError(message: String) {
|
fun showError(message: String) {
|
||||||
@ -325,10 +329,7 @@ open class MangaDetailsController : BaseController,
|
|||||||
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
override fun onChangeStarted(handler: ControllerChangeHandler, type: ControllerChangeType) {
|
||||||
super.onChangeStarted(handler, type)
|
super.onChangeStarted(handler, type)
|
||||||
if (type == ControllerChangeType.PUSH_ENTER || type == ControllerChangeType.POP_ENTER) {
|
if (type == ControllerChangeType.PUSH_ENTER || type == ControllerChangeType.POP_ENTER) {
|
||||||
setStatusBar()
|
setStatusBarAndToolbar()
|
||||||
(activity as MainActivity).appbar.setBackgroundColor(Color.TRANSPARENT)
|
|
||||||
(activity as MainActivity).toolbar.setBackgroundColor(activity?.window?.statusBarColor
|
|
||||||
?: Color.TRANSPARENT)
|
|
||||||
}
|
}
|
||||||
else if (type == ControllerChangeType.PUSH_EXIT || type == ControllerChangeType.POP_EXIT) {
|
else if (type == ControllerChangeType.PUSH_EXIT || type == ControllerChangeType.POP_EXIT) {
|
||||||
if (router.backstack.lastOrNull()?.controller() is DialogController)
|
if (router.backstack.lastOrNull()?.controller() is DialogController)
|
||||||
@ -351,15 +352,9 @@ open class MangaDetailsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateHeader() {
|
fun updateHeader() {
|
||||||
if (presenter.chapters.isEmpty()) {
|
swipe_refresh?.isRefreshing = presenter.isLoading
|
||||||
adapter?.updateDataSet(listOf(presenter.headerItem))
|
adapter?.setChapters(presenter.chapters)
|
||||||
}
|
addMangaHeader()
|
||||||
else {
|
|
||||||
swipe_refresh?.isRefreshing = presenter.isLoading
|
|
||||||
adapter?.updateDataSet(
|
|
||||||
listOf(ChapterItem(presenter.headerItem, presenter.manga)) + presenter.chapters
|
|
||||||
)
|
|
||||||
}
|
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,15 +364,15 @@ open class MangaDetailsController : BaseController,
|
|||||||
launchUI { swipe_refresh?.isRefreshing = true }
|
launchUI { swipe_refresh?.isRefreshing = true }
|
||||||
presenter.fetchChaptersFromSource()
|
presenter.fetchChaptersFromSource()
|
||||||
}
|
}
|
||||||
adapter?.updateDataSet(listOf(presenter.headerItem) + chapters)
|
adapter?.setChapters(chapters)
|
||||||
|
addMangaHeader()
|
||||||
activity?.invalidateOptionsMenu()
|
activity?.invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun refreshAdapter() = adapter?.notifyDataSetChanged()
|
fun refreshAdapter() = adapter?.notifyDataSetChanged()
|
||||||
|
|
||||||
override fun onItemClick(view: View?, position: Int): Boolean {
|
override fun onItemClick(view: View?, position: Int): Boolean {
|
||||||
val chapter = adapter?.getItem(position)?.chapter ?: return false
|
val chapter = (adapter?.getItem(position) as? ChapterItem)?.chapter ?: return false
|
||||||
if (chapter.isHeader) return false
|
|
||||||
if (actionMode != null) {
|
if (actionMode != null) {
|
||||||
if (startingDLChapterPos == null) {
|
if (startingDLChapterPos == null) {
|
||||||
adapter?.addSelection(position)
|
adapter?.addSelection(position)
|
||||||
@ -410,7 +405,7 @@ open class MangaDetailsController : BaseController,
|
|||||||
|
|
||||||
override fun onItemLongClick(position: Int) {
|
override fun onItemLongClick(position: Int) {
|
||||||
val adapter = adapter ?: return
|
val adapter = adapter ?: return
|
||||||
val item = adapter.getItem(position) ?: return
|
val item = (adapter.getItem(position) as? ChapterItem) ?: return
|
||||||
val itemView = getHolder(item)?.itemView ?: return
|
val itemView = getHolder(item)?.itemView ?: return
|
||||||
val popup = PopupMenu(itemView.context, itemView, Gravity.END)
|
val popup = PopupMenu(itemView.context, itemView, Gravity.END)
|
||||||
|
|
||||||
@ -709,7 +704,7 @@ open class MangaDetailsController : BaseController,
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun startDownloadRange(position: Int) {
|
override fun startDownloadRange(position: Int) {
|
||||||
createActionModeIfNeeded()
|
if (actionMode == null) createActionModeIfNeeded()
|
||||||
onItemClick(null, position)
|
onItemClick(null, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,8 +738,11 @@ open class MangaDetailsController : BaseController,
|
|||||||
|
|
||||||
override fun downloadChapter(position: Int) {
|
override fun downloadChapter(position: Int) {
|
||||||
val view = view ?: return
|
val view = view ?: return
|
||||||
val chapter = adapter?.getItem(position) ?: return
|
val chapter = (adapter?.getItem(position) as? ChapterItem) ?: return
|
||||||
if (chapter.isHeader) return
|
if (actionMode != null) {
|
||||||
|
onItemClick(null, position)
|
||||||
|
return
|
||||||
|
}
|
||||||
if (chapter.status != Download.NOT_DOWNLOADED && chapter.status != Download.ERROR) {
|
if (chapter.status != Download.NOT_DOWNLOADED && chapter.status != Download.ERROR) {
|
||||||
presenter.deleteChapters(listOf(chapter))
|
presenter.deleteChapters(listOf(chapter))
|
||||||
}
|
}
|
||||||
@ -970,19 +968,30 @@ open class MangaDetailsController : BaseController,
|
|||||||
|
|
||||||
override fun onDestroyActionMode(mode: ActionMode?) {
|
override fun onDestroyActionMode(mode: ActionMode?) {
|
||||||
actionMode = null
|
actionMode = null
|
||||||
setStatusBar()
|
setStatusBarAndToolbar()
|
||||||
startingDLChapterPos = null
|
startingDLChapterPos = null
|
||||||
adapter?.mode = SelectableAdapter.Mode.IDLE
|
adapter?.mode = SelectableAdapter.Mode.IDLE
|
||||||
adapter?.clearSelection()
|
adapter?.clearSelection()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setStatusBar() {
|
/**
|
||||||
|
* Called to set the last used catalogue at the top of the view.
|
||||||
|
*/
|
||||||
|
private fun addMangaHeader() {
|
||||||
|
adapter?.removeAllScrollableHeaders()
|
||||||
|
adapter?.addScrollableHeader(presenter.headerItem)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setStatusBarAndToolbar() {
|
||||||
activity?.window?.statusBarColor = if (toolbarIsColored) {
|
activity?.window?.statusBarColor = if (toolbarIsColored) {
|
||||||
val translucentColor = ColorUtils.setAlphaComponent(coverColor ?: Color.TRANSPARENT, 175)
|
val translucentColor = ColorUtils.setAlphaComponent(coverColor ?: Color.TRANSPARENT, 175)
|
||||||
(activity as MainActivity).toolbar.setBackgroundColor(translucentColor)
|
(activity as MainActivity).toolbar.setBackgroundColor(translucentColor)
|
||||||
translucentColor
|
translucentColor
|
||||||
} else Color.TRANSPARENT
|
} else Color.TRANSPARENT
|
||||||
|
(activity as MainActivity).appbar.setBackgroundColor(Color.TRANSPARENT)
|
||||||
|
(activity as MainActivity).toolbar.setBackgroundColor(activity?.window?.statusBarColor
|
||||||
|
?: Color.TRANSPARENT)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
override fun onPrepareActionMode(mode: ActionMode?, menu: Menu?): Boolean {
|
||||||
|
@ -69,7 +69,7 @@ class MangaDetailsPresenter(private val controller: MangaDetailsController,
|
|||||||
var chapters:List<ChapterItem> = emptyList()
|
var chapters:List<ChapterItem> = emptyList()
|
||||||
private set
|
private set
|
||||||
|
|
||||||
var headerItem = ChapterItem(Chapter.createHeader(controller.fromCatalogue), manga)
|
var headerItem = MangaHeaderItem(manga, controller.fromCatalogue)
|
||||||
|
|
||||||
fun onCreate() {
|
fun onCreate() {
|
||||||
isLockedFromSearch = SecureActivityDelegate.shouldBeLocked()
|
isLockedFromSearch = SecureActivityDelegate.shouldBeLocked()
|
||||||
|
@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga
|
|||||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||||
import eu.kanade.tachiyomi.data.glide.GlideApp
|
import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter
|
import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
@ -30,7 +30,7 @@ class MangaHeaderHolder(
|
|||||||
private val view: View,
|
private val view: View,
|
||||||
private val adapter: ChaptersAdapter,
|
private val adapter: ChaptersAdapter,
|
||||||
startExpanded: Boolean
|
startExpanded: Boolean
|
||||||
) : MangaChapterHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
start_reading_button.setOnClickListener { adapter.coverListener.readNextChapter() }
|
start_reading_button.setOnClickListener { adapter.coverListener.readNextChapter() }
|
||||||
@ -84,8 +84,8 @@ class MangaHeaderHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun bind(item: ChapterItem, manga: Manga) {
|
fun bind(item: MangaHeaderItem, manga: Manga) {
|
||||||
val presenter = adapter.coverListener?.mangaPresenter() ?: return
|
val presenter = adapter.coverListener.mangaPresenter()
|
||||||
manga_full_title.text = manga.currentTitle()
|
manga_full_title.text = manga.currentTitle()
|
||||||
|
|
||||||
if (manga.currentGenres().isNullOrBlank().not())
|
if (manga.currentGenres().isNullOrBlank().not())
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
package eu.kanade.tachiyomi.ui.manga
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.AbstractFlexibleItem
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
import eu.kanade.tachiyomi.ui.manga.chapter.ChaptersAdapter
|
||||||
|
|
||||||
|
class MangaHeaderItem(val manga: Manga, private val startExpanded: Boolean):
|
||||||
|
AbstractFlexibleItem<MangaHeaderHolder>(){
|
||||||
|
|
||||||
|
var isLocked = false
|
||||||
|
|
||||||
|
override fun getLayoutRes(): Int {
|
||||||
|
return R.layout.manga_header_item
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isSelectable(): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): MangaHeaderHolder {
|
||||||
|
return MangaHeaderHolder(view, adapter as ChaptersAdapter, startExpanded)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
|
holder: MangaHeaderHolder,
|
||||||
|
position: Int,
|
||||||
|
payloads: MutableList<Any?>?) {
|
||||||
|
holder.bind(this, manga)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
return (this === other)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return manga.id!!.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,11 +10,9 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
|
|||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaChapterHolder
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaHeaderHolder
|
|
||||||
|
|
||||||
class ChapterItem(val chapter: Chapter, val manga: Manga) :
|
class ChapterItem(val chapter: Chapter, val manga: Manga) :
|
||||||
AbstractFlexibleItem<MangaChapterHolder>(),
|
AbstractFlexibleItem<ChapterMatHolder>(),
|
||||||
Chapter by chapter {
|
Chapter by chapter {
|
||||||
|
|
||||||
private var _status: Int = 0
|
private var _status: Int = 0
|
||||||
@ -36,22 +34,19 @@ class ChapterItem(val chapter: Chapter, val manga: Manga) :
|
|||||||
get() = status == Download.DOWNLOADED
|
get() = status == Download.DOWNLOADED
|
||||||
|
|
||||||
override fun getLayoutRes(): Int {
|
override fun getLayoutRes(): Int {
|
||||||
return if (chapter.isHeader) R.layout.manga_header_item
|
return R.layout.chapters_mat_item
|
||||||
else R.layout.chapters_mat_item
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isSelectable(): Boolean {
|
override fun isSelectable(): Boolean {
|
||||||
return !chapter.isHeader
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): MangaChapterHolder {
|
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>): ChapterMatHolder {
|
||||||
return if (chapter.isHeader) MangaHeaderHolder(view, adapter as ChaptersAdapter,
|
return ChapterMatHolder(view, adapter as ChaptersAdapter)
|
||||||
startExpanded = chapter.read)
|
|
||||||
else ChapterMatHolder(view, adapter as ChaptersAdapter)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<RecyclerView.ViewHolder>>,
|
||||||
holder: MangaChapterHolder,
|
holder: ChapterMatHolder,
|
||||||
position: Int,
|
position: Int,
|
||||||
payloads: MutableList<Any?>?) {
|
payloads: MutableList<Any?>?) {
|
||||||
holder.bind(this, manga)
|
holder.bind(this, manga)
|
||||||
|
@ -6,10 +6,10 @@ import androidx.appcompat.widget.PopupMenu
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaChapterHolder
|
import eu.kanade.tachiyomi.source.LocalSource
|
||||||
|
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||||
import eu.kanade.tachiyomi.util.view.gone
|
import eu.kanade.tachiyomi.util.view.gone
|
||||||
import eu.kanade.tachiyomi.util.view.invisible
|
import eu.kanade.tachiyomi.util.view.visibleIf
|
||||||
import eu.kanade.tachiyomi.util.view.visible
|
|
||||||
import kotlinx.android.synthetic.main.chapters_mat_item.*
|
import kotlinx.android.synthetic.main.chapters_mat_item.*
|
||||||
import kotlinx.android.synthetic.main.download_button.*
|
import kotlinx.android.synthetic.main.download_button.*
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
@ -17,8 +17,9 @@ import java.util.Date
|
|||||||
class ChapterMatHolder(
|
class ChapterMatHolder(
|
||||||
private val view: View,
|
private val view: View,
|
||||||
private val adapter: ChaptersAdapter
|
private val adapter: ChaptersAdapter
|
||||||
) : MangaChapterHolder(view, adapter) {
|
) : BaseFlexibleViewHolder(view, adapter) {
|
||||||
|
|
||||||
|
private var localSource = false
|
||||||
init {
|
init {
|
||||||
download_button.setOnClickListener { downloadOrRemoveMenu() }
|
download_button.setOnClickListener { downloadOrRemoveMenu() }
|
||||||
download_button.setOnLongClickListener {
|
download_button.setOnLongClickListener {
|
||||||
@ -28,7 +29,7 @@ class ChapterMatHolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun downloadOrRemoveMenu() {
|
private fun downloadOrRemoveMenu() {
|
||||||
val chapter = adapter.getItem(adapterPosition) ?: return
|
val chapter = adapter.getItem(adapterPosition) as? ChapterItem ?: return
|
||||||
if (chapter.status == Download.NOT_DOWNLOADED || chapter.status == Download.ERROR) {
|
if (chapter.status == Download.NOT_DOWNLOADED || chapter.status == Download.ERROR) {
|
||||||
adapter.coverListener.downloadChapter(adapterPosition)
|
adapter.coverListener.downloadChapter(adapterPosition)
|
||||||
} else {
|
} else {
|
||||||
@ -56,7 +57,7 @@ class ChapterMatHolder(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun bind(item: ChapterItem, manga: Manga) {
|
fun bind(item: ChapterItem, manga: Manga) {
|
||||||
val chapter = item.chapter
|
val chapter = item.chapter
|
||||||
val isLocked = item.isLocked
|
val isLocked = item.isLocked
|
||||||
chapter_title.text = when (manga.displayMode) {
|
chapter_title.text = when (manga.displayMode) {
|
||||||
@ -67,12 +68,10 @@ class ChapterMatHolder(
|
|||||||
else -> chapter.name
|
else -> chapter.name
|
||||||
}
|
}
|
||||||
|
|
||||||
//chapter_menu.visible()
|
localSource = manga.source == LocalSource.ID
|
||||||
// Set the correct drawable for dropdown and update the tint to match theme.
|
download_button.visibleIf(!localSource)
|
||||||
//chapter_menu.setVectorCompat(R.drawable.ic_more_vert_black_24dp, view.context
|
|
||||||
// .getResourceColor(R.attr.icon_color))
|
|
||||||
|
|
||||||
if (isLocked) download_button.invisible()
|
if (isLocked) download_button.gone()
|
||||||
|
|
||||||
|
|
||||||
// Set correct text color
|
// Set correct text color
|
||||||
@ -110,7 +109,7 @@ class ChapterMatHolder(
|
|||||||
gone()
|
gone()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
visible()
|
download_button.visibleIf(!localSource)
|
||||||
setDownloadStatus(status, progress)
|
setDownloadStatus(status, progress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,22 +4,21 @@ import android.content.Context
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import eu.davidea.flexibleadapter.FlexibleAdapter
|
import eu.davidea.flexibleadapter.FlexibleAdapter
|
||||||
|
import eu.davidea.flexibleadapter.items.IFlexible
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsPresenter
|
import eu.kanade.tachiyomi.ui.manga.MangaDetailsPresenter
|
||||||
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
|
||||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.text.DateFormat
|
|
||||||
import java.text.DecimalFormat
|
import java.text.DecimalFormat
|
||||||
import java.text.DecimalFormatSymbols
|
import java.text.DecimalFormatSymbols
|
||||||
|
|
||||||
class ChaptersAdapter(
|
class ChaptersAdapter(
|
||||||
val controller: MangaDetailsController,
|
val controller: MangaDetailsController,
|
||||||
context: Context
|
context: Context
|
||||||
) : FlexibleAdapter<ChapterItem>(null, controller, true) {
|
) : FlexibleAdapter<IFlexible<*>>(null, controller, true) {
|
||||||
|
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
|
|
||||||
@ -36,9 +35,7 @@ class ChaptersAdapter(
|
|||||||
val decimalFormat = DecimalFormat("#.###", DecimalFormatSymbols()
|
val decimalFormat = DecimalFormat("#.###", DecimalFormatSymbols()
|
||||||
.apply { decimalSeparator = '.' })
|
.apply { decimalSeparator = '.' })
|
||||||
|
|
||||||
val dateFormat: DateFormat = preferences.dateFormat().getOrDefault()
|
fun setChapters(items: List<ChapterItem>?) {
|
||||||
|
|
||||||
override fun updateDataSet(items: List<ChapterItem>?) {
|
|
||||||
this.items = items ?: emptyList()
|
this.items = items ?: emptyList()
|
||||||
super.updateDataSet(items)
|
super.updateDataSet(items)
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,5 @@
|
|||||||
tools:text="Sample artist" />
|
tools:text="Sample artist" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -30,7 +30,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="2dp"
|
android:layout_marginTop="2dp"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:paddingStart="20dp"
|
android:paddingStart="10dp"
|
||||||
android:paddingTop="8dp"
|
android:paddingTop="8dp"
|
||||||
android:paddingEnd="20dp"
|
android:paddingEnd="20dp"
|
||||||
android:paddingBottom="6dp"
|
android:paddingBottom="6dp"
|
||||||
@ -63,7 +63,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="23dp"
|
android:layout_marginStart="10dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<com.google.android.material.checkbox.MaterialCheckBox
|
<com.google.android.material.checkbox.MaterialCheckBox
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/download_text"
|
android:id="@+id/download_text"
|
||||||
style="@style/TextAppearance.Regular.Caption.Light"
|
style="@style/TextAppearance.MaterialComponents.Caption"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/pale_red"
|
android:background="@color/pale_red"
|
||||||
@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@+id/unread_text"
|
android:id="@+id/unread_text"
|
||||||
style="@style/TextAppearance.Regular.Caption.Light"
|
style="@style/TextAppearance.MaterialComponents.Caption"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/colorAccent"
|
android:background="@color/colorAccent"
|
||||||
|
@ -551,8 +551,8 @@
|
|||||||
<string name="manga_download">Download</string>
|
<string name="manga_download">Download</string>
|
||||||
<string name="custom_download">Download custom amount</string>
|
<string name="custom_download">Download custom amount</string>
|
||||||
<string name="download_1">Next chapter</string>
|
<string name="download_1">Next chapter</string>
|
||||||
<string name="download_first">First unread chapter</string>
|
<string name="download_first">Next unread chapter</string>
|
||||||
<string name="download_5">Next 5 chapters</string>
|
<string name="download_5">Next 5 unread</string>
|
||||||
<string name="download_10">Next 10 chapters</string>
|
<string name="download_10">Next 10 chapters</string>
|
||||||
<string name="download_custom">Custom range</string>
|
<string name="download_custom">Custom range</string>
|
||||||
<string name="download_all">All chapters</string>
|
<string name="download_all">All chapters</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user