Merge remote-tracking branch 'origin/master'

This commit is contained in:
hvarona 2018-05-16 22:07:58 -04:00
commit dd78076906
11 changed files with 169 additions and 211 deletions

View file

@ -76,7 +76,7 @@ public class IntroActivity extends AppCompatActivity {
} }
}); });
this.getApplication().registerActivityLifecycleCallbacks(new CrystalSecurityMonitor(this)); this.getApplication().registerActivityLifecycleCallbacks(CrystalSecurityMonitor.getInstance(this));
//Checks if the user has any seed created //Checks if the user has any seed created

View file

@ -19,6 +19,7 @@ import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import cy.agorise.crystalwallet.BuildConfig; import cy.agorise.crystalwallet.BuildConfig;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.fragments.AccountsSettingsFragment; import cy.agorise.crystalwallet.fragments.AccountsSettingsFragment;
import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment; import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment;
import cy.agorise.crystalwallet.fragments.BalanceFragment; import cy.agorise.crystalwallet.fragments.BalanceFragment;

View file

@ -16,6 +16,7 @@ import java.util.List;
import cy.agorise.crystalwallet.activities.PatternRequestActivity; import cy.agorise.crystalwallet.activities.PatternRequestActivity;
import cy.agorise.crystalwallet.activities.PinRequestActivity; import cy.agorise.crystalwallet.activities.PinRequestActivity;
import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier;
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
/** /**
@ -27,44 +28,77 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
private String passwordEncrypted; private String passwordEncrypted;
private String patternEncrypted; private String patternEncrypted;
public CrystalSecurityMonitor(final FragmentActivity fragmentActivity){ private static CrystalSecurityMonitor instance;
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(fragmentActivity).get(GeneralSettingListViewModel.class); private GeneralSettingListViewModel generalSettingListViewModel;
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
generalSettingsLiveData.observe(fragmentActivity, new Observer<List<GeneralSetting>>() { private CrystalSecurityMonitor(final FragmentActivity fragmentActivity){
@Override //For security reasons, this code is not asynchronous because the pattern or password data
public void onChanged(@Nullable List<GeneralSetting> generalSettings) { //must be retrieved before the principal activity starts
boolean founded = false; generalSettingListViewModel = ViewModelProviders.of(fragmentActivity).get(GeneralSettingListViewModel.class);
passwordEncrypted = "";
if (generalSettings != null){ this.passwordEncrypted = "";
for (GeneralSetting generalSetting:generalSettings) { this.patternEncrypted = "";
if (generalSetting.getName().equals(GeneralSetting.SETTING_PASSWORD)){ GeneralSetting passwordGeneralSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_PASSWORD);;
if (!generalSetting.getValue().isEmpty()){ GeneralSetting patternGeneralSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_PATTERN);;
passwordEncrypted = generalSetting.getValue();
callPasswordRequest(fragmentActivity); if (passwordGeneralSetting != null){
this.passwordEncrypted = passwordGeneralSetting.getValue();
} }
break; if (patternGeneralSetting != null){
} else if (generalSetting.getName().equals(GeneralSetting.SETTING_PATTERN)){ this.patternEncrypted = patternGeneralSetting.getValue();
if (!generalSetting.getValue().isEmpty()){
patternEncrypted = generalSetting.getValue();
callPasswordRequest(fragmentActivity);
}
break;
} }
} }
public static CrystalSecurityMonitor getInstance(final FragmentActivity fragmentActivity){
if (instance == null){
instance = new CrystalSecurityMonitor(fragmentActivity);
} }
return instance;
} }
});
public void clearSecurity(){
this.patternEncrypted = "";
this.passwordEncrypted = "";
generalSettingListViewModel.deleteGeneralSettingByName(GeneralSetting.SETTING_PASSWORD);
generalSettingListViewModel.deleteGeneralSettingByName(GeneralSetting.SETTING_PATTERN);
}
public void setPasswordSecurity(String password){
clearSecurity();
this.passwordEncrypted = password;
GeneralSetting passwordGeneralSetting = new GeneralSetting();
passwordGeneralSetting.setName(GeneralSetting.SETTING_PASSWORD);
passwordGeneralSetting.setValue(password);
generalSettingListViewModel.saveGeneralSetting(passwordGeneralSetting);
}
public void setPatternEncrypted(String pattern){
clearSecurity();
this.patternEncrypted = pattern;
GeneralSetting patternGeneralSetting = new GeneralSetting();
patternGeneralSetting.setName(GeneralSetting.SETTING_PATTERN);
patternGeneralSetting.setValue(pattern);
generalSettingListViewModel.saveGeneralSetting(patternGeneralSetting);
}
public String actualSecurity(){
if ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))){
return GeneralSetting.SETTING_PATTERN;
} else if ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))){
return GeneralSetting.SETTING_PASSWORD;
}
return "";
} }
@Override @Override
public void onActivityStarted(Activity activity) { public void onActivityStarted(Activity activity) {
if (numStarted == 0) { if (numStarted == 0) {
if ( if (!actualSecurity().equals("")){
((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals("")))
|| ((this.patternEncrypted != null) && (!this.patternEncrypted.equals("")))
) {
callPasswordRequest(activity); callPasswordRequest(activity);
} }
} }
@ -75,10 +109,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall
public void onActivityStopped(Activity activity) { public void onActivityStopped(Activity activity) {
numStarted--; numStarted--;
if (numStarted == 0) { if (numStarted == 0) {
if ( if (!actualSecurity().equals("")){
((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals("")))
|| ((this.patternEncrypted != null) && (!this.patternEncrypted.equals("")))
) {
callPasswordRequest(activity); callPasswordRequest(activity);
} }
} }

View file

@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.dao;
import android.arch.lifecycle.LiveData; import android.arch.lifecycle.LiveData;
import android.arch.persistence.room.Dao; import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert; import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy; import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query; import android.arch.persistence.room.Query;
@ -32,4 +33,10 @@ public interface GeneralSettingDao {
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)
public long insertGeneralSetting(GeneralSetting generalSetting); public long insertGeneralSetting(GeneralSetting generalSetting);
@Delete
public void deleteGeneralSettings(GeneralSetting... generalSettings);
@Query("DELETE FROM general_setting WHERE name = :name")
public void deleteByName(String name);
} }

View file

@ -1,13 +1,23 @@
package cy.agorise.crystalwallet.fragments; package cy.agorise.crystalwallet.fragments;
import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import java.util.List;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
import cy.agorise.crystalwallet.viewmodels.validators.PinSecurityValidator;
/** /**
* Created by xd on 1/18/18. * Created by xd on 1/18/18.
@ -15,6 +25,11 @@ import cy.agorise.crystalwallet.R;
public class NoneSecurityFragment extends Fragment { public class NoneSecurityFragment extends Fragment {
GeneralSetting passwordGeneralSetting = new GeneralSetting();
GeneralSetting patternGeneralSetting = new GeneralSetting();
GeneralSettingListViewModel generalSettingListViewModel;
public NoneSecurityFragment() { public NoneSecurityFragment() {
// Required empty public constructor // Required empty public constructor
} }
@ -33,6 +48,39 @@ public class NoneSecurityFragment extends Fragment {
View v = inflater.inflate(R.layout.fragment_none_security, container, false); View v = inflater.inflate(R.layout.fragment_none_security, container, false);
ButterKnife.bind(this, v); ButterKnife.bind(this, v);
generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
generalSettingsLiveData.observe(this, new Observer<List<GeneralSetting>>() {
@Override
public void onChanged(@Nullable List<GeneralSetting> generalSettings) {
if (generalSettings != null){
for (GeneralSetting generalSetting:generalSettings) {
if (generalSetting.getName().equals(GeneralSetting.SETTING_PASSWORD)){
passwordGeneralSetting = generalSetting;
} else if (generalSetting.getName().equals(GeneralSetting.SETTING_PATTERN)){
patternGeneralSetting = generalSetting;
}
}
}
}
});
return v; return v;
} }
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
setSecurityOff();
}
}
public void setSecurityOff(){
generalSettingListViewModel.deleteGeneralSettings(passwordGeneralSetting,patternGeneralSetting);
CrystalSecurityMonitor.getInstance(null).setPasswordSecurity("");
CrystalSecurityMonitor.getInstance(null).setPatternEncrypted("");
}
} }

View file

@ -23,6 +23,7 @@ import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnTextChanged; import butterknife.OnTextChanged;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.util.PasswordManager;
import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
@ -36,10 +37,6 @@ import cy.agorise.crystalwallet.viewmodels.validators.validationfields.Validatio
public class PatternSecurityFragment extends Fragment { public class PatternSecurityFragment extends Fragment {
GeneralSettingListViewModel generalSettingListViewModel;
GeneralSetting patternGeneralSetting;
//PatternSecurityValidator patternSecurityValidator;
@BindView(R.id.patternLockView) @BindView(R.id.patternLockView)
PatternLockView patternLockView; PatternLockView patternLockView;
@BindView(R.id.tvPatternText) @BindView(R.id.tvPatternText)
@ -66,35 +63,7 @@ public class PatternSecurityFragment extends Fragment {
View v = inflater.inflate(R.layout.fragment_pattern_security, container, false); View v = inflater.inflate(R.layout.fragment_pattern_security, container, false);
ButterKnife.bind(this, v); ButterKnife.bind(this, v);
generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
generalSettingsLiveData.observe(this, new Observer<List<GeneralSetting>>() {
@Override
public void onChanged(@Nullable List<GeneralSetting> generalSettings) {
boolean founded = false;
if (generalSettings != null){
for (GeneralSetting generalSetting:generalSettings) {
if (generalSetting.getName().equals(GeneralSetting.SETTING_PATTERN)){
founded = true;
if (!generalSetting.getValue().isEmpty()){
patternGeneralSetting = generalSetting;
showEnterPatternUI();
} else {
showNewPatternUI(); showNewPatternUI();
}
break;
}
}
if (!founded){
showNewPatternUI();
}
} else {
showNewPatternUI();
}
}
});
return v; return v;
} }
@ -166,7 +135,7 @@ public class PatternSecurityFragment extends Fragment {
public void onComplete(List<PatternLockView.Dot> pattern) { public void onComplete(List<PatternLockView.Dot> pattern) {
if (patternEntered.equals(patternToString(pattern))){ if (patternEntered.equals(patternToString(pattern))){
savePattern(patternEntered); savePattern(patternEntered);
showEnterPatternUI(); showNewPatternUI();
} }
} }
@ -180,44 +149,7 @@ public class PatternSecurityFragment extends Fragment {
public void savePattern(String pattern){ public void savePattern(String pattern){
String patternEncripted = PasswordManager.encriptPassword(pattern); String patternEncripted = PasswordManager.encriptPassword(pattern);
CrystalSecurityMonitor.getInstance(null).setPatternEncrypted(patternEncripted);
if (patternGeneralSetting == null) { CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
patternGeneralSetting = new GeneralSetting();
patternGeneralSetting.setName(GeneralSetting.SETTING_PATTERN);
}
patternGeneralSetting.setValue(patternEncripted);
generalSettingListViewModel.saveGeneralSetting(patternGeneralSetting);
}
public void showEnterPatternUI(){
removePatternListener();
patternLockView.clearPattern();
tvPatternText.setText("Enter old pattern");
actualPatternListener = new PatternLockViewListener() {
@Override
public void onStarted() {
}
@Override
public void onProgress(List<PatternLockView.Dot> progressPattern) {
}
@Override
public void onComplete(List<PatternLockView.Dot> pattern) {
if (PasswordManager.checkPassword(patternGeneralSetting.getValue(),patternToString(pattern))){
showNewPatternUI();
}
}
@Override
public void onCleared() {
}
};
patternLockView.addPatternLockListener(actualPatternListener);
} }
} }

View file

@ -22,6 +22,7 @@ import butterknife.ButterKnife;
import butterknife.OnTextChanged; import butterknife.OnTextChanged;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.activities.CreateSeedActivity; import cy.agorise.crystalwallet.activities.CreateSeedActivity;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.dao.CrystalDatabase;
import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.util.PasswordManager;
@ -36,17 +37,11 @@ import cy.agorise.crystalwallet.viewmodels.validators.validationfields.Validatio
public class PinSecurityFragment extends Fragment implements UIValidatorListener { public class PinSecurityFragment extends Fragment implements UIValidatorListener {
@BindView(R.id.tvCurrentPin)
TextView tvCurrentPin;
@BindView(R.id.etCurrentPin)
EditText etCurrentPin;
@BindView(R.id.etNewPin) @BindView(R.id.etNewPin)
EditText etNewPin; EditText etNewPin;
@BindView(R.id.etConfirmPin) @BindView(R.id.etConfirmPin)
EditText etConfirmPin; EditText etConfirmPin;
@BindView(R.id.tvCurrentPinError)
TextView tvCurrentPinError;
@BindView(R.id.tvNewPinError) @BindView(R.id.tvNewPinError)
TextView tvNewPinError; TextView tvNewPinError;
@BindView(R.id.tvConfirmPinError) @BindView(R.id.tvConfirmPinError)
@ -77,55 +72,12 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
pinSecurityValidator = new PinSecurityValidator(this.getContext(), etCurrentPin, etNewPin, etConfirmPin); pinSecurityValidator = new PinSecurityValidator(this.getContext(), etNewPin, etConfirmPin);
pinSecurityValidator.setListener(this); pinSecurityValidator.setListener(this);
generalSettingsLiveData.observe(this, new Observer<List<GeneralSetting>>() {
@Override
public void onChanged(@Nullable List<GeneralSetting> generalSettings) {
boolean founded = false;
if (generalSettings != null){
for (GeneralSetting generalSetting:generalSettings) {
if (generalSetting.getName().equals(GeneralSetting.SETTING_PASSWORD)){
founded = true;
if (!generalSetting.getValue().isEmpty()){
passwordGeneralSetting = generalSetting;
showCurrentPinUI(true);
} else {
showCurrentPinUI(false);
}
break;
}
}
if (!founded){
showCurrentPinUI(false);
}
} else {
showCurrentPinUI(false);
}
}
});
return v; return v;
} }
public void showCurrentPinUI(Boolean visible){
if (visible){
tvCurrentPin.setVisibility(View.VISIBLE);
etCurrentPin.setVisibility(View.VISIBLE);
} else {
tvCurrentPin.setVisibility(View.GONE);
etCurrentPin.setVisibility(View.GONE);
}
}
@OnTextChanged(value = R.id.etCurrentPin,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterCurrentPinChanged(Editable editable) {
this.pinSecurityValidator.validate();
}
@OnTextChanged(value = R.id.etNewPin, @OnTextChanged(value = R.id.etNewPin,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterNewPinChanged(Editable editable) { void afterNewPinChanged(Editable editable) {
@ -139,9 +91,6 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
} }
public void clearFields(){ public void clearFields(){
if (!this.etCurrentPin.getText().toString().equals("")) {
this.etCurrentPin.setText("");
}
if (!this.etNewPin.getText().toString().equals("")) { if (!this.etNewPin.getText().toString().equals("")) {
this.etNewPin.setText(""); this.etNewPin.setText("");
} }
@ -157,9 +106,7 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
this.getActivity().runOnUiThread(new Runnable() { this.getActivity().runOnUiThread(new Runnable() {
public void run() { public void run() {
if (field.getView() == etCurrentPin) { if (field.getView() == etNewPin){
tvCurrentPinError.setText("");
} else if (field.getView() == etNewPin){
tvNewPinError.setText(""); tvNewPinError.setText("");
} else if (field.getView() == etConfirmPin){ } else if (field.getView() == etConfirmPin){
tvConfirmPinError.setText(""); tvConfirmPinError.setText("");
@ -171,7 +118,6 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
Toast toast = Toast.makeText(getContext(), text, duration); Toast toast = Toast.makeText(getContext(), text, duration);
toast.show(); toast.show();
//showCurrentPinUI(true);
savePassword(etNewPin.getText().toString()); savePassword(etNewPin.getText().toString());
@ -184,14 +130,8 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
public void savePassword(String password) { public void savePassword(String password) {
String passwordEncripted = PasswordManager.encriptPassword(password); String passwordEncripted = PasswordManager.encriptPassword(password);
CrystalSecurityMonitor.getInstance(null).setPasswordSecurity(passwordEncripted);
if (passwordGeneralSetting == null) { CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
passwordGeneralSetting = new GeneralSetting();
passwordGeneralSetting.setName(GeneralSetting.SETTING_PASSWORD);
}
passwordGeneralSetting.setValue(passwordEncripted);
generalSettingListViewModel.saveGeneralSetting(passwordGeneralSetting);
} }
@Override @Override
@ -200,9 +140,7 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener
@Override @Override
public void run() { public void run() {
if (field.getView() == etCurrentPin) { if (field.getView() == etNewPin){
tvCurrentPinError.setText(field.getMessage());
} else if (field.getView() == etNewPin){
tvNewPinError.setText(field.getMessage()); tvNewPinError.setText(field.getMessage());
} else if (field.getView() == etConfirmPin){ } else if (field.getView() == etConfirmPin){
tvConfirmPinError.setText(field.getMessage()); tvConfirmPinError.setText(field.getMessage());

View file

@ -12,6 +12,8 @@ import android.view.ViewGroup;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.util.ChildViewPager; import cy.agorise.crystalwallet.util.ChildViewPager;
/** /**
@ -46,6 +48,17 @@ public class SecuritySettingsFragment extends Fragment {
securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager()); securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager());
mPager.setAdapter(securityPagerAdapter); mPager.setAdapter(securityPagerAdapter);
switch(CrystalSecurityMonitor.getInstance(null).actualSecurity()) {
case GeneralSetting.SETTING_PASSWORD:
mPager.setCurrentItem(1);
break;
case GeneralSetting.SETTING_PATTERN:
mPager.setCurrentItem(2);
break;
default:
mPager.setCurrentItem(0);
}
mPager.setSwipeLocked(true); mPager.setSwipeLocked(true);
TabLayout tabLayout = v.findViewById(R.id.tabs); TabLayout tabLayout = v.findViewById(R.id.tabs);
@ -56,6 +69,14 @@ public class SecuritySettingsFragment extends Fragment {
return v; return v;
} }
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity());
}
}
private class SecurityPagerAdapter extends FragmentPagerAdapter { private class SecurityPagerAdapter extends FragmentPagerAdapter {
SecurityPagerAdapter(FragmentManager fm) { SecurityPagerAdapter(FragmentManager fm) {
super(fm); super(fm);

View file

@ -45,4 +45,16 @@ public class GeneralSettingListViewModel extends AndroidViewModel {
public LiveData<GeneralSetting> getGeneralSettingLiveDataByName(String name){ public LiveData<GeneralSetting> getGeneralSettingLiveDataByName(String name){
return this.db.generalSettingDao().getByName(name); return this.db.generalSettingDao().getByName(name);
} }
public void deleteGeneralSettings(GeneralSetting... generalSettings){
this.db.generalSettingDao().deleteGeneralSettings(generalSettings);
}
public void deleteGeneralSettingByName(String name){
this.db.generalSettingDao().deleteByName(name);
}
//public void addGeneralSetting(String name, String value){
// this.db.generalSettingDao().addGeneralSetting(name,value);
//}
} }

View file

@ -14,9 +14,8 @@ import cy.agorise.crystalwallet.viewmodels.validators.validationfields.PinValida
public class PinSecurityValidator extends UIValidator { public class PinSecurityValidator extends UIValidator {
public PinSecurityValidator(Context context, EditText currentPinEdit, EditText newPinEdit, EditText newPinConfirmationEdit){ public PinSecurityValidator(Context context, EditText newPinEdit, EditText newPinConfirmationEdit){
super(context); super(context);
this.addField(new CurrentPinValidationField(currentPinEdit));
this.addField(new PinValidationField(newPinEdit)); this.addField(new PinValidationField(newPinEdit));
this.addField(new PinConfirmationValidationField(newPinEdit,newPinConfirmationEdit)); this.addField(new PinConfirmationValidationField(newPinEdit,newPinConfirmationEdit));
} }

View file

@ -6,35 +6,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<TextView
android:id="@+id/tvCurrentPin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/current_pin"
app:layout_constraintBottom_toTopOf="@+id/etCurrentPin"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed" />
<EditText
android:id="@+id/etCurrentPin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:inputType="numberPassword"
app:layout_constraintBottom_toTopOf="@+id/etNewPin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvCurrentPin"
tools:ignore="LabelFor" />
<TextView
android:id="@+id/tvCurrentPinError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/red"
app:layout_constraintTop_toBottomOf="@+id/etCurrentPin" />
<EditText <EditText
android:id="@+id/etNewPin" android:id="@+id/etNewPin"
android:layout_width="0dp" android:layout_width="0dp"
@ -42,11 +13,9 @@
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:hint="@string/new_pin" android:hint="@string/new_pin"
android:inputType="numberPassword" android:inputType="numberPassword"
app:layout_constraintBottom_toTopOf="@+id/etConfirmPin"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent" />
app:layout_constraintTop_toBottomOf="@+id/tvCurrentPinError" />
<TextView <TextView
android:id="@+id/tvNewPinError" android:id="@+id/tvNewPinError"
android:layout_width="wrap_content" android:layout_width="wrap_content"