diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java index b06e56fb..5ccbbcf9 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java @@ -35,6 +35,7 @@ import android.widget.Toast; import com.m2049r.xmrwallet.model.PendingTransaction; import com.m2049r.xmrwallet.model.TransactionInfo; import com.m2049r.xmrwallet.model.Wallet; +import com.m2049r.xmrwallet.model.WalletManager; import com.m2049r.xmrwallet.service.WalletService; import com.m2049r.xmrwallet.util.TxData; @@ -156,6 +157,7 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment. String walletId = extras.getString(REQUEST_ID); if (walletId != null) { setTitle(walletId); + setSubtitle(""); } } updateProgress(); @@ -170,6 +172,7 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment. // see this happen. mBoundService = null; setTitle(getString(R.string.wallet_activity_name)); + setSubtitle(""); Log.d(TAG, "DISCONNECTED"); } }; @@ -268,6 +271,11 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment. tbWallet.setTitle(title); } + @Override + public void setSubtitle(String subtitle) { + tbWallet.setSubtitle(subtitle); + } + @Override public void onSendRequest() { replaceFragment(new SendFragment(), null, null); diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java index f1fa22f6..77633ad2 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java @@ -22,6 +22,7 @@ import android.content.ClipboardManager; import android.content.Context; import android.content.DialogInterface; import android.os.Bundle; +import android.support.constraint.ConstraintLayout; import android.support.v7.app.AlertDialog; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.RecyclerView; @@ -29,6 +30,7 @@ import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.animation.Interpolator; import android.widget.Button; import android.widget.LinearLayout; import android.widget.ProgressBar; @@ -49,10 +51,10 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O private NumberFormat formatter = NumberFormat.getInstance(); TextView tvBalance; - TextView tvUnlockedBalance; + LinearLayout llUnconfirmedAmount; + TextView tvUnconfirmedAmount; TextView tvBlockHeightProgress; - TextView tvConnectionStatus; - LinearLayout llProgress; + ConstraintLayout clProgress; TextView tvProgress; ProgressBar pbProgress; Button bSend; @@ -64,11 +66,13 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O tvProgress = (TextView) view.findViewById(R.id.tvProgress); pbProgress = (ProgressBar) view.findViewById(R.id.pbProgress); - llProgress = (LinearLayout) view.findViewById(R.id.llProgress); + clProgress = (ConstraintLayout) view.findViewById(R.id.clProgress); + llUnconfirmedAmount = (LinearLayout) view.findViewById(R.id.llUnconfirmedAmount); tvBalance = (TextView) view.findViewById(R.id.tvBalance); - tvUnlockedBalance = (TextView) view.findViewById(R.id.tvUnlockedBalance); + tvBalance.setText(getDisplayAmount(0)); + tvUnconfirmedAmount = (TextView) view.findViewById(R.id.tvUnconfirmedAmount); + tvUnconfirmedAmount.setText(getDisplayAmount(0)); tvBlockHeightProgress = (TextView) view.findViewById(R.id.tvBlockHeightProgress); - tvConnectionStatus = (TextView) view.findViewById(R.id.tvConnectionStatus); bSend = (Button) view.findViewById(R.id.bSend); @@ -145,11 +149,11 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O } public void showProgress() { - llProgress.setVisibility(View.VISIBLE); + clProgress.setVisibility(View.VISIBLE); } public void hideProgress() { - llProgress.setVisibility(View.GONE); + clProgress.setVisibility(View.GONE); } String setActivityTitle(Wallet wallet) { @@ -158,10 +162,12 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O if (shortName.length() > 16) { shortName = shortName.substring(0, 14) + "..."; } - String title = "[" + wallet.getAddress().substring(0, 6) + "] " - + shortName - + (wallet.isWatchOnly() ? " " + getString(R.string.watchonly_label) : ""); + String title = "[" + wallet.getAddress().substring(0, 6) + "] " + shortName; activityCallback.setTitle(title); + + String watchOnly = (wallet.isWatchOnly() ? " " + getString(R.string.watchonly_label) : ""); + String net = (wallet.isTestNet() ? getString(R.string.connect_testnet) : getString(R.string.connect_mainnet)); + activityCallback.setSubtitle(net + " " + watchOnly); Log.d(TAG, "wallet title is " + title); return title; } @@ -169,14 +175,39 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O private long firstBlock = 0; private String walletTitle = null; + private String getDisplayAmount(long amount) { + String s = Wallet.getDisplayAmount(amount); + int lastZero = 0; + int decimal = 0; + for (int i = s.length() - 1; i >= 0; i--) { + if ((lastZero == 0) && (s.charAt(i) != '0')) lastZero = i + 1; + // TODO i18n + if (s.charAt(i) == '.') { + decimal = i; + break; + } + } + //Log.d(TAG, decimal + "/" + lastZero + "/" + s); + int cutoff = Math.max(lastZero, decimal + 2); + return s.substring(0, cutoff); + } + private void updateStatus(Wallet wallet) { Log.d(TAG, "updateStatus()"); if (walletTitle == null) { walletTitle = setActivityTitle(wallet); onProgress(100); // of loading } - tvBalance.setText(Wallet.getDisplayAmount(wallet.getBalance())); - tvUnlockedBalance.setText(Wallet.getDisplayAmount(wallet.getUnlockedBalance())); + long balance = wallet.getBalance(); + long unlockedBalance = wallet.getUnlockedBalance(); + tvBalance.setText(getDisplayAmount(unlockedBalance)); + tvUnconfirmedAmount.setText(getDisplayAmount(balance - unlockedBalance)); + // balance cannot be less than unlockedBalance + /*if (balance != unlockedBalance) { + llPendingAmount.setVisibility(View.VISIBLE); + } else { + llPendingAmount.setVisibility(View.INVISIBLE); + }*/ String sync = ""; if (!activityCallback.hasBoundService()) throw new IllegalStateException("WalletService not bound."); @@ -197,9 +228,10 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O sync = getString(R.string.status_synced) + ": " + formatter.format(wallet.getBlockChainHeight()); } } - String net = (wallet.isTestNet() ? getString(R.string.connect_testnet) : getString(R.string.connect_mainnet)); tvBlockHeightProgress.setText(sync); - tvConnectionStatus.setText(net + " " + daemonConnected.toString().substring(17)); + //String net = (wallet.isTestNet() ? getString(R.string.connect_testnet) : getString(R.string.connect_mainnet)); + //activityCallback.setSubtitle(net + " " + daemonConnected.toString().substring(17)); + // TODO show connected status somewhere } Listener activityCallback; @@ -216,6 +248,8 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O void setTitle(String title); + void setSubtitle(String subtitle); + void onSendRequest(); void onTxDetailsRequest(TransactionInfo info); diff --git a/app/src/main/res/layout/gen_review_fragment.xml b/app/src/main/res/layout/gen_review_fragment.xml index 56a2a725..a162f4bf 100644 --- a/app/src/main/res/layout/gen_review_fragment.xml +++ b/app/src/main/res/layout/gen_review_fragment.xml @@ -4,6 +4,20 @@ android:layout_height="match_parent" android:orientation="vertical"> + <LinearLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="8dp" + android:orientation="vertical"> + + <ProgressBar + android:id="@+id/pbProgress" + style="@android:style/Widget.ProgressBar.Horizontal" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:visibility="invisible" /> + </LinearLayout> + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" @@ -58,20 +72,6 @@ android:textSize="16sp" /> </LinearLayout> - <LinearLayout - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:orientation="vertical"> - - <ProgressBar - android:id="@+id/pbProgress" - style="@android:style/Widget.ProgressBar.Horizontal" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:visibility="invisible" /> - </LinearLayout> - <TextView android:id="@+id/tvWalletMnemonicLabel" android:layout_width="match_parent" @@ -103,10 +103,10 @@ android:id="@+id/tvWalletAddress" android:layout_width="match_parent" android:layout_height="wrap_content" + android:selectAllOnFocus="true" android:textAlignment="center" android:textColor="@color/colorPrimaryDark" android:textIsSelectable="true" - android:selectAllOnFocus="true" android:textSize="16sp" /> <TextView @@ -123,10 +123,10 @@ android:id="@+id/tvWalletViewKey" android:layout_width="match_parent" android:layout_height="wrap_content" + android:selectAllOnFocus="true" android:textAlignment="center" android:textColor="@color/colorPrimaryDark" android:textIsSelectable="true" - android:selectAllOnFocus="true" android:textSize="16sp" /> <TextView @@ -143,10 +143,10 @@ android:id="@+id/tvWalletSpendKey" android:layout_width="match_parent" android:layout_height="wrap_content" + android:selectAllOnFocus="true" android:textAlignment="center" android:textColor="@color/colorPrimaryDark" android:textIsSelectable="true" - android:selectAllOnFocus="true" android:textSize="16sp" /> <Button diff --git a/app/src/main/res/layout/wallet_fragment.xml b/app/src/main/res/layout/wallet_fragment.xml index 77470e2b..8d4d4a5e 100644 --- a/app/src/main/res/layout/wallet_fragment.xml +++ b/app/src/main/res/layout/wallet_fragment.xml @@ -5,111 +5,121 @@ android:layout_height="match_parent" android:orientation="vertical"> - <android.support.constraint.ConstraintLayout - xmlns:app="http://schemas.android.com/apk/res-auto" + <android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="8dp"> - - <TextView - android:id="@+id/tvBalanceLabel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="4dp" - android:text="@string/label_balance" - android:textSize="10sp" - app:layout_constraintBaseline_toBaselineOf="@+id/tvBalance" - app:layout_constraintRight_toLeftOf="@+id/tvBalance" /> - - <TextView - android:id="@+id/tvBalance" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="8dp" - android:layout_marginTop="8dp" - android:text="00000000.000000000000" - app:layout_constraintRight_toRightOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - <TextView - android:id="@+id/tvUnlockedBalanceLabel" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="4dp" - android:text="@string/label_unlockedBalance" - android:textColor="@color/colorAccent" - android:textSize="10sp" - app:layout_constraintBaseline_toBaselineOf="@+id/tvUnlockedBalance" - app:layout_constraintRight_toLeftOf="@+id/tvUnlockedBalance" /> - - <TextView - android:id="@+id/tvUnlockedBalance" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="4dp" - android:text="00000000.000000000000" - android:textColor="@color/colorAccent" - app:layout_constraintRight_toRightOf="@+id/tvBalance" - app:layout_constraintTop_toBottomOf="@+id/tvBalance" /> - - <TextView - android:id="@+id/tvConnectionStatus" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" - android:text="Loading..." - android:textSize="10sp" - app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintBaseline_toBaselineOf="@+id/tvBalance" /> + android:layout_marginBottom="4sp" + android:layout_marginLeft="4sp" + android:layout_marginRight="4sp"> <TextView android:id="@+id/tvBlockHeightProgress" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="8dp" - android:layout_marginTop="8dp" android:text="Loading..." - android:textSize="10sp" + android:textSize="16sp" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + <android.support.constraint.ConstraintLayout xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools" + android:id="@+id/clProgress" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:visibility="gone" + app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" - app:layout_constraintBaseline_toBaselineOf="@+id/tvUnlockedBalance"/> + app:layout_constraintRight_toRightOf="parent"> - </android.support.constraint.ConstraintLayout> + <ProgressBar + android:id="@+id/pbProgress" + style="@android:style/Widget.ProgressBar.Horizontal" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:progress="0" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" /> - <LinearLayout - android:id="@+id/llProgress" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:layout_marginBottom="8dp" - android:layout_marginTop="8dp" - android:gravity="center" - android:orientation="vertical" - android:visibility="gone"> + <TextView + android:id="@+id/tvProgress" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="Loading..." + android:textSize="16sp" + android:textColor="@color/white" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" /> + </android.support.constraint.ConstraintLayout> - <TextView - android:id="@+id/tvProgress" + <LinearLayout + android:id="@+id/llBalance" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Loading..." - android:textSize="16sp" /> + android:layout_marginTop="4dp" + android:orientation="horizontal" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvBlockHeightProgress"> - <ProgressBar - android:id="@+id/pbProgress" - style="@android:style/Widget.ProgressBar.Horizontal" - android:layout_width="match_parent" + <TextView + android:id="@+id/tvBalance" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="00000000.000000000000" + android:textColor="@color/moneroOrange" + android:textSize="24sp" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="4sp" + android:text="@string/label_xmr" + android:textColor="@color/moneroOrange" + android:textSize="24sp" /> + </LinearLayout> + + <LinearLayout + android:id="@+id/llUnconfirmedAmount" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:progress="0" /> - </LinearLayout> + android:orientation="horizontal" + android:visibility="visible" + app:layout_constraintLeft_toLeftOf="parent" + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintTop_toBottomOf="@+id/llBalance"> - <android.support.constraint.ConstraintLayout - xmlns:app="http://schemas.android.com/apk/res-auto" + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="4sp" + android:text="+" + android:textSize="16sp" /> + + <TextView + android:id="@+id/tvUnconfirmedAmount" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="00000000.000000000000" + android:textSize="16sp" /> + + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="4sp" + android:text="@string/label_unconfirmed_alance" + android:textSize="16sp" /> + </LinearLayout> + </android.support.constraint.ConstraintLayout> + + <android.support.constraint.ConstraintLayout 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.support.v7.widget.RecyclerView - xmlns:app="http://schemas.android.com/apk/res-auto" + <android.support.v7.widget.RecyclerView xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/list" android:layout_width="0dp" @@ -125,7 +135,6 @@ android:id="@+id/bSend" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_marginBottom="8dp" android:background="@color/colorPrimary" android:enabled="true" android:text="@string/wallet_send_hint" @@ -133,5 +142,7 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" /> + </android.support.constraint.ConstraintLayout> + </LinearLayout> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index d00a4f27..fa2b0184 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -11,4 +11,7 @@ <color name="tx_red">#ff4f41</color> <color name="tx_pending">#FF4081</color> + <color name="moneroOrange">#fa6600</color> + <color name="white">#ffffff</color> + </resources> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bb505e1b..30a4a509 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -35,7 +35,9 @@ <string name="title_amount">Amount</string> <string name="title_date">Date</string> - <string name="label_balance">Balance</string> + <string name="label_balance">Unconfirmed</string> + <string name="label_unconfirmed_alance">unconfirmed</string> + <string name="label_xmr">XMR</string> <string name="label_unlockedBalance">Available</string> <string name="label_transactions">Transactions</string> <string name="text_daemonConnected">Daemon connected!</string>