SendTransactionFragment animations and layout and small fixes

This commit is contained in:
Severiano Jaramillo 2017-12-05 22:14:48 -06:00
parent 7ca7e1ef39
commit 3df50a6836
8 changed files with 236 additions and 105 deletions

View file

@ -44,8 +44,8 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
SendTransactionValidator sendTransactionValidator; SendTransactionValidator sendTransactionValidator;
@BindView(R.id.etFrom) /*@BindView(R.id.etFrom)
EditText etFrom; EditText etFrom;*/
@BindView(R.id.tvFromError) @BindView(R.id.tvFromError)
TextView tvFromError; TextView tvFromError;
@BindView(R.id.etTo) @BindView(R.id.etTo)
@ -111,18 +111,18 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
} }
}); });
sendTransactionValidator = new SendTransactionValidator(this.getApplicationContext(), this.cryptoNetAccount, etFrom, etTo, spAsset, etAmount, etMemo); //sendTransactionValidator = new SendTransactionValidator(this.getApplicationContext(), this.cryptoNetAccount, etFrom, etTo, spAsset, etAmount, etMemo);
sendTransactionValidator.setListener(this); sendTransactionValidator.setListener(this);
} else { } else {
this.finish(); this.finish();
} }
} }
@OnTextChanged(value = R.id.etFrom, /*@OnTextChanged(value = R.id.etFrom,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterFromChanged(Editable editable) { void afterFromChanged(Editable editable) {
this.sendTransactionValidator.validate(); this.sendTransactionValidator.validate();
} }*/
@OnTextChanged(value = R.id.etTo, @OnTextChanged(value = R.id.etTo,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
@ -177,9 +177,9 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
public void run() { public void run() {
if (field.getView() == etFrom) { /*if (field.getView() == etFrom) {
tvFromError.setText(""); tvFromError.setText("");
} else if (field.getView() == etTo){ } else*/ if (field.getView() == etTo){
tvToError.setText(""); tvToError.setText("");
} else if (field.getView() == etAmount){ } else if (field.getView() == etAmount){
tvAmountError.setText(""); tvAmountError.setText("");
@ -201,9 +201,9 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
@Override @Override
public void onValidationFailed(ValidationField field) { public void onValidationFailed(ValidationField field) {
if (field.getView() == etFrom) { /*if (field.getView() == etFrom) {
tvFromError.setText(field.getMessage()); tvFromError.setText(field.getMessage());
} else if (field.getView() == etTo){ } else*/ if (field.getView() == etTo){
tvToError.setText(field.getMessage()); tvToError.setText(field.getMessage());
} else if (field.getView() == spAsset){ } else if (field.getView() == spAsset){
tvAssetError.setText(field.getMessage()); tvAssetError.setText(field.getMessage());

View file

@ -44,8 +44,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
SendTransactionValidator sendTransactionValidator; SendTransactionValidator sendTransactionValidator;
@BindView(R.id.etFrom) @BindView(R.id.spFrom)
EditText etFrom; Spinner spFrom;
@BindView(R.id.tvFromError) @BindView(R.id.tvFromError)
TextView tvFromError; TextView tvFromError;
@BindView(R.id.etTo) @BindView(R.id.etTo)
@ -66,8 +66,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
TextView tvMemoError; TextView tvMemoError;
//@BindView(R.id.btnSend) //@BindView(R.id.btnSend)
Button btnSend; Button btnSend;
//@BindView(R.id.btnCancel) @BindView(R.id.btnCancel)
Button btnCancel; TextView btnCancel;
private long cryptoNetAccountId; private long cryptoNetAccountId;
private CryptoNetAccount cryptoNetAccount; private CryptoNetAccount cryptoNetAccount;
@ -94,7 +94,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@Override @Override
public Dialog onCreateDialog(Bundle savedInstanceState) { public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.SendTransactionTheme); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.SendTransactionTheme);
builder.setTitle("Send"); //builder.setTitle("Send");
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.send_transaction, null); View view = inflater.inflate(R.layout.send_transaction, null);
@ -127,15 +127,15 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
spAsset.setAdapter(assetAdapter); spAsset.setAdapter(assetAdapter);
} }
}); });
// TODO SendTransactionValidator to accept spFrom
sendTransactionValidator = new SendTransactionValidator(this.getContext(), this.cryptoNetAccount, etFrom, etTo, spAsset, etAmount, etMemo); //sendTransactionValidator = new SendTransactionValidator(this.getContext(), this.cryptoNetAccount, spFrom, etTo, spAsset, etAmount, etMemo);
sendTransactionValidator.setListener(this); sendTransactionValidator.setListener(this);
etFrom.setText(this.grapheneAccount.getName()); // etFrom.setText(this.grapheneAccount.getName());
} }
builder.setView(view); builder.setView(view);
builder.setPositiveButton("Send", new DialogInterface.OnClickListener() { /*builder.setPositiveButton("Send", new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
sendTransaction(); sendTransaction();
@ -146,7 +146,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
dialog.dismiss(); dialog.dismiss();
} }
}); });*/
AlertDialog dialog = builder.create(); AlertDialog dialog = builder.create();
@ -202,9 +202,8 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
return view; return view;
}*/ }*/
@OnTextChanged(value = R.id.etFrom, @OnItemSelected(R.id.spFrom)
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED) public void afterFromSelected(Spinner spinner, int position) {
void afterFromChanged(Editable editable) {
this.sendTransactionValidator.validate(); this.sendTransactionValidator.validate();
} }
@ -232,10 +231,10 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
this.sendTransactionValidator.validate(); this.sendTransactionValidator.validate();
} }
//@OnClick(R.id.btnCancel) @OnClick(R.id.btnCancel)
//public void cancel(){ public void cancel(){
// this.finish(); this.dismiss();
//} }
//@OnClick(R.id.btnSend) //@OnClick(R.id.btnSend)
public void sendTransaction(){ public void sendTransaction(){
@ -259,7 +258,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
final SendTransactionFragment fragment = this; final SendTransactionFragment fragment = this;
if (field.getView() == etFrom) { if (field.getView() == spFrom) {
tvFromError.setText(""); tvFromError.setText("");
} else if (field.getView() == etTo){ } else if (field.getView() == etTo){
tvToError.setText(""); tvToError.setText("");
@ -282,7 +281,7 @@ public class SendTransactionFragment extends DialogFragment implements UIValidat
@Override @Override
public void onValidationFailed(ValidationField field) { public void onValidationFailed(ValidationField field) {
if (field.getView() == etFrom) { if (field.getView() == spFrom) {
tvFromError.setText(field.getMessage()); tvFromError.setText(field.getMessage());
} else if (field.getView() == etTo){ } else if (field.getView() == etTo){
tvToError.setText(field.getMessage()); tvToError.setText(field.getMessage());

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFC4C4C4"
android:pathData="M16,11c1.66,0 2.99,-1.34 2.99,-3S17.66,5 16,5c-1.66,0 -3,1.34 -3,3s1.34,3 3,3zM8,11c1.66,0 2.99,-1.34 2.99,-3S9.66,5 8,5C6.34,5 5,6.34 5,8s1.34,3 3,3zM8,13c-2.33,0 -7,1.17 -7,3.5L1,19h14v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5zM16,13c-0.29,0 -0.62,0.02 -0.97,0.05 1.16,0.84 1.97,1.97 1.97,3.45L17,19h6v-2.5c0,-2.33 -4.67,-3.5 -7,-3.5z"/>
</vector>

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M15,12c2.21,0 4,-1.79 4,-4s-1.79,-4 -4,-4 -4,1.79 -4,4 1.79,4 4,4zM6,10L6,7L4,7v3L1,10v2h3v3h2v-3h3v-2L6,10zM15,14c-2.67,0 -8,1.34 -8,4v2h16v-2c0,-2.66 -5.33,-4 -8,-4z"/>
</vector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="0"
android:startColor="#FF9269"
android:endColor="#FF7063"/>
</shape>

View file

@ -98,7 +98,7 @@
android:layout_gravity="end|bottom" android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
app:backgroundTint="@color/colorPrimaryDark" app:backgroundTint="@color/colorPrimaryDark"
app:srcCompat="@drawable/add_contact_fab" /> app:srcCompat="@drawable/ic_person_add" />
<!-- Place settings button correctly --> <!-- Place settings button correctly -->

View file

@ -1,105 +1,208 @@
<?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"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:orientation="vertical" android:minWidth="350dp">
android:weightSum="1">
<View
android:id="@+id/topView"
android:layout_width="match_parent"
android:background="@drawable/send_transaction_top_view"
android:layout_height="120dp"
android:layout_marginEnd="0dp"
android:layout_marginStart="0dp"
android:layout_marginTop="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/from_capital"
android:inputType="textFilter"
android:textSize="15sp" />
<EditText
android:id="@+id/etFrom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textFilter"
android:textColor="@color/white" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvFromError"
android:textColor="@color/red" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/to_capital" android:layout_marginStart="24dp"
android:textSize="15sp" /> android:layout_marginTop="24dp"
android:text="Send Assets"
android:textColor="@color/white"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/gravatar"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/gravtr"
android:layout_marginStart="32dp"
android:layout_marginTop="90dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Spinner
android:id="@+id/spFrom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/gravatar"
app:layout_constraintTop_toTopOf="@id/gravatar" />
<TextView
android:id="@+id/tvFromError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/red"
app:layout_constraintEnd_toEndOf="@+id/spFrom"
app:layout_constraintStart_toStartOf="@+id/spFrom"
app:layout_constraintTop_toBottomOf="@+id/topView" />
<EditText <EditText
android:id="@+id/etTo" android:id="@+id/etTo"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:gravity="top" android:gravity="top"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:textColor="@color/white" /> android:textColor="@color/white"
android:textSize="20sp"
android:hint="@string/to_capital"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/gravatar" />
<ImageView
android:id="@+id/ivPeople"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginEnd="5dp"
android:src="@drawable/ic_people"
android:layout_marginBottom="15dp"
app:layout_constraintEnd_toEndOf="@id/etTo"
app:layout_constraintBottom_toBottomOf="@id/etTo"/>
<TextView <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvToError" android:id="@+id/tvToError"
android:textColor="@color/red" /> android:layout_width="0dp"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Asset" android:textColor="@color/red"
android:textSize="15sp" /> app:layout_constraintEnd_toEndOf="@+id/etTo"
<Spinner app:layout_constraintStart_toStartOf="@+id/etTo"
android:id="@+id/spAsset" app:layout_constraintTop_toBottomOf="@+id/etTo" />
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
android:inputType="textMultiLine"
android:textColor="@color/white" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvAssetError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/amount"
android:textSize="15sp" />
<EditText <EditText
android:id="@+id/etAmount" android:id="@+id/etAmount"
android:layout_width="match_parent" android:layout_width="150dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginStart="24dp"
android:inputType="textMultiLine"
android:textColor="@color/white"
android:textSize="20sp"
android:hint="@string/amount"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvToError" />
<TextView
android:id="@+id/tvAmountError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textColor="@color/red"
app:layout_constraintEnd_toEndOf="@+id/etAmount"
app:layout_constraintStart_toStartOf="@+id/etAmount"
app:layout_constraintTop_toBottomOf="@+id/etAmount" />
<Spinner
android:id="@+id/spAsset"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginTop="8dp"
android:gravity="top" android:gravity="top"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:textColor="@color/white" /> android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/etAmount" />
<TextView <TextView
android:layout_width="match_parent" android:id="@+id/tvAssetError"
android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/tvAmountError" android:textColor="@color/red"
android:textColor="@color/red" /> app:layout_constraintBottom_toBottomOf="@+id/tvAmountError"
<TextView app:layout_constraintEnd_toEndOf="@+id/spAsset"
android:layout_width="wrap_content" app:layout_constraintStart_toStartOf="@+id/spAsset" />
android:layout_height="wrap_content"
android:text="@string/memo_capital"
android:textSize="15sp" />
<EditText <EditText
android:id="@+id/etMemo" android:id="@+id/etMemo"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="top" android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:inputType="textMultiLine" android:inputType="textMultiLine"
android:textColor="@color/white" /> android:textColor="@color/white"
android:hint="@string/memo_capital"
android:textSize="20sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tvAmountError" />
<TextView <TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvMemoError" android:id="@+id/tvMemoError"
android:textColor="@color/red" /> android:layout_width="0dp"
<!--<Button android:layout_height="wrap_content"
android:textColor="@color/red"
app:layout_constraintEnd_toEndOf="@+id/etMemo"
app:layout_constraintStart_toStartOf="@+id/etMemo"
app:layout_constraintTop_toBottomOf="@+id/etMemo" />
<TextView
android:id="@+id/tvScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginStart="24dp"
android:text="@string/scan_capital"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMemoError" />
<ImageView
android:id="@+id/ivCamera"
android:layout_width="180dp"
android:layout_height="180dp"
android:layout_marginBottom="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:src="#666"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvScan" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fabSend"
android:layout_width="140dp"
android:layout_height="140dp"
android:layout_marginEnd="0dp"
android:backgroundTint="#FFCEC8"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/ivCamera" />
<TextView
android:id="@+id/btnCancel" android:id="@+id/btnCancel"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/cancel"> android:layout_marginBottom="24dp"
</Button> android:layout_marginEnd="24dp"
<Button android:text="@string/cancel_capital"
android:id="@+id/btnSend" android:textSize="18sp"
android:layout_width="match_parent" app:layout_constraintBottom_toBottomOf="parent"
android:layout_height="wrap_content" app:layout_constraintEnd_toEndOf="parent" />
android:text="@string/send_capital">
</Button>--> </android.support.constraint.ConstraintLayout>
</LinearLayout>

View file

@ -452,4 +452,6 @@
<!-- TODO: Remove or change this placeholder text --> <!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string> <string name="hello_blank_fragment">Hello blank fragment</string>
<string name="scan_capital">Scan a QR or NFC signal</string>
<string name="cancel_capital">CANCEL</string>
</resources> </resources>