* new domain

* InetSocketAddress.IllegalArgumentException

* white text for buttons

* tweak credit dialog

* prevent multiple popups
This commit is contained in:
m2049r 2017-11-11 08:02:13 +01:00 committed by GitHub
parent 347123d961
commit 1875e2df62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 43 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "com.m2049r.xmrwallet"
minSdkVersion 21
targetSdkVersion 25
versionCode 44
versionName "1.2.3"
versionCode 45
versionName "1.2.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {

View File

@ -48,8 +48,8 @@ import android.widget.TextView;
import android.widget.Toast;
import com.m2049r.xmrwallet.dialog.AboutFragment;
import com.m2049r.xmrwallet.dialog.HelpFragment;
import com.m2049r.xmrwallet.dialog.DonationFragment;
import com.m2049r.xmrwallet.dialog.HelpFragment;
import com.m2049r.xmrwallet.dialog.PrivacyFragment;
import com.m2049r.xmrwallet.layout.Toolbar;
import com.m2049r.xmrwallet.model.Wallet;
@ -1145,7 +1145,11 @@ public class LoginActivity extends AppCompatActivity
}
}
private class AsyncOpenWallet extends AsyncTask<WalletNode, Void, Boolean> {
private class AsyncOpenWallet extends AsyncTask<WalletNode, Void, Integer> {
final static int OK = 0;
final static int TIMEOUT = 1;
final static int INVALID = 2;
final static int IOEX = 3;
WalletNode walletNode;
@ -1156,45 +1160,57 @@ public class LoginActivity extends AppCompatActivity
}
@Override
protected Boolean doInBackground(WalletNode... params) {
if (params.length != 1) return false;
protected Integer doInBackground(WalletNode... params) {
if (params.length != 1) return INVALID;
this.walletNode = params[0];
if (!walletNode.isValid()) return false;
if (!walletNode.isValid()) return INVALID;
Log.d(TAG, "checking " + walletNode.getAddress());
long timeDA = new Date().getTime();
SocketAddress address = new InetSocketAddress(walletNode.host, walletNode.port);
long timeDB = new Date().getTime();
Log.d(TAG, "Resolving " + walletNode.host + " took " + (timeDB - timeDA) + "ms.");
Socket socket = new Socket();
long timeA = new Date().getTime();
try {
long timeDA = new Date().getTime();
SocketAddress address = new InetSocketAddress(walletNode.host, walletNode.port);
long timeDB = new Date().getTime();
Log.d(TAG, "Resolving " + walletNode.host + " took " + (timeDB - timeDA) + "ms.");
Socket socket = new Socket();
long timeA = new Date().getTime();
socket.connect(address, LoginActivity.DAEMON_TIMEOUT);
socket.close();
long timeB = new Date().getTime();
long time = timeB - timeA;
Log.d(TAG, "Daemon " + walletNode.host + " is " + time + "ms away.");
return (time < LoginActivity.DAEMON_TIMEOUT ? OK : TIMEOUT);
} catch (IOException ex) {
Log.d(TAG, "Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage());
return false;
return IOEX;
} catch (IllegalArgumentException ex) {
Log.d(TAG, "Cannot reach daemon " + walletNode.host + "/" + walletNode.port + " because " + ex.getMessage());
return INVALID;
}
long timeB = new Date().getTime();
long time = timeB - timeA;
Log.d(TAG, "Daemon " + walletNode.host + " is " + time + "ms away.");
return time < LoginActivity.DAEMON_TIMEOUT;
}
@Override
protected void onPostExecute(Boolean result) {
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
if (isDestroyed()) {
return;
}
dismissProgressDialog();
if (result) {
Log.d(TAG, "selected wallet is ." + walletNode.name + ".");
// now it's getting real, check if wallet exists
promptAndStart(walletNode);
} else {
Toast.makeText(LoginActivity.this, getString(R.string.status_wallet_connect_timeout), Toast.LENGTH_LONG).show();
switch (result) {
case OK:
Log.d(TAG, "selected wallet is ." + walletNode.name + ".");
// now it's getting real, check if wallet exists
promptAndStart(walletNode);
break;
case TIMEOUT:
Toast.makeText(LoginActivity.this, getString(R.string.status_wallet_connect_timeout), Toast.LENGTH_LONG).show();
break;
case INVALID:
Toast.makeText(LoginActivity.this, getString(R.string.status_wallet_node_invalid), Toast.LENGTH_LONG).show();
break;
case IOEX:
Toast.makeText(LoginActivity.this, getString(R.string.status_wallet_connect_ioex), Toast.LENGTH_LONG).show();
break;
}
}
}

View File

@ -103,6 +103,7 @@ public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.Vi
final TextView tvAddress;
final ImageButton ibOptions;
WalletManager.WalletInfo infoItem;
boolean popupOpen = false;
ViewHolder(View itemView) {
super(itemView);
@ -112,10 +113,12 @@ public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.Vi
ibOptions.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (popupOpen) return;
//creating a popup menu
PopupMenu popup = new PopupMenu(context, ibOptions);
//inflating menu from xml resource
popup.inflate(R.menu.list_context_menu);
popupOpen = true;
//adding click listener
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
@ -128,6 +131,12 @@ public class WalletInfoAdapter extends RecyclerView.Adapter<WalletInfoAdapter.Vi
});
//displaying the popup
popup.show();
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu menu) {
popupOpen = false;
}
});
}
});

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/moneroText" android:state_enabled="false" />
<item android:color="@color/moneroWhite" />
</selector>

View File

@ -14,10 +14,10 @@
<string name="donation_credits"><![CDATA[
<b>Credits</b>
<br/>
m2049r, baltsar777, rehrar, anhdres,
keejef, TheMonera, EarlOfEgo
m2049r, baltsar777, anhdres, keejef,
rehrar, EarlOfEgo et al.
<br/><br/>
<a href="www.xmrujo.com">www.xmrujo.com</a>
<a href="https://monerujo.io/">monerujo.io</a>
]]></string>
<string name="privacy_policy"><![CDATA[
@ -53,14 +53,14 @@
<h2>Changes to this Privacy Policy</h2>
<p>We may update this privacy policy from time to time. We will notify
you of any changes by posting the new privacy policy in the app and on the
website (www.xmrujo.com)
website (www.monerujo.io)
You are advised to review this privacy policy periodically for any changes.
<p>This Privacy Policy was last updated: 2nd November, 2017.
<p>This Privacy Policy was last updated: 10th November, 2017.
</p>
<h2>Contact Us</h2>
<p>If you have any questions about our privacy policy,
or how your data is being collected and processed,
please e-mail privacy@xmrujo.com.
please e-mail privacy@monerujo.io.
</p>
]]></string>

View File

@ -14,7 +14,7 @@
<color name="give">#FFFF6105</color>
<color name="moneroOrange">#cc5100</color>
<color name="moneroWhite">#e2e2e2</color>
<color name="moneroWhite">#ffffff</color>
<color name="moneroBlack">#000000</color>
<color name="moneroGray">#FD9B9B9B</color>

View File

@ -45,8 +45,11 @@
<string name="status_wallet_unloaded">Wallet saved</string>
<string name="status_wallet_unload_failed">Wallet save failed!</string>
<string name="status_wallet_connecting">Connecting &#8230;</string>
<string name="status_wallet_connect_failed">Daemon connection failed!\nCheck username/password</string>
<string name="status_wallet_connect_timeout">Daemon connection timed out!\nTry again or another!</string>
<string name="status_wallet_connect_failed">Node connection failed!\nCheck username/password</string>
<string name="status_wallet_connect_timeout">Node connection timed out!\nTry again or another.</string>
<string name="status_wallet_node_invalid">Node invalid!\nTry another.</string>
<string name="status_wallet_connect_ioex">Cannot reach node!\nTry again or another.</string>
<string name="status_working">Working on it &#8230;</string>
<string name="status_wallet_disconnected">Disconnected</string>

View File

@ -179,7 +179,7 @@
<style name="MoneroButton" parent="@style/Widget.AppCompat.Button">
<item name="android:background">@drawable/button_selector</item>
<item name="android:textColor">@color/text_color</item>
<item name="android:textColor">@color/moneroWhite</item>
<item name="android:textAppearance">@style/MoneroLabel</item>
<item name="android:textAllCaps">true</item>
</style>
@ -194,16 +194,13 @@
</style>
<style name="MoneroButton.ReallySend">
<item name="android:textColor">@color/white</item>
</style>
<style name="MoneroButton.Take">
<item name="android:textColor">@color/white</item>
<item name="android:background">@color/take</item>
</style>
<style name="MoneroButton.Give">
<item name="android:textColor">@color/white</item>
<item name="android:background">@color/give</item>
</style>