mirror of
https://github.com/m2049r/xmrwallet
synced 2025-05-08 05:58:48 +02:00
Bugfixes based on ANR reports from google (#81)
* remove id in toolbar include (NPE on some devices) * deal with progress when activity closed
This commit is contained in:
parent
9aa8d10d9d
commit
af18a89a5e
app/src/main
java/com/m2049r/xmrwallet
res
@ -40,7 +40,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@ -78,6 +77,7 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.login_activity);
|
setContentView(R.layout.login_activity);
|
||||||
|
setContentView(R.layout.login_activity);
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -187,13 +187,10 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class AsyncRename extends AsyncTask<String, Void, Boolean> {
|
private class AsyncRename extends AsyncTask<String, Void, Boolean> {
|
||||||
ProgressDialog progressDialog = new MyProgressDialog(LoginActivity.this, R.string.rename_progress);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
progressDialog.show();
|
showProgressDialog(R.string.rename_progress);
|
||||||
LoginActivity.this.asyncWaitTask = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -207,13 +204,15 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
progressDialog.dismiss();
|
if (isDestroyed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dismissProgressDialog();
|
||||||
if (result) {
|
if (result) {
|
||||||
reloadWalletList();
|
reloadWalletList();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(LoginActivity.this, getString(R.string.rename_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this, getString(R.string.rename_failed), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
LoginActivity.this.asyncWaitTask = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -283,13 +282,10 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
|
|
||||||
|
|
||||||
private class AsyncBackup extends AsyncTask<String, Void, Boolean> {
|
private class AsyncBackup extends AsyncTask<String, Void, Boolean> {
|
||||||
ProgressDialog progressDialog = new MyProgressDialog(LoginActivity.this, R.string.backup_progress);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
progressDialog.show();
|
showProgressDialog(R.string.backup_progress);
|
||||||
LoginActivity.this.asyncWaitTask = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -301,11 +297,13 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
progressDialog.dismiss();
|
if (isDestroyed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dismissProgressDialog();
|
||||||
if (!result) {
|
if (!result) {
|
||||||
Toast.makeText(LoginActivity.this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this, getString(R.string.backup_failed), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
LoginActivity.this.asyncWaitTask = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,13 +333,10 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class AsyncArchive extends AsyncTask<String, Void, Boolean> {
|
private class AsyncArchive extends AsyncTask<String, Void, Boolean> {
|
||||||
ProgressDialog progressDialog = new MyProgressDialog(LoginActivity.this, R.string.archive_progress);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
progressDialog.show();
|
showProgressDialog(R.string.archive_progress);
|
||||||
LoginActivity.this.asyncWaitTask = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -358,13 +353,15 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
progressDialog.dismiss();
|
if (isDestroyed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dismissProgressDialog();
|
||||||
if (result) {
|
if (result) {
|
||||||
reloadWalletList();
|
reloadWalletList();
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(LoginActivity.this, getString(R.string.archive_failed), Toast.LENGTH_LONG).show();
|
Toast.makeText(LoginActivity.this, getString(R.string.archive_failed), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
LoginActivity.this.asyncWaitTask = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +527,26 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
AsyncTask asyncWaitTask = null; // TODO should this really be set from all AsyncTasks here?
|
ProgressDialog progressDialog = null;
|
||||||
|
|
||||||
|
private void showProgressDialog(int msgId) {
|
||||||
|
dismissProgressDialog(); // just in case
|
||||||
|
progressDialog = new MyProgressDialog(LoginActivity.this, msgId);
|
||||||
|
progressDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dismissProgressDialog() {
|
||||||
|
if (progressDialog != null && progressDialog.isShowing()) {
|
||||||
|
progressDialog.dismiss();
|
||||||
|
}
|
||||||
|
progressDialog = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
dismissProgressDialog();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
@ -538,7 +554,7 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
Log.d(TAG, "onResume()");
|
Log.d(TAG, "onResume()");
|
||||||
setTitle(getString(R.string.login_activity_name));
|
setTitle(getString(R.string.login_activity_name));
|
||||||
// wait for WalletService to finish
|
// wait for WalletService to finish
|
||||||
if (WalletService.Running && (asyncWaitTask == null)) {
|
if (WalletService.Running && (progressDialog == null)) {
|
||||||
// and show a progress dialog, but only if there isn't one already
|
// and show a progress dialog, but only if there isn't one already
|
||||||
new AsyncWaitForService().execute();
|
new AsyncWaitForService().execute();
|
||||||
}
|
}
|
||||||
@ -562,13 +578,10 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
|
|
||||||
|
|
||||||
private class AsyncWaitForService extends AsyncTask<Void, Void, Void> {
|
private class AsyncWaitForService extends AsyncTask<Void, Void, Void> {
|
||||||
ProgressDialog progressDialog = new MyProgressDialog(LoginActivity.this, R.string.service_progress);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
progressDialog.show();
|
showProgressDialog(R.string.service_progress);
|
||||||
LoginActivity.this.asyncWaitTask = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -586,12 +599,13 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
progressDialog.dismiss();
|
if (isDestroyed()) {
|
||||||
LoginActivity.this.asyncWaitTask = null;
|
return;
|
||||||
|
}
|
||||||
|
dismissProgressDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void startWallet(String walletName, String walletPassword) {
|
void startWallet(String walletName, String walletPassword) {
|
||||||
Log.d(TAG, "startWallet()");
|
Log.d(TAG, "startWallet()");
|
||||||
Intent intent = new Intent(getApplicationContext(), WalletActivity.class);
|
Intent intent = new Intent(getApplicationContext(), WalletActivity.class);
|
||||||
@ -707,6 +721,7 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
super.onPreExecute();
|
super.onPreExecute();
|
||||||
|
showProgressDialog(R.string.generate_wallet_creating);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -747,6 +762,10 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean result) {
|
protected void onPostExecute(Boolean result) {
|
||||||
super.onPostExecute(result);
|
super.onPostExecute(result);
|
||||||
|
if (isDestroyed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dismissProgressDialog();
|
||||||
if (result) {
|
if (result) {
|
||||||
startDetails(newWalletFile, walletPassword, GenerateReviewFragment.VIEW_TYPE_ACCEPT);
|
startDetails(newWalletFile, walletPassword, GenerateReviewFragment.VIEW_TYPE_ACCEPT);
|
||||||
} else {
|
} else {
|
||||||
@ -754,7 +773,6 @@ public class LoginActivity extends AppCompatActivity
|
|||||||
getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show();
|
getString(R.string.generate_wallet_create_failed), Toast.LENGTH_LONG).show();
|
||||||
walletGenerateError();
|
walletGenerateError();
|
||||||
}
|
}
|
||||||
LoginActivity.this.asyncWaitTask = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/toolbar"
|
|
||||||
layout="@layout/toolbar" />
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
<include
|
||||||
android:id="@+id/toolbar"
|
|
||||||
layout="@layout/toolbar" />
|
layout="@layout/toolbar" />
|
||||||
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
@ -97,6 +97,7 @@
|
|||||||
|
|
||||||
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
<string name="generate_wallet_exists">Wallet exists! Choose another name</string>
|
||||||
<string name="generate_wallet_dot">Wallet name may not begin with \'.\'</string>
|
<string name="generate_wallet_dot">Wallet name may not begin with \'.\'</string>
|
||||||
|
<string name="generate_wallet_creating">Creating wallet</string>
|
||||||
<string name="generate_wallet_created">Wallet created</string>
|
<string name="generate_wallet_created">Wallet created</string>
|
||||||
<string name="generate_wallet_create_failed">Wallet create failed</string>
|
<string name="generate_wallet_create_failed">Wallet create failed</string>
|
||||||
<string name="generate_wallet_create_failed_1">Wallet create failed (1/2)</string>
|
<string name="generate_wallet_create_failed_1">Wallet create failed (1/2)</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user