From a82a90575de9a4a6fe32da380f8725989f6b8bba Mon Sep 17 00:00:00 2001
From: m2049r <30435443+m2049r@users.noreply.github.com>
Date: Thu, 24 Aug 2017 10:30:42 +0200
Subject: [PATCH 1/2] deamon prompt show syntax
---
app/src/main/res/values/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 30a4a50..5e73960 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -3,7 +3,7 @@
Select Wallet
Wallet
- Daemon Address
+ [<user>:<pass>@]<daemonhost>[:<port>]
Net Selection
TestNet
MainNet
From 191aa6ac223051cf7aa1a4bba21979a61d887bf0 Mon Sep 17 00:00:00 2001
From: m2049r <30435443+m2049r@users.noreply.github.com>
Date: Sat, 26 Aug 2017 22:28:53 +0200
Subject: [PATCH 2/2] action button for create wallet + setting activity title
in LoginActivity
---
.../m2049r/xmrwallet/GenerateFragment.java | 11 +++++
.../com/m2049r/xmrwallet/LoginActivity.java | 43 ++++++++++--------
.../com/m2049r/xmrwallet/LoginFragment.java | 45 +++++++++++--------
.../com/m2049r/xmrwallet/WalletActivity.java | 15 +++----
app/src/main/res/layout/login_fragment.xml | 44 +++++++++++-------
app/src/main/res/values/strings.xml | 2 +-
6 files changed, 100 insertions(+), 60 deletions(-)
diff --git a/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java b/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
index e4196ce..7e6e0f3 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/GenerateFragment.java
@@ -22,6 +22,7 @@ import android.os.Bundle;
import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;
+import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
@@ -344,6 +345,13 @@ public class GenerateFragment extends Fragment {
bGenerate.setVisibility(View.VISIBLE);
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d(TAG, "onPause()");
+ activityCallback.setTitle(getString(R.string.generate_title));
+ }
+
GenerateFragment.Listener activityCallback;
public interface Listener {
@@ -354,6 +362,9 @@ public class GenerateFragment extends Fragment {
void onGenerate(String name, String password, String address, String viewKey, String spendKey, long height);
File getStorageRoot();
+
+ void setTitle(String title);
+
}
@Override
diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
index 33f6870..fde65fc 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
@@ -27,6 +27,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
+import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
@@ -55,6 +56,8 @@ public class LoginActivity extends AppCompatActivity
static final int DAEMON_TIMEOUT = 500; // deamon must respond in 500ms
+ Toolbar toolbar;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -63,8 +66,7 @@ public class LoginActivity extends AppCompatActivity
return;
}
- Toolbar toolbar = (Toolbar) findViewById(R.id.tbLogin);
- toolbar.setTitle(R.string.login_activity_name);
+ toolbar = (Toolbar) findViewById(R.id.tbLogin);
setSupportActionBar(toolbar);
if (Helper.getWritePermission(this)) {
@@ -77,21 +79,17 @@ public class LoginActivity extends AppCompatActivity
@Override
public void onWalletSelected(final String walletName) {
Log.d(TAG, "selected wallet is ." + walletName + ".");
- if (walletName.equals(':' + getString(R.string.generate_title))) {
- startGenerateFragment();
- } else {
- // now it's getting real, check if wallet exists
- String walletPath = Helper.getWalletPath(this, walletName);
- if (WalletManager.getInstance().walletExists(walletPath)) {
- promptPassword(walletName, new PasswordAction() {
- @Override
- public void action(String walletName, String password) {
- startWallet(walletName, password);
- }
- });
- } else { // this cannot really happen as we prefilter choices
- Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
- }
+ // now it's getting real, check if wallet exists
+ String walletPath = Helper.getWalletPath(this, walletName);
+ if (WalletManager.getInstance().walletExists(walletPath)) {
+ promptPassword(walletName, new PasswordAction() {
+ @Override
+ public void action(String walletName, String password) {
+ startWallet(walletName, password);
+ }
+ });
+ } else { // this cannot really happen as we prefilter choices
+ Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
}
}
@@ -111,6 +109,11 @@ public class LoginActivity extends AppCompatActivity
}
}
+ @Override
+ public void onAddWallet() {
+ startGenerateFragment();
+ }
+
AlertDialog passwordDialog = null; // for preventing multiple clicks in wallet list
void promptPassword(final String wallet, final PasswordAction action) {
@@ -203,9 +206,13 @@ public class LoginActivity extends AppCompatActivity
@Override
public void setTitle(String title) {
- super.setTitle(title);
+ toolbar.setTitle(title);
}
+ @Override
+ public void setSubtitle(String subtitle) {
+ toolbar.setSubtitle(subtitle);
+ }
////////////////////////////////////////
////////////////////////////////////////
diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginFragment.java b/app/src/main/java/com/m2049r/xmrwallet/LoginFragment.java
index c9df5ae..5a35ea8 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/LoginFragment.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/LoginFragment.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.StrictMode;
+import android.support.design.widget.FloatingActionButton;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
@@ -68,6 +69,7 @@ public class LoginFragment extends Fragment {
ToggleButton tbMainNet;
EditText etDaemonAddress;
+ FloatingActionButton fabAdd;
Listener activityCallback;
@@ -81,7 +83,12 @@ public class LoginFragment extends Fragment {
void onWalletDetails(final String wallet);
+ void onAddWallet();
+
void setTitle(String title);
+
+ void setSubtitle(String subtitle);
+
}
@Override
@@ -102,6 +109,13 @@ public class LoginFragment extends Fragment {
super.onPause();
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ Log.d(TAG, "onPause()");
+ activityCallback.setTitle(getString(R.string.login_activity_name));
+ }
+
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
@@ -111,6 +125,16 @@ public class LoginFragment extends Fragment {
tbMainNet = (ToggleButton) view.findViewById(R.id.tbMainNet);
etDaemonAddress = (EditText) view.findViewById(R.id.etDaemonAddress);
+
+ fabAdd = (FloatingActionButton) view.findViewById(R.id.fabAdd);
+ fabAdd.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ checkAndSetWalletDaemon("", !isMainNet());
+ activityCallback.onAddWallet();
+ }
+ });
+
Helper.hideKeyboard(getActivity());
etDaemonAddress.setOnClickListener(new View.OnClickListener() {
@@ -139,14 +163,14 @@ public class LoginFragment extends Fragment {
} else {
setDaemon(daemonTestNet);
}
- activityCallback.setTitle(getString(R.string.app_name) + " " +
- getString(mainnet ? R.string.connect_mainnet : R.string.connect_testnet));
+ activityCallback.setSubtitle(getString(mainnet ? R.string.connect_mainnet : R.string.connect_testnet));
filterList();
((BaseAdapter) listView.getAdapter()).notifyDataSetChanged();
}
});
loadPrefs();
+ activityCallback.setSubtitle(getString(isMainNet()? R.string.connect_mainnet : R.string.connect_testnet));
listView = (ListView) view.findViewById(R.id.list);
ArrayAdapter adapter = new ArrayAdapter<>(getActivity(),
@@ -187,7 +211,6 @@ public class LoginFragment extends Fragment {
savePrefs();
String wallet = itemValue.substring(WALLETNAME_PREAMBLE_LENGTH);
- if (itemValue.charAt(1) == '-') wallet = ':' + wallet;
activityCallback.onWalletSelected(wallet);
}
});
@@ -204,30 +227,18 @@ public class LoginFragment extends Fragment {
}
String wallet = itemValue.substring(WALLETNAME_PREAMBLE_LENGTH);
- if (itemValue.charAt(1) == '-') {
- Toast.makeText(getActivity(), getString(R.string.bad_wallet), Toast.LENGTH_LONG).show();
- return true;
- }
-
String x = isMainNet() ? "4" : "9A";
if (x.indexOf(itemValue.charAt(1)) < 0) {
Toast.makeText(getActivity(), getString(R.string.prompt_wrong_net), Toast.LENGTH_LONG).show();
return true;
}
- if (!checkAndSetWalletDaemon("", !isMainNet())) {
- Toast.makeText(getActivity(), getString(R.string.warn_daemon_unavailable), Toast.LENGTH_SHORT).show();
- return true;
- }
+ checkAndSetWalletDaemon("", !isMainNet()); // just set selected net
activityCallback.onWalletDetails(wallet);
return true;
}
});
-
- activityCallback.setTitle(getString(R.string.app_name) + " " +
- getString(isMainNet() ? R.string.connect_mainnet : R.string.connect_testnet));
-
loadList();
return view;
}
@@ -239,7 +250,6 @@ public class LoginFragment extends Fragment {
// Log.d(TAG, "filtering " + s);
if (x.indexOf(s.charAt(1)) >= 0) displayedList.add(s);
}
- displayedList.add(WALLETNAME_PREAMBLE + getString(R.string.generate_title));
}
private void loadList() {
@@ -261,7 +271,6 @@ public class LoginFragment extends Fragment {
}
-
boolean isMainNet() {
return tbMainNet.isChecked();
}
diff --git a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
index 5ccbbcf..af07d81 100644
--- a/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
+++ b/app/src/main/java/com/m2049r/xmrwallet/WalletActivity.java
@@ -35,7 +35,6 @@ 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;
@@ -46,7 +45,7 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
public static final String REQUEST_ID = "id";
public static final String REQUEST_PW = "pw";
- Toolbar tbWallet;
+ Toolbar toolbar;
private boolean synced = false;
@@ -115,10 +114,10 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
return;
}
- tbWallet = (Toolbar) findViewById(R.id.tbWallet);
- tbWallet.setTitle(R.string.app_name);
- setSupportActionBar(tbWallet);
- tbWallet.setOnClickListener(new View.OnClickListener() {
+ toolbar = (Toolbar) findViewById(R.id.tbWallet);
+ toolbar.setTitle(R.string.app_name);
+ setSupportActionBar(toolbar);
+ toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onWalletDetails();
@@ -268,12 +267,12 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
@Override
public void setTitle(String title) {
- tbWallet.setTitle(title);
+ toolbar.setTitle(title);
}
@Override
public void setSubtitle(String subtitle) {
- tbWallet.setSubtitle(subtitle);
+ toolbar.setSubtitle(subtitle);
}
@Override
diff --git a/app/src/main/res/layout/login_fragment.xml b/app/src/main/res/layout/login_fragment.xml
index bf23420..0578f5d 100644
--- a/app/src/main/res/layout/login_fragment.xml
+++ b/app/src/main/res/layout/login_fragment.xml
@@ -17,35 +17,49 @@
android:textOff="@string/connect_testnet"
android:textOn="@string/connect_mainnet"
app:layout_constraintRight_toRightOf="parent"
- app:layout_constraintTop_toTopOf="parent">
-
+ app:layout_constraintTop_toTopOf="parent">
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toLeftOf="@+id/tbMainNet" />
-
-
+ android:layout_height="match_parent">
+
+
+
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5e73960..10a0958 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -57,7 +57,7 @@
External Storage is not writable! Panic!
We really need those External Storage permissions!
- Generate Wallet
+ Create Wallet
Wallet Name
Wallet Password
Make me a wallet already!