mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-04 08:15:02 -05:00
Use passphrase dialog activity instead of passphrase dialog
This commit is contained in:
parent
1099382250
commit
c1ef9ed149
@ -40,18 +40,17 @@ import android.widget.ListView;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||||
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
|
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.OperationResult.LogType;
|
|
||||||
import org.sufficientlysecure.keychain.operations.results.SingletonResult;
|
|
||||||
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
|
||||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.SubkeysAdapter;
|
||||||
@ -63,8 +62,8 @@ import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment;
|
|||||||
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.ActionBarHelper;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
@ -74,6 +73,8 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
public static final String ARG_SAVE_KEYRING_PARCEL = "save_keyring_parcel";
|
public static final String ARG_SAVE_KEYRING_PARCEL = "save_keyring_parcel";
|
||||||
|
|
||||||
|
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
||||||
|
|
||||||
private ListView mUserIdsList;
|
private ListView mUserIdsList;
|
||||||
private ListView mSubkeysList;
|
private ListView mSubkeysList;
|
||||||
private ListView mUserIdsAddedList;
|
private ListView mUserIdsAddedList;
|
||||||
@ -242,23 +243,9 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mCurrentPassphrase == null) {
|
if (mCurrentPassphrase == null) {
|
||||||
PassphraseDialogFragment.show(getActivity(), mSaveKeyringParcel.mMasterKeyId,
|
Intent intent = new Intent(getActivity(), PassphraseDialogActivity.class);
|
||||||
new Handler() {
|
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, mSaveKeyringParcel.mMasterKeyId);
|
||||||
@Override
|
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||||
public void handleMessage(Message message) {
|
|
||||||
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
|
||||||
mCurrentPassphrase = message.getData().getString(
|
|
||||||
PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE);
|
|
||||||
// Prepare the loaders. Either re-connect with an existing ones,
|
|
||||||
// or start new ones.
|
|
||||||
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this);
|
|
||||||
getLoaderManager().initLoader(LOADER_ID_SUBKEYS, null, EditKeyFragment.this);
|
|
||||||
} else {
|
|
||||||
EditKeyFragment.this.getActivity().finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
// Prepare the loaders. Either re-connect with an existing ones,
|
// Prepare the loaders. Either re-connect with an existing ones,
|
||||||
// or start new ones.
|
// or start new ones.
|
||||||
@ -280,6 +267,28 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CODE_PASSPHRASE: {
|
||||||
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
|
mCurrentPassphrase = data.getStringExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
|
||||||
|
// Prepare the loaders. Either re-connect with an existing ones,
|
||||||
|
// or start new ones.
|
||||||
|
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, EditKeyFragment.this);
|
||||||
|
getLoaderManager().initLoader(LOADER_ID_SUBKEYS, null, EditKeyFragment.this);
|
||||||
|
} else {
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
mChangePassphrase.setOnClickListener(new View.OnClickListener() {
|
mChangePassphrase.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
package org.sufficientlysecure.keychain.ui;
|
package org.sufficientlysecure.keychain.ui;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
@ -68,6 +69,8 @@ import java.util.ArrayList;
|
|||||||
public class MultiCertifyKeyFragment extends LoaderFragment
|
public class MultiCertifyKeyFragment extends LoaderFragment
|
||||||
implements LoaderManager.LoaderCallbacks<Cursor> {
|
implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
|
|
||||||
|
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
||||||
|
|
||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
|
|
||||||
private CheckBox mUploadKeyCheckbox;
|
private CheckBox mUploadKeyCheckbox;
|
||||||
@ -303,22 +306,33 @@ public class MultiCertifyKeyFragment extends LoaderFragment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (passphrase == null) {
|
if (passphrase == null) {
|
||||||
PassphraseDialogFragment.show(mActivity, mSignMasterKeyId,
|
Intent intent = new Intent(getActivity(), PassphraseDialogActivity.class);
|
||||||
new Handler() {
|
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, mSignMasterKeyId);
|
||||||
@Override
|
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||||
public void handleMessage(Message message) {
|
|
||||||
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
|
|
||||||
startCertifying();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
// bail out; need to wait until the user has entered the passphrase before trying again
|
// bail out; need to wait until the user has entered the passphrase before trying again
|
||||||
} else {
|
} else {
|
||||||
startCertifying();
|
startCertifying();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CODE_PASSPHRASE: {
|
||||||
|
if (resultCode == Activity.RESULT_OK && data != null) {
|
||||||
|
String passphrase = data.getStringExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
|
||||||
|
startCertifying();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* kicks off the actual signing process on a background thread
|
* kicks off the actual signing process on a background thread
|
||||||
*/
|
*/
|
||||||
|
@ -329,9 +329,17 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void certify(Uri dataUri) {
|
private void certify(Uri dataUri) {
|
||||||
Intent signIntent = new Intent(getActivity(), CertifyKeyActivity.class);
|
long keyId = 0;
|
||||||
signIntent.setData(dataUri);
|
try {
|
||||||
startActivityForResult(signIntent, 0);
|
keyId = new ProviderHelper(getActivity())
|
||||||
|
.getCachedPublicKeyRing(dataUri)
|
||||||
|
.extractOrGetMasterKeyId();
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Log.e(Constants.TAG, "key not found!", e);
|
||||||
|
}
|
||||||
|
Intent certifyIntent = new Intent(getActivity(), MultiCertifyKeyActivity.class);
|
||||||
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, new long[]{keyId});
|
||||||
|
startActivityForResult(certifyIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editKey(Uri dataUri) {
|
private void editKey(Uri dataUri) {
|
||||||
|
Loading…
Reference in New Issue
Block a user