mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-24 13:48:55 +03:00
Fix list scrolling on quad-state dialog (#5602)
This commit is contained in:
parent
649209890d
commit
00ac632d8f
4 changed files with 70 additions and 10 deletions
|
@ -243,8 +243,8 @@ class SettingsDownloadController : SettingsController() {
|
|||
|
||||
return MaterialAlertDialogBuilder(activity!!)
|
||||
.setTitle(R.string.categories)
|
||||
.setMessage(R.string.pref_download_new_categories_details)
|
||||
.setQuadStateMultiChoiceItems(
|
||||
message = R.string.pref_download_new_categories_details,
|
||||
items = items,
|
||||
initialSelected = selected
|
||||
) { selections ->
|
||||
|
|
|
@ -355,8 +355,11 @@ class SettingsLibraryController : SettingsController() {
|
|||
|
||||
return MaterialAlertDialogBuilder(activity!!)
|
||||
.setTitle(R.string.categories)
|
||||
.setMessage(R.string.pref_library_update_categories_details)
|
||||
.setQuadStateMultiChoiceItems(items = items, initialSelected = selected) { selections ->
|
||||
.setQuadStateMultiChoiceItems(
|
||||
message = R.string.pref_library_update_categories_details,
|
||||
items = items,
|
||||
initialSelected = selected
|
||||
) { selections ->
|
||||
selected = selections
|
||||
}
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
|
|
|
@ -3,7 +3,9 @@ package eu.kanade.tachiyomi.widget.materialdialogs
|
|||
import android.view.LayoutInflater
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.getSystemService
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.doAfterTextChanged
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
|
@ -36,6 +38,7 @@ fun MaterialAlertDialogBuilder.setTextInput(
|
|||
* @see eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
||||
*/
|
||||
fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
||||
@StringRes message: Int? = null,
|
||||
items: List<CharSequence>,
|
||||
initialSelected: IntArray,
|
||||
disabledIndices: IntArray? = null,
|
||||
|
@ -49,6 +52,20 @@ fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
|||
initialSelected = initialSelected,
|
||||
listener = selection
|
||||
)
|
||||
setView(binding.root)
|
||||
return this
|
||||
val updateScrollIndicators = {
|
||||
binding.scrollIndicatorUp.isVisible = binding.list.canScrollVertically(-1)
|
||||
binding.scrollIndicatorDown.isVisible = binding.list.canScrollVertically(1)
|
||||
}
|
||||
binding.list.setOnScrollChangeListener { _, _, _, _, _ ->
|
||||
updateScrollIndicators()
|
||||
}
|
||||
binding.list.post {
|
||||
updateScrollIndicators()
|
||||
}
|
||||
|
||||
if (message != null) {
|
||||
binding.message.setText(message)
|
||||
binding.message.isVisible = true
|
||||
}
|
||||
return setView(binding.root)
|
||||
}
|
||||
|
|
|
@ -1,9 +1,49 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.recyclerview.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:scrollIndicators="none"
|
||||
tools:listitem="@layout/dialog_quadstatemultichoice_item" />
|
||||
android:orientation="vertical"
|
||||
android:minHeight="48dp">
|
||||
|
||||
<Space
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/abc_dialog_title_divider_material" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/message"
|
||||
style="?attr/materialAlertDialogBodyTextStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="@dimen/abc_dialog_title_divider_material"
|
||||
android:paddingHorizontal="?attr/dialogPreferredPadding"
|
||||
android:visibility="gone"
|
||||
tools:text="Dialog Message for quad-state dialog"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/scrollIndicatorUp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollIndicators="none"
|
||||
tools:listitem="@layout/dialog_quadstatemultichoice_item" />
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:id="@+id/scrollIndicatorDown"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
Loading…
Reference in a new issue