mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Partial fix for #304
This commit is contained in:
parent
fa6ea57121
commit
5ddf001f9c
@ -17,22 +17,9 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.nfc.NdefMessage;
|
import android.nfc.NdefMessage;
|
||||||
@ -51,6 +38,18 @@ import android.widget.ArrayAdapter;
|
|||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.devspark.appmsg.AppMsg;
|
import com.devspark.appmsg.AppMsg;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
|
import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry;
|
||||||
|
import org.sufficientlysecure.keychain.ui.dialog.BadImportKeyDialogFragment;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNavigationListener {
|
public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNavigationListener {
|
||||||
public static final String ACTION_IMPORT_KEY = Constants.INTENT_PREFIX + "IMPORT_KEY";
|
public static final String ACTION_IMPORT_KEY = Constants.INTENT_PREFIX + "IMPORT_KEY";
|
||||||
public static final String ACTION_IMPORT_KEY_FROM_QR_CODE = Constants.INTENT_PREFIX
|
public static final String ACTION_IMPORT_KEY_FROM_QR_CODE = Constants.INTENT_PREFIX
|
||||||
@ -236,10 +235,10 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
* inside your Activity."
|
* inside your Activity."
|
||||||
* <p/>
|
* <p/>
|
||||||
* from http://stackoverflow.com/questions/10983396/fragment-oncreateview-and-onactivitycreated-called-twice/14295474#14295474
|
* from http://stackoverflow.com/questions/10983396/fragment-oncreateview-and-onactivitycreated-called-twice/14295474#14295474
|
||||||
*
|
* <p/>
|
||||||
* In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint,
|
* In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint,
|
||||||
* the fragment would be loaded twice resulting in the query being empty after the second load.
|
* the fragment would be loaded twice resulting in the query being empty after the second load.
|
||||||
*
|
* <p/>
|
||||||
* Our solution:
|
* Our solution:
|
||||||
* To prevent that a fragment will be loaded again even if it was already loaded loadNavFragment
|
* To prevent that a fragment will be loaded again even if it was already loaded loadNavFragment
|
||||||
* checks against mCurrentNavPostition.
|
* checks against mCurrentNavPostition.
|
||||||
@ -395,23 +394,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa
|
|||||||
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
AppMsg.makeText(ImportKeysActivity.this, toastMessage, AppMsg.STYLE_INFO)
|
||||||
.show();
|
.show();
|
||||||
if (bad > 0) {
|
if (bad > 0) {
|
||||||
AlertDialog.Builder alert = new AlertDialog.Builder(
|
BadImportKeyDialogFragment badImportKeyDialogFragment = BadImportKeyDialogFragment.newInstance(bad);
|
||||||
ImportKeysActivity.this);
|
badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog");
|
||||||
|
|
||||||
alert.setIcon(android.R.drawable.ic_dialog_alert);
|
|
||||||
alert.setTitle(R.string.warning);
|
|
||||||
|
|
||||||
alert.setMessage(ImportKeysActivity.this.getResources()
|
|
||||||
.getQuantityString(R.plurals.bad_keys_encountered, bad, bad));
|
|
||||||
|
|
||||||
alert.setPositiveButton(android.R.string.ok,
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
dialog.cancel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alert.setCancelable(true);
|
|
||||||
alert.create().show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,66 @@
|
|||||||
|
package org.sufficientlysecure.keychain.ui.dialog;
|
||||||
|
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Haven on 26/2/14.
|
||||||
|
*/
|
||||||
|
public class BadImportKeyDialogFragment extends DialogFragment {
|
||||||
|
private static final String ARG_BAD_IMPORT = "bad_import";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of this Bad Import Key DialogFragment
|
||||||
|
* @param bad
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static BadImportKeyDialogFragment newInstance(int bad) {
|
||||||
|
BadImportKeyDialogFragment frag = new BadImportKeyDialogFragment();
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
|
||||||
|
args.putInt(ARG_BAD_IMPORT, bad);
|
||||||
|
frag.setArguments(args);
|
||||||
|
|
||||||
|
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
final FragmentActivity activity = getActivity();
|
||||||
|
|
||||||
|
final int badImport = getArguments().getInt(ARG_BAD_IMPORT);
|
||||||
|
|
||||||
|
AlertDialog.Builder alert = new AlertDialog.Builder(activity);
|
||||||
|
|
||||||
|
alert.setIcon(R.drawable.ic_dialog_alert_holo_light);
|
||||||
|
alert.setTitle(R.string.warning);
|
||||||
|
|
||||||
|
alert.setMessage(activity.getResources()
|
||||||
|
.getQuantityString(R.plurals.bad_keys_encountered, badImport, badImport));
|
||||||
|
|
||||||
|
alert.setPositiveButton(android.R.string.ok,
|
||||||
|
new DialogInterface.OnClickListener() {
|
||||||
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
dialog.cancel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
alert.setCancelable(true);
|
||||||
|
|
||||||
|
|
||||||
|
return alert.create();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user