Format code of merged password strength widget

This commit is contained in:
Dominik Schürmann 2015-03-05 23:39:41 +01:00
parent a321131ed5
commit 0bb3b9c6cc
2 changed files with 49 additions and 40 deletions

View File

@ -34,7 +34,6 @@ import android.util.AttributeSet;
/** /**
* Created by matt on 04/07/2014. * Created by matt on 04/07/2014.
* https://github.com/matt-allen/android-password-strength-indicator * https://github.com/matt-allen/android-password-strength-indicator
*
*/ */
public class PasswordStrengthBarView extends PasswordStrengthView { public class PasswordStrengthBarView extends PasswordStrengthView {

View File

@ -38,15 +38,15 @@ import org.sufficientlysecure.keychain.R;
* 01/07/14 * 01/07/14
* http://www.mattallensoftware.co.uk * http://www.mattallensoftware.co.uk
* mattallen092@gmail.com * mattallen092@gmail.com
* * <p/>
* https://github.com/matt-allen/android-password-strength-indicator * https://github.com/matt-allen/android-password-strength-indicator
* * <p/>
* <p> * <p>
* This View is designed to indicate how secure a user-entered password is in a visual way to * This View is designed to indicate how secure a user-entered password is in a visual way to
* relay to the user if they need to make it stronger. The strength of the password can be set * relay to the user if they need to make it stronger. The strength of the password can be set
* at creation (or after) which will decide whether their password is strong enough. * at creation (or after) which will decide whether their password is strong enough.
* </p> * </p>
* * <p/>
* <p> * <p>
* The password strength is decided by an index of 20. The minimum score needed to pass is 10 * The password strength is decided by an index of 20. The minimum score needed to pass is 10
* which means the String has met the conditions imposed by the strength test, but can be improved. * which means the String has met the conditions imposed by the strength test, but can be improved.
@ -128,6 +128,7 @@ public class PasswordStrengthView extends View {
/** /**
* This view can determine if the password entered by the user is acceptable for * This view can determine if the password entered by the user is acceptable for
* use by your use case. This is based on the strength requirement you have set. * use by your use case. This is based on the strength requirement you have set.
*
* @return True if requirement has been met * @return True if requirement has been met
*/ */
public boolean isStrengthRequirementMet() { public boolean isStrengthRequirementMet() {
@ -137,6 +138,7 @@ public class PasswordStrengthView extends View {
/** /**
* Change the strength requirement of the password entered by the user. This will also * Change the strength requirement of the password entered by the user. This will also
* re-check the password already entered against these new requirements. * re-check the password already entered against these new requirements.
*
* @param requiredStrength Use the public constants of this class to set * @param requiredStrength Use the public constants of this class to set
*/ */
public void setStrengthRequirement(int requiredStrength) { public void setStrengthRequirement(int requiredStrength) {
@ -155,6 +157,7 @@ public class PasswordStrengthView extends View {
/** /**
* Update the password string to check strength of * Update the password string to check strength of
*
* @param passwordString String representation of user-input * @param passwordString String representation of user-input
*/ */
public void setPassword(String passwordString) { public void setPassword(String passwordString) {
@ -173,6 +176,7 @@ public class PasswordStrengthView extends View {
/** /**
* Private convenience method for adding to the password score * Private convenience method for adding to the password score
*
* @param score Amount to be added to current score * @param score Amount to be added to current score
*/ */
protected void addToPasswordScore(int score) { protected void addToPasswordScore(int score) {
@ -188,6 +192,7 @@ public class PasswordStrengthView extends View {
/** /**
* Call this to determine the current strength requirement set on the algorithm * Call this to determine the current strength requirement set on the algorithm
*
* @return Int representation of the current strength set for the indicator * @return Int representation of the current strength set for the indicator
*/ */
public int getStrengthRequirement() { public int getStrengthRequirement() {
@ -241,6 +246,7 @@ public class PasswordStrengthView extends View {
* The standard parts of the onMeasure needed to create the password strength * The standard parts of the onMeasure needed to create the password strength
* indicator. Subclasses should call super.onMeasure, but also need to set * indicator. Subclasses should call super.onMeasure, but also need to set
* the minimum height and width in the constructor. * the minimum height and width in the constructor.
*
* @param widthMeasureSpec The measurement given by the system * @param widthMeasureSpec The measurement given by the system
* @param heightMeasureSpec The measurement given by the system * @param heightMeasureSpec The measurement given by the system
*/ */
@ -264,8 +270,7 @@ public class PasswordStrengthView extends View {
int color = mColorFail; int color = mColorFail;
if (mCurrentScore >= 18) { if (mCurrentScore >= 18) {
color = mColorStrong; color = mColorStrong;
} } else if (mCurrentScore >= 10) {
else if (mCurrentScore >= 10) {
color = mColorWeak; color = mColorWeak;
} }
mIndicatorPaint.setColor(color); mIndicatorPaint.setColor(color);
@ -273,6 +278,7 @@ public class PasswordStrengthView extends View {
/** /**
* Quick method to determine how many of the characters in a given string are upper case * Quick method to determine how many of the characters in a given string are upper case
*
* @param stringToCheck The string to examine * @param stringToCheck The string to examine
* @return Number of upper case characters * @return Number of upper case characters
*/ */
@ -290,6 +296,7 @@ public class PasswordStrengthView extends View {
/** /**
* A convenience method to determine how many characters in the given String aren't * A convenience method to determine how many characters in the given String aren't
* letters or numbers. * letters or numbers.
*
* @param stringToCheck * @param stringToCheck
* @return Number of characters that aren't numbers or letters * @return Number of characters that aren't numbers or letters
*/ */
@ -307,6 +314,7 @@ public class PasswordStrengthView extends View {
/** /**
* A convenience method for returning the count of numbers in a given String. * A convenience method for returning the count of numbers in a given String.
*
* @param stringToCheck * @param stringToCheck
* @return The numbers of digits in the String * @return The numbers of digits in the String
*/ */
@ -326,6 +334,7 @@ public class PasswordStrengthView extends View {
* On the line style, the guides will show underneath<br /> * On the line style, the guides will show underneath<br />
* On the rounded style, the guides will be shown on the outer edges.<br /> * On the rounded style, the guides will be shown on the outer edges.<br />
* The view will be redrawn after the method is called. * The view will be redrawn after the method is called.
*
* @param showGuides True if you want the guides to be shown * @param showGuides True if you want the guides to be shown
*/ */
public void setShowGuides(boolean showGuides) { public void setShowGuides(boolean showGuides) {
@ -342,6 +351,7 @@ public class PasswordStrengthView extends View {
/** /**
* Determine whether the view is showing the guides for the password score * Determine whether the view is showing the guides for the password score
*
* @return True if the guides are being shown * @return True if the guides are being shown
*/ */
public boolean isShowingGuides() { public boolean isShowingGuides() {