-When the PIN does not match in the screen of import seed it does not show error message

-Set a button in the PIN request activity to clic when the complete PIN is completely typed
-In the PIN request activity, the OK button should not be enabled till a valid PIN is on it
-Change the button style in the PIN request screen
This commit is contained in:
dtvv 2018-10-17 01:06:35 -05:00
parent d2668bc04e
commit a4c6b1cfb1
2 changed files with 67 additions and 7 deletions

View file

@ -7,15 +7,25 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.OnTextChanged;
import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.application.CrystalSecurityMonitor;
import cy.agorise.crystalwallet.dialogs.material.DialogMaterial;
import cy.agorise.crystalwallet.dialogs.material.NegativeResponse;
import cy.agorise.crystalwallet.dialogs.material.PositiveResponse;
import cy.agorise.crystalwallet.dialogs.material.QuestionDialog;
import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.models.GeneralSetting;
import cy.agorise.crystalwallet.util.PasswordManager;
@ -24,6 +34,12 @@ import cy.agorise.crystalwallet.viewmodels.GeneralSettingListViewModel;
public class PinRequestActivity extends AppCompatActivity {
private String passwordEncrypted;
@BindView(R.id.btnOK)
Button btnOK;
@Override
public void onBackPressed() {
//Do nothing to prevent the user to use the back button
@ -38,6 +54,11 @@ public class PinRequestActivity extends AppCompatActivity {
setContentView(R.layout.activity_pin_request);
ButterKnife.bind(this);
/*
* Initially the button is disabled till the user type a valid PIN
* */
btnOK.setEnabled(false);
GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this).get(GeneralSettingListViewModel.class);
LiveData<List<GeneralSetting>> generalSettingsLiveData = generalSettingListViewModel.getGeneralSettingList();
generalSettingsLiveData.observe(this, new Observer<List<GeneralSetting>>() {
@ -59,9 +80,10 @@ public class PinRequestActivity extends AppCompatActivity {
});
}
@OnTextChanged(value = R.id.etPassword,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterPasswordChanged(Editable editable) {
@OnClick(R.id.btnOK)
void okClic(final View view) {
if (PasswordManager.checkPassword(passwordEncrypted, etPassword.getText().toString())) {
if (CrystalSecurityMonitor.getInstance(null).is2ndFactorSet()) {
CrystalSecurityMonitor.getInstance(null).call2ndFactor(this);
@ -69,6 +91,26 @@ public class PinRequestActivity extends AppCompatActivity {
this.finish();
}
}
else{
Toast.makeText(getBaseContext(),this.getResources().getString(R.string.invalid_pin),
Toast.LENGTH_SHORT).show();
}
}
@OnTextChanged(value = R.id.etPassword,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterPasswordChanged(Editable editable) {
/*
* If it is valid length enable button
* */
if(etPassword.getText().length()>=6){
btnOK.setEnabled(true);
}
else{
btnOK.setEnabled(false);
}
}
}

View file

@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/gradient">
<LinearLayout
android:id="@+id/linearMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:padding="5dp"
android:background="@drawable/gradient">
android:layout_centerInParent="true"
android:padding="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -26,5 +29,20 @@
android:maxLength="10"
android:textColor="@color/white"
android:inputType="numberPassword" />
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/btnOK"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/linearMain"
android:layout_marginTop="5dp"
android:textColor="@color/white"
android:background="@android:color/transparent"
android:text="@string/ok"
android:layout_margin="20dp"
android:textSize="18dp"
android:layout_alignParentRight="true"/>
</RelativeLayout>