allow back only if not accepting (#54)

This commit is contained in:
m2049r 2017-09-10 10:40:13 +02:00 committed by GitHub
parent eb2b3b5675
commit 924c3fa260
2 changed files with 21 additions and 5 deletions

View File

@ -79,12 +79,14 @@ public class GenerateReviewFragment extends Fragment {
Bundle args = getArguments();
String path = args.getString("path");
String password = args.getString("password");
String type = args.getString("type");
this.type = args.getString("type");
new AsyncShow().executeOnExecutor(MoneroThreadPoolExecutor.MONERO_THREAD_POOL_EXECUTOR,
path, password, type);
path, password);
return view;
}
String type;
private void acceptWallet() {
String name = tvWalletName.getText().toString();
String password = tvWalletPassword.getText().toString();
@ -93,7 +95,6 @@ public class GenerateReviewFragment extends Fragment {
}
private class AsyncShow extends AsyncTask<String, Void, Boolean> {
String type;
String password;
String name;
@ -106,10 +107,9 @@ public class GenerateReviewFragment extends Fragment {
@Override
protected Boolean doInBackground(String... params) {
if (params.length != 3) return false;
if (params.length != 2) return false;
String walletPath = params[0];
password = params[1];
type = params[2];
Wallet wallet;
boolean closeWallet;
@ -195,4 +195,8 @@ public class GenerateReviewFragment extends Fragment {
public void hideProgress() {
pbProgress.setVisibility(View.INVISIBLE);
}
boolean backOk() {
return !type.equals(GenerateReviewFragment.VIEW_TYPE_ACCEPT);
}
}

View File

@ -905,4 +905,16 @@ public class LoginActivity extends AppCompatActivity
outChannel.close();
}
}
@Override
public void onBackPressed() {
Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
if (f instanceof GenerateReviewFragment) {
if (((GenerateReviewFragment) f).backOk()) {
super.onBackPressed();
}
} else {
super.onBackPressed();
}
}
}