Improved CreateSeedLayout using TextInputLayout
This commit is contained in:
parent
aabdab2951
commit
dc4bd347c3
2 changed files with 157 additions and 198 deletions
|
@ -3,6 +3,8 @@ package cy.agorise.crystalwallet.activities;
|
|||
import android.arch.lifecycle.ViewModelProviders;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.support.design.widget.TextInputLayout;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.text.Editable;
|
||||
|
@ -39,23 +41,26 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
AccountSeedViewModel accountSeedViewModel;
|
||||
CreateSeedValidator createSeedValidator;
|
||||
|
||||
@BindView(R.id.etPin)
|
||||
EditText etPin;
|
||||
@BindView(R.id.tvPinError)
|
||||
TextView tvPinError;
|
||||
@BindView(R.id.tilPin)
|
||||
TextInputLayout tilPin;
|
||||
|
||||
@BindView(R.id.etPinConfirmation)
|
||||
EditText etPinConfirmation;
|
||||
@BindView(R.id.tvPinConfirmationError)
|
||||
TextView tvPinConfirmationError;
|
||||
@BindView(R.id.tietPin)
|
||||
TextInputEditText tietPin;
|
||||
|
||||
@BindView(R.id.tilPinConfirmation)
|
||||
TextInputLayout tilPinConfirmation;
|
||||
|
||||
@BindView(R.id.tietPinConfirmation)
|
||||
TextInputEditText tietPinConfirmation;
|
||||
|
||||
//@BindView(R.id.tvSeedWords)
|
||||
//TextView tvSeedWords;
|
||||
|
||||
@BindView (R.id.etAccountName)
|
||||
EditText etAccountName;
|
||||
@BindView(R.id.tvAccountNameError)
|
||||
TextView tvAccountNameError;
|
||||
@BindView(R.id.tilAccountName)
|
||||
TextInputLayout tilAccountName;
|
||||
|
||||
@BindView (R.id.tietAccountName)
|
||||
TextInputEditText tietAccountName;
|
||||
|
||||
@BindView(R.id.btnCreate)
|
||||
Button btnCreate;
|
||||
|
@ -69,19 +74,23 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
setContentView(R.layout.create_seed);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
tilPin.setErrorEnabled(true);
|
||||
tilPinConfirmation.setErrorEnabled(true);
|
||||
tilAccountName.setErrorEnabled(true);
|
||||
|
||||
btnCreate.setEnabled(false);
|
||||
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
|
||||
createSeedValidator = new CreateSeedValidator(this.getApplicationContext(),etPin,etPinConfirmation,etAccountName);
|
||||
createSeedValidator = new CreateSeedValidator(this.getApplicationContext(),tietPin,tietPinConfirmation,tietAccountName);
|
||||
createSeedValidator.setListener(this);
|
||||
}
|
||||
|
||||
@OnTextChanged(value = R.id.etPin,
|
||||
@OnTextChanged(value = R.id.tietPin,
|
||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||
void afterPinChanged(Editable editable) {
|
||||
this.createSeedValidator.validate();
|
||||
}
|
||||
|
||||
@OnTextChanged(value = R.id.etPinConfirmation,
|
||||
@OnTextChanged(value = R.id.tietPinConfirmation,
|
||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||
void afterPinConfirmationChanged(Editable editable) {
|
||||
this.createSeedValidator.validate();
|
||||
|
@ -94,7 +103,7 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
}
|
||||
*/
|
||||
|
||||
@OnTextChanged(value = R.id.etAccountName,
|
||||
@OnTextChanged(value = R.id.tietAccountName,
|
||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||
void afterAccountNameChanged(Editable editable) {
|
||||
this.createSeedValidator.validate();
|
||||
|
@ -110,7 +119,7 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
if (this.createSeedValidator.isValid()) {
|
||||
// Make request to create a bitshare account
|
||||
final ValidateCreateBitsharesAccountRequest request =
|
||||
new ValidateCreateBitsharesAccountRequest(etAccountName.getText().toString(), getApplicationContext());
|
||||
new ValidateCreateBitsharesAccountRequest(tietAccountName.getText().toString(), getApplicationContext());
|
||||
|
||||
|
||||
//Makes dialog to tell the user that the account is been created
|
||||
|
@ -168,12 +177,12 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
|
||||
if (field.getView() == etPin) {
|
||||
tvPinError.setText("");
|
||||
} else if (field.getView() == etPinConfirmation){
|
||||
tvPinConfirmationError.setText("");
|
||||
} else if (field.getView() == etAccountName){
|
||||
tvAccountNameError.setText("");
|
||||
if (field.getView() == tietPin) {
|
||||
tilPin.setError("");
|
||||
} else if (field.getView() == tietPinConfirmation){
|
||||
tilPinConfirmation.setError("");
|
||||
} else if (field.getView() == tietAccountName){
|
||||
tilAccountName.setError("");
|
||||
} //else if (field.getView() == etSeedWords){
|
||||
// tvSeedWordsError.setText("");
|
||||
//}
|
||||
|
@ -194,12 +203,12 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
if (field.getView() == etPin) {
|
||||
tvPinError.setText(field.getMessage());
|
||||
} else if (field.getView() == etPinConfirmation){
|
||||
tvPinConfirmationError.setText(field.getMessage());
|
||||
} else if (field.getView() == etAccountName){
|
||||
tvAccountNameError.setText(field.getMessage());
|
||||
if (field.getView() == tietPin) {
|
||||
tilPin.setError(field.getMessage());
|
||||
} else if (field.getView() == tietPinConfirmation){
|
||||
tilPinConfirmation.setError(field.getMessage());
|
||||
} else if (field.getView() == tietAccountName){
|
||||
tilAccountName.setError(field.getMessage());
|
||||
} //else if (field.getView() == etSeedWords){
|
||||
// tvSeedWordsError.setText(field.getMessage());
|
||||
//}
|
||||
|
|
|
@ -1,108 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="0dp"
|
||||
android:paddingLeft="0dp"
|
||||
android:paddingRight="0dp"
|
||||
android:paddingTop="@dimen/activity_vertical_margin">
|
||||
tools:context=".activities.CreateSeedActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPin"
|
||||
android:layout_width="match_parent"
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/tilPin"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/txt_6_digits_pin"
|
||||
android:textStyle="bold" />
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="32dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tilPinConfirmation"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintVertical_bias="0.1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_chainStyle="packed">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etPin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:inputType="number"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/black" />
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/tietPin"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/txt_6_digits_pin"
|
||||
android:inputType="number"
|
||||
android:singleLine="true" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPinError"
|
||||
android:layout_width="match_parent"
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/tilPinConfirmation"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/red"
|
||||
android:textStyle="bold" />
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tilAccountName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tilPin"
|
||||
app:layout_constraintStart_toStartOf="@id/tilPin"
|
||||
app:layout_constraintEnd_toEndOf="@id/tilPin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPinConfirmation"
|
||||
android:layout_width="match_parent"
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/tietPinConfirmation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/txt_6_digits_pin_confirm"
|
||||
android:inputType="number"
|
||||
android:singleLine="true" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/tilAccountName"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/txt_6_digits_pin_confirm"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etPinConfirmation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:inputType="number"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvPinConfirmationError"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/red"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/txt_account_name"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/etAccountName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:background="@drawable/edittext_bg"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:textColor="@color/black" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAccountNameError"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="@color/red"
|
||||
android:textStyle="bold" />
|
||||
android:layout_marginTop="8dp"
|
||||
app:layout_constraintBottom_toTopOf="@+id/btnCancel"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tilPinConfirmation"
|
||||
app:layout_constraintStart_toStartOf="@id/tilPinConfirmation"
|
||||
app:layout_constraintEnd_toEndOf="@id/tilPinConfirmation">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/tietAccountName"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/txt_account_name"
|
||||
android:inputType="textMultiLine"
|
||||
android:singleLine="true" />
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
<!--
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -111,90 +76,75 @@
|
|||
android:layout_marginTop="10dp"
|
||||
android:text="@string/txt_brain_key_info"
|
||||
android:textSize="15dp"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone" /> -->
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<Button
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="24dp"
|
||||
android:layout_marginTop="48dp"
|
||||
android:background="@color/redcolor"
|
||||
android:text="@string/cancel"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintBottom_toTopOf="@+id/linearLayout"
|
||||
app:layout_constraintStart_toStartOf="@id/tilAccountName"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tilAccountName" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCancel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@color/pink"
|
||||
android:text="@string/cancel"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnCreate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_margin="10dp"
|
||||
android:background="@color/green"
|
||||
android:padding="10dp"
|
||||
android:text="@string/create_wallet"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
</LinearLayout>
|
||||
<Button
|
||||
android:id="@+id/btnCreate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:background="@color/colorPrimary"
|
||||
android:padding="10dp"
|
||||
android:text="@string/create_wallet"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toEndOf="@id/tilAccountName"
|
||||
app:layout_constraintTop_toTopOf="@id/btnCancel" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="35dp"
|
||||
android:background="@color/bottomBarColor"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/tvAppVersion_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/v_1_0_beta" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBlockNumberHead_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:text="@string/block_number" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSocketConnected_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/black"></LinearLayout>
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="35dp"
|
||||
android:background="@color/bottomBarColor"
|
||||
android:gravity="bottom"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvAppVersion_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@string/v_1_0_beta" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvBlockNumberHead_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="2"
|
||||
android:gravity="center"
|
||||
android:text="@string/block_number" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivSocketConnected_brain_key_activity"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:src="@drawable/icon_setting"
|
||||
android:visibility="invisible" />
|
||||
</LinearLayout>
|
||||
<ImageView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_weight="0.5"
|
||||
android:src="@drawable/icon_setting"
|
||||
android:visibility="invisible" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
Loading…
Reference in a new issue