Merge pull request #35 from m2049r/feature_info_alert

Alert before showing wallet details
This commit is contained in:
m2049r 2017-09-03 09:44:37 +02:00 committed by GitHub
commit 89ada5b294
3 changed files with 59 additions and 14 deletions

View File

@ -99,19 +99,40 @@ public class LoginActivity extends AppCompatActivity
}
@Override
public void onWalletDetails(String walletName) {
public void onWalletDetails(final String walletName) {
Log.d(TAG, "details for wallet ." + walletName + ".");
final File walletFile = Helper.getWalletFile(this, walletName);
if (WalletManager.getInstance().walletExists(walletFile)) {
promptPassword(walletName, new PasswordAction() {
@Override
public void action(String walletName, String password) {
startDetails(walletFile, password, GenerateReviewFragment.VIEW_DETAILS);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
final File walletFile = Helper.getWalletFile(LoginActivity.this, walletName);
if (WalletManager.getInstance().walletExists(walletFile)) {
promptPassword(walletName, new PasswordAction() {
@Override
public void action(String walletName, String password) {
startDetails(walletFile, password, GenerateReviewFragment.VIEW_DETAILS);
}
});
} else { // this cannot really happen as we prefilter choices
Log.e(TAG, "Wallet missing: " + walletName);
Toast.makeText(LoginActivity.this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
}
break;
case DialogInterface.BUTTON_NEGATIVE:
// do nothing
break;
}
});
} else { // this cannot really happen as we prefilter choices
Toast.makeText(this, getString(R.string.bad_wallet), Toast.LENGTH_SHORT).show();
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.details_alert_message))
.setPositiveButton(getString(R.string.details_alert_yes), dialogClickListener)
.setNegativeButton(getString(R.string.details_alert_no), dialogClickListener)
.show();
}
@Override

View File

@ -16,8 +16,10 @@
package com.m2049r.xmrwallet;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
@ -585,9 +587,27 @@ public class WalletActivity extends AppCompatActivity implements WalletFragment.
}
private void onWalletDetails() {
Bundle extras = new Bundle();
extras.putString("type", GenerateReviewFragment.VIEW_WALLET);
replaceFragment(new GenerateReviewFragment(), null, extras);
DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_POSITIVE:
Bundle extras = new Bundle();
extras.putString("type", GenerateReviewFragment.VIEW_WALLET);
replaceFragment(new GenerateReviewFragment(), null, extras);
break;
case DialogInterface.BUTTON_NEGATIVE:
// do nothing
break;
}
}
};
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(getString(R.string.details_alert_message))
.setPositiveButton(getString(R.string.details_alert_yes), dialogClickListener)
.setNegativeButton(getString(R.string.details_alert_no), dialogClickListener)
.show();
}
@Override

View File

@ -159,6 +159,10 @@
<string name="receive_amount_label">Amount</string>
<string name="receive_amount_hint">(optional)</string>
<string name="details_alert_message">Sensitive data will now be shown.\nLook over your shoulder!</string>
<string name="details_alert_yes">I\'m safe</string>
<string name="details_alert_no">Take me back!</string>
<string name="big_amount">999999.999999999999</string>
<string-array name="mixin">