Skip to content

Commit

Permalink
Bugfixes (#126)
Browse files Browse the repository at this point in the history
* new domain

* InetSocketAddress.IllegalArgumentException

* white text for buttons

* tweak credit dialog

* prevent multiple popups
  • Loading branch information
m2049r authored Nov 11, 2017
1 parent 347123d commit 1875e2d
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 43 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
62 changes: 39 additions & 23 deletions app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
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;
Expand Down Expand Up @@ -1145,7 +1145,11 @@ boolean isValid() {
}
}

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;

Expand All @@ -1156,45 +1160,57 @@ protected void onPreExecute() {
}

@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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
final TextView tvAddress;
final ImageButton ibOptions;
WalletManager.WalletInfo infoItem;
boolean popupOpen = false;

ViewHolder(View itemView) {
super(itemView);
Expand All @@ -112,10 +113,12 @@ class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
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
Expand All @@ -128,6 +131,12 @@ public boolean onMenuItemClick(MenuItem item) {
});
//displaying the popup
popup.show();
popup.setOnDismissListener(new PopupMenu.OnDismissListener() {
@Override
public void onDismiss(PopupMenu menu) {
popupOpen = false;
}
});

}
});
Expand Down
5 changes: 0 additions & 5 deletions app/src/main/res/color/text_color.xml

This file was deleted.

12 changes: 6 additions & 6 deletions app/src/main/res/values/about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
5 changes: 1 addition & 4 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>

Expand Down

0 comments on commit 1875e2d

Please sign in to comment.