Remove most of old API
This commit is contained in:
@@ -17,13 +17,21 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.helper.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.helper.PgpMain;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
@@ -35,12 +43,8 @@ import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.LookupUnknownKeyDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
@@ -60,14 +64,11 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.regex.Matcher;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
/* Intents */
|
||||
@@ -75,16 +76,10 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT";
|
||||
public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
|
||||
|
||||
// with permission
|
||||
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "DECRYPT_AND_RETURN";
|
||||
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "DECRYPT_STREAM_AND_RETURN";
|
||||
|
||||
/* EXTRA keys for input */
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
public static final String EXTRA_DATA = "data";
|
||||
public static final String EXTRA_REPLY_TO = "replyTo";
|
||||
public static final String EXTRA_REPLY_TO = "reply_to";
|
||||
public static final String EXTRA_SUBJECT = "subject";
|
||||
public static final String EXTRA_BINARY = "binary";
|
||||
|
||||
@@ -248,11 +243,6 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// check permissions for intent actions without user interaction
|
||||
String[] restrictedActions = new String[] { ACTION_DECRYPT_AND_RETURN };
|
||||
OtherHelper.checkPackagePermissionForActions(this, this.getCallingPackage(),
|
||||
Constants.PERMISSION_ACCESS_API, getIntent().getAction(), restrictedActions);
|
||||
|
||||
setContentView(R.layout.decrypt);
|
||||
|
||||
// set actionbar without home button if called from another app
|
||||
@@ -456,38 +446,39 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
// end activity
|
||||
finish();
|
||||
}
|
||||
} else if (ACTION_DECRYPT_AND_RETURN.equals(action)) {
|
||||
mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
|
||||
|
||||
if (mContentUri == null) {
|
||||
mDataBytes = extras.getByteArray(EXTRA_DATA);
|
||||
String data = extras.getString(EXTRA_TEXT);
|
||||
if (data != null) {
|
||||
Matcher matcher = PgpMain.PGP_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
} else {
|
||||
matcher = PgpMain.PGP_SIGNED_MESSAGE.matcher(data);
|
||||
if (matcher.matches()) {
|
||||
data = matcher.group(1);
|
||||
// replace non breakable spaces
|
||||
data = data.replaceAll("\\xa0", " ");
|
||||
mMessage.setText(data);
|
||||
mDecryptString = getString(R.string.btn_verify);
|
||||
|
||||
// build new action bar
|
||||
invalidateOptionsMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mReturnResult = true;
|
||||
} else if (ACTION_DECRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||
// TODO: Implement decrypt stream
|
||||
}
|
||||
// } else if (ACTION_DECRYPT_AND_RETURN.equals(action)) {
|
||||
// mReturnBinary = extras.getBoolean(EXTRA_BINARY, false);
|
||||
//
|
||||
// if (mContentUri == null) {
|
||||
// mDataBytes = extras.getByteArray(EXTRA_DATA);
|
||||
// String data = extras.getString(EXTRA_TEXT);
|
||||
// if (data != null) {
|
||||
// Matcher matcher = PgpMain.PGP_MESSAGE.matcher(data);
|
||||
// if (matcher.matches()) {
|
||||
// data = matcher.group(1);
|
||||
// // replace non breakable spaces
|
||||
// data = data.replaceAll("\\xa0", " ");
|
||||
// mMessage.setText(data);
|
||||
// } else {
|
||||
// matcher = PgpMain.PGP_SIGNED_MESSAGE.matcher(data);
|
||||
// if (matcher.matches()) {
|
||||
// data = matcher.group(1);
|
||||
// // replace non breakable spaces
|
||||
// data = data.replaceAll("\\xa0", " ");
|
||||
// mMessage.setText(data);
|
||||
// mDecryptString = getString(R.string.btn_verify);
|
||||
//
|
||||
// // build new action bar
|
||||
// invalidateOptionsMenu();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// mReturnResult = true;
|
||||
// } else if (ACTION_DECRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||
// // TODO: Implement decrypt stream
|
||||
// }
|
||||
}
|
||||
|
||||
private void guessOutputFilename() {
|
||||
@@ -662,7 +653,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
try {
|
||||
try {
|
||||
if (inStream.markSupported()) {
|
||||
inStream.mark(200); //should probably set this to the max size of two pgpF objects, if it even needs to be anything other than 0.
|
||||
inStream.mark(200); // should probably set this to the max size of two pgpF
|
||||
// objects, if it even needs to be anything other than 0.
|
||||
}
|
||||
mSecretKeyId = PgpMain.getDecryptionKeyId(this, inStream);
|
||||
if (mSecretKeyId == Id.key.none) {
|
||||
@@ -781,7 +773,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mDataBytes);
|
||||
} else {
|
||||
String message = mMessage.getText().toString();
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
|
||||
data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES,
|
||||
message.getBytes());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -877,7 +870,8 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
|
||||
if (returnData.getBoolean(KeychainIntentService.RESULT_SIGNATURE_SUCCESS)) {
|
||||
mSignatureStatusImage.setImageResource(R.drawable.overlay_ok);
|
||||
} else if (returnData.getBoolean(KeychainIntentService.RESULT_SIGNATURE_UNKNOWN)) {
|
||||
} else if (returnData
|
||||
.getBoolean(KeychainIntentService.RESULT_SIGNATURE_UNKNOWN)) {
|
||||
mSignatureStatusImage.setImageResource(R.drawable.overlay_error);
|
||||
Toast.makeText(DecryptActivity.this,
|
||||
R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG)
|
||||
@@ -952,4 +946,3 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -65,20 +65,20 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
// possible intent actions for this activity
|
||||
public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEYRING";
|
||||
public static final String ACTION_EDIT_KEY = Constants.INTENT_PREFIX + "EDIT_KEYRING";
|
||||
// Actions for internal use only:
|
||||
public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEY";
|
||||
public static final String ACTION_EDIT_KEY = Constants.INTENT_PREFIX + "EDIT_KEY";
|
||||
|
||||
// possible extra keys
|
||||
public static final String EXTRA_USER_IDS = "userIds";
|
||||
public static final String EXTRA_NO_PASSPHRASE = "noPassphrase";
|
||||
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
||||
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
public static final String EXTRA_MASTER_CAN_SIGN = "masterCanSign";
|
||||
public static final String EXTRA_USER_IDS = "user_ids";
|
||||
public static final String EXTRA_NO_PASSPHRASE = "no_passphrase";
|
||||
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generate_default_keys";
|
||||
public static final String EXTRA_MASTER_KEY_ID = "master_key_id";
|
||||
public static final String EXTRA_MASTER_CAN_SIGN = "master_can_sign";
|
||||
|
||||
// results when saving key
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
public static final String RESULT_EXTRA_USER_ID = "userId";
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id";
|
||||
public static final String RESULT_EXTRA_USER_ID = "user_id";
|
||||
|
||||
private ActionBar mActionBar;
|
||||
|
||||
@@ -106,12 +106,6 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// TODO: disabled, old API!
|
||||
// check permissions for intent actions without user interaction
|
||||
// String[] restrictedActions = new String[] { ACTION_CREATE_KEY };
|
||||
// OtherHelper.checkPackagePermissionForActions(this, this.getCallingPackage(),
|
||||
// Constants.PERMISSION_ACCESS_API, getIntent().getAction(), restrictedActions);
|
||||
|
||||
// Inflate a "Done"/"Cancel" custom action bar view
|
||||
final LayoutInflater inflater = (LayoutInflater) getSupportActionBar().getThemedContext()
|
||||
.getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
@@ -30,7 +30,6 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
|
||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||
import org.sufficientlysecure.keychain.helper.FileHelper;
|
||||
import org.sufficientlysecure.keychain.helper.OtherHelper;
|
||||
import org.sufficientlysecure.keychain.helper.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.helper.PgpMain;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
@@ -77,29 +76,20 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
|
||||
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
|
||||
|
||||
// with permission
|
||||
public static final String ACTION_ENCRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "ENCRYPT_AND_RETURN";
|
||||
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "ENCRYPT_STREAM_AND_RETURN";
|
||||
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "GENERATE_SIGNATURE_AND_RETURN";
|
||||
|
||||
/* EXTRA keys for input */
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
public static final String EXTRA_DATA = "data";
|
||||
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
|
||||
public static final String EXTRA_SEND_TO = "sendTo";
|
||||
public static final String EXTRA_ASCII_ARMOUR = "ascii_armor";
|
||||
public static final String EXTRA_SEND_TO = "send_to";
|
||||
public static final String EXTRA_SUBJECT = "subject";
|
||||
public static final String EXTRA_SIGNATURE_KEY_ID = "signatureKeyId";
|
||||
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryptionKeyIds";
|
||||
public static final String EXTRA_SIGNATURE_KEY_ID = "signature_key_id";
|
||||
public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryption_key_ids";
|
||||
|
||||
private String mSubject = null;
|
||||
private String mSendTo = null;
|
||||
|
||||
private long mEncryptionKeyIds[] = null;
|
||||
|
||||
private boolean mEncryptImmediately = false;
|
||||
private EditText mMessage = null;
|
||||
private Button mSelectKeysButton = null;
|
||||
|
||||
@@ -197,12 +187,6 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// check permissions for intent actions without user interaction
|
||||
String[] restrictedActions = new String[] { ACTION_ENCRYPT_AND_RETURN,
|
||||
ACTION_GENERATE_SIGNATURE_AND_RETURN, ACTION_ENCRYPT_STREAM_AND_RETURN };
|
||||
OtherHelper.checkPackagePermissionForActions(this, this.getCallingPackage(),
|
||||
Constants.PERMISSION_ACCESS_API, getIntent().getAction(), restrictedActions);
|
||||
|
||||
setContentView(R.layout.encrypt);
|
||||
|
||||
// set actionbar without home button if called from another app
|
||||
@@ -217,26 +201,26 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
updateSource();
|
||||
updateMode();
|
||||
|
||||
if (mEncryptImmediately) {
|
||||
mSourcePrevious.setClickable(false);
|
||||
mSourcePrevious.setEnabled(false);
|
||||
mSourcePrevious.setVisibility(View.INVISIBLE);
|
||||
|
||||
mSourceNext.setClickable(false);
|
||||
mSourceNext.setEnabled(false);
|
||||
mSourceNext.setVisibility(View.INVISIBLE);
|
||||
|
||||
mSourceLabel.setClickable(false);
|
||||
mSourceLabel.setEnabled(false);
|
||||
}
|
||||
// if (mEncryptImmediately) {
|
||||
// mSourcePrevious.setClickable(false);
|
||||
// mSourcePrevious.setEnabled(false);
|
||||
// mSourcePrevious.setVisibility(View.INVISIBLE);
|
||||
//
|
||||
// mSourceNext.setClickable(false);
|
||||
// mSourceNext.setEnabled(false);
|
||||
// mSourceNext.setVisibility(View.INVISIBLE);
|
||||
//
|
||||
// mSourceLabel.setClickable(false);
|
||||
// mSourceLabel.setEnabled(false);
|
||||
// }
|
||||
|
||||
updateActionBarButtons();
|
||||
|
||||
if (mEncryptImmediately
|
||||
&& (mMessage.getText().length() > 0 || mData != null)
|
||||
&& ((mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) || mSecretKeyId != 0)) {
|
||||
encryptClicked();
|
||||
}
|
||||
// if (mEncryptImmediately
|
||||
// && (mMessage.getText().length() > 0 || mData != null)
|
||||
// && ((mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) || mSecretKeyId != 0)) {
|
||||
// encryptClicked();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -276,16 +260,16 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
}
|
||||
|
||||
if (ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
|| ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
mEncryptImmediately = true;
|
||||
}
|
||||
|
||||
if (ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
mGenerateSignature = true;
|
||||
mOverrideAsciiArmour = true;
|
||||
mAsciiArmorDemand = false;
|
||||
}
|
||||
// if (ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
// || ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
// mEncryptImmediately = true;
|
||||
// }
|
||||
//
|
||||
// if (ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
// mGenerateSignature = true;
|
||||
// mOverrideAsciiArmour = true;
|
||||
// mAsciiArmorDemand = false;
|
||||
// }
|
||||
|
||||
if (extras.containsKey(EXTRA_ASCII_ARMOUR)) {
|
||||
mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOUR, true);
|
||||
@@ -309,8 +293,9 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
/**
|
||||
* Main Actions
|
||||
*/
|
||||
if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
|| ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
// if (ACTION_ENCRYPT.equals(action) || ACTION_ENCRYPT_AND_RETURN.equals(action)
|
||||
// || ACTION_GENERATE_SIGNATURE_AND_RETURN.equals(action)) {
|
||||
if (ACTION_ENCRYPT.equals(action)) {
|
||||
if (textData != null) {
|
||||
mMessage.setText(textData);
|
||||
}
|
||||
@@ -340,10 +325,10 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
// end activity
|
||||
finish();
|
||||
}
|
||||
} else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||
// TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
|
||||
|
||||
mStreamAndReturnUri = uri;
|
||||
// } else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||
// // TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
|
||||
//
|
||||
// mStreamAndReturnUri = uri;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,31 +455,31 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
mSourceLabel.setText(R.string.label_message);
|
||||
|
||||
if (mMode.getCurrentView().getId() == R.id.modeSymmetric) {
|
||||
if (mEncryptImmediately) {
|
||||
setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
} else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
}
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
// }
|
||||
} else {
|
||||
if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) {
|
||||
if (mSecretKeyId == 0) {
|
||||
setActionbarButtons(false, 0, false, 0);
|
||||
} else {
|
||||
if (mEncryptImmediately) {
|
||||
setActionbarButtons(true, R.string.btn_sign, false, 0);
|
||||
} else {
|
||||
setActionbarButtons(true, R.string.btn_signAndEmail, true,
|
||||
R.string.btn_signToClipboard);
|
||||
}
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_sign, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_signAndEmail, true,
|
||||
R.string.btn_signToClipboard);
|
||||
// }
|
||||
}
|
||||
} else {
|
||||
if (mEncryptImmediately) {
|
||||
setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
} else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
}
|
||||
// if (mEncryptImmediately) {
|
||||
// setActionbarButtons(true, R.string.btn_encrypt, false, 0);
|
||||
// } else {
|
||||
setActionbarButtons(true, R.string.btn_encryptAndEmail, true,
|
||||
R.string.btn_encryptToClipboard);
|
||||
// }
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -726,7 +711,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, mData);
|
||||
} else {
|
||||
String message = mMessage.getText().toString();
|
||||
if (signOnly && !mEncryptImmediately) {
|
||||
// if (signOnly && !mEncryptImmediately) {
|
||||
if (signOnly) {
|
||||
fixBadCharactersForGmail(message);
|
||||
}
|
||||
data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());
|
||||
@@ -769,13 +755,13 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
||||
break;
|
||||
|
||||
case Id.target.email:
|
||||
if (mEncryptImmediately) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtras(data);
|
||||
setResult(RESULT_OK, intent);
|
||||
finish();
|
||||
return;
|
||||
}
|
||||
// if (mEncryptImmediately) {
|
||||
// Intent intent = new Intent();
|
||||
// intent.putExtras(data);
|
||||
// setResult(RESULT_OK, intent);
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
|
||||
output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING);
|
||||
Log.d(Constants.TAG, "output: " + output);
|
||||
|
||||
@@ -48,17 +48,20 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
||||
import com.google.zxing.integration.android.IntentResult;
|
||||
|
||||
public class ImportKeysActivity extends SherlockFragmentActivity {
|
||||
public static final String ACTION_IMPORT = Constants.INTENT_PREFIX + "IMPORT";
|
||||
public static final String ACTION_IMPORT_FROM_FILE = Constants.INTENT_PREFIX
|
||||
+ "IMPORT_FROM_FILE";
|
||||
public static final String ACTION_IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX
|
||||
+ "IMPORT_FROM_QR_CODE";
|
||||
public static final String ACTION_IMPORT_FROM_NFC = Constants.INTENT_PREFIX + "IMPORT_FROM_NFC";
|
||||
public static final String ACTION_KEY_IMPORT = Constants.INTENT_PREFIX + "KEY_IMPORT";
|
||||
public static final String ACTION_KEY_IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX
|
||||
+ "KEY_IMPORT_FROM_QR_CODE";
|
||||
|
||||
// Actions for internal use only:
|
||||
public static final String ACTION_KEY_IMPORT_FROM_FILE = Constants.INTENT_PREFIX
|
||||
+ "KEY_IMPORT_FROM_FILE";
|
||||
public static final String ACTION_KEY_IMPORT_FROM_NFC = Constants.INTENT_PREFIX
|
||||
+ "KEY_IMPORT_FROM_NFC";
|
||||
|
||||
// only used by IMPORT
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
public static final String EXTRA_KEYRING_BYTES = "keyringBytes";
|
||||
public static final String EXTRA_KEYRING_BYTES = "keyring_bytes";
|
||||
|
||||
// TODO: import keys from server
|
||||
// public static final String EXTRA_KEY_ID = "keyId";
|
||||
|
||||
protected String mImportFilename;
|
||||
@@ -140,35 +143,32 @@ public class ImportKeysActivity extends SherlockFragmentActivity {
|
||||
* Android Standard Actions
|
||||
*/
|
||||
if (Intent.ACTION_VIEW.equals(action)) {
|
||||
// Android's Action when opening file associated to APG (see AndroidManifest.xml)
|
||||
// override action to delegate it to APGs ACTION_IMPORT
|
||||
action = ACTION_IMPORT;
|
||||
// Android's Action when opening file associated to Keychain (see AndroidManifest.xml)
|
||||
// override action to delegate it to Keychains ACTION_IMPORT
|
||||
action = ACTION_KEY_IMPORT;
|
||||
}
|
||||
|
||||
/**
|
||||
* APG's own Actions
|
||||
*/
|
||||
if (ACTION_IMPORT.equals(action)) {
|
||||
if (ACTION_KEY_IMPORT.equals(action)) {
|
||||
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
|
||||
mImportFilename = intent.getData().getPath();
|
||||
mImportData = null;
|
||||
} else if (extras.containsKey(EXTRA_TEXT)) {
|
||||
mImportData = intent.getStringExtra(EXTRA_TEXT).getBytes();
|
||||
mImportFilename = null;
|
||||
} else if (extras.containsKey(EXTRA_KEYRING_BYTES)) {
|
||||
mImportData = intent.getByteArrayExtra(EXTRA_KEYRING_BYTES);
|
||||
mImportFilename = null;
|
||||
}
|
||||
loadKeyListFragment();
|
||||
} else if (ACTION_IMPORT_FROM_FILE.equals(action)) {
|
||||
} else if (ACTION_KEY_IMPORT_FROM_FILE.equals(action)) {
|
||||
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
|
||||
mImportFilename = intent.getData().getPath();
|
||||
mImportData = null;
|
||||
}
|
||||
showImportFromFileDialog();
|
||||
} else if (ACTION_IMPORT_FROM_QR_CODE.equals(action)) {
|
||||
} else if (ACTION_KEY_IMPORT_FROM_QR_CODE.equals(action)) {
|
||||
importFromQrCode();
|
||||
} else if (ACTION_IMPORT_FROM_NFC.equals(action)) {
|
||||
} else if (ACTION_KEY_IMPORT_FROM_NFC.equals(action)) {
|
||||
importFromNfc();
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public class ImportKeysActivity extends SherlockFragmentActivity {
|
||||
Bundle data = message.getData();
|
||||
mImportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME);
|
||||
mDeleteAfterImport = data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED);
|
||||
|
||||
|
||||
Log.d(Constants.TAG, "mImportFilename: " + mImportFilename);
|
||||
Log.d(Constants.TAG, "mDeleteAfterImport: " + mDeleteAfterImport);
|
||||
|
||||
@@ -325,7 +325,7 @@ public class ImportKeysActivity extends SherlockFragmentActivity {
|
||||
Bundle data = new Bundle();
|
||||
|
||||
// TODO: check for key type?
|
||||
// data.putInt(ApgIntentService.IMPORT_KEY_TYPE, Id.type.secret_key);
|
||||
// data.putInt(KeychainIntentService.IMPORT_KEY_TYPE, Id.type.secret_key);
|
||||
|
||||
if (mImportData != null) {
|
||||
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);
|
||||
@@ -349,7 +349,8 @@ public class ImportKeysActivity extends SherlockFragmentActivity {
|
||||
Bundle returnData = message.getData();
|
||||
|
||||
int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED);
|
||||
int updated = returnData.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED);
|
||||
int updated = returnData
|
||||
.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED);
|
||||
int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD);
|
||||
String toastMessage;
|
||||
if (added > 0 && updated > 0) {
|
||||
|
||||
@@ -154,7 +154,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
||||
|
||||
case Id.menu.option.import_from_file: {
|
||||
Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_IMPORT_FROM_FILE);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_KEY_IMPORT_FROM_FILE);
|
||||
startActivityForResult(intentImportFromFile, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class KeyListPublicActivity extends KeyListActivity {
|
||||
}
|
||||
case Id.menu.option.import_from_file: {
|
||||
Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_IMPORT_FROM_FILE);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_KEY_IMPORT_FROM_FILE);
|
||||
startActivityForResult(intentImportFromFile, 0);
|
||||
|
||||
return true;
|
||||
@@ -75,7 +75,7 @@ public class KeyListPublicActivity extends KeyListActivity {
|
||||
|
||||
case Id.menu.option.import_from_qr_code: {
|
||||
Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_IMPORT_FROM_QR_CODE);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_KEY_IMPORT_FROM_QR_CODE);
|
||||
startActivityForResult(intentImportFromFile, Id.request.import_from_qr_code);
|
||||
|
||||
return true;
|
||||
@@ -83,7 +83,7 @@ public class KeyListPublicActivity extends KeyListActivity {
|
||||
|
||||
case Id.menu.option.import_from_nfc: {
|
||||
Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_IMPORT_FROM_NFC);
|
||||
intentImportFromFile.setAction(ImportKeysActivity.ACTION_KEY_IMPORT_FROM_NFC);
|
||||
startActivityForResult(intentImportFromFile, 0);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -227,8 +227,8 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
if (mKeyData != null) {
|
||||
Intent intent = new Intent(KeyServerQueryActivity.this,
|
||||
ImportKeysActivity.class);
|
||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT);
|
||||
intent.putExtra(ImportKeysActivity.EXTRA_TEXT, mKeyData);
|
||||
intent.setAction(ImportKeysActivity.ACTION_KEY_IMPORT);
|
||||
intent.putExtra(ImportKeysActivity.EXTRA_KEYRING_BYTES, mKeyData.getBytes());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
|
||||
public class SelectPublicKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
// Not used in sourcode, but listed in AndroidManifest!
|
||||
// Actions for internal use only:
|
||||
public static final String ACTION_SELECT_PUBLIC_KEYS = Constants.INTENT_PREFIX
|
||||
+ "SELECT_PUBLIC_KEYRINGS";
|
||||
|
||||
public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "masterKeyIds";
|
||||
public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids";
|
||||
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_IDS = "masterKeyIds";
|
||||
public static final String RESULT_EXTRA_USER_IDS = "userIds";
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_IDS = "master_key_ids";
|
||||
public static final String RESULT_EXTRA_USER_IDS = "user_ids";
|
||||
|
||||
SelectPublicKeyFragment mSelectFragment;
|
||||
|
||||
|
||||
@@ -30,14 +30,14 @@ import android.os.Bundle;
|
||||
|
||||
public class SelectSecretKeyActivity extends SherlockFragmentActivity {
|
||||
|
||||
// Not used in sourcode, but listed in AndroidManifest!
|
||||
// Actions for internal use only:
|
||||
public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX
|
||||
+ "SELECT_SECRET_KEYRING";
|
||||
|
||||
public static final String EXTRA_FILTER_CERTIFY = "filter_certify";
|
||||
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
public static final String RESULT_EXTRA_USER_ID = "userId";
|
||||
public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id";
|
||||
public static final String RESULT_EXTRA_USER_ID = "user_id";
|
||||
|
||||
private boolean mFilterCertify = false;
|
||||
private SelectSecretKeyFragment mSelectFragment;
|
||||
|
||||
@@ -30,11 +30,12 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class ShareActivity extends SherlockFragmentActivity {
|
||||
// Actions for internal use only:
|
||||
public static final String ACTION_SHARE_KEYRING = Constants.INTENT_PREFIX + "SHARE_KEYRING";
|
||||
public static final String ACTION_SHARE_KEYRING_WITH_QR_CODE = Constants.INTENT_PREFIX
|
||||
+ "SHARE_KEYRING_WITH_QR_CODE";
|
||||
|
||||
public static final String EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||
public static final String EXTRA_MASTER_KEY_ID = "master_key_id";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ShareNfcBeamActivity extends SherlockFragmentActivity implements
|
||||
byte[] receivedKeyringBytes = msg.getRecords()[0].getPayload();
|
||||
|
||||
Intent importIntent = new Intent(this, ImportKeysActivity.class);
|
||||
importIntent.setAction(ImportKeysActivity.ACTION_IMPORT);
|
||||
importIntent.setAction(ImportKeysActivity.ACTION_KEY_IMPORT);
|
||||
importIntent.putExtra(ImportKeysActivity.EXTRA_KEYRING_BYTES, receivedKeyringBytes);
|
||||
|
||||
finish();
|
||||
|
||||
Reference in New Issue
Block a user