Skip to content

Commit

Permalink
Variable length password mask
Browse files Browse the repository at this point in the history
  • Loading branch information
codokie committed Apr 9, 2024
1 parent 7ce9d9f commit 9b6bc78
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class SuggestionStripLayoutHelper {
private static final int DEFAULT_MAX_MORE_SUGGESTIONS_ROW = 2;
private static final int PUNCTUATIONS_IN_STRIP = 5;
private static final float MIN_TEXT_XSCALE = 0.70f;
private static final CharSequence PASSWORD_MASK = "********";
private static final int MAX_PASSWORD_LENGTH = 12;

public final int mPadding;
public final int mDividerWidth;
Expand Down Expand Up @@ -201,7 +201,8 @@ private CharSequence getStyledSuggestedWord(final SuggestedWords suggestedWords,
final String word = suggestedWords.getLabel(indexInSuggestedWords);
// If input type of the editor is that of a password, make sure the content is redacted
if (suggestedWords.mInputStyle == SuggestedWords.INPUT_STYLE_PASSWORD) {
return PASSWORD_MASK;
int maskLength = Math.min(word.length(), MAX_PASSWORD_LENGTH);
return "*".repeat(maskLength);
}
// TODO: don't use the index to decide whether this is the auto-correction/typed word, as
// this is brittle
Expand Down

0 comments on commit 9b6bc78

Please sign in to comment.