Skip to content

Commit

Permalink
Merge pull request #2831 from nextcloud/backport/2830/stable-16.0
Browse files Browse the repository at this point in the history
[stable-16.0] Fix theming of set status dialog buttons
  • Loading branch information
mahibi authored Mar 3, 2023
2 parents 72ee50d + ea04334 commit a32bda1
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ class SetStatusDialogFragment :
binding.awayStatus.setOnClickListener { setStatus(StatusType.AWAY) }
binding.invisibleStatus.setOnClickListener { setStatus(StatusType.INVISIBLE) }

viewThemeUtils.talk.themeStatusCardView(binding.onlineStatus)
viewThemeUtils.talk.themeStatusCardView(binding.dndStatus)
viewThemeUtils.talk.themeStatusCardView(binding.awayStatus)
viewThemeUtils.talk.themeStatusCardView(binding.invisibleStatus)

binding.clearStatus.setOnClickListener { clearStatus() }
binding.setStatus.setOnClickListener { setStatusMessage() }
binding.emoji.setOnClickListener { openEmojiPopup() }
Expand Down Expand Up @@ -244,8 +249,8 @@ class SetStatusDialogFragment :

viewThemeUtils.platform.themeDialog(binding.root)

viewThemeUtils.material.colorMaterialButtonText(binding.clearStatus)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.setStatus)
viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.clearStatus)
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(binding.setStatus)

viewThemeUtils.material.colorTextInputLayout(binding.customStatusInputContainer)

Expand Down Expand Up @@ -418,18 +423,12 @@ class SetStatusDialogFragment :
return
}
}
viewThemeUtils.material.colorCardViewBackground(views.first)
viewThemeUtils.platform.colorPrimaryTextViewElement(views.second)
views.first.isChecked = true
viewThemeUtils.platform.colorOnSecondaryContainerTextViewElement(views.second)
}

private fun clearTopStatus() {
context?.let {
val grey = it.resources.getColor(R.color.grey_200)
binding.onlineStatus.setCardBackgroundColor(grey)
binding.awayStatus.setCardBackgroundColor(grey)
binding.dndStatus.setCardBackgroundColor(grey)
binding.invisibleStatus.setCardBackgroundColor(grey)

binding.onlineHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
binding.awayHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
binding.dndHeadline.setTextColor(resources.getColor(R.color.high_emphasis_text))
Expand All @@ -439,6 +438,11 @@ class SetStatusDialogFragment :
binding.awayIcon.imageTintList = null
binding.dndIcon.imageTintList = null
binding.invisibleIcon.imageTintList = null

binding.onlineStatus.isChecked = false
binding.awayStatus.isChecked = false
binding.dndStatus.isChecked = false
binding.invisibleStatus.isChecked = false
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,35 @@ class TalkSpecificViewThemeUtils @Inject constructor(
}
}

fun themeStatusCardView(cardView: MaterialCardView) {
withScheme(cardView) { scheme ->
val background = cardView.context.getColor(R.color.grey_200)
cardView.backgroundTintList =
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_checked),
intArrayOf(-android.R.attr.state_checked)
),
intArrayOf(
scheme.secondaryContainer,
background
)
)
cardView.setStrokeColor(
ColorStateList(
arrayOf(
intArrayOf(android.R.attr.state_checked),
intArrayOf(-android.R.attr.state_checked)
),
intArrayOf(
scheme.onSecondaryContainer,
scheme.surface
)
)
)
}
}

companion object {
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
R.drawable.ic_mimetype_package_x_generic,
Expand Down
23 changes: 15 additions & 8 deletions app/src/main/res/layout/dialog_set_status.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_weight="1"
android:checkable="true"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardCornerRadius="@dimen/button_corner_radius"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
app:checkedIcon="@null">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -128,10 +130,12 @@
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_half_margin"
android:layout_weight="1"
android:checkable="true"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardCornerRadius="@dimen/button_corner_radius"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
app:checkedIcon="@null">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -205,10 +209,12 @@
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_weight="1"
android:checkable="true"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardCornerRadius="@dimen/button_corner_radius"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
app:checkedIcon="@null">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -259,12 +265,13 @@
android:layout_height="@dimen/online_status_item_height"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/standard_half_margin"

android:layout_weight="1"
android:checkable="true"
android:orientation="horizontal"
app:cardBackgroundColor="@color/grey_200"
app:cardCornerRadius="@dimen/button_corner_radius"
app:cardElevation="0dp"
app:cardCornerRadius="@dimen/button_corner_radius">
app:checkedIcon="@null">

<RelativeLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -436,9 +443,9 @@

<com.google.android.material.button.MaterialButton
android:id="@+id/clearStatus"
style="@style/OutlinedButton"
style="@style/Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_weight="1"
android:text="@string/clear_status_message"
Expand All @@ -447,7 +454,7 @@
<com.google.android.material.button.MaterialButton
android:id="@+id/setStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/set_status_message"
android:theme="@style/Button.Primary"
Expand Down

0 comments on commit a32bda1

Please sign in to comment.