Skip to content

Commit

Permalink
show button only when there is summary
Browse files Browse the repository at this point in the history
  • Loading branch information
LuftVerbot committed Aug 7, 2024
1 parent 0b76026 commit 97eda4b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class ExtensionFragment : BaseSettingsFragment() {
it.entryValues = this.entryValues.toTypedArray()

it.isIconSpaceReserved = false
it.layoutResource = R.layout.preference_summary_button
it.layoutResource = R.layout.preference
preferenceGroup.addPreference(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dev.brahmkshatriya.echo.R

class MaterialListPreference(context: Context) : ListPreference(context) {

private var customSummary: String? = null
private var customSummary: CharSequence? = null

override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
Expand All @@ -21,7 +21,12 @@ class MaterialListPreference(context: Context) : ListPreference(context) {

override fun onSetInitialValue(defaultValue: Any?) {
super.onSetInitialValue(defaultValue)
customSummary = summary.toString()
customSummary = summary
layoutResource = if (customSummary != null){
R.layout.preference_summary_button
} else {
this.layoutResource
}
updateSummary()
}

Expand All @@ -46,7 +51,7 @@ class MaterialListPreference(context: Context) : ListPreference(context) {

private fun showSummaryDialog() {
MaterialAlertDialogBuilder(context)
.setMessage(customSummary)
.setMessage(customSummary.toString())
.setPositiveButton(android.R.string.ok, null)
.show()
}
Expand Down

0 comments on commit 97eda4b

Please sign in to comment.