2
0

Fixed a few bugs.

This commit is contained in:
Maarten Billemont 2016-02-20 21:45:11 -05:00
parent b346b3be65
commit 6a1768a50d
3 changed files with 21 additions and 18 deletions

View File

@ -66,7 +66,7 @@
android:onClick="onAction" />
<CheckBox
android:id="@+id/nativeKDF"
android:id="@+id/nativeKDFField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"

View File

@ -76,8 +76,9 @@ public class EmergencyActivity extends Activity {
@InjectView(R.id.maskPasswordField)
CheckBox maskPasswordField;
private int hc_userName;
private int hc_masterPassword;
private int id_userName;
private int id_masterPassword;
private int id_version;
private String sitePassword;
public static void start(Context context) {
@ -221,7 +222,7 @@ public class EmergencyActivity extends Activity {
protected void onPause() {
if (preferences.isForgetPassword()) {
synchronized (this) {
hc_userName = hc_masterPassword = 0;
id_userName = id_masterPassword = 0;
if (masterKeyFuture != null) {
masterKeyFuture.cancel( true );
masterKeyFuture = null;
@ -242,16 +243,13 @@ public class EmergencyActivity extends Activity {
final String fullName = fullNameField.getText().toString();
final char[] masterPassword = masterPasswordField.getText().toString().toCharArray();
final MasterKey.Version version = (MasterKey.Version) siteVersionButton.getTag();
try {
if (fullName.hashCode() == hc_userName && Arrays.hashCode( masterPassword ) == hc_masterPassword &&
masterKeyFuture != null && masterKeyFuture.get().getAlgorithmVersion() == version)
if (fullName.hashCode() == id_userName && Arrays.hashCode( masterPassword ) == id_masterPassword &&
version.ordinal() == id_version && masterKeyFuture != null && !masterKeyFuture.isCancelled())
return;
}
catch (InterruptedException | ExecutionException e) {
return;
}
hc_userName = fullName.hashCode();
hc_masterPassword = Arrays.hashCode( masterPassword );
id_userName = fullName.hashCode();
id_masterPassword = Arrays.hashCode( masterPassword );
id_version = version.ordinal();
if (preferences.isRememberFullName())
preferences.setFullName( fullName );
@ -345,6 +343,10 @@ public class EmergencyActivity extends Activity {
}
public void integrityTests(View view) {
if (masterKeyFuture != null) {
masterKeyFuture.cancel( true );
masterKeyFuture = null;
}
TestActivity.startNoSkip( this );
}

View File

@ -39,8 +39,8 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
@InjectView(R.id.actionButton)
Button actionButton;
@InjectView(R.id.nativeKDF)
CheckBox nativeKDF;
@InjectView(R.id.nativeKDFField)
CheckBox nativeKDFField;
private MPTestSuite testSuite;
private ListenableFuture<Boolean> testFuture;
@ -59,10 +59,11 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
setContentView( R.layout.activity_test );
ButterKnife.inject( this );
nativeKDF.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
nativeKDFField.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
MasterKey.setAllowNativeByDefault( preferences.isAllowNativeKDF() );
preferences.setNativeKDFEnabled( isChecked );
MasterKey.setAllowNativeByDefault( isChecked );
}
} );
@ -94,7 +95,7 @@ public class TestActivity extends Activity implements MPTestSuite.Listener {
protected void onResume() {
super.onResume();
nativeKDF.setChecked( preferences.isAllowNativeKDF() );
nativeKDFField.setChecked( preferences.isAllowNativeKDF() );
if (testFuture == null)
startTestSuite();