From fe84bae9ed7fcc4ebc1cc7db5de60be77c56a1d1 Mon Sep 17 00:00:00 2001
From: m2049r <30435443+m2049r@users.noreply.github.com>
Date: Sat, 2 Sep 2017 10:05:50 +0200
Subject: [PATCH] rework options menus
---
.../m2049r/xmrwallet/GenerateFragment.java | 2 +-
.../com/m2049r/xmrwallet/ReceiveFragment.java | 1 +
.../com/m2049r/xmrwallet/WalletActivity.java | 51 +++++++++++--------
.../com/m2049r/xmrwallet/WalletFragment.java | 21 ++++++++
app/src/main/res/drawable/ic_monero_32dp.xml | 6 ---
.../main/res/drawable/ic_monero_qr_24dp.xml | 33 ++++++++++++
app/src/main/res/layout/receive_fragment.xml | 8 ++-
app/src/main/res/menu/wallet_menu.xml | 7 +++
app/src/main/res/values/strings.xml | 5 +-
9 files changed, 101 insertions(+), 33 deletions(-)
create mode 100644 app/src/main/res/drawable/ic_monero_qr_24dp.xml
diff --git a/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java b/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
index 8fa139e8..a5d87c3b 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
@@ -345,7 +345,7 @@ public class GenerateFragment extends Fragment {
@Override
public void onResume() {
super.onResume();
- Log.d(TAG, "onPause()");
+ Log.d(TAG, "onResume()");
activityCallback.setTitle(getString(R.string.generate_title));
}
diff --git a/app/src/main/java/com/m2049r/xmrwallet/ReceiveFragment.java b/app/src/main/java/com/m2049r/xmrwallet/ReceiveFragment.java
index 850fa0b7..4beb1dd9 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/ReceiveFragment.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/ReceiveFragment.java
@@ -230,6 +230,7 @@ public class ReceiveFragment extends Fragment {
return null;
}
+ // TODO check if we can sensibly cache some of this
private Bitmap addLogo(Bitmap qrBitmap) {
Bitmap logo = getMoneroLogo();
int qrWidth = qrBitmap.getWidth();
diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
index 36026f24..6690bad9 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
@@ -47,6 +47,7 @@ import com.m2049r.xmrwallet.util.BarcodeData;
import com.m2049r.xmrwallet.util.Helper;
import com.m2049r.xmrwallet.util.TxData;
+import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -120,11 +121,8 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
}
@Override
- public boolean onCreateOptionsMenu(Menu menu) {
- if (!haveWallet) return true;
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.wallet_menu, menu);
- return true;
+ public boolean hasWallet() {
+ return haveWallet;
}
@Override
@@ -132,14 +130,16 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
switch (item.getItemId()) {
case R.id.action_info:
onWalletDetails();
- break;
+ return true;
+ case R.id.action_receive:
+ onWalletReceive();
+ return true;
default:
- break;
+ return super.onOptionsItemSelected(item);
}
-
- return true;
}
+
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.d(TAG, "onCreate()");
@@ -585,12 +585,9 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
}
private void onWalletDetails() {
- Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
- if (!(fragment instanceof GenerateReviewFragment)) {
- Bundle extras = new Bundle();
- extras.putString("type", GenerateReviewFragment.VIEW_WALLET);
- replaceFragment(new GenerateReviewFragment(), null, extras);
- }
+ Bundle extras = new Bundle();
+ extras.putString("type", GenerateReviewFragment.VIEW_WALLET);
+ replaceFragment(new GenerateReviewFragment(), null, extras);
}
@Override
@@ -600,11 +597,8 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
private void startScanFragment() {
- Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
- if (fragment instanceof SendFragment) {
- Bundle extras = new Bundle();
- replaceFragment(new ScannerFragment(), null, extras);
- }
+ Bundle extras = new Bundle();
+ replaceFragment(new ScannerFragment(), null, extras);
}
/// QR scanner callbacks
@@ -703,4 +697,21 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
}
}
+ @Override
+ public void onWalletReceive() {
+ startReceive(getWalletAddress());
+ }
+
+ void startReceive(String address) {
+ Log.d(TAG, "startReceive()");
+ Bundle b = new Bundle();
+ b.putString("address", address);
+ startReceiveFragment(b);
+ }
+
+ void startReceiveFragment(Bundle extras) {
+ replaceFragment(new ReceiveFragment(), null, extras);
+ Log.d(TAG, "ReceiveFragment placed");
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java
index ca53a848..0fcaa1fe 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java
@@ -18,12 +18,16 @@ package com.m2049r.xmrwallet;
import android.content.Context;
import android.os.Bundle;
+import android.support.annotation.Nullable;
import android.support.constraint.ConstraintLayout;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@@ -53,6 +57,19 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
ProgressBar pbProgress;
Button bSend;
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setHasOptionsMenu(true);
+ }
+
+ @Override
+ public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+ if (activityCallback.hasWallet())
+ inflater.inflate(R.menu.wallet_menu, menu);
+ super.onCreateOptionsMenu(menu, inflater);
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -236,6 +253,10 @@ public class WalletFragment extends Fragment implements TransactionInfoAdapter.O
boolean isWatchOnly();
String getTxKey(String txId);
+
+ void onWalletReceive();
+
+ boolean hasWallet();
}
@Override
diff --git a/app/src/main/res/drawable/ic_monero_32dp.xml b/app/src/main/res/drawable/ic_monero_32dp.xml
index acb46742..b5f12a4e 100644
--- a/app/src/main/res/drawable/ic_monero_32dp.xml
+++ b/app/src/main/res/drawable/ic_monero_32dp.xml
@@ -3,12 +3,6 @@
android:height="32dp"
android:viewportHeight="75.0"
android:viewportWidth="75.0">
-
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/receive_fragment.xml b/app/src/main/res/layout/receive_fragment.xml
index aa22b563..f81fcd42 100644
--- a/app/src/main/res/layout/receive_fragment.xml
+++ b/app/src/main/res/layout/receive_fragment.xml
@@ -27,9 +27,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="8sp"
android:layout_weight="3"
- android:text="@string/receive_paymentid_hint"
+ android:text="@string/receive_paymentid_label"
android:textAlignment="textEnd"
- android:textColor="@color/colorAccent"
android:textSize="16sp" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ae61634d..51e29ece 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -154,7 +154,10 @@
Generate QR Code
Generate
- PaymentID
+ PaymentID
+ (optional)
+ Amount
+ (optional)
999999.999999999999