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.arch.lifecycle.ViewModelProviders;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
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.AlertDialog;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -39,23 +41,26 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
AccountSeedViewModel accountSeedViewModel;
|
AccountSeedViewModel accountSeedViewModel;
|
||||||
CreateSeedValidator createSeedValidator;
|
CreateSeedValidator createSeedValidator;
|
||||||
|
|
||||||
@BindView(R.id.etPin)
|
@BindView(R.id.tilPin)
|
||||||
EditText etPin;
|
TextInputLayout tilPin;
|
||||||
@BindView(R.id.tvPinError)
|
|
||||||
TextView tvPinError;
|
|
||||||
|
|
||||||
@BindView(R.id.etPinConfirmation)
|
@BindView(R.id.tietPin)
|
||||||
EditText etPinConfirmation;
|
TextInputEditText tietPin;
|
||||||
@BindView(R.id.tvPinConfirmationError)
|
|
||||||
TextView tvPinConfirmationError;
|
@BindView(R.id.tilPinConfirmation)
|
||||||
|
TextInputLayout tilPinConfirmation;
|
||||||
|
|
||||||
|
@BindView(R.id.tietPinConfirmation)
|
||||||
|
TextInputEditText tietPinConfirmation;
|
||||||
|
|
||||||
//@BindView(R.id.tvSeedWords)
|
//@BindView(R.id.tvSeedWords)
|
||||||
//TextView tvSeedWords;
|
//TextView tvSeedWords;
|
||||||
|
|
||||||
@BindView (R.id.etAccountName)
|
@BindView(R.id.tilAccountName)
|
||||||
EditText etAccountName;
|
TextInputLayout tilAccountName;
|
||||||
@BindView(R.id.tvAccountNameError)
|
|
||||||
TextView tvAccountNameError;
|
@BindView (R.id.tietAccountName)
|
||||||
|
TextInputEditText tietAccountName;
|
||||||
|
|
||||||
@BindView(R.id.btnCreate)
|
@BindView(R.id.btnCreate)
|
||||||
Button btnCreate;
|
Button btnCreate;
|
||||||
|
@ -69,19 +74,23 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
setContentView(R.layout.create_seed);
|
setContentView(R.layout.create_seed);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
tilPin.setErrorEnabled(true);
|
||||||
|
tilPinConfirmation.setErrorEnabled(true);
|
||||||
|
tilAccountName.setErrorEnabled(true);
|
||||||
|
|
||||||
btnCreate.setEnabled(false);
|
btnCreate.setEnabled(false);
|
||||||
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
|
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);
|
createSeedValidator.setListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnTextChanged(value = R.id.etPin,
|
@OnTextChanged(value = R.id.tietPin,
|
||||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
void afterPinChanged(Editable editable) {
|
void afterPinChanged(Editable editable) {
|
||||||
this.createSeedValidator.validate();
|
this.createSeedValidator.validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnTextChanged(value = R.id.etPinConfirmation,
|
@OnTextChanged(value = R.id.tietPinConfirmation,
|
||||||
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
void afterPinConfirmationChanged(Editable editable) {
|
void afterPinConfirmationChanged(Editable editable) {
|
||||||
this.createSeedValidator.validate();
|
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)
|
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
|
||||||
void afterAccountNameChanged(Editable editable) {
|
void afterAccountNameChanged(Editable editable) {
|
||||||
this.createSeedValidator.validate();
|
this.createSeedValidator.validate();
|
||||||
|
@ -110,7 +119,7 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
if (this.createSeedValidator.isValid()) {
|
if (this.createSeedValidator.isValid()) {
|
||||||
// Make request to create a bitshare account
|
// Make request to create a bitshare account
|
||||||
final ValidateCreateBitsharesAccountRequest request =
|
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
|
//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() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
if (field.getView() == etPin) {
|
if (field.getView() == tietPin) {
|
||||||
tvPinError.setText("");
|
tilPin.setError("");
|
||||||
} else if (field.getView() == etPinConfirmation){
|
} else if (field.getView() == tietPinConfirmation){
|
||||||
tvPinConfirmationError.setText("");
|
tilPinConfirmation.setError("");
|
||||||
} else if (field.getView() == etAccountName){
|
} else if (field.getView() == tietAccountName){
|
||||||
tvAccountNameError.setText("");
|
tilAccountName.setError("");
|
||||||
} //else if (field.getView() == etSeedWords){
|
} //else if (field.getView() == etSeedWords){
|
||||||
// tvSeedWordsError.setText("");
|
// tvSeedWordsError.setText("");
|
||||||
//}
|
//}
|
||||||
|
@ -194,12 +203,12 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (field.getView() == etPin) {
|
if (field.getView() == tietPin) {
|
||||||
tvPinError.setText(field.getMessage());
|
tilPin.setError(field.getMessage());
|
||||||
} else if (field.getView() == etPinConfirmation){
|
} else if (field.getView() == tietPinConfirmation){
|
||||||
tvPinConfirmationError.setText(field.getMessage());
|
tilPinConfirmation.setError(field.getMessage());
|
||||||
} else if (field.getView() == etAccountName){
|
} else if (field.getView() == tietAccountName){
|
||||||
tvAccountNameError.setText(field.getMessage());
|
tilAccountName.setError(field.getMessage());
|
||||||
} //else if (field.getView() == etSeedWords){
|
} //else if (field.getView() == etSeedWords){
|
||||||
// tvSeedWordsError.setText(field.getMessage());
|
// tvSeedWordsError.setText(field.getMessage());
|
||||||
//}
|
//}
|
||||||
|
|
|
@ -1,108 +1,73 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical"
|
tools:context=".activities.CreateSeedActivity">
|
||||||
android:paddingBottom="0dp"
|
|
||||||
android:paddingLeft="0dp"
|
|
||||||
android:paddingRight="0dp"
|
|
||||||
android:paddingTop="@dimen/activity_vertical_margin">
|
|
||||||
|
|
||||||
<TextView
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/tvPin"
|
android:id="@+id/tilPin"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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">
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputEditText
|
||||||
|
android:id="@+id/tietPin"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
android:hint="@string/txt_6_digits_pin"
|
||||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:text="@string/txt_6_digits_pin"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<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:inputType="number"
|
||||||
android:maxLines="1"
|
android:singleLine="true" />
|
||||||
android:textColor="@color/black" />
|
</android.support.design.widget.TextInputLayout>
|
||||||
|
|
||||||
<TextView
|
<android.support.design.widget.TextInputLayout
|
||||||
android:id="@+id/tvPinError"
|
android:id="@+id/tilPinConfirmation"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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">
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputEditText
|
||||||
|
android:id="@+id/tietPinConfirmation"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
android:hint="@string/txt_6_digits_pin_confirm"
|
||||||
android:layout_marginRight="@dimen/activity_horizontal_margin"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:textColor="@color/red"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tvPinConfirmation"
|
|
||||||
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_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:inputType="number"
|
||||||
android:maxLines="1"
|
android:singleLine="true" />
|
||||||
android:singleLine="true"
|
</android.support.design.widget.TextInputLayout>
|
||||||
android:textColor="@color/black" />
|
|
||||||
|
|
||||||
|
<android.support.design.widget.TextInputLayout
|
||||||
|
android:id="@+id/tilAccountName"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
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">
|
||||||
|
|
||||||
<TextView
|
<android.support.design.widget.TextInputEditText
|
||||||
android:id="@+id/tvPinConfirmationError"
|
android:id="@+id/tietAccountName"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/activity_horizontal_margin"
|
android:hint="@string/txt_account_name"
|
||||||
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:inputType="textMultiLine"
|
||||||
android:textColor="@color/black" />
|
android:singleLine="true" />
|
||||||
|
</android.support.design.widget.TextInputLayout>
|
||||||
<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" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
@ -111,58 +76,44 @@
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:text="@string/txt_brain_key_info"
|
android:text="@string/txt_brain_key_info"
|
||||||
android:textSize="15dp"
|
android:textSize="15dp"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" /> -->
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
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:gravity="center"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/btnCancel"
|
android:id="@+id/btnCancel"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_margin="10dp"
|
android:layout_marginStart="24dp"
|
||||||
android:background="@color/pink"
|
android:layout_marginTop="48dp"
|
||||||
|
android:background="@color/redcolor"
|
||||||
android:text="@string/cancel"
|
android:text="@string/cancel"
|
||||||
android:textColor="@color/white" />
|
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
|
<Button
|
||||||
android:id="@+id/btnCreate"
|
android:id="@+id/btnCreate"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:layout_margin="10dp"
|
android:layout_marginEnd="24dp"
|
||||||
android:background="@color/green"
|
android:background="@color/colorPrimary"
|
||||||
android:padding="10dp"
|
android:padding="10dp"
|
||||||
android:text="@string/create_wallet"
|
android:text="@string/create_wallet"
|
||||||
android:textColor="@color/white" />
|
android:textColor="@color/white"
|
||||||
|
android:textStyle="bold"
|
||||||
</LinearLayout>
|
app:layout_constraintEnd_toEndOf="@id/tilAccountName"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/btnCancel" />
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:background="@color/white"
|
|
||||||
android:gravity="bottom"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="@color/black"></LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:id="@+id/linearLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:background="@color/bottomBarColor"
|
android:background="@color/bottomBarColor"
|
||||||
android:gravity="bottom"
|
android:orientation="horizontal"
|
||||||
android:orientation="horizontal">
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvAppVersion_brain_key_activity"
|
android:id="@+id/tvAppVersion_brain_key_activity"
|
||||||
|
@ -195,6 +146,5 @@
|
||||||
android:src="@drawable/icon_setting"
|
android:src="@drawable/icon_setting"
|
||||||
android:visibility="invisible" />
|
android:visibility="invisible" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</android.support.constraint.ConstraintLayout>
|
||||||
|
|
Loading…
Reference in a new issue