widget: update preview
Update the widget preview to reflect the new filled buttons.
This commit is contained in:
parent
276f067152
commit
f838fc8b0e
4 changed files with 10 additions and 72 deletions
|
@ -22,8 +22,8 @@ import android.os.Build
|
||||||
import android.text.method.MovementMethod
|
import android.text.method.MovementMethod
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.annotation.AttrRes
|
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
|
import org.oxycblt.auxio.R
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [TextInputEditText] that deliberately restricts all input except for selection. Yes, this is a
|
* A [TextInputEditText] that deliberately restricts all input except for selection. Yes, this is a
|
||||||
|
@ -32,16 +32,13 @@ import com.google.android.material.textfield.TextInputEditText
|
||||||
*
|
*
|
||||||
* @author OxygenCobalt
|
* @author OxygenCobalt
|
||||||
*/
|
*/
|
||||||
class ReadOnlyTextInput : TextInputEditText {
|
class ReadOnlyTextInput
|
||||||
constructor(context: Context) : super(context)
|
@JvmOverloads
|
||||||
|
constructor(
|
||||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
context: Context,
|
||||||
|
attrs: AttributeSet? = null,
|
||||||
constructor(
|
defStyleAttr: Int = R.attr.editTextStyle
|
||||||
context: Context,
|
) : TextInputEditText(context, attrs, defStyleAttr) {
|
||||||
attrs: AttributeSet?,
|
|
||||||
@AttrRes defStyleAttr: Int
|
|
||||||
) : super(context, attrs, defStyleAttr)
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setTextIsSelectable(true)
|
setTextIsSelectable(true)
|
||||||
|
|
|
@ -41,7 +41,8 @@ constructor(
|
||||||
context: Context,
|
context: Context,
|
||||||
attrs: AttributeSet? = null,
|
attrs: AttributeSet? = null,
|
||||||
defStyleAttr: Int = 0,
|
defStyleAttr: Int = 0,
|
||||||
) : FrameLayout(context, attrs, defStyleAttr) {
|
defStyleRes: Int = 0,
|
||||||
|
) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) {
|
||||||
override fun onFinishInflate() {
|
override fun onFinishInflate() {
|
||||||
super.onFinishInflate()
|
super.onFinishInflate()
|
||||||
check(childCount == 1) { "This layout should only contain one child" }
|
check(childCount == 1) { "This layout should only contain one child" }
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2022 Auxio Project
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.oxycblt.auxio.settings.ui
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Build
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import androidx.appcompat.widget.SwitchCompat
|
|
||||||
import androidx.preference.PreferenceViewHolder
|
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
|
||||||
import org.oxycblt.auxio.R
|
|
||||||
import org.oxycblt.auxio.util.getColorStateListSafe
|
|
||||||
import org.oxycblt.auxio.util.getDrawableSafe
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A [SwitchPreferenceCompat] that emulates the M3 switches until the design team actually bothers
|
|
||||||
* to add them to MDC
|
|
||||||
*
|
|
||||||
* TODO: Remove this once MaterialSwitch is stabilized.
|
|
||||||
*/
|
|
||||||
class M3SwitchPreference
|
|
||||||
@JvmOverloads
|
|
||||||
constructor(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet? = null,
|
|
||||||
defStyleAttr: Int = R.attr.switchPreferenceCompatStyle,
|
|
||||||
defStyleRes: Int = 0
|
|
||||||
) : SwitchPreferenceCompat(context, attrs, defStyleAttr, defStyleRes) {
|
|
||||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
|
||||||
super.onBindViewHolder(holder)
|
|
||||||
|
|
||||||
// Lollipop cannot into ColorStateList, disable this feature on that version
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
||||||
val switch = holder.findViewById(androidx.preference.R.id.switchWidget)
|
|
||||||
if (switch is SwitchCompat) {
|
|
||||||
switch.apply {
|
|
||||||
trackDrawable = context.getDrawableSafe(R.drawable.ui_m3_switch_track)
|
|
||||||
trackTintList = context.getColorStateListSafe(R.color.sel_m3_switch_track)
|
|
||||||
thumbDrawable = context.getDrawableSafe(R.drawable.ui_m3_switch_thumb)
|
|
||||||
thumbTintList = context.getColorStateListSafe(R.color.sel_m3_switch_thumb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 132 KiB After Width: | Height: | Size: 132 KiB |
Loading…
Reference in a new issue