From 9b82023a9fa30d278df34502a72c36cf57e054c1 Mon Sep 17 00:00:00 2001 From: m2049r <30435443+m2049r@users.noreply.github.com> Date: Fri, 8 Sep 2017 23:59:50 +0200 Subject: [PATCH] UI facelift (#49) --- app/src/main/AndroidManifest.xml | 2 +- .../xmrwallet/GenerateReviewFragment.java | 17 ++- .../com/m2049r/xmrwallet/LoginActivity.java | 6 +- .../com/m2049r/xmrwallet/WalletFragment.java | 27 ++-- .../layout/TransactionInfoAdapter.java | 66 +++++---- app/src/main/res/color/text_color.xml | 5 + app/src/main/res/layout/gen_fragment.xml | 28 ++-- .../main/res/layout/gen_review_fragment.xml | 62 ++++----- app/src/main/res/layout/login_activity.xml | 8 +- app/src/main/res/layout/login_fragment.xml | 8 +- app/src/main/res/layout/prompt_password.xml | 2 + app/src/main/res/layout/prompt_rename.xml | 2 + app/src/main/res/layout/receive_fragment.xml | 32 ++--- app/src/main/res/layout/send_fragment.xml | 86 ++++++------ app/src/main/res/layout/toolbar.xml | 10 ++ app/src/main/res/layout/transaction_item.xml | 118 ++++++++-------- app/src/main/res/layout/tx_fragment.xml | 78 ++++++----- app/src/main/res/layout/wallet_activity.xml | 9 +- app/src/main/res/layout/wallet_fragment.xml | 126 ++++++------------ app/src/main/res/values/attrs_my_view.xml | 8 -- app/src/main/res/values/colors.xml | 27 ++-- app/src/main/res/values/dimens.xml | 6 +- app/src/main/res/values/strings.xml | 17 ++- app/src/main/res/values/styles.xml | 55 +++++++- 24 files changed, 421 insertions(+), 384 deletions(-) create mode 100644 app/src/main/res/color/text_color.xml create mode 100644 app/src/main/res/layout/toolbar.xml delete mode 100644 app/src/main/res/values/attrs_my_view.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 83f1734..7affb3c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,7 +14,7 @@ android:icon="@drawable/ic_monero_32dp" android:label="@string/app_name" android:supportsRtl="true" - android:theme="@style/AppTheme"> + android:theme="@style/MyMaterialTheme"> 16) { shortName = shortName.substring(0, 14) + "..."; } + // TODO very very rarely this craches because getAddress returns "" or so ... + // maybe because this runs in the ui thread and not in a 5MB thread String title = "[" + wallet.getAddress().substring(0, 6) + "] " + shortName; activityCallback.setTitle(title); @@ -194,14 +193,8 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O } long balance = wallet.getBalance(); long unlockedBalance = wallet.getUnlockedBalance(); - tvBalance.setText(Helper.getDisplayAmount(unlockedBalance)); - tvUnconfirmedAmount.setText(Helper.getDisplayAmount(balance - unlockedBalance)); - // balance cannot be less than unlockedBalance - /*if (balance != unlockedBalance) { - llPendingAmount.setVisibility(View.VISIBLE); - } else { - llPendingAmount.setVisibility(View.INVISIBLE); - }*/ + tvBalance.setText(getResources().getString(R.string.xmr_balance, Helper.getDisplayAmount(unlockedBalance))); + tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_balance, Helper.getDisplayAmount(balance - unlockedBalance))); String sync = ""; if (!activityCallback.hasBoundService()) throw new IllegalStateException("WalletService not bound."); diff --git a/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java b/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java index 3b8dc54..7e83300 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java +++ b/app/src/main/java/com/m2049r/xmrwallet/layout/TransactionInfoAdapter.java @@ -16,7 +16,9 @@ package com.m2049r.xmrwallet.layout; +import android.content.Context; import android.graphics.Color; +import android.support.v4.content.ContextCompat; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.view.LayoutInflater; @@ -42,10 +44,15 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter infoItems; private final OnInteractionListener listener; - public TransactionInfoAdapter(OnInteractionListener listener) { + Context context; + + public TransactionInfoAdapter(Context context, OnInteractionListener listener) { + this.context = context; + inboundColour = ContextCompat.getColor(context, R.color.tx_green); + outboundColour = ContextCompat.getColor(context, R.color.tx_red); + pendingColour = ContextCompat.getColor(context, R.color.tx_pending); + failedColour = ContextCompat.getColor(context, R.color.tx_failed); this.infoItems = new ArrayList<>(); this.listener = listener; Calendar cal = Calendar.getInstance(); @@ -109,8 +123,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter 0)) { + String feeAmount = Wallet.getDisplayAmount(infoItem.fee); + String fee = feeAmount.substring(0, feeAmount.length() - (12 - 5)); + if (infoItem.isPending) { + this.tvFee.setText(context.getString(R.string.tx_list_fee_pending, fee)); + } else { + this.tvFee.setText(context.getString(R.string.tx_list_fee, fee)); + } + } else { + this.tvFee.setText(""); + } if (infoItem.isFailed) { - this.tvAmount.setText('(' + amountParts[0]); - this.tvAmountDecimal.setText(amountParts[1] + ')'); - setTxColour(TX_FAILED); + this.tvAmount.setText(context.getString(R.string.tx_list_amount_failed, amount)); + setTxColour(failedColour); } else if (infoItem.isPending) { - setTxColour(TX_PENDING); + setTxColour(pendingColour); if (infoItem.direction == TransactionInfo.Direction.Direction_Out) { - this.tvAmount.setText('-' + amountParts[0]); + this.tvAmount.setText(context.getString(R.string.tx_list_amount_negative, amount)); } } else if (infoItem.direction == TransactionInfo.Direction.Direction_In) { - setTxColour(TX_GREEN); + setTxColour(inboundColour); } else { - setTxColour(TX_RED); + setTxColour(outboundColour); } - this.tvPaymentId.setText(infoItem.paymentId.equals("0000000000000000")?"":infoItem.paymentId); + this.tvPaymentId.setText(infoItem.paymentId.equals("0000000000000000") ? "" : infoItem.paymentId); this.tvDateTime.setText(getDateTime(infoItem.timestamp)); itemView.setOnClickListener(this); diff --git a/app/src/main/res/color/text_color.xml b/app/src/main/res/color/text_color.xml new file mode 100644 index 0000000..bdb0a30 --- /dev/null +++ b/app/src/main/res/color/text_color.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/gen_fragment.xml b/app/src/main/res/layout/gen_fragment.xml index 567abaf..99e88eb 100644 --- a/app/src/main/res/layout/gen_fragment.xml +++ b/app/src/main/res/layout/gen_fragment.xml @@ -12,6 +12,7 @@ + android:textAlignment="center" /> + android:textAlignment="center" /> + android:textAlignment="center" /> + android:textAlignment="center" /> + android:textAlignment="center" /> + android:textAlignment="center"/>