Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve color contrast on hidden codes #1602

Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading