Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/res/layout/fragment_connect_delivery_dashboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<TextView
android:id="@+id/delivery_chip_label"
style="@style/TextStyle.Connect.LabelM"
style="@style/TextStyle.Connect.LabelS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/connect_space_xs"
Expand Down Expand Up @@ -81,7 +81,6 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/connect_space_sm"
android:layout_marginTop="@dimen/connect_space_lg"
app:contentDisabledColor="?attr/connectOnSurfaceVariant"
app:contentPrimaryColor="?attr/connectOnSurfaceVariant" />

<org.commcare.views.connect.ConnectTaskCard
Expand Down
4 changes: 2 additions & 2 deletions app/res/layout/view_connect_info_half_card.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/connect_space_sm"
android:textColor="?attr/colorOnSurface"
android:textColor="?attr/connectOnSurfaceEmphasis"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_card_value_text"
Expand All @@ -51,7 +51,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/connect_space_xs"
android:textColor="?attr/connectOutline"
android:textColor="?attr/connectOnSurfaceSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/info_card_title_text"
Expand Down
2 changes: 1 addition & 1 deletion app/res/layout/view_connect_learn_progress.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
android:src="@drawable/ic_connect_learn_app" />

<TextView
style="@style/TextStyle.Connect.LabelM"
style="@style/TextStyle.Connect.LabelS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/standard_spacer_half"
Expand Down
2 changes: 1 addition & 1 deletion app/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<attr name="connectOnSurfaceEmphasis" format="reference|color" />
<attr name="connectOnSurfaceStrong" format="reference|color" />
<attr name="connectOnSurfaceVariant" format="reference|color" />
<attr name="connectOnSurfaceSecondary" format="reference|color" />
<attr name="connectOnSurfaceMuted" format="reference|color" />
<attr name="connectDisabledContainer" format="reference|color" />
<attr name="connectOnDisabledContainer" format="reference|color" />
<attr name="connectCtaButtonBackground" format="reference|color" />
<attr name="connectCtaButtonForeground" format="reference|color" />
<attr name="connectOnSurfaceDisabled" format="reference|color" />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if getting rid of this attribute is the right call? It seems like instead we could just map it to cool_gray_900 in the theme, rather than merge it with connectOnSurfaceEmphasis. And setting something called "disabled" to a value called "emphasis" at multiple places in the code feels confusing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, changed here

<attr name="connectOutline" format="reference|color" />
<attr name="connectOutlineVariant" format="reference|color" />
<attr name="connectStatusPositive" format="reference|color" />
Expand Down
1 change: 0 additions & 1 deletion app/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
<color name="connect_subtext_color">#9CA3AF</color>
<color name="cool_gray_100">#F3F4F6</color>
<color name="cool_gray_300">#D1D5DB</color>
<color name="neutral_gray_600">#57595B</color>
<color name="connect_grey">#9A9A9A</color>
<color name="connect_dark_grey">#4B5563</color>
<color name="cool_gray_50">#F9FAFB</color>
Expand Down
2 changes: 1 addition & 1 deletion app/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@
<style name="Widget.CommCare.ConnectProgressCard" parent="">
<item name="contentPrimaryColor">?attr/colorOnSurface</item>
<item name="contentAccentColor">?attr/colorPrimary</item>
<item name="contentDisabledColor">?attr/connectOutline</item>
<item name="contentDisabledColor">?attr/connectOnSurfaceEmphasis</item>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disabled" = "emphasis"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</style>

<style name="Widget.CommCare.ConnectSuccessFailureCard" parent="">
Expand Down
2 changes: 1 addition & 1 deletion app/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@
<item name="connectOnSurfaceEmphasis">@color/cool_gray_900</item>
<item name="connectOnSurfaceStrong">@color/cool_gray_800</item>
<item name="connectOnSurfaceVariant">@color/connect_dark_grey</item>
<item name="connectOnSurfaceSecondary">@color/connect_secondary_text</item>
<item name="connectOnSurfaceMuted">@color/connect_subtext_color</item>
<item name="connectDisabledContainer">@color/cool_gray_100</item>
<item name="connectOnDisabledContainer">@color/connect_subtext_color</item>
<item name="connectCtaButtonBackground">@color/connect_cta_button_background</item>
<item name="connectCtaButtonForeground">@color/connect_cta_button_foreground</item>
<item name="connectOnSurfaceDisabled">@color/neutral_gray_600</item>
<item name="connectOutline">@color/connect_grey</item>
<item name="connectOutlineVariant">@color/connect_light_grey</item>
<item name="connectStatusPositive">@color/connect_green</item>
Expand Down
23 changes: 15 additions & 8 deletions app/src/org/commcare/views/connect/ConnectInfoHalfCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.commcare.dalvik.databinding.ViewConnectInfoHalfCardBinding
import org.commcare.views.extensions.bindOptional
import org.commcare.views.extensions.bindReservingSpace
import org.commcare.views.extensions.themeColor
import org.commcare.views.extensions.tint

/**
* Reusable half-width Connect info card.
Expand Down Expand Up @@ -43,26 +44,32 @@ class ConnectInfoHalfCard
get() = binding.infoCardSubtitleText.text
set(value) = binding.infoCardSubtitleText.bindReservingSpace(value)

/** When false the value reads as disabled, matching a disabled [ConnectProgressCard]. */
/** When false the value and icon read as disabled, matching a disabled [ConnectProgressCard]. */
var contentEnabled: Boolean = true
set(value) {
field = value
binding.infoCardValueText.setTextColor(
if (value) {
MaterialColors.getColor(this, com.google.android.material.R.attr.colorPrimary)
} else {
context.themeColor(R.attr.connectOnSurfaceDisabled)
},
)
applyContentColors()
}

var icon: Drawable? = null
set(value) {
field = value
binding.infoCardIcon.setImageDrawable(value)
binding.infoCardIcon.visibility = if (value == null) GONE else VISIBLE
applyContentColors()
}

private fun applyContentColors() {
val accent =
if (contentEnabled) {
MaterialColors.getColor(this, com.google.android.material.R.attr.colorPrimary)
} else {
context.themeColor(R.attr.connectOnSurfaceEmphasis)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disabled" = "emphasis"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
binding.infoCardValueText.setTextColor(accent)
binding.infoCardIcon.tint(accent)
}

var navigable: Boolean = false
set(value) {
field = value
Expand Down
4 changes: 3 additions & 1 deletion app/src/org/commcare/views/connect/ConnectProgressCard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ class ConnectProgressCard
binding.progressCardTitle.setTextColor(primary)
binding.progressCardBarLabel.setTextColor(primary)
binding.progressCardBarCount.setTextColor(accent)
binding.progressCardBarCaption.setTextColor(accent)
// The caption keeps the accent even when disabled - it explains why the card is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: comment feels unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done here

// blocked, so it stays legible rather than greying out with the figures.
binding.progressCardBarCaption.setTextColor(contentAccentColor)
binding.progressCardLinearBar.setProgressColor(accent)
binding.progressCardSemiCircle.progressColor = accent
binding.progressCardSemiCircle.valueTextColor = accent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ class ConnectDeliveryDashboardFragmentTest {
private fun accentColor(): Int =
MaterialColors.getColor(activity.findViewById(android.R.id.content), com.google.android.material.R.attr.colorPrimary)

private fun disabledColor(): Int = activity.themeColor(R.attr.connectOnSurfaceDisabled)
private fun disabledColor(): Int = activity.themeColor(R.attr.connectOnSurfaceEmphasis)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disabled" = "emphasis"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private fun progressResponse(
deliveries: List<String> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class ConnectInfoHalfCardTest {

card.contentEnabled = false
assertEquals(
card.context.themeColor(R.attr.connectOnSurfaceDisabled),
card.context.themeColor(R.attr.connectOnSurfaceEmphasis),
value.currentTextColor,
)

Expand Down Expand Up @@ -158,7 +158,7 @@ class ConnectInfoHalfCardTest {
assertEquals("100 each", card.subtitleText.toString())
assertEquals(false, card.contentEnabled)
assertEquals(
card.context.themeColor(R.attr.connectOnSurfaceDisabled),
card.context.themeColor(R.attr.connectOnSurfaceEmphasis),
card.findViewById<TextView>(R.id.info_card_value_text).currentTextColor,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.google.android.material.color.MaterialColors
import org.commcare.CommCareTestApplication
import org.commcare.dalvik.R
import org.commcare.views.connect.ConnectProgressCard.State
import org.commcare.views.extensions.themeColor
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
Expand Down Expand Up @@ -173,12 +174,12 @@ class ConnectProgressCardTest {
}

@Test
fun `contentEnabled recolors caption and semi-circle`() {
fun `contentEnabled recolors the semi-circle but leaves the caption at the accent`() {
val card = newCard()
val caption = card.findViewById<TextView>(R.id.progress_card_bar_caption)
val semi = card.findViewById<SemiCircleProgressBar>(R.id.progress_card_semi_circle)

val grey = ContextCompat.getColor(card.context, R.color.connect_grey)
val disabled = card.context.themeColor(R.attr.connectOnSurfaceEmphasis)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"disabled" = "emphasis"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val accent = MaterialColors.getColor(card, com.google.android.material.R.attr.colorPrimary)
val primary = ContextCompat.getColor(card.context, R.color.connect_text_color)

Expand All @@ -189,9 +190,9 @@ class ConnectProgressCardTest {
)

card.bind(content.copy(contentEnabled = false))
assertEquals(grey, caption.currentTextColor)
assertEquals(grey, semi.progressColor)
assertEquals(grey, semi.valueTextColor)
assertEquals(accent, caption.currentTextColor)
assertEquals(disabled, semi.progressColor)
assertEquals(disabled, semi.valueTextColor)
assertEquals(primary, semi.descriptionTextColor)

card.bind(content.copy(contentEnabled = true))
Expand Down
Loading