Skip to content

Commit

Permalink
Improve color contrast on hidden codes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelschattgen committed Jan 22, 2025
1 parent 9ab949a commit 3d50ab1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,11 @@ public void revealCode() {
public void hideCode() {
String code = getOtp();
String hiddenText = code.replaceAll("\\S", Character.toString(HIDDEN_CHAR));
stopExpirationAnimation();

updateTextViewWithDots(_profileCode, hiddenText, code);
updateTextViewWithDots(_nextProfileCode, hiddenText, code);
stopExpirationAnimation();

_hidden = true;
}

Expand All @@ -384,6 +386,7 @@ private void updateTextViewWithDots(TextView textView, String hiddenCode, String
float dotsWidth = paint.measureText(hiddenCode);
float scaleFactor = codeWidth / dotsWidth;
scaleFactor = (float)(Math.round(scaleFactor * 10.0) / 10.0);
textView.setTextColor(MaterialColors.getColor(textView, R.attr.colorCodeHidden));

// If scale is higher or equal to 0.8, do nothing and proceed with the normal text rendering
if (scaleFactor >= 0.8) {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<attr name="colorSuccess" />
<attr name="colorOnSurfaceDim" />
<attr name="colorCode" />
<attr name="colorCodeHidden" />

<declare-styleable name="SlideIndicator">
<attr name="dot_radius" format="dimension" />
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<item name="colorSuccess">@color/aegis_theme_light_success</item>
<item name="colorOnSurfaceDim">@color/aegis_theme_light_onSurfaceDim</item>
<item name="colorCode">?attr/colorPrimary</item>
<item name="colorCodeHidden">?attr/colorOutlineVariant</item>
<!-- Intro colors -->
<item name="dot_color">?attr/colorSurfaceVariant</item>
<item name="dot_color_selected">?attr/colorOnSurfaceVariant</item>
Expand Down Expand Up @@ -132,6 +133,7 @@
<item name="colorSuccess">@color/aegis_theme_dark_success</item>
<item name="colorOnSurfaceDim">@color/aegis_theme_dark_onSurfaceDim</item>
<item name="colorCode">?attr/colorPrimary</item>
<item name="colorCodeHidden">?attr/colorOutlineVariant</item>
<!-- Intro colors -->
<item name="dot_color">?attr/colorSurfaceVariant</item>
<item name="dot_color_selected">?attr/colorOnSurfaceVariant</item>
Expand Down Expand Up @@ -159,6 +161,7 @@
<item name="colorSurfaceDim">#000000</item>
<item name="colorSurfaceBright">#000000</item>
<item name="colorCode">@android:color/white</item>
<item name="colorCodeHidden">#2F2F2F</item>
<item name="colorProgressbar">@android:color/white</item>
</style>

Expand All @@ -179,6 +182,7 @@
<item name="colorSurfaceDim">#000000</item>
<item name="colorSurfaceBright">#000000</item>
<item name="colorCode">@android:color/white</item>
<item name="colorCodeHidden">#2F2F2F</item>
<item name="colorProgressbar">@android:color/white</item>
</style>

Expand Down

0 comments on commit 3d50ab1

Please sign in to comment.