-Correct the variables convenion of the changes i have made in the code

-In the screen of Create Seed that the size of the two buttons be the same te get armonony in the visual
-In the screen of Create Seed that the button of CREATE WALLET get disabled till all fields be correctly to continue
-In the screen of Create Seed show some info about PIN functionality
-In the screen of Create Seed at the moment the window appears, the Focus automatically is set on the first PIN field and show the keyboard
-In the screen of Create Seed set the limit for the Account Name field to 255
This commit is contained in:
dtvv 2018-08-01 17:11:26 -05:00
parent 7a9c4c0012
commit acd1f9cfb1
6 changed files with 161 additions and 29 deletions

View file

@ -23,16 +23,16 @@ import butterknife.OnClick;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.models.AccountSeed; import cy.agorise.crystalwallet.models.AccountSeed;
import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel; import cy.agorise.crystalwallet.viewmodels.AccountSeedViewModel;
//tvBrainKey
public class BackupSeedActivity extends AppCompatActivity { public class BackupSeedActivity extends AppCompatActivity {
AccountSeedViewModel accountSeedViewModel; AccountSeedViewModel accountSeedViewModel;
@BindView(R.id.backup_seed_view_textview_brainkey) @BindView(R.id.tvBrainKey)
TextView textfieldBrainkey; TextView textfieldBrainkey;
@BindView(R.id.btnOk) @BindView(R.id.btnOk)
Button btnOk; Button btnOk;
@BindView(R.id.backup_seed_view_button_copy) @BindView(R.id.btnCopy)
Button btnCopy; Button btnCopy;
@Override @Override
@ -41,7 +41,7 @@ public class BackupSeedActivity extends AppCompatActivity {
setContentView(R.layout.backup_seed); setContentView(R.layout.backup_seed);
//Note: Test porpouses //Note: Test porpouses
/*final TextView textView = findViewById(R.id.backup_seed_view_textview_brainkey); /*final TextView textView = findViewById(R.id.tvBrainKey);
textView.setText("sakk902909321o p3k21kldsa0'dsa90'e930eidakdñsakdñlsakdi90i03 2i90idopsasakk902909321op3k21 kldsa0'dsa90'e930eid akdñsakdñlsakdi90i032i90idopsa"); textView.setText("sakk902909321o p3k21kldsa0'dsa90'e930eidakdñsakdñlsakdi90i03 2i90idopsasakk902909321op3k21 kldsa0'dsa90'e930eid akdñsakdñlsakdi90i032i90idopsa");
*/ */
@ -75,7 +75,7 @@ public class BackupSeedActivity extends AppCompatActivity {
/* /*
* Clic on button copy to clipboard * Clic on button copy to clipboard
* */ * */
@OnClick(R.id.backup_seed_view_button_copy) @OnClick(R.id.btnCopy)
public void btnCopyClick(){ public void btnCopyClick(){
/* /*

View file

@ -1,14 +1,19 @@
package cy.agorise.crystalwallet.activities; package cy.agorise.crystalwallet.activities;
import android.arch.lifecycle.ViewModelProviders; import android.arch.lifecycle.ViewModelProviders;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.TextInputEditText; import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout; 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;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button; import android.widget.Button;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
@ -16,6 +21,7 @@ import com.afollestad.materialdialogs.MaterialDialog;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import butterknife.OnClick; import butterknife.OnClick;
import butterknife.OnFocusChange;
import butterknife.OnTextChanged; import butterknife.OnTextChanged;
import cy.agorise.crystalwallet.R; import cy.agorise.crystalwallet.R;
import cy.agorise.crystalwallet.dialogs.ProgressCreatingAccountDialog; import cy.agorise.crystalwallet.dialogs.ProgressCreatingAccountDialog;
@ -90,12 +96,16 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
@BindView(R.id.btnCancel) @BindView(R.id.btnCancel)
Button btnCancel; Button btnCancel;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.create_seed); setContentView(R.layout.create_seed);
ButterKnife.bind(this); ButterKnife.bind(this);
/*This button should not be enabled till all the fields be correctly filled*/
disableCreate();
tilPin.setErrorEnabled(true); tilPin.setErrorEnabled(true);
tilPinConfirmation.setErrorEnabled(true); tilPinConfirmation.setErrorEnabled(true);
tilAccountName.setErrorEnabled(true); tilAccountName.setErrorEnabled(true);
@ -104,6 +114,13 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class); accountSeedViewModel = ViewModelProviders.of(this).get(AccountSeedViewModel.class);
createSeedValidator = new CreateSeedValidator(this.getApplicationContext(),tietPin,tietPinConfirmation,tietAccountName); createSeedValidator = new CreateSeedValidator(this.getApplicationContext(),tietPin,tietPinConfirmation,tietAccountName);
createSeedValidator.setListener(this); createSeedValidator.setListener(this);
/*
* Set the focus on the fisrt field and show keyboard
* */
tilPin.requestFocus();
final InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(tilPin, InputMethodManager.SHOW_IMPLICIT);
} }
@OnTextChanged(value = R.id.tietPin, @OnTextChanged(value = R.id.tietPin,
@ -212,6 +229,9 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
@Override @Override
public void onValidationFailed(final ValidationField field) { public void onValidationFailed(final ValidationField field) {
disableCreate(); //Can not create account yet
runOnUiThread(new Runnable() { runOnUiThread(new Runnable() {
@Override @Override
@ -228,4 +248,110 @@ public class CreateSeedActivity extends AppCompatActivity implements UIValidator
} }
}); });
} }
@OnFocusChange(R.id.tietPin)
public void onFocusChangePIN(View v, boolean hasFocus){
/*
* On lost focus
* */
if(!hasFocus){
/*
* Validate continue to create account
* */
if(validateFieldsToContinue()){
enableCreate();
}
else {
disableCreate();
}
}
}
@OnFocusChange(R.id.tietPinConfirmation)
public void onFocusChangePINConfirmation(View v, boolean hasFocus){
/*
* On lost focus
* */
if(!hasFocus){
/*
* Validate continue to create account
* */
if(validateFieldsToContinue()){
enableCreate();
}
else {
disableCreate();
}
}
}
@OnFocusChange(R.id.tietAccountName)
public void onFocusChangeAccountName(View v, boolean hasFocus){
/*
* On lost focus
* */
if(!hasFocus){
/*
* Validate continue to create account
* */
if(validateFieldsToContinue()){
enableCreate();
}
else {
disableCreate();
}
}
}
/*
* Validate that all is complete to continue to create
* */
private boolean validateFieldsToContinue(){
/*
* Get the value of the fields
* */
final String pin = tilPin.getEditText().getText().toString().trim();
final String pinConfirmation = tilPinConfirmation.getEditText().getText().toString().trim();
final String accountName = tilAccountName.getEditText().getText().toString().trim();
final String pinError = tilPin.getError()==null?"":tilPin.getError().toString().trim();
final String pinConfirmationError = tietPinConfirmation.getError()==null?"":tietPinConfirmation.getError().toString().trim();
final String accountNameError = tietAccountName.getError()==null?"":tietAccountName.getError().toString().trim();
boolean result = false; //Contains the final result
if(!pin.isEmpty() && !pinConfirmation.isEmpty() && !accountName.isEmpty()) {
if(pinError.isEmpty() && pinConfirmationError.isEmpty() && accountNameError.isEmpty()){
result = true;
}
}
/*
* If the result is true so the user can continue to the creation of the account
* */
return result;
}
/*
* Enable create button
* */
private void enableCreate(){
btnCreate.setEnabled(true);
btnCreate.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
}
/*
* Disable create button
* */
private void disableCreate(){
btnCreate.setEnabled(false);
btnCreate.setBackground(getResources().getDrawable(R.drawable.disable_style));
}
} }

View file

@ -28,7 +28,7 @@
android:textStyle="bold" /> android:textStyle="bold" />
<TextView <TextView
android:id="@+id/backup_seed_view_textview_brainkey" android:id="@+id/tvBrainKey"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/tvMnemonicTitle" android:layout_below="@+id/tvMnemonicTitle"
@ -58,7 +58,7 @@
android:layout_marginRight="70dp" android:layout_marginRight="70dp"
android:text="@string/window_seed_leyend_backup" android:text="@string/window_seed_leyend_backup"
android:textSize="14dp" android:textSize="14dp"
android:layout_below="@+id/backup_seed_view_textview_brainkey"/> android:layout_below="@+id/tvBrainKey"/>
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -76,7 +76,7 @@
android:background="@drawable/ok"/> android:background="@drawable/ok"/>
<Button <Button
android:id="@+id/backup_seed_view_button_copy" android:id="@+id/btnCopy"
android:layout_width="80dp" android:layout_width="80dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"

View file

@ -6,13 +6,23 @@
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activities.CreateSeedActivity"> tools:context=".activities.CreateSeedActivity">
<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="20dp"
android:text="@string/txt_brain_key_info"
app:layout_constraintTop_toTopOf="parent"
android:textSize="15dp" />
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:id="@+id/tilPin" android:id="@+id/tilPin"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="24dp" android:layout_marginEnd="24dp"
android:layout_marginStart="24dp" android:layout_marginStart="24dp"
android:layout_marginTop="32dp" android:layout_marginTop="112dp"
app:layout_constraintBottom_toTopOf="@+id/tilPinConfirmation" app:layout_constraintBottom_toTopOf="@+id/tilPinConfirmation"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
@ -29,6 +39,7 @@
android:hint="@string/txt_6_digits_pin" android:hint="@string/txt_6_digits_pin"
android:inputType="number" android:inputType="number"
android:singleLine="true" /> android:singleLine="true" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
@ -49,6 +60,7 @@
android:maxLength="32" android:maxLength="32"
android:inputType="number" android:inputType="number"
android:singleLine="true" /> android:singleLine="true" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
@ -67,26 +79,18 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/txt_account_name" android:hint="@string/txt_account_name"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:maxLength="255"
android:singleLine="true" /> android:singleLine="true" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<!--
<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_brain_key_info"
android:textSize="15dp"
android:visibility="gone" /> -->
<Button <Button
android:id="@+id/btnCancel" android:id="@+id/btnCancel"
android:layout_width="wrap_content" android:layout_width="140dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginStart="24dp" android:layout_marginStart="4dp"
android:layout_marginTop="48dp" android:layout_marginTop="28dp"
android:background="@color/redColor" android:background="@color/redColor"
android:text="@string/cancel" android:text="@string/cancel"
android:textColor="@color/white" android:textColor="@color/white"
@ -97,10 +101,10 @@
<Button <Button
android:id="@+id/btnCreate" android:id="@+id/btnCreate"
android:layout_width="wrap_content" android:layout_width="140dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_marginEnd="24dp" android:layout_marginEnd="4dp"
android:background="@color/colorPrimary" android:background="@color/colorPrimary"
android:padding="10dp" android:padding="10dp"
android:text="@string/create_wallet" android:text="@string/create_wallet"

View file

@ -18,15 +18,15 @@
<attr name="civ_selectorStrokeColor" format="color"/> <attr name="civ_selectorStrokeColor" format="color"/>
<!-- The selector stroke drawn around the image upon touch events this pixels wide. (if enabled) --> <!-- The selector stroke drawn around the image upon touch events this pixels wide. (if enabled) -->
<attr name="civ_selectorStrokeWidth" format="dimension"/> <attr name="civ_selectorStrokeWidth" format="dimension"/>
<!-- Whether or not to draw a shadow around your circular image. --> <!-- Whether or not to draw a disable_style around your circular image. -->
<attr name="civ_shadow" format="boolean"/> <attr name="civ_shadow" format="boolean"/>
<!-- The radius for the shadow to extend to. (if enabled) --> <!-- The radius for the disable_style to extend to. (if enabled) -->
<attr name="civ_shadowRadius" format="float"/> <attr name="civ_shadowRadius" format="float"/>
<!-- Horizontal shadow offset. (if enabled) --> <!-- Horizontal disable_style offset. (if enabled) -->
<attr name="civ_shadowDx" format="float"/> <attr name="civ_shadowDx" format="float"/>
<!-- Vertical shadow offset. (if enabled) --> <!-- Vertical disable_style offset. (if enabled) -->
<attr name="civ_shadowDy" format="float"/> <attr name="civ_shadowDy" format="float"/>
<!-- The color of the shadow drawn around your circular image. (if enabled) --> <!-- The color of the disable_style drawn around your circular image. (if enabled) -->
<attr name="civ_shadowColor" format="color"/> <attr name="civ_shadowColor" format="color"/>
</declare-styleable> </declare-styleable>

View file

@ -36,6 +36,8 @@
<string name="window_create_seed_DialogTittle"></string> <string name="window_create_seed_DialogTittle"></string>
<string name="window_create_seed_DialogMessage">Creating New Account ...</string> <string name="window_create_seed_DialogMessage">Creating New Account ...</string>
<string name="window_create_seed_Info">You will use your PIN yo make transactions between accounts</string>
<string name="window_seed_backup">Backup brainkey</string> <string name="window_seed_backup">Backup brainkey</string>
<string name="window_seed_toast_clipboard">Brainkey copied to clipboard!</string> <string name="window_seed_toast_clipboard">Brainkey copied to clipboard!</string>
<string name="window_seed_copy">Copy</string> <string name="window_seed_copy">Copy</string>