Fix list scrolling on quad-state dialog (#5602)
This commit is contained in:
parent
649209890d
commit
00ac632d8f
@ -243,8 +243,8 @@ class SettingsDownloadController : SettingsController() {
|
|||||||
|
|
||||||
return MaterialAlertDialogBuilder(activity!!)
|
return MaterialAlertDialogBuilder(activity!!)
|
||||||
.setTitle(R.string.categories)
|
.setTitle(R.string.categories)
|
||||||
.setMessage(R.string.pref_download_new_categories_details)
|
|
||||||
.setQuadStateMultiChoiceItems(
|
.setQuadStateMultiChoiceItems(
|
||||||
|
message = R.string.pref_download_new_categories_details,
|
||||||
items = items,
|
items = items,
|
||||||
initialSelected = selected
|
initialSelected = selected
|
||||||
) { selections ->
|
) { selections ->
|
||||||
|
@ -355,8 +355,11 @@ class SettingsLibraryController : SettingsController() {
|
|||||||
|
|
||||||
return MaterialAlertDialogBuilder(activity!!)
|
return MaterialAlertDialogBuilder(activity!!)
|
||||||
.setTitle(R.string.categories)
|
.setTitle(R.string.categories)
|
||||||
.setMessage(R.string.pref_library_update_categories_details)
|
.setQuadStateMultiChoiceItems(
|
||||||
.setQuadStateMultiChoiceItems(items = items, initialSelected = selected) { selections ->
|
message = R.string.pref_library_update_categories_details,
|
||||||
|
items = items,
|
||||||
|
initialSelected = selected
|
||||||
|
) { selections ->
|
||||||
selected = selections
|
selected = selections
|
||||||
}
|
}
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
|
@ -3,7 +3,9 @@ package eu.kanade.tachiyomi.widget.materialdialogs
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.annotation.StringRes
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.doAfterTextChanged
|
import androidx.core.widget.doAfterTextChanged
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
@ -36,6 +38,7 @@ fun MaterialAlertDialogBuilder.setTextInput(
|
|||||||
* @see eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
* @see eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
||||||
*/
|
*/
|
||||||
fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
||||||
|
@StringRes message: Int? = null,
|
||||||
items: List<CharSequence>,
|
items: List<CharSequence>,
|
||||||
initialSelected: IntArray,
|
initialSelected: IntArray,
|
||||||
disabledIndices: IntArray? = null,
|
disabledIndices: IntArray? = null,
|
||||||
@ -49,6 +52,20 @@ fun MaterialAlertDialogBuilder.setQuadStateMultiChoiceItems(
|
|||||||
initialSelected = initialSelected,
|
initialSelected = initialSelected,
|
||||||
listener = selection
|
listener = selection
|
||||||
)
|
)
|
||||||
setView(binding.root)
|
val updateScrollIndicators = {
|
||||||
return this
|
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"?>
|
<?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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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:id="@+id/list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingTop="8dp"
|
|
||||||
android:scrollIndicators="none"
|
android:scrollIndicators="none"
|
||||||
tools:listitem="@layout/dialog_quadstatemultichoice_item" />
|
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 New Issue
Block a user