More work to the bottom sheet + fixed white theme in webview for dark mode
This commit is contained in:
parent
c35b4472dd
commit
40e4adc23b
@ -38,7 +38,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
|
|
||||||
private lateinit var categories:FilterTagGroup
|
private lateinit var categories:FilterTagGroup
|
||||||
|
|
||||||
val items:List<FilterTagGroup> by lazy {
|
val filterItems:List<FilterTagGroup> by lazy {
|
||||||
val list = mutableListOf<FilterTagGroup>()
|
val list = mutableListOf<FilterTagGroup>()
|
||||||
if (Injekt.get<DatabaseHelper>().getCategories().executeAsBlocking().isNotEmpty())
|
if (Injekt.get<DatabaseHelper>().getCategories().executeAsBlocking().isNotEmpty())
|
||||||
list.add(categories)
|
list.add(categories)
|
||||||
@ -53,7 +53,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
var onGroupClicked: (Int) -> Unit = { _ -> }
|
var onGroupClicked: (Int) -> Unit = { _ -> }
|
||||||
val recycler = androidx.recyclerview.widget.RecyclerView(context)
|
val recycler = androidx.recyclerview.widget.RecyclerView(context)
|
||||||
var pager:View? = null
|
var pager:View? = null
|
||||||
var filters = listOf<FilterTagGroup>()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|
||||||
@ -68,8 +67,16 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
sheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
line.alpha = 0f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sortText.alpha = if (sheetBehavior.state != BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
||||||
|
title.alpha = if (sheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) 1f else 0f
|
||||||
|
|
||||||
pager = pagerView
|
pager = pagerView
|
||||||
pager?.setPadding(0, 0, 0, topbar.height)
|
pager?.setPadding(0, 0, 0, topbar.height)
|
||||||
|
updateTitle()
|
||||||
sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
sheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||||
val minHeight = sheetBehavior.peekHeight
|
val minHeight = sheetBehavior.peekHeight
|
||||||
@ -77,7 +84,9 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
val percent = (progress * 100).roundToInt()
|
val percent = (progress * 100).roundToInt()
|
||||||
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
val value = (percent * (maxHeight - minHeight) / 100) + minHeight
|
||||||
pager?.setPadding(0, 0, 0, value)
|
pager?.setPadding(0, 0, 0, value)
|
||||||
line.alpha = 1 - progress
|
sortText.alpha = 1 - progress
|
||||||
|
title.alpha = progress
|
||||||
|
//line.alpha = 1 - progress
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStateChanged(p0: View, p1: Int) {
|
override fun onStateChanged(p0: View, p1: Int) {
|
||||||
@ -93,6 +102,64 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
createTags()
|
createTags()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateTitle() {
|
||||||
|
val filters = getFilters().toMutableList()
|
||||||
|
if (filters.isEmpty()) {
|
||||||
|
sortText.text = context.getString(
|
||||||
|
R.string.sorting_by_, context.getString(
|
||||||
|
when (preferences.librarySortingMode().getOrDefault()) {
|
||||||
|
LibrarySort.LAST_UPDATED -> R.string.action_sort_last_updated
|
||||||
|
LibrarySort.DRAG_AND_DROP -> R.string.action_sort_drag_and_drop
|
||||||
|
LibrarySort.TOTAL -> R.string.action_sort_total
|
||||||
|
LibrarySort.UNREAD -> R.string.action_filter_unread
|
||||||
|
LibrarySort.LAST_READ -> R.string.action_sort_last_read
|
||||||
|
else -> R.string.title
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filters.add(0, when (preferences.librarySortingMode().getOrDefault()) {
|
||||||
|
LibrarySort.LAST_UPDATED -> R.string.action_sort_last_updated
|
||||||
|
LibrarySort.DRAG_AND_DROP -> R.string.action_sort_drag_and_drop
|
||||||
|
LibrarySort.TOTAL -> R.string.action_sort_total
|
||||||
|
LibrarySort.UNREAD -> R.string.action_filter_unread
|
||||||
|
LibrarySort.LAST_READ -> R.string.action_sort_last_read
|
||||||
|
else -> R.string.action_sort_alpha
|
||||||
|
})
|
||||||
|
sortText.text = filters.joinToString(", ") { context.getString(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getFilters(): List<Int> {
|
||||||
|
val filters = mutableListOf<Int>()
|
||||||
|
var filter = preferences.filterDownloaded().getOrDefault()
|
||||||
|
if (filter > 0) {
|
||||||
|
filters.add(if (filter == 1) R.string.action_filter_downloaded else R.string
|
||||||
|
.action_filter_not_downloaded)
|
||||||
|
}
|
||||||
|
filter = preferences.filterCompleted().getOrDefault()
|
||||||
|
if (filter > 0) {
|
||||||
|
filters.add(if (filter == 1) R.string.completed else R.string
|
||||||
|
.ongoing)
|
||||||
|
}
|
||||||
|
filter = preferences.filterUnread().getOrDefault()
|
||||||
|
if (filter > 0) {
|
||||||
|
filters.add(when (filter) {
|
||||||
|
3 -> R.string.action_filter_read
|
||||||
|
2 -> R.string.action_filter_in_progress
|
||||||
|
else -> R.string.action_filter_not_started
|
||||||
|
})
|
||||||
|
}
|
||||||
|
filter = preferences.filterTracked().getOrDefault()
|
||||||
|
if (filter > 0) {
|
||||||
|
filters.add(if (filter == 1) R.string.action_filter_tracked else R.string
|
||||||
|
.action_filter_not_tracked)
|
||||||
|
}
|
||||||
|
return filters
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fun createTags() {
|
fun createTags() {
|
||||||
categories = inflate(R.layout.filter_buttons) as FilterTagGroup
|
categories = inflate(R.layout.filter_buttons) as FilterTagGroup
|
||||||
categories.setup(this, R.string.categories)
|
categories.setup(this, R.string.categories)
|
||||||
@ -120,15 +187,15 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
tracked.onItemClicked = { view, index -> onFilterClicked(view, index) }
|
tracked.onItemClicked = { view, index -> onFilterClicked(view, index) }
|
||||||
tracked.setState(preferences.filterTracked())
|
tracked.setState(preferences.filterTracked())
|
||||||
|
|
||||||
items.forEach {
|
filterItems.forEach {
|
||||||
filterLayout.addView(it)
|
filterLayout.addView(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun onFilterClicked(view: View, index: Int) {
|
private fun onFilterClicked(view: View, index: Int) {
|
||||||
val transition = AutoTransition()
|
/*val transition = AutoTransition()
|
||||||
transition.duration = 150
|
transition.duration = 150
|
||||||
TransitionManager.beginDelayedTransition(this, transition)
|
TransitionManager.beginDelayedTransition(this, transition)*/
|
||||||
/*f (index > -1) {
|
/*f (index > -1) {
|
||||||
filterScrollView.scrollX = 0
|
filterScrollView.scrollX = 0
|
||||||
filterLayout.removeView(view)
|
filterLayout.removeView(view)
|
||||||
@ -160,6 +227,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
|
|||||||
onGroupClicked(ACTION_FILTER)
|
onGroupClicked(ACTION_FILTER)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateTitle()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -61,7 +61,7 @@ class FilterTagGroup@JvmOverloads constructor(context: Context, attrs: Attribute
|
|||||||
|
|
||||||
fun setState(preference: Preference<Int>) {
|
fun setState(preference: Preference<Int>) {
|
||||||
val index = preference.getOrDefault() - 1
|
val index = preference.getOrDefault() - 1
|
||||||
if (index > 1)
|
if (index > -1)
|
||||||
toggleButton(index)
|
toggleButton(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,14 +139,19 @@ class LibraryPresenter(
|
|||||||
|
|
||||||
val filterTracked = preferences.filterTracked().getOrDefault()
|
val filterTracked = preferences.filterTracked().getOrDefault()
|
||||||
|
|
||||||
|
val lastReadManga by lazy {
|
||||||
|
db.getLastReadManga().executeAsBlocking()
|
||||||
|
}
|
||||||
|
|
||||||
val filterFn: (LibraryItem) -> Boolean = f@ { item ->
|
val filterFn: (LibraryItem) -> Boolean = f@ { item ->
|
||||||
// Filter when there isn't unread chapters.
|
// Filter when there isn't unread chapters.
|
||||||
if (MainActivity.bottomNav) {
|
if (MainActivity.bottomNav) {
|
||||||
if (filterUnread == STATE_INCLUDE &&
|
if (filterUnread == STATE_INCLUDE &&
|
||||||
(item.manga.unread == 0 || db.getChapters(item.manga).executeAsBlocking()
|
(item.manga.unread == 0 || lastReadManga.find { it.id == item.manga.id } ==
|
||||||
.size != item.manga.unread)) return@f false
|
null)) return@f false
|
||||||
if (filterUnread == STATE_EXCLUDE &&
|
if (filterUnread == STATE_EXCLUDE &&
|
||||||
(item.manga.unread == 0 || db.getChapters(item.manga).executeAsBlocking().size == item.manga.unread)) return@f false
|
(item.manga.unread == 0 || lastReadManga.find { it.id == item.manga.id } !=
|
||||||
|
null)) return@f false
|
||||||
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
if (filterUnread == STATE_REALLY_EXCLUDE && item.manga.unread > 0) return@f false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -112,15 +112,13 @@ open class MainActivity : BaseActivity() {
|
|||||||
lateinit var tabAnimator: TabsAnimator
|
lateinit var tabAnimator: TabsAnimator
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
if (preferences.theme() in 1..4) {
|
super.onCreate(savedInstanceState)
|
||||||
Timber.d("Manually instantiating WebView to avoid night mode issue.")
|
Timber.d("Manually instantiating WebView to avoid night mode issue.")
|
||||||
try {
|
try {
|
||||||
WebView(applicationContext)
|
WebView(applicationContext)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "Exception when creating webview at start")
|
Timber.e(e, "Exception when creating webview at start")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
if (trulyGoBack) return
|
if (trulyGoBack) return
|
||||||
|
|
||||||
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
|
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
|
||||||
|
@ -14,6 +14,7 @@ import android.view.ViewGroup
|
|||||||
import android.webkit.WebChromeClient
|
import android.webkit.WebChromeClient
|
||||||
import android.webkit.WebView
|
import android.webkit.WebView
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -55,6 +56,11 @@ class WebViewActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
delegate.localNightMode = when (preferences.theme()) {
|
||||||
|
1, 8 -> AppCompatDelegate.MODE_NIGHT_NO
|
||||||
|
2, 3, 4 -> AppCompatDelegate.MODE_NIGHT_YES
|
||||||
|
else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM
|
||||||
|
}
|
||||||
setContentView(R.layout.webview_activity)
|
setContentView(R.layout.webview_activity)
|
||||||
title = intent.extras?.getString(TITLE_KEY)
|
title = intent.extras?.getString(TITLE_KEY)
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
@ -188,7 +194,7 @@ class WebViewActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
val currentNightMode = newConfig.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
val currentNightMode = resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
|
||||||
val lightMode = currentNightMode == Configuration.UI_MODE_NIGHT_NO
|
val lightMode = currentNightMode == Configuration.UI_MODE_NIGHT_NO
|
||||||
window.statusBarColor = getResourceColor(R.attr.colorPrimary)
|
window.statusBarColor = getResourceColor(R.attr.colorPrimary)
|
||||||
toolbar.setBackgroundColor(getResourceColor(R.attr.colorPrimary))
|
toolbar.setBackgroundColor(getResourceColor(R.attr.colorPrimary))
|
||||||
|
7
app/src/main/res/drawable/shape_gradient_top_shadow.xml
Normal file
7
app/src/main/res/drawable/shape_gradient_top_shadow.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:endColor="@android:color/transparent"
|
||||||
|
android:startColor="?android:attr/textColorSecondary"/>
|
||||||
|
</shape>
|
@ -17,27 +17,43 @@
|
|||||||
android:id="@+id/topbar"
|
android:id="@+id/topbar"
|
||||||
android:background="?android:attr/colorPrimary">
|
android:background="?android:attr/colorPrimary">
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="24dp"
|
|
||||||
android:layout_marginTop="15dp"
|
|
||||||
android:textColor="?attr/actionBarTintColor"
|
|
||||||
android:text="Filter & Sort"
|
|
||||||
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imageView2"
|
android:id="@+id/imageView2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_marginStart="8dp"
|
android:layout_marginStart="24dp"
|
||||||
android:src="@drawable/ic_sort_white_24dp"
|
android:src="@drawable/ic_sort_white_24dp"
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/textView2"
|
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||||
app:layout_constraintStart_toEndOf="@+id/textView2"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="@+id/textView2" />
|
app:layout_constraintTop_toTopOf="@+id/sortText" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/sortText"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:textColor="?attr/actionBarTintColor"
|
||||||
|
android:text="Filter & Sort"
|
||||||
|
android:textAlignment="textStart"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/imageView2"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/title"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?attr/actionBarTintColor"
|
||||||
|
android:text="Filter & Sort"
|
||||||
|
android:textAlignment="textStart"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/sortText"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/sortText"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/sortText"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/sortText" />
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:id="@+id/line"
|
android:id="@+id/line"
|
||||||
@ -48,7 +64,7 @@
|
|||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
app:layout_constraintTop_toBottomOf="@+id/sortText" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
@ -67,6 +83,9 @@
|
|||||||
android:id="@+id/filterScrollView"
|
android:id="@+id/filterScrollView"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
|
android:paddingStart="20dp"
|
||||||
|
android:paddingEnd="20dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -16,6 +16,21 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/shadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="16dp"
|
||||||
|
android:backgroundTint="@color/md_black_1000_54"
|
||||||
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
|
app:layout_anchor="@id/bottom_sheet" />
|
||||||
<!-- Adding bottom sheet after main content -->
|
<!-- Adding bottom sheet after main content -->
|
||||||
<include layout="@layout/filter_bottom_sheet" />
|
<include layout="@layout/filter_bottom_sheet" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/shadow2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="8dp"
|
||||||
|
android:alpha="0.25"
|
||||||
|
android:background="@drawable/shape_gradient_top_shadow"
|
||||||
|
android:layout_gravity="bottom" />
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -44,6 +44,7 @@
|
|||||||
<string name="action_filter_tracked">Tracked</string>
|
<string name="action_filter_tracked">Tracked</string>
|
||||||
<string name="action_filter_not_tracked">Not tracked</string>
|
<string name="action_filter_not_tracked">Not tracked</string>
|
||||||
|
|
||||||
|
<string name="sorting_by_">Sorting by %1$s</string>
|
||||||
<string name="action_filter_empty">Remove filter</string>
|
<string name="action_filter_empty">Remove filter</string>
|
||||||
<string name="action_sort_alpha">Alphabetically</string>
|
<string name="action_sort_alpha">Alphabetically</string>
|
||||||
<string name="action_sort_enabled">Enabled</string>
|
<string name="action_sort_enabled">Enabled</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user