mirror of
https://github.com/wownero/wownerujo.git
synced 2026-11-17 22:03:58 +01:00
UI facelift (#49)
This commit is contained in:
@@ -101,6 +101,7 @@ public class GenerateReviewFragment extends Fragment {
|
||||
String seed;
|
||||
String viewKey;
|
||||
boolean isWatchOnly;
|
||||
Wallet.Status status;
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(String... params) {
|
||||
@@ -118,8 +119,13 @@ public class GenerateReviewFragment extends Fragment {
|
||||
wallet = WalletManager.getInstance().openWallet(walletPath, password);
|
||||
closeWallet = true;
|
||||
}
|
||||
if (wallet.getStatus() != Wallet.Status.Status_Ok) return false;
|
||||
name = wallet.getName();
|
||||
status = wallet.getStatus();
|
||||
if (status != Wallet.Status.Status_Ok) {
|
||||
if (closeWallet) wallet.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
address = wallet.getAddress();
|
||||
seed = wallet.getSeed();
|
||||
viewKey = wallet.getSecretViewKey();
|
||||
@@ -131,13 +137,13 @@ public class GenerateReviewFragment extends Fragment {
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
super.onPostExecute(result);
|
||||
tvWalletName.setText(name);
|
||||
if (result) {
|
||||
if (type.equals(GenerateReviewFragment.VIEW_TYPE_ACCEPT)) {
|
||||
tvWalletPassword.setText(password);
|
||||
bAccept.setVisibility(View.VISIBLE);
|
||||
bAccept.setEnabled(true);
|
||||
}
|
||||
tvWalletName.setText(name);
|
||||
tvWalletAddress.setText(address);
|
||||
tvWalletMnemonic.setText(seed);
|
||||
tvWalletViewKey.setText(viewKey);
|
||||
@@ -147,6 +153,13 @@ public class GenerateReviewFragment extends Fragment {
|
||||
} else {
|
||||
tvWalletSpendKey.setText(getString(R.string.generate_wallet_watchonly));
|
||||
}
|
||||
} else {
|
||||
// TODO show proper error message
|
||||
// TODO end the fragment
|
||||
tvWalletAddress.setText(status.toString());
|
||||
tvWalletMnemonic.setText(status.toString());
|
||||
tvWalletViewKey.setText(status.toString());
|
||||
tvWalletSpendKey.setText(status.toString());
|
||||
}
|
||||
hideProgress();
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ public class LoginActivity extends AppCompatActivity
|
||||
}
|
||||
}
|
||||
|
||||
// copy + delete seems safer than rename bevause we call rollback easily
|
||||
// copy + delete seems safer than rename because we call rollback easily
|
||||
boolean renameWallet(File walletFile, String newName) {
|
||||
if (copyWallet(walletFile, new File(walletFile.getParentFile(), newName), false)) {
|
||||
deleteWallet(walletFile);
|
||||
@@ -215,7 +215,7 @@ public class LoginActivity extends AppCompatActivity
|
||||
final EditText etRename = (EditText) promptsView.findViewById(R.id.etRename);
|
||||
final TextView tvRenameLabel = (TextView) promptsView.findViewById(R.id.tvRenameLabel);
|
||||
|
||||
tvRenameLabel.setText(getString(R.string.prompt_rename) + " " + walletName);
|
||||
tvRenameLabel.setText(getString(R.string.prompt_rename, walletName));
|
||||
|
||||
// set dialog message
|
||||
alertDialogBuilder
|
||||
@@ -396,7 +396,7 @@ public class LoginActivity extends AppCompatActivity
|
||||
final EditText etPassword = (EditText) promptsView.findViewById(R.id.etPassword);
|
||||
final TextView tvPasswordLabel = (TextView) promptsView.findViewById(R.id.tvPasswordLabel);
|
||||
|
||||
tvPasswordLabel.setText(LoginActivity.this.getString(R.string.prompt_password) + " " + wallet);
|
||||
tvPasswordLabel.setText(LoginActivity.this.getString(R.string.prompt_password, wallet));
|
||||
|
||||
// set dialog message
|
||||
alertDialogBuilder
|
||||
|
||||
@@ -49,7 +49,6 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||
private NumberFormat formatter = NumberFormat.getInstance();
|
||||
|
||||
TextView tvBalance;
|
||||
LinearLayout llUnconfirmedAmount;
|
||||
TextView tvUnconfirmedAmount;
|
||||
TextView tvBlockHeightProgress;
|
||||
ConstraintLayout clProgress;
|
||||
@@ -66,7 +65,7 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
if (activityCallback.hasWallet())
|
||||
inflater.inflate(R.menu.wallet_menu, menu);
|
||||
inflater.inflate(R.menu.wallet_menu, menu);
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@@ -78,21 +77,17 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||
tvProgress = (TextView) view.findViewById(R.id.tvProgress);
|
||||
pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress);
|
||||
clProgress = (ConstraintLayout) view.findViewById(R.id.clProgress);
|
||||
llUnconfirmedAmount = (LinearLayout) view.findViewById(R.id.llUnconfirmedAmount);
|
||||
tvBalance = (TextView) view.findViewById(R.id.tvBalance);
|
||||
tvBalance.setText(Helper.getDisplayAmount(0));
|
||||
tvBalance.setText(getResources().getString(R.string.xmr_balance, Helper.getDisplayAmount(0)));
|
||||
tvUnconfirmedAmount = (TextView) view.findViewById(R.id.tvUnconfirmedAmount);
|
||||
tvUnconfirmedAmount.setText(Helper.getDisplayAmount(0));
|
||||
tvUnconfirmedAmount.setText(getResources().getString(R.string.xmr_unconfirmed_amount, Helper.getDisplayAmount(0)));
|
||||
tvBlockHeightProgress = (TextView) view.findViewById(R.id.tvBlockHeightProgress);
|
||||
|
||||
bSend = (Button) view.findViewById(R.id.bSend);
|
||||
|
||||
RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.list);
|
||||
RecyclerView.ItemDecoration itemDecoration = new
|
||||
DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration.VERTICAL);
|
||||
recyclerView.addItemDecoration(itemDecoration);
|
||||
|
||||
this.adapter = new TransactionInfoAdapter(this);
|
||||
this.adapter = new TransactionInfoAdapter(getActivity(), this);
|
||||
recyclerView.setAdapter(adapter);
|
||||
|
||||
bSend.setOnClickListener(new View.OnClickListener()
|
||||
@@ -161,10 +156,12 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||
|
||||
public void showProgress() {
|
||||
clProgress.setVisibility(View.VISIBLE);
|
||||
tvBlockHeightProgress.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
public void hideProgress() {
|
||||
clProgress.setVisibility(View.GONE);
|
||||
tvBlockHeightProgress.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
String setActivityTitle(Wallet wallet) {
|
||||
@@ -173,6 +170,8 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
|
||||
if (shortName.length() > 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.");
|
||||
|
||||
@@ -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<TransactionInfo
|
||||
|
||||
private final SimpleDateFormat DATETIME_FORMATTER = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||
|
||||
static final int TX_RED = Color.rgb(255, 79, 65);
|
||||
static final int TX_GREEN = Color.rgb(54, 176, 91);
|
||||
static final int TX_PENDING = Color.rgb(72, 53, 176);
|
||||
static final int TX_FAILED = Color.rgb(208, 0, 255);
|
||||
//static final int TX_RED = Color.rgb(255, 79, 65);
|
||||
//static final int TX_GREEN = Color.rgb(54, 176, 91);
|
||||
//static final int TX_PENDING = Color.rgb(72, 53, 176);
|
||||
//static final int TX_FAILED = Color.rgb(208, 0, 255);
|
||||
|
||||
int outboundColour;
|
||||
int inboundColour;
|
||||
int pendingColour;
|
||||
int failedColour;
|
||||
|
||||
public interface OnInteractionListener {
|
||||
void onInteraction(View view, TransactionInfo item);
|
||||
@@ -54,7 +61,14 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||
private final List<TransactionInfo> 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<TransactionInfo
|
||||
|
||||
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
final TextView tvAmount;
|
||||
final TextView tvAmountPoint;
|
||||
final TextView tvAmountDecimal;
|
||||
final TextView tvFee;
|
||||
final TextView tvPaymentId;
|
||||
final TextView tvDateTime;
|
||||
TransactionInfo infoItem;
|
||||
@@ -118,9 +131,7 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||
ViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
this.tvAmount = (TextView) itemView.findViewById(R.id.tx_amount);
|
||||
// I know this is stupid but can't be bothered to align decimals otherwise
|
||||
this.tvAmountPoint = (TextView) itemView.findViewById(R.id.tx_amount_point);
|
||||
this.tvAmountDecimal = (TextView) itemView.findViewById(R.id.tx_amount_decimal);
|
||||
this.tvFee = (TextView) itemView.findViewById(R.id.tx_fee);
|
||||
this.tvPaymentId = (TextView) itemView.findViewById(R.id.tx_paymentid);
|
||||
this.tvDateTime = (TextView) itemView.findViewById(R.id.tx_datetime);
|
||||
}
|
||||
@@ -131,34 +142,41 @@ public class TransactionInfoAdapter extends RecyclerView.Adapter<TransactionInfo
|
||||
|
||||
private void setTxColour(int clr) {
|
||||
tvAmount.setTextColor(clr);
|
||||
tvAmountDecimal.setTextColor(clr);
|
||||
tvAmountPoint.setTextColor(clr);
|
||||
tvFee.setTextColor(clr);
|
||||
}
|
||||
|
||||
void bind(int position) {
|
||||
this.infoItem = infoItems.get(position);
|
||||
String displayAmount = Wallet.getDisplayAmount(infoItem.amount);
|
||||
// TODO fix this with i8n code but cryptonote::print_money always uses '.' for decimal point
|
||||
String amountParts[] = displayAmount.split("\\.");
|
||||
amountParts[1] = amountParts[1].substring(0,5);
|
||||
String amount = displayAmount.substring(0, displayAmount.length() - (12 - 5));
|
||||
this.tvAmount.setText(amount);
|
||||
|
||||
this.tvAmount.setText(amountParts[0]);
|
||||
this.tvAmountDecimal.setText(amountParts[1]);
|
||||
if ((infoItem.fee > 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);
|
||||
|
||||
Reference in New Issue
Block a user