mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 01:35:10 +01:00
Going to manga chapters now jumps to your last unread chapter
Fixes to dark theme dialogs for custom download amount
This commit is contained in:
parent
5c80acacb7
commit
2c7f0743db
@ -33,6 +33,7 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import kotlin.math.*
|
||||
|
||||
class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
@ -51,6 +52,8 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
*/
|
||||
private var adapter: ChaptersAdapter? = null
|
||||
|
||||
private var scrollToUnread = true
|
||||
|
||||
/**
|
||||
* Action mode for multiple selection.
|
||||
*/
|
||||
@ -84,19 +87,14 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
adapter = ChaptersAdapter(this, view.context)
|
||||
|
||||
recycler.adapter = adapter
|
||||
recycler.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(view.context)
|
||||
recycler.addItemDecoration(androidx.recyclerview.widget.DividerItemDecoration(view.context, androidx.recyclerview.widget.DividerItemDecoration.VERTICAL))
|
||||
recycler.layoutManager = LinearLayoutManager(view.context)
|
||||
recycler.addItemDecoration(DividerItemDecoration(view.context, DividerItemDecoration.VERTICAL))
|
||||
recycler.setHasFixedSize(true)
|
||||
adapter?.fastScroller = fast_scroller
|
||||
|
||||
val fabBaseMarginBottom = fab?.marginBottom ?: 0
|
||||
recycler.doOnApplyWindowInsets { v, insets, padding ->
|
||||
v.updatePaddingRelative(bottom = padding.bottom + insets.systemWindowInsetBottom)
|
||||
//if (snack == null) {
|
||||
//fab?.translationY = -insets.systemWindowInsetBottom.toFloat()
|
||||
/*}
|
||||
else
|
||||
fab?.translationY = 0f*/
|
||||
fab?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
bottomMargin = fabBaseMarginBottom + insets.systemWindowInsetBottom
|
||||
}
|
||||
@ -213,8 +211,9 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
fun onNextChapters(chapters: List<ChapterItem>) {
|
||||
// If the list is empty, fetch chapters from source if the conditions are met
|
||||
// We use presenter chapters instead because they are always unfiltered
|
||||
if (presenter.chapters.isEmpty())
|
||||
if (presenter.chapters.isEmpty()) {
|
||||
initialFetchChapters()
|
||||
}
|
||||
|
||||
val adapter = adapter ?: return
|
||||
adapter.updateDataSet(chapters)
|
||||
@ -230,7 +229,17 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
actionMode?.invalidate()
|
||||
}
|
||||
scrollToUnread()
|
||||
}
|
||||
|
||||
private fun scrollToUnread() {
|
||||
if (scrollToUnread) {
|
||||
val index = presenter.getFirstUnreadIndex()
|
||||
val centerOfScreen = recycler.height / 2 - 96
|
||||
(recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(index,
|
||||
centerOfScreen)
|
||||
}
|
||||
scrollToUnread = false
|
||||
}
|
||||
|
||||
private fun initialFetchChapters() {
|
||||
@ -520,7 +529,3 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class ShrinkBehavior(context: Context, attrs: AttributeSet) :
|
||||
CoordinatorLayout.Behavior<FloatingActionButton>(context, attrs) {
|
||||
}
|
||||
|
@ -415,4 +415,9 @@ class ChaptersPresenter(
|
||||
return manga.sortDescending()
|
||||
}
|
||||
|
||||
fun getFirstUnreadIndex(): Int {
|
||||
val index = chapters.sortedByDescending { it.source_order }.indexOfFirst { !it.read }
|
||||
return if (sortDescending()) (chapters.size - 1) - index
|
||||
else index
|
||||
}
|
||||
}
|
||||
|
19
app/src/main/res/drawable/dialog_selector.xml
Normal file
19
app/src/main/res/drawable/dialog_selector.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="@color/rippleColor">
|
||||
<item>
|
||||
<selector>
|
||||
<item android:state_selected="true">
|
||||
<color android:color="@color/cardBackground"/>
|
||||
</item>
|
||||
|
||||
<item android:state_activated="true">
|
||||
<color android:color="@color/dialogBackground"/>
|
||||
</item>
|
||||
|
||||
<item>
|
||||
<color android:color="@color/dialogBackground"/>
|
||||
</item>
|
||||
</selector>
|
||||
</item>
|
||||
</ripple>
|
@ -10,7 +10,7 @@
|
||||
android:id="@+id/btn_decrease_10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectable_list_drawable"
|
||||
android:background="@drawable/dialog_selector"
|
||||
android:padding="8dp"
|
||||
android:tint="?colorAccent"
|
||||
app:srcCompat="@drawable/ic_chevron_left_double_black_24dp" />
|
||||
@ -19,7 +19,7 @@
|
||||
android:id="@+id/btn_decrease"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectable_list_drawable"
|
||||
android:background="@drawable/dialog_selector"
|
||||
android:tint="?colorAccent"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_chevron_left_black_24dp" />
|
||||
@ -38,7 +38,7 @@
|
||||
android:id="@+id/btn_increase"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectable_list_drawable"
|
||||
android:background="@drawable/dialog_selector"
|
||||
android:tint="?colorAccent"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_chevron_right_black_24dp" />
|
||||
@ -47,7 +47,7 @@
|
||||
android:id="@+id/btn_increase_10"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectable_list_drawable"
|
||||
android:background="@drawable/dialog_selector"
|
||||
android:tint="?colorAccent"
|
||||
android:padding="8dp"
|
||||
app:srcCompat="@drawable/ic_chevron_right_double_black_24dp" />
|
||||
|
@ -5,4 +5,6 @@
|
||||
<color name="oldNavBarBackground">#B3000000</color>
|
||||
<color name="snackbarBackground">#FFFFFF</color>
|
||||
<color name="cardBackground">@color/colorDarkPrimary</color>
|
||||
<color name="rippleColor">@color/md_white_1000_20</color>
|
||||
<color name="dialogBackground">@color/md_grey_800</color>
|
||||
</resources>
|
@ -7,6 +7,8 @@
|
||||
<color name="drawerPrimary">@color/colorPrimary</color>
|
||||
<color name="cardBackground">#FFFFFF</color>
|
||||
<color name="snackbarBackground">#323232</color>
|
||||
<color name="dialogBackground">@color/md_white_1000</color>
|
||||
<color name="rippleColor">@color/md_black_1000_12</color>
|
||||
<!-- Dark Application Colors -->
|
||||
<color name="colorDarkPrimary">#212121</color>
|
||||
<color name="colorDarkPrimaryDark">#212121</color>
|
||||
@ -37,7 +39,7 @@
|
||||
<color name="textColorSecondaryDark">@color/md_white_1000_70</color>
|
||||
<color name="textColorHintDark">@color/md_white_1000_50</color>
|
||||
<color name="dividerDark">@android:color/transparent</color>
|
||||
<color name="rippleColorDark">@color/md_white_1000_20</color>-
|
||||
<color name="rippleColorDark">@color/md_white_1000_20</color>
|
||||
|
||||
<color name="statusBarDark">@color/md_black_1000</color>
|
||||
<color name="appBarDark">@color/md_grey_900</color>
|
||||
|
Loading…
Reference in New Issue
Block a user