mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 02:18:27 +03:00
formatting fixes
This commit is contained in:
parent
421f7e8799
commit
fdea212415
1 changed files with 7 additions and 11 deletions
|
@ -10,7 +10,7 @@ namespace Bit.App.Utilities
|
||||||
class PasswordFormatter
|
class PasswordFormatter
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This enum is used for the statemachine when building the colorized
|
* This enum is used for the state machine when building the colorized
|
||||||
* password string.
|
* password string.
|
||||||
*/
|
*/
|
||||||
private enum CharType
|
private enum CharType
|
||||||
|
@ -25,22 +25,22 @@ namespace Bit.App.Utilities
|
||||||
{
|
{
|
||||||
var result = new FormattedString();
|
var result = new FormattedString();
|
||||||
|
|
||||||
// Start off with an empty span to prevent possible NPEs. Due to the way the statemachine
|
// Start off with an empty span to prevent possible NPEs. Due to the way the state machine
|
||||||
// works, this will actually always be replaced by a new span anyway.
|
// works, this will actually always be replaced by a new span anyway.
|
||||||
var currentSpan = new Span();
|
var currentSpan = new Span();
|
||||||
// Start with an otherwise uncovered case so we will definitely enter the "something changed"
|
// Start with an otherwise uncovered case so we will definitely enter the "something changed"
|
||||||
// state.
|
// state.
|
||||||
var currentType = CharType.None;
|
var currentType = CharType.None;
|
||||||
|
|
||||||
foreach (var c in password)
|
foreach(var c in password)
|
||||||
{
|
{
|
||||||
// First, identify what the current char is.
|
// First, identify what the current char is.
|
||||||
CharType charType;
|
CharType charType;
|
||||||
if (char.IsLetter(c))
|
if(char.IsLetter(c))
|
||||||
{
|
{
|
||||||
charType = CharType.Normal;
|
charType = CharType.Normal;
|
||||||
}
|
}
|
||||||
else if (char.IsDigit(c))
|
else if(char.IsDigit(c))
|
||||||
{
|
{
|
||||||
charType = CharType.Number;
|
charType = CharType.Number;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace Bit.App.Utilities
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the char type changed, build a new span to append the text to.
|
// If the char type changed, build a new span to append the text to.
|
||||||
if (charType != currentType)
|
if(charType != currentType)
|
||||||
{
|
{
|
||||||
currentSpan = new Span();
|
currentSpan = new Span();
|
||||||
result.Spans.Add(currentSpan);
|
result.Spans.Add(currentSpan);
|
||||||
|
@ -58,20 +58,16 @@ namespace Bit.App.Utilities
|
||||||
|
|
||||||
// Switch the color if it is not a normal text. Otherwise leave the
|
// Switch the color if it is not a normal text. Otherwise leave the
|
||||||
// default value.
|
// default value.
|
||||||
switch (currentType)
|
switch(currentType)
|
||||||
{
|
{
|
||||||
case CharType.Number:
|
case CharType.Number:
|
||||||
{
|
|
||||||
currentSpan.TextColor = Color.DodgerBlue;
|
currentSpan.TextColor = Color.DodgerBlue;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case CharType.Special:
|
case CharType.Special:
|
||||||
{
|
|
||||||
currentSpan.TextColor = Color.Firebrick;
|
currentSpan.TextColor = Color.Firebrick;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
currentSpan.Text += c;
|
currentSpan.Text += c;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue