SendTransactionFragment animations and layout and small fixes

master
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;
@BindView(R.id.etFrom)
EditText etFrom;
/*@BindView(R.id.etFrom)
EditText etFrom;*/
@BindView(R.id.tvFromError)
TextView tvFromError;
@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);
} else {
this.finish();
}
}
@OnTextChanged(value = R.id.etFrom,
/*@OnTextChanged(value = R.id.etFrom,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
void afterFromChanged(Editable editable) {
this.sendTransactionValidator.validate();
}
}*/
@OnTextChanged(value = R.id.etTo,
callback = OnTextChanged.Callback.AFTER_TEXT_CHANGED)
@ -177,9 +177,9 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
activity.runOnUiThread(new Runnable() {
public void run() {
if (field.getView() == etFrom) {
/*if (field.getView() == etFrom) {
tvFromError.setText("");
} else if (field.getView() == etTo){
} else*/ if (field.getView() == etTo){
tvToError.setText("");
} else if (field.getView() == etAmount){
tvAmountError.setText("");
@ -201,9 +201,9 @@ public class SendTransactionActivity extends AppCompatActivity implements UIVali
@Override
public void onValidationFailed(ValidationField field) {
if (field.getView() == etFrom) {
/*if (field.getView() == etFrom) {
tvFromError.setText(field.getMessage());
} else if (field.getView() == etTo){
} else*/ if (field.getView() == etTo){
tvToError.setText(field.getMessage());
} else if (field.getView() == spAsset){
tvAssetError.setText(field.getMessage());

View File

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

View File

@ -1,105 +1,208 @@
<?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:weightSum="1">
android:layout_height="wrap_content"
android:minWidth="350dp">
<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
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/to_capital"
android:textSize="15sp" />
android:layout_marginStart="24dp"
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
android:id="@+id/etTo"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="24dp"
android:gravity="top"
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
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvToError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Asset"
android:textSize="15sp" />
<Spinner
android:id="@+id/spAsset"
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" />
android:textColor="@color/red"
app:layout_constraintEnd_toEndOf="@+id/etTo"
app:layout_constraintStart_toStartOf="@+id/etTo"
app:layout_constraintTop_toBottomOf="@+id/etTo" />
<EditText
android:id="@+id/etAmount"
android:layout_width="match_parent"
android:layout_width="150dp"
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:inputType="textMultiLine"
android:textColor="@color/white" />
android:textColor="@color/white"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/etAmount" />
<TextView
android:layout_width="match_parent"
android:id="@+id/tvAssetError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="@+id/tvAmountError"
android:textColor="@color/red" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/memo_capital"
android:textSize="15sp" />
android:textColor="@color/red"
app:layout_constraintBottom_toBottomOf="@+id/tvAmountError"
app:layout_constraintEnd_toEndOf="@+id/spAsset"
app:layout_constraintStart_toStartOf="@+id/spAsset" />
<EditText
android:id="@+id/etMemo"
android:layout_width="match_parent"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="top"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
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
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvMemoError"
android:textColor="@color/red" />
<!--<Button
android:layout_width="0dp"
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:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/cancel">
</Button>
<Button
android:id="@+id/btnSend"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/send_capital">
</Button>-->
</LinearLayout>
android:layout_marginBottom="24dp"
android:layout_marginEnd="24dp"
android:text="@string/cancel_capital"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</android.support.constraint.ConstraintLayout>

View File

@ -452,4 +452,6 @@
<!-- TODO: Remove or change this placeholder text -->
<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>