-The strings in PatternSecurityFragment save them as android strings

-In the settings pattern screen when user tries to set a new one and is going to confirm it and makes a mistake it does not show error
-When the pattern is set in the security settings, it should not open the pattern activity after that
This commit is contained in:
dtvv 2018-10-18 04:03:50 -05:00
parent e24b355281
commit 03e03f2fb1
2 changed files with 46 additions and 3 deletions

View file

@ -3,6 +3,7 @@ package cy.agorise.crystalwallet.fragments;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
@ -18,6 +19,8 @@ import com.andrognito.patternlockview.PatternLockView;
import com.andrognito.patternlockview.listener.PatternLockViewListener;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import butterknife.BindView;
import butterknife.ButterKnife;
@ -87,7 +90,8 @@ public class PatternSecurityFragment extends Fragment {
public void showNewPatternUI(){
removePatternListener();
patternLockView.clearPattern();
tvPatternText.setText("Enter new pattern");
tvPatternText.setTextColor(Color.WHITE);
tvPatternText.setText(getActivity().getResources().getString(R.string.Enter_new_pattern));
actualPatternListener = new PatternLockViewListener() {
@Override
@ -118,7 +122,7 @@ public class PatternSecurityFragment extends Fragment {
removePatternListener();
patternLockView.clearPattern();
patternLockView.requestFocus();
tvPatternText.setText("Confirm new pattern");
tvPatternText.setText(getActivity().getResources().getString(R.string.Confirm_new_pattern));
actualPatternListener = new PatternLockViewListener() {
@Override
@ -137,6 +141,9 @@ public class PatternSecurityFragment extends Fragment {
savePattern(patternEntered);
showNewPatternUI();
}
else{
resetPattern();
}
}
@Override
@ -147,9 +154,39 @@ public class PatternSecurityFragment extends Fragment {
patternLockView.addPatternLockListener(actualPatternListener);
}
private void resetPattern(){
/*
* Show error
* */
tvPatternText.setText(getActivity().getResources().getString(R.string.Incorrect_pattern));
tvPatternText.setTextColor(Color.RED);
final Timer t = new Timer();
t.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
t.cancel();
showNewPatternUI();
}
});
}
},
//Set how long before to start calling the TimerTask (in milliseconds)
1000,
//Set the amount of time between each execution (in milliseconds)
1000);
}
public void savePattern(String pattern){
String patternEncripted = PasswordManager.encriptPassword(pattern);
CrystalSecurityMonitor.getInstance(null).setPatternEncrypted(patternEncripted);
CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
//CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
}
}

View file

@ -74,6 +74,12 @@
<string name="pin_number_warning">The pin number must be at least 6 digits</string>
<string name="old_pin_number_warning">The old pin number must be at least 6 digits</string>
<string name="mismatch_pin">mismatch pin</string>
<string name="Enter_new_pattern">Enter new pattern</string>
<string name="Incorrect_pattern">Incorrect pattern</string>
<string name="Confirm_new_pattern">Confirm new pattern</string>
<string name="error_invalid_account">Invalid account, please check your brain key for typing errors</string>
<string name="key_brainkey" translatable="false">menace saa tenible carless koftgar snarly stoned gear abater outbow defile stowage unsappy scrout cowskin wramp</string>
<string name="txt_pin" translatable="false">pin</string>