mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 11:35:07 -05:00
code cleanup
This commit is contained in:
parent
66cab704e7
commit
a507204b9e
@ -263,7 +263,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable,
|
||||
case Id.request.secret_keys: {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Bundle bundle = data.getExtras();
|
||||
setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.EXTRA_KEY_ID));
|
||||
setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.RESULT_EXTRA_KEY_ID));
|
||||
} else {
|
||||
setSecretKeyId(Id.key.none);
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.spongycastle.openpgp.PGPObjectFactory;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
|
@ -994,7 +994,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
initialKeyIds[i] = keyIds.get(i);
|
||||
}
|
||||
}
|
||||
intent.putExtra(SelectPublicKeyListActivity.EXTRA_SELECTION, initialKeyIds);
|
||||
intent.putExtra(SelectPublicKeyListActivity.RESULT_EXTRA_SELECTION, initialKeyIds);
|
||||
startActivityForResult(intent, Id.request.public_keys);
|
||||
}
|
||||
|
||||
@ -1038,7 +1038,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Bundle bundle = data.getExtras();
|
||||
mEncryptionKeyIds = bundle
|
||||
.getLongArray(SelectPublicKeyListActivity.EXTRA_SELECTION);
|
||||
.getLongArray(SelectPublicKeyListActivity.RESULT_EXTRA_SELECTION);
|
||||
}
|
||||
updateView();
|
||||
break;
|
||||
@ -1047,7 +1047,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
case Id.request.secret_keys: {
|
||||
if (resultCode == RESULT_OK) {
|
||||
Bundle bundle = data.getExtras();
|
||||
setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.EXTRA_KEY_ID));
|
||||
setSecretKeyId(bundle.getLong(SelectSecretKeyListActivity.RESULT_EXTRA_KEY_ID));
|
||||
} else {
|
||||
setSecretKeyId(Id.key.none);
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ package org.thialfihar.android.apg.ui;
|
||||
|
||||
import org.thialfihar.android.apg.Constants;
|
||||
import org.thialfihar.android.apg.Id;
|
||||
import org.thialfihar.android.apg.helper.OtherHelper;
|
||||
import org.thialfihar.android.apg.service.ApgServiceHandler;
|
||||
import org.thialfihar.android.apg.service.ApgService;
|
||||
import org.thialfihar.android.apg.R;
|
||||
@ -63,16 +64,7 @@ public class ImportFromQRCodeActivity extends SherlockFragmentActivity {
|
||||
mContentView = (TextView) findViewById(R.id.import_from_qr_code_content);
|
||||
|
||||
// set actionbar without home button if called from another app
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
|
||||
+ getCallingPackage());
|
||||
if (getCallingPackage() != null && getCallingPackage().equals(Constants.PACKAGE_NAME)) {
|
||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||
actionBar.setHomeButtonEnabled(true);
|
||||
} else {
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
}
|
||||
OtherHelper.setActionBarBackButton(this);
|
||||
|
||||
// start scanning
|
||||
new IntentIntegrator(this).initiateScan();
|
||||
|
@ -63,8 +63,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
|
||||
public static final String EXTRA_KEY_ID = "keyId";
|
||||
|
||||
// TODO: Change?
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
public static final String RESULT_EXTRA_TEXT = "text";
|
||||
|
||||
private ListView mList;
|
||||
private EditText mQuery;
|
||||
@ -134,8 +133,8 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (ACTION_LOOK_UP_KEY_ID.equals(intent.getAction())
|
||||
|| ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) {
|
||||
String action = intent.getAction();
|
||||
if (ACTION_LOOK_UP_KEY_ID.equals(action) || ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(action)) {
|
||||
long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0);
|
||||
if (keyId != 0) {
|
||||
String query = "0x" + PGPHelper.keyToHex(keyId);
|
||||
@ -215,7 +214,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
if (ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) {
|
||||
if (mKeyData != null) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_TEXT, mKeyData);
|
||||
intent.putExtra(RESULT_EXTRA_TEXT, mKeyData);
|
||||
setResult(RESULT_OK, intent);
|
||||
} else {
|
||||
setResult(RESULT_CANCELED);
|
||||
|
@ -66,10 +66,6 @@ public class PreferencesActivity extends SherlockPreferenceActivity {
|
||||
mPassPhraseCacheTtl.setValue(newValue.toString());
|
||||
mPassPhraseCacheTtl.setSummary(mPassPhraseCacheTtl.getEntry());
|
||||
mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString()));
|
||||
|
||||
// restart cache service with new ttl
|
||||
// TODO: not needed anymore!
|
||||
// PassphraseCacheService.startCacheService(PreferencesActivity.this);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
@ -176,7 +176,7 @@ public class PublicKeyListActivity extends KeyListActivity {
|
||||
switch (requestCode) {
|
||||
case Id.request.look_up_key_id: {
|
||||
if (resultCode == RESULT_CANCELED || data == null
|
||||
|| data.getStringExtra(KeyServerQueryActivity.EXTRA_TEXT) == null) {
|
||||
|| data.getStringExtra(KeyServerQueryActivity.RESULT_EXTRA_TEXT) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ public class SelectPublicKeyListActivity extends SherlockFragmentActivity {
|
||||
public static final String ACTION_SELECT_PUBLIC_KEYS = Constants.INTENT_PREFIX
|
||||
+ "SELECT_PUBLIC_KEYS";
|
||||
|
||||
public static final String EXTRA_SELECTION = "selection";
|
||||
public static final String EXTRA_USER_IDS = "userIds";
|
||||
public static final String RESULT_EXTRA_SELECTION = "selection";
|
||||
public static final String RESULT_EXTRA_USER_IDS = "userIds";
|
||||
|
||||
protected ListView mList;
|
||||
protected SelectPublicKeyListAdapter mListAdapter;
|
||||
@ -98,7 +98,7 @@ public class SelectPublicKeyListActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
|
||||
long selectedKeyIds[] = null;
|
||||
selectedKeyIds = intent.getLongArrayExtra(EXTRA_SELECTION);
|
||||
selectedKeyIds = intent.getLongArrayExtra(RESULT_EXTRA_SELECTION);
|
||||
|
||||
if (selectedKeyIds == null) {
|
||||
Vector<Long> vector = new Vector<Long>();
|
||||
@ -160,8 +160,8 @@ public class SelectPublicKeyListActivity extends SherlockFragmentActivity {
|
||||
selectedKeyIds[i] = keys.get(i);
|
||||
}
|
||||
String userIdArray[] = new String[0];
|
||||
data.putExtra(EXTRA_SELECTION, selectedKeyIds);
|
||||
data.putExtra(EXTRA_USER_IDS, userIds.toArray(userIdArray));
|
||||
data.putExtra(RESULT_EXTRA_SELECTION, selectedKeyIds);
|
||||
data.putExtra(RESULT_EXTRA_USER_IDS, userIds.toArray(userIdArray));
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ public class SelectSecretKeyListActivity extends SherlockFragmentActivity {
|
||||
public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX
|
||||
+ "SELECT_SECRET_KEY";
|
||||
|
||||
public static final String EXTRA_USER_ID = "userId";
|
||||
public static final String EXTRA_KEY_ID = "keyId";
|
||||
public static final String RESULT_EXTRA_USER_ID = "userId";
|
||||
public static final String RESULT_EXTRA_KEY_ID = "keyId";
|
||||
|
||||
protected ListView mList;
|
||||
protected SelectSecretKeyListAdapter mListAdapter;
|
||||
@ -71,8 +71,8 @@ public class SelectSecretKeyListActivity extends SherlockFragmentActivity {
|
||||
mList.setOnItemClickListener(new OnItemClickListener() {
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra(EXTRA_KEY_ID, id);
|
||||
data.putExtra(EXTRA_USER_ID, (String) mList.getItemAtPosition(position));
|
||||
data.putExtra(RESULT_EXTRA_KEY_ID, id);
|
||||
data.putExtra(RESULT_EXTRA_USER_ID, (String) mList.getItemAtPosition(position));
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
}
|
||||
|
@ -60,9 +60,6 @@ public class SignKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
public static final String EXTRA_KEY_ID = "keyId";
|
||||
|
||||
// TODO: remove when using new intentservice:
|
||||
public static final String EXTRA_ERROR = "error";
|
||||
|
||||
private long mPubKeyId = 0;
|
||||
private long mMasterKeyId = 0;
|
||||
|
||||
@ -185,33 +182,14 @@ public class SignKeyActivity extends SherlockFragmentActivity {
|
||||
startSigning();
|
||||
}
|
||||
} else {
|
||||
final Bundle status = new Bundle();
|
||||
// Message msg = new Message();
|
||||
Toast.makeText(this, "Key has already been signed", Toast.LENGTH_SHORT).show();
|
||||
|
||||
// status.putString(EXTRA_ERROR, "Key has already been signed");
|
||||
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
|
||||
// msg.setData(status);
|
||||
// sendMessage(msg);
|
||||
|
||||
setResult(Id.return_value.error);
|
||||
setResult(RESULT_CANCELED);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public long getSecretKeyId() {
|
||||
// return masterKeyId;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void passPhraseCallback(long keyId, String passPhrase) {
|
||||
// super.passPhraseCallback(keyId, passPhrase);
|
||||
// startSigning();
|
||||
// }
|
||||
|
||||
/**
|
||||
* kicks off the actual signing process on a background thread
|
||||
*/
|
||||
@ -311,97 +289,6 @@ public class SignKeyActivity extends SherlockFragmentActivity {
|
||||
startService(intent);
|
||||
}
|
||||
|
||||
// private void startSigning() {
|
||||
// showDialog(Id.dialog.signing);
|
||||
// startThread();
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void run() {
|
||||
// final Bundle status = new Bundle();
|
||||
// Message msg = new Message();
|
||||
//
|
||||
// try {
|
||||
// String passphrase = PGPMain.getCachedPassPhrase(masterKeyId);
|
||||
// if (passphrase == null || passphrase.length() <= 0) {
|
||||
// status.putString(EXTRA_ERROR, "Unable to obtain passphrase");
|
||||
// } else {
|
||||
// PGPPublicKeyRing pubring = PGPMain.getPublicKeyRing(pubKeyId);
|
||||
//
|
||||
// /*
|
||||
// * sign the incoming key
|
||||
// */
|
||||
// PGPSecretKey secretKey = PGPMain.getSecretKey(masterKeyId);
|
||||
// PGPPrivateKey signingKey = secretKey.extractPrivateKey(passphrase.toCharArray(),
|
||||
// BouncyCastleProvider.PROVIDER_NAME);
|
||||
// PGPSignatureGenerator sGen = new PGPSignatureGenerator(secretKey.getPublicKey()
|
||||
// .getAlgorithm(), PGPUtil.SHA256, BouncyCastleProvider.PROVIDER_NAME);
|
||||
// sGen.initSign(PGPSignature.DIRECT_KEY, signingKey);
|
||||
//
|
||||
// PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator();
|
||||
//
|
||||
// PGPSignatureSubpacketVector packetVector = spGen.generate();
|
||||
// sGen.setHashedSubpackets(packetVector);
|
||||
//
|
||||
// PGPPublicKey signedKey = PGPPublicKey.addCertification(
|
||||
// pubring.getPublicKey(pubKeyId), sGen.generate());
|
||||
// pubring = PGPPublicKeyRing.insertPublicKey(pubring, signedKey);
|
||||
//
|
||||
// // check if we need to send the key to the server or not
|
||||
// CheckBox sendKey = (CheckBox) findViewById(R.id.sendKey);
|
||||
// if (sendKey.isChecked()) {
|
||||
// Spinner keyServer = (Spinner) findViewById(R.id.keyServer);
|
||||
// HkpKeyServer server = new HkpKeyServer((String) keyServer.getSelectedItem());
|
||||
//
|
||||
// /*
|
||||
// * upload the newly signed key to the key server
|
||||
// */
|
||||
//
|
||||
// PGPMain.uploadKeyRingToServer(server, pubring);
|
||||
// }
|
||||
//
|
||||
// // store the signed key in our local cache
|
||||
// int retval = PGPMain.storeKeyRingInCache(pubring);
|
||||
// if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
|
||||
// status.putString(EXTRA_ERROR, "Failed to store signed key in local cache");
|
||||
// }
|
||||
// }
|
||||
// } catch (PGPException e) {
|
||||
// Log.e(Constants.TAG, "Failed to sign key", e);
|
||||
// status.putString(EXTRA_ERROR, "Failed to sign key");
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
// return;
|
||||
// } catch (NoSuchAlgorithmException e) {
|
||||
// Log.e(Constants.TAG, "Failed to sign key", e);
|
||||
// status.putString(EXTRA_ERROR, "Failed to sign key");
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
// return;
|
||||
// } catch (NoSuchProviderException e) {
|
||||
// Log.e(Constants.TAG, "Failed to sign key", e);
|
||||
// status.putString(EXTRA_ERROR, "Failed to sign key");
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
// return;
|
||||
// } catch (SignatureException e) {
|
||||
// Log.e(Constants.TAG, "Failed to sign key", e);
|
||||
// status.putString(EXTRA_ERROR, "Failed to sign key");
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||
//
|
||||
// msg.setData(status);
|
||||
// sendMessage(msg);
|
||||
//
|
||||
// if (status.containsKey(EXTRA_ERROR)) {
|
||||
// setResult(Id.return_value.error);
|
||||
// } else {
|
||||
// setResult(Id.return_value.ok);
|
||||
// }
|
||||
//
|
||||
// finish();
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
|
Loading…
Reference in New Issue
Block a user