From f00427ed19202d9eb215cea2b51b04660b7ab47e Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Sun, 13 May 2018 21:25:03 -0400 Subject: [PATCH] - Security Improved: Now when the user tries to set a new security setting gets directly to the block screen (when there is a security setting already set) - Now the "None" security setting works --- .../activities/IntroActivity.java | 2 +- .../activities/SettingsActivity.java | 1 + .../application/CrystalSecurityMonitor.java | 101 ++++++++++++------ .../crystalwallet/dao/GeneralSettingDao.java | 7 ++ .../fragments/NoneSecurityFragment.java | 48 +++++++++ .../fragments/PatternSecurityFragment.java | 78 +------------- .../fragments/PinSecurityFragment.java | 74 ++----------- .../fragments/SecuritySettingsFragment.java | 21 ++++ .../GeneralSettingListViewModel.java | 12 +++ .../validators/PinSecurityValidator.java | 3 +- .../main/res/layout/fragment_pin_security.xml | 33 +----- 11 files changed, 169 insertions(+), 211 deletions(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java index 6c7d429..5c82104 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/IntroActivity.java @@ -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 diff --git a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java index 8f708f9..26b74a8 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java +++ b/app/src/main/java/cy/agorise/crystalwallet/activities/SettingsActivity.java @@ -19,6 +19,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import cy.agorise.crystalwallet.BuildConfig; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.fragments.AccountsSettingsFragment; import cy.agorise.crystalwallet.fragments.BackupsSettingsFragment; import cy.agorise.crystalwallet.fragments.BalanceFragment; diff --git a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java index b08726c..c3ca8bb 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java +++ b/app/src/main/java/cy/agorise/crystalwallet/application/CrystalSecurityMonitor.java @@ -16,6 +16,7 @@ import java.util.List; import cy.agorise.crystalwallet.activities.PatternRequestActivity; import cy.agorise.crystalwallet.activities.PinRequestActivity; import cy.agorise.crystalwallet.models.GeneralSetting; +import cy.agorise.crystalwallet.notifiers.CrystalWalletNotifier; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; /** @@ -27,44 +28,77 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall private String passwordEncrypted; private String patternEncrypted; - public CrystalSecurityMonitor(final FragmentActivity fragmentActivity){ - GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(fragmentActivity).get(GeneralSettingListViewModel.class); - LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); + private static CrystalSecurityMonitor instance; + private GeneralSettingListViewModel generalSettingListViewModel; - generalSettingsLiveData.observe(fragmentActivity, new Observer>() { - @Override - public void onChanged(@Nullable List generalSettings) { - boolean founded = false; - passwordEncrypted = ""; + private CrystalSecurityMonitor(final FragmentActivity fragmentActivity){ + //For security reasons, this code is not asynchronous because the pattern or password data + //must be retrieved before the principal activity starts + generalSettingListViewModel = ViewModelProviders.of(fragmentActivity).get(GeneralSettingListViewModel.class); - if (generalSettings != null){ - for (GeneralSetting generalSetting:generalSettings) { - if (generalSetting.getName().equals(GeneralSetting.SETTING_PASSWORD)){ - if (!generalSetting.getValue().isEmpty()){ - passwordEncrypted = generalSetting.getValue(); - callPasswordRequest(fragmentActivity); - } - break; - } else if (generalSetting.getName().equals(GeneralSetting.SETTING_PATTERN)){ - if (!generalSetting.getValue().isEmpty()){ - patternEncrypted = generalSetting.getValue(); - callPasswordRequest(fragmentActivity); - } - break; - } - } - } - } - }); + this.passwordEncrypted = ""; + this.patternEncrypted = ""; + GeneralSetting passwordGeneralSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_PASSWORD);; + GeneralSetting patternGeneralSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_PATTERN);; + + if (passwordGeneralSetting != null){ + this.passwordEncrypted = passwordGeneralSetting.getValue(); + } + if (patternGeneralSetting != null){ + this.patternEncrypted = patternGeneralSetting.getValue(); + } + } + + 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 public void onActivityStarted(Activity activity) { if (numStarted == 0) { - if ( - ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) - || ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) - ) { + if (!actualSecurity().equals("")){ callPasswordRequest(activity); } } @@ -75,10 +109,7 @@ public class CrystalSecurityMonitor implements Application.ActivityLifecycleCall public void onActivityStopped(Activity activity) { numStarted--; if (numStarted == 0) { - if ( - ((this.passwordEncrypted != null) && (!this.passwordEncrypted.equals(""))) - || ((this.patternEncrypted != null) && (!this.patternEncrypted.equals(""))) - ) { + if (!actualSecurity().equals("")){ callPasswordRequest(activity); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/dao/GeneralSettingDao.java b/app/src/main/java/cy/agorise/crystalwallet/dao/GeneralSettingDao.java index e7c6acb..d8a9357 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/dao/GeneralSettingDao.java +++ b/app/src/main/java/cy/agorise/crystalwallet/dao/GeneralSettingDao.java @@ -2,6 +2,7 @@ package cy.agorise.crystalwallet.dao; import android.arch.lifecycle.LiveData; import android.arch.persistence.room.Dao; +import android.arch.persistence.room.Delete; import android.arch.persistence.room.Insert; import android.arch.persistence.room.OnConflictStrategy; import android.arch.persistence.room.Query; @@ -32,4 +33,10 @@ public interface GeneralSettingDao { @Insert(onConflict = OnConflictStrategy.REPLACE) public long insertGeneralSetting(GeneralSetting generalSetting); + + @Delete + public void deleteGeneralSettings(GeneralSetting... generalSettings); + + @Query("DELETE FROM general_setting WHERE name = :name") + public void deleteByName(String name); } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/NoneSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/NoneSecurityFragment.java index a8cb92b..fc34e1e 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/NoneSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/NoneSecurityFragment.java @@ -1,13 +1,23 @@ 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.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import java.util.List; + import butterknife.ButterKnife; 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. @@ -15,6 +25,11 @@ import cy.agorise.crystalwallet.R; public class NoneSecurityFragment extends Fragment { + GeneralSetting passwordGeneralSetting = new GeneralSetting(); + GeneralSetting patternGeneralSetting = new GeneralSetting(); + + GeneralSettingListViewModel generalSettingListViewModel; + public NoneSecurityFragment() { // Required empty public constructor } @@ -33,6 +48,39 @@ public class NoneSecurityFragment extends Fragment { View v = inflater.inflate(R.layout.fragment_none_security, container, false); ButterKnife.bind(this, v); + generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); + LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); + + generalSettingsLiveData.observe(this, new Observer>() { + @Override + public void onChanged(@Nullable List 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; } + + @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(""); + } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java index 2a53dd7..73c3f8a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/PatternSecurityFragment.java @@ -23,6 +23,7 @@ import butterknife.BindView; import butterknife.ButterKnife; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.PasswordManager; import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel; @@ -36,10 +37,6 @@ import cy.agorise.crystalwallet.viewmodels.validators.validationfields.Validatio public class PatternSecurityFragment extends Fragment { - GeneralSettingListViewModel generalSettingListViewModel; - GeneralSetting patternGeneralSetting; - //PatternSecurityValidator patternSecurityValidator; - @BindView(R.id.patternLockView) PatternLockView patternLockView; @BindView(R.id.tvPatternText) @@ -66,35 +63,7 @@ public class PatternSecurityFragment extends Fragment { View v = inflater.inflate(R.layout.fragment_pattern_security, container, false); ButterKnife.bind(this, v); - generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); - LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); - - generalSettingsLiveData.observe(this, new Observer>() { - @Override - public void onChanged(@Nullable List 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(); - } - break; - } - } - if (!founded){ - showNewPatternUI(); - } - } else { - showNewPatternUI(); - } - } - }); + showNewPatternUI(); return v; } @@ -166,7 +135,7 @@ public class PatternSecurityFragment extends Fragment { public void onComplete(List pattern) { if (patternEntered.equals(patternToString(pattern))){ savePattern(patternEntered); - showEnterPatternUI(); + showNewPatternUI(); } } @@ -180,44 +149,7 @@ public class PatternSecurityFragment extends Fragment { public void savePattern(String pattern){ String patternEncripted = PasswordManager.encriptPassword(pattern); - - if (patternGeneralSetting == null) { - 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 progressPattern) { - - } - - @Override - public void onComplete(List pattern) { - if (PasswordManager.checkPassword(patternGeneralSetting.getValue(),patternToString(pattern))){ - showNewPatternUI(); - } - } - - @Override - public void onCleared() { - - } - }; - patternLockView.addPatternLockListener(actualPatternListener); + CrystalSecurityMonitor.getInstance(null).setPatternEncrypted(patternEncripted); + CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity()); } } diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/PinSecurityFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/PinSecurityFragment.java index 6c75211..edfaea9 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/PinSecurityFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/PinSecurityFragment.java @@ -22,6 +22,7 @@ import butterknife.ButterKnife; import butterknife.OnTextChanged; import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.activities.CreateSeedActivity; +import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; import cy.agorise.crystalwallet.dao.CrystalDatabase; import cy.agorise.crystalwallet.models.GeneralSetting; 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 { - @BindView(R.id.tvCurrentPin) - TextView tvCurrentPin; - @BindView(R.id.etCurrentPin) - EditText etCurrentPin; @BindView(R.id.etNewPin) EditText etNewPin; @BindView(R.id.etConfirmPin) EditText etConfirmPin; - @BindView(R.id.tvCurrentPinError) - TextView tvCurrentPinError; @BindView(R.id.tvNewPinError) TextView tvNewPinError; @BindView(R.id.tvConfirmPinError) @@ -77,55 +72,12 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class); LiveData> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList(); - pinSecurityValidator = new PinSecurityValidator(this.getContext(), etCurrentPin, etNewPin, etConfirmPin); + pinSecurityValidator = new PinSecurityValidator(this.getContext(), etNewPin, etConfirmPin); pinSecurityValidator.setListener(this); - generalSettingsLiveData.observe(this, new Observer>() { - @Override - public void onChanged(@Nullable List 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; } - 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, callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) void afterNewPinChanged(Editable editable) { @@ -139,9 +91,6 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener } public void clearFields(){ - if (!this.etCurrentPin.getText().toString().equals("")) { - this.etCurrentPin.setText(""); - } if (!this.etNewPin.getText().toString().equals("")) { this.etNewPin.setText(""); } @@ -157,9 +106,7 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener this.getActivity().runOnUiThread(new Runnable() { public void run() { - if (field.getView() == etCurrentPin) { - tvCurrentPinError.setText(""); - } else if (field.getView() == etNewPin){ + if (field.getView() == etNewPin){ tvNewPinError.setText(""); } else if (field.getView() == etConfirmPin){ tvConfirmPinError.setText(""); @@ -171,7 +118,6 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener Toast toast = Toast.makeText(getContext(), text, duration); toast.show(); - //showCurrentPinUI(true); savePassword(etNewPin.getText().toString()); @@ -184,14 +130,8 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener public void savePassword(String password) { String passwordEncripted = PasswordManager.encriptPassword(password); - - if (passwordGeneralSetting == null) { - passwordGeneralSetting = new GeneralSetting(); - passwordGeneralSetting.setName(GeneralSetting.SETTING_PASSWORD); - } - - passwordGeneralSetting.setValue(passwordEncripted); - generalSettingListViewModel.saveGeneralSetting(passwordGeneralSetting); + CrystalSecurityMonitor.getInstance(null).setPasswordSecurity(passwordEncripted); + CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity()); } @Override @@ -200,9 +140,7 @@ public class PinSecurityFragment extends Fragment implements UIValidatorListener @Override public void run() { - if (field.getView() == etCurrentPin) { - tvCurrentPinError.setText(field.getMessage()); - } else if (field.getView() == etNewPin){ + if (field.getView() == etNewPin){ tvNewPinError.setText(field.getMessage()); } else if (field.getView() == etConfirmPin){ tvConfirmPinError.setText(field.getMessage()); diff --git a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java index 39e4a25..bd7447a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java +++ b/app/src/main/java/cy/agorise/crystalwallet/fragments/SecuritySettingsFragment.java @@ -12,6 +12,8 @@ import android.view.ViewGroup; import butterknife.BindView; import butterknife.ButterKnife; import cy.agorise.crystalwallet.R; +import cy.agorise.crystalwallet.application.CrystalSecurityMonitor; +import cy.agorise.crystalwallet.models.GeneralSetting; import cy.agorise.crystalwallet.util.ChildViewPager; /** @@ -46,6 +48,17 @@ public class SecuritySettingsFragment extends Fragment { securityPagerAdapter = new SecurityPagerAdapter(getChildFragmentManager()); 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); TabLayout tabLayout = v.findViewById(R.id.tabs); @@ -56,6 +69,14 @@ public class SecuritySettingsFragment extends Fragment { return v; } + @Override + public void setUserVisibleHint(boolean isVisibleToUser) { + super.setUserVisibleHint(isVisibleToUser); + if (isVisibleToUser) { + CrystalSecurityMonitor.getInstance(null).callPasswordRequest(this.getActivity()); + } + } + private class SecurityPagerAdapter extends FragmentPagerAdapter { SecurityPagerAdapter(FragmentManager fm) { super(fm); diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/GeneralSettingListViewModel.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/GeneralSettingListViewModel.java index b3d3c35..0a171ba 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/GeneralSettingListViewModel.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/GeneralSettingListViewModel.java @@ -45,4 +45,16 @@ public class GeneralSettingListViewModel extends AndroidViewModel { public LiveData getGeneralSettingLiveDataByName(String 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); + //} } diff --git a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/PinSecurityValidator.java b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/PinSecurityValidator.java index b99f155..b70ba0a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/PinSecurityValidator.java +++ b/app/src/main/java/cy/agorise/crystalwallet/viewmodels/validators/PinSecurityValidator.java @@ -14,9 +14,8 @@ import cy.agorise.crystalwallet.viewmodels.validators.validationfields.PinValida 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); - this.addField(new CurrentPinValidationField(currentPinEdit)); this.addField(new PinValidationField(newPinEdit)); this.addField(new PinConfirmationValidationField(newPinEdit,newPinConfirmationEdit)); } diff --git a/app/src/main/res/layout/fragment_pin_security.xml b/app/src/main/res/layout/fragment_pin_security.xml index f5742f2..22e3f5c 100644 --- a/app/src/main/res/layout/fragment_pin_security.xml +++ b/app/src/main/res/layout/fragment_pin_security.xml @@ -6,35 +6,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - + app:layout_constraintStart_toStartOf="parent" />