mirror of https://github.com/m2049r/xmrwallet.git
make user wait for service to finish
This commit is contained in:
parent
5b38cc438c
commit
78c053f4e8
|
@ -40,6 +40,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.model.Wallet;
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
import com.m2049r.xmrwallet.service.WalletService;
|
||||||
import com.m2049r.xmrwallet.util.Helper;
|
import com.m2049r.xmrwallet.util.Helper;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -77,6 +78,10 @@ public class LoginActivity extends AppCompatActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWalletSelected(final String walletName) {
|
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 + ".");
|
Log.d(TAG, "selected wallet is ." + walletName + ".");
|
||||||
// now it's getting real, check if wallet exists
|
// now it's getting real, check if wallet exists
|
||||||
String walletPath = Helper.getWalletPath(this, walletName);
|
String walletPath = Helper.getWalletPath(this, walletName);
|
||||||
|
|
|
@ -19,10 +19,7 @@ package com.m2049r.xmrwallet.service;
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Binder;
|
import android.os.Binder;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
@ -30,13 +27,11 @@ import android.os.IBinder;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.os.Process;
|
import android.os.Process;
|
||||||
import android.support.v4.app.NotificationCompat;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.m2049r.xmrwallet.R;
|
import com.m2049r.xmrwallet.R;
|
||||||
import com.m2049r.xmrwallet.WalletActivity;
|
import com.m2049r.xmrwallet.WalletActivity;
|
||||||
import com.m2049r.xmrwallet.model.PendingTransaction;
|
import com.m2049r.xmrwallet.model.PendingTransaction;
|
||||||
import com.m2049r.xmrwallet.model.TransactionHistory;
|
|
||||||
import com.m2049r.xmrwallet.model.Wallet;
|
import com.m2049r.xmrwallet.model.Wallet;
|
||||||
import com.m2049r.xmrwallet.model.WalletListener;
|
import com.m2049r.xmrwallet.model.WalletListener;
|
||||||
import com.m2049r.xmrwallet.model.WalletManager;
|
import com.m2049r.xmrwallet.model.WalletManager;
|
||||||
|
@ -44,6 +39,8 @@ import com.m2049r.xmrwallet.util.Helper;
|
||||||
import com.m2049r.xmrwallet.util.TxData;
|
import com.m2049r.xmrwallet.util.TxData;
|
||||||
|
|
||||||
public class WalletService extends Service {
|
public class WalletService extends Service {
|
||||||
|
public static boolean Running = false;
|
||||||
|
|
||||||
final static String TAG = "WalletService";
|
final static String TAG = "WalletService";
|
||||||
final static int NOTIFICATION_ID = 2049;
|
final static int NOTIFICATION_ID = 2049;
|
||||||
|
|
||||||
|
@ -400,9 +397,6 @@ public class WalletService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
//mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
|
|
||||||
//showNotification();
|
|
||||||
|
|
||||||
// We are using a HandlerThread and a Looper to avoid loading and closing
|
// We are using a HandlerThread and a Looper to avoid loading and closing
|
||||||
// concurrency
|
// concurrency
|
||||||
MoneroHandlerThread thread = new MoneroHandlerThread("WalletService",
|
MoneroHandlerThread thread = new MoneroHandlerThread("WalletService",
|
||||||
|
@ -419,8 +413,6 @@ public class WalletService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
Log.d(TAG, "onDestroy()");
|
Log.d(TAG, "onDestroy()");
|
||||||
// Cancel the persistent notification.
|
|
||||||
//mNM.cancel(NOTIFICATION);
|
|
||||||
if (this.listener != null) {
|
if (this.listener != null) {
|
||||||
Log.w(TAG, "onDestroy() with active listener");
|
Log.w(TAG, "onDestroy() with active listener");
|
||||||
// no need to stop() here because the wallet closing should have been triggered
|
// no need to stop() here because the wallet closing should have been triggered
|
||||||
|
@ -438,7 +430,8 @@ public class WalletService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
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
|
// the service is possibly still occupied with saving the last opened wallet
|
||||||
// so we queue the open request
|
// so we queue the open request
|
||||||
// this should not matter since the old activity is not getting updates
|
// this should not matter since the old activity is not getting updates
|
||||||
|
@ -514,6 +507,7 @@ public class WalletService extends Service {
|
||||||
}
|
}
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
Running = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Wallet loadWallet(String walletName, String walletPassword) {
|
private Wallet loadWallet(String walletName, String walletPassword) {
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
<string name="status_transaction_failed">Transaction failed!</string>
|
<string name="status_transaction_failed">Transaction failed!</string>
|
||||||
<string name="status_transaction_prepare_failed">Could not create transaction!</string>
|
<string name="status_transaction_prepare_failed">Could not create transaction!</string>
|
||||||
|
|
||||||
|
<string name="service_busy">I am still busy with your last wallet …</string>
|
||||||
|
|
||||||
<string name="prompt_password">Password for</string>
|
<string name="prompt_password">Password for</string>
|
||||||
<string name="bad_password">Bad password!</string>
|
<string name="bad_password">Bad password!</string>
|
||||||
<string name="bad_wallet">Wallet does not exists!</string>
|
<string name="bad_wallet">Wallet does not exists!</string>
|
||||||
|
|
Loading…
Reference in New Issue