diff --git a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java index 996d3517..83b77e61 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java +++ b/app/src/main/java/com/m2049r/xmrwallet/LoginActivity.java @@ -40,6 +40,7 @@ import android.widget.Toast; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.WalletManager; +import com.m2049r.xmrwallet.service.WalletService; import com.m2049r.xmrwallet.util.Helper; import java.io.File; @@ -77,6 +78,10 @@ public class LoginActivity extends AppCompatActivity @Override public void onWalletSelected(final String walletName) { + if (WalletService.Running) { + Toast.makeText(this, getString(R.string.service_busy), Toast.LENGTH_SHORT).show(); + return; + } Log.d(TAG, "selected wallet is ." + walletName + "."); // now it's getting real, check if wallet exists String walletPath = Helper.getWalletPath(this, walletName); diff --git a/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java b/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java index 374c83c0..58836041 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java +++ b/app/src/main/java/com/m2049r/xmrwallet/service/WalletService.java @@ -19,10 +19,7 @@ package com.m2049r.xmrwallet.service; import android.app.Notification; import android.app.PendingIntent; import android.app.Service; -import android.content.Context; import android.content.Intent; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; import android.os.Binder; import android.os.Bundle; import android.os.Handler; @@ -30,13 +27,11 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Process; -import android.support.v4.app.NotificationCompat; import android.util.Log; import com.m2049r.xmrwallet.R; import com.m2049r.xmrwallet.WalletActivity; import com.m2049r.xmrwallet.model.PendingTransaction; -import com.m2049r.xmrwallet.model.TransactionHistory; import com.m2049r.xmrwallet.model.Wallet; import com.m2049r.xmrwallet.model.WalletListener; import com.m2049r.xmrwallet.model.WalletManager; @@ -44,6 +39,8 @@ import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.TxData; public class WalletService extends Service { + public static boolean Running = false; + final static String TAG = "WalletService"; final static int NOTIFICATION_ID = 2049; @@ -400,9 +397,6 @@ public class WalletService extends Service { @Override public void onCreate() { - //mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - //showNotification(); - // We are using a HandlerThread and a Looper to avoid loading and closing // concurrency MoneroHandlerThread thread = new MoneroHandlerThread("WalletService", @@ -419,8 +413,6 @@ public class WalletService extends Service { @Override public void onDestroy() { Log.d(TAG, "onDestroy()"); - // Cancel the persistent notification. - //mNM.cancel(NOTIFICATION); if (this.listener != null) { Log.w(TAG, "onDestroy() with active listener"); // no need to stop() here because the wallet closing should have been triggered @@ -438,7 +430,8 @@ public class WalletService extends Service { @Override public int onStartCommand(Intent intent, int flags, int startId) { - // when the activity satrts the service, it expects to start it for a new wallet + Running = true; + // when the activity starts the service, it expects to start it for a new wallet // the service is possibly still occupied with saving the last opened wallet // so we queue the open request // this should not matter since the old activity is not getting updates @@ -514,6 +507,7 @@ public class WalletService extends Service { } stopForeground(true); stopSelf(); + Running = false; } private Wallet loadWallet(String walletName, String walletPassword) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c1553fe2..cdb93b5c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -22,6 +22,8 @@ Transaction failed! Could not create transaction! + I am still busy with your last wallet … + Password for Bad password! Wallet does not exists!