mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
make filled buttons Material 3
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
4d93a2099f
commit
c10a0a7c65
@ -106,7 +106,7 @@ public class TakePhotoActivity extends AppCompatActivity {
|
|||||||
setContentView(binding.getRoot());
|
setContentView(binding.getRoot());
|
||||||
|
|
||||||
viewThemeUtils.themeFAB(binding.takePhoto);
|
viewThemeUtils.themeFAB(binding.takePhoto);
|
||||||
viewThemeUtils.colorMaterialButtonBackground(binding.send);
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.send);
|
||||||
|
|
||||||
cameraProviderFuture = ProcessCameraProvider.getInstance(this);
|
cameraProviderFuture = ProcessCameraProvider.getInstance(this);
|
||||||
cameraProviderFuture.addListener(() -> {
|
cameraProviderFuture.addListener(() -> {
|
||||||
|
@ -108,7 +108,7 @@ class PollCreateDialogFragment : DialogFragment(), PollCreateOptionsItemListener
|
|||||||
viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem)
|
viewThemeUtils.colorMaterialButtonText(binding.pollAddOptionsItem)
|
||||||
// TODO button also needs a disabled state handling for colors
|
// TODO button also needs a disabled state handling for colors
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollDismiss)
|
viewThemeUtils.colorMaterialButtonText(binding.pollDismiss)
|
||||||
viewThemeUtils.colorMaterialButtonBackground(binding.pollCreateButton)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollCreateButton)
|
||||||
|
|
||||||
viewThemeUtils.themeCheckbox(binding.pollPrivatePollCheckbox)
|
viewThemeUtils.themeCheckbox(binding.pollPrivatePollCheckbox)
|
||||||
viewThemeUtils.themeCheckbox(binding.pollMultipleAnswersCheckbox)
|
viewThemeUtils.themeCheckbox(binding.pollMultipleAnswersCheckbox)
|
||||||
|
@ -98,7 +98,7 @@ class PollResultsFragment : Fragment(), PollResultItemClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun themeDialog() {
|
private fun themeDialog() {
|
||||||
viewThemeUtils.colorMaterialButtonBackground(binding.editVoteButton)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.editVoteButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollResultsEndPollButton)
|
viewThemeUtils.colorMaterialButtonText(binding.pollResultsEndPollButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class PollVoteFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun themeDialog() {
|
private fun themeDialog() {
|
||||||
viewThemeUtils.colorMaterialButtonBackground(binding.pollVoteSubmitButton)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.pollVoteSubmitButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEndPollButton)
|
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEndPollButton)
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEditDismiss)
|
viewThemeUtils.colorMaterialButtonText(binding.pollVoteEditDismiss)
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ class SetStatusDialogFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
viewThemeUtils.colorMaterialButtonText(binding.clearStatus)
|
viewThemeUtils.colorMaterialButtonText(binding.clearStatus)
|
||||||
viewThemeUtils.colorMaterialButtonBackground(binding.setStatus)
|
viewThemeUtils.colorMaterialButtonPrimaryFilled(binding.setStatus)
|
||||||
|
|
||||||
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
binding.customStatusInput.highlightColor = resources.getColor(R.color.colorPrimary)
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ import com.yarolegovich.mp.MaterialPreferenceCategory
|
|||||||
import com.yarolegovich.mp.MaterialSwitchPreference
|
import com.yarolegovich.mp.MaterialSwitchPreference
|
||||||
import scheme.Scheme
|
import scheme.Scheme
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Suppress("TooManyFunctions")
|
@Suppress("TooManyFunctions")
|
||||||
class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private val colorUtil: ColorUtil) {
|
class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private val colorUtil: ColorUtil) {
|
||||||
@ -229,21 +230,42 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun colorMaterialButtonBackground(button: MaterialButton) {
|
fun colorMaterialButtonPrimaryFilled(button: MaterialButton) {
|
||||||
withElementColor(button) { color ->
|
withScheme(button) { scheme ->
|
||||||
button.setBackgroundColor(color)
|
button.backgroundTintList =
|
||||||
|
ColorStateList(
|
||||||
val disabledColor = ContextCompat.getColor(button.context, R.color.disabled_text)
|
|
||||||
val colorStateList = ColorStateList(
|
|
||||||
arrayOf(
|
arrayOf(
|
||||||
intArrayOf(android.R.attr.state_enabled),
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
intArrayOf(-android.R.attr.state_enabled)
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
),
|
),
|
||||||
intArrayOf(theme.colorText, disabledColor)
|
intArrayOf(
|
||||||
|
scheme.primary,
|
||||||
|
calculateDisabledColor(scheme.primary, SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
button.setTextColor(colorStateList)
|
button.setTextColor(
|
||||||
button.iconTint = colorStateList
|
ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.onPrimary,
|
||||||
|
calculateDisabledColor(scheme.onPrimary, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
button.iconTint = ColorStateList(
|
||||||
|
arrayOf(
|
||||||
|
intArrayOf(android.R.attr.state_enabled),
|
||||||
|
intArrayOf(-android.R.attr.state_enabled)
|
||||||
|
),
|
||||||
|
intArrayOf(
|
||||||
|
scheme.onPrimary,
|
||||||
|
calculateDisabledColor(scheme.onPrimary, ON_SURFACE_OPACITY_BUTTON_DISABLED)
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,6 +457,15 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun calculateDisabledColor(color: Int, opacity: Float): Int {
|
||||||
|
return Color.argb(
|
||||||
|
(Color.alpha(color) * opacity).roundToInt(),
|
||||||
|
Color.red(color),
|
||||||
|
Color.green(color),
|
||||||
|
Color.blue(color)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
||||||
R.drawable.ic_mimetype_package_x_generic,
|
R.drawable.ic_mimetype_package_x_generic,
|
||||||
@ -443,5 +474,7 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
private const val SWITCHCOMPAT_TRACK_ALPHA: Int = 77
|
private const val SWITCHCOMPAT_TRACK_ALPHA: Int = 77
|
||||||
private const val PROGRESS_LIGHTNESS_LIGHT_THEME: Float = 0.76f
|
private const val PROGRESS_LIGHTNESS_LIGHT_THEME: Float = 0.76f
|
||||||
private const val PROGRESS_LIGHTNESS_DARK_THEME: Float = 0.28f
|
private const val PROGRESS_LIGHTNESS_DARK_THEME: Float = 0.28f
|
||||||
|
private const val SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.12f
|
||||||
|
private const val ON_SURFACE_OPACITY_BUTTON_DISABLED: Float = 0.38f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user