API changes
@ -22,36 +22,36 @@ import java.util.Arrays;
|
|||||||
|
|
||||||
public class ApgData implements Serializable {
|
public class ApgData implements Serializable {
|
||||||
private static final long serialVersionUID = 6314045536270848410L;
|
private static final long serialVersionUID = 6314045536270848410L;
|
||||||
protected long mEncryptionKeyIds[] = null;
|
protected long mPublicKeyIds[] = null;
|
||||||
protected long mSignatureKeyId = 0;
|
protected long mSecretKeyId = 0;
|
||||||
protected String mSignatureUserId = null;
|
protected String mSecretKeyUserId = null;
|
||||||
protected boolean mSignatureSuccess = false;
|
protected boolean mSignatureSuccess = false;
|
||||||
protected boolean mSignatureUnknown = false;
|
protected boolean mSignatureUnknown = false;
|
||||||
protected String mDecryptedData = null;
|
protected String mDecryptedData = null;
|
||||||
protected String mEncryptedData = null;
|
protected String mEncryptedData = null;
|
||||||
|
|
||||||
public void setSignatureKeyId(long keyId) {
|
public void setSecretKeyId(long keyId) {
|
||||||
mSignatureKeyId = keyId;
|
mSecretKeyId = keyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSignatureKeyId() {
|
public long getSecretKeyId() {
|
||||||
return mSignatureKeyId;
|
return mSecretKeyId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEncryptionKeys(long keyIds[]) {
|
public void setPublicKeys(long keyIds[]) {
|
||||||
mEncryptionKeyIds = keyIds;
|
mPublicKeyIds = keyIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long[] getEncryptionKeys() {
|
public long[] getPublicKeys() {
|
||||||
return mEncryptionKeyIds;
|
return mPublicKeyIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasSignatureKey() {
|
public boolean hasSecretKey() {
|
||||||
return mSignatureKeyId != 0;
|
return mSecretKeyId != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEncryptionKeys() {
|
public boolean hasPublicKeys() {
|
||||||
return (mEncryptionKeyIds != null) && (mEncryptionKeyIds.length > 0);
|
return (mPublicKeyIds != null) && (mPublicKeyIds.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEncryptedData() {
|
public String getEncryptedData() {
|
||||||
@ -70,12 +70,12 @@ public class ApgData implements Serializable {
|
|||||||
mDecryptedData = data;
|
mDecryptedData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSignatureUserId(String userId) {
|
public void setSecretKeyUserId(String userId) {
|
||||||
mSignatureUserId = userId;
|
mSecretKeyUserId = userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSignatureUserId() {
|
public String getSecretKeyUserId() {
|
||||||
return mSignatureUserId;
|
return mSecretKeyUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getSignatureSuccess() {
|
public boolean getSignatureSuccess() {
|
||||||
@ -96,11 +96,11 @@ public class ApgData implements Serializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
String output = "mEncryptionKeyIds: " + Arrays.toString(mEncryptionKeyIds)
|
String output = "mPublicKeyIds: " + Arrays.toString(mPublicKeyIds) + "\nmSecretKeyId: "
|
||||||
+ "\nmSignatureKeyId: " + mSignatureKeyId + "\nmSignatureUserId: "
|
+ mSecretKeyId + "\nmSecretKeyUserId: " + mSecretKeyUserId
|
||||||
+ mSignatureUserId + "\nmSignatureSuccess: " + mSignatureSuccess
|
+ "\nmSignatureSuccess: " + mSignatureSuccess + "\nmSignatureUnknown: "
|
||||||
+ "\nmSignatureUnknown: " + mSignatureUnknown + "\nmDecryptedData: "
|
+ mSignatureUnknown + "\nmDecryptedData: " + mDecryptedData + "\nmEncryptedData: "
|
||||||
+ mDecryptedData + "\nmEncryptedData: " + mEncryptedData;
|
+ mEncryptedData;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,32 @@ public class ApgIntentHelper {
|
|||||||
public static final String APG_INTENT_PREFIX = "org.thialfihar.android.apg.intent.";
|
public static final String APG_INTENT_PREFIX = "org.thialfihar.android.apg.intent.";
|
||||||
|
|
||||||
// Intents
|
// Intents
|
||||||
public static final String ACTION_DECRYPT = APG_INTENT_PREFIX + "DECRYPT";
|
/**
|
||||||
|
* Encrypt
|
||||||
|
*/
|
||||||
|
// without permission
|
||||||
public static final String ACTION_ENCRYPT = APG_INTENT_PREFIX + "ENCRYPT";
|
public static final String ACTION_ENCRYPT = APG_INTENT_PREFIX + "ENCRYPT";
|
||||||
public static final String ACTION_DECRYPT_FILE = APG_INTENT_PREFIX + "DECRYPT_FILE";
|
|
||||||
public static final String ACTION_ENCRYPT_FILE = APG_INTENT_PREFIX + "ENCRYPT_FILE";
|
public static final String ACTION_ENCRYPT_FILE = APG_INTENT_PREFIX + "ENCRYPT_FILE";
|
||||||
public static final String ACTION_DECRYPT_AND_RETURN = APG_INTENT_PREFIX + "DECRYPT_AND_RETURN";
|
|
||||||
|
// with permission
|
||||||
public static final String ACTION_ENCRYPT_AND_RETURN = APG_INTENT_PREFIX + "ENCRYPT_AND_RETURN";
|
public static final String ACTION_ENCRYPT_AND_RETURN = APG_INTENT_PREFIX + "ENCRYPT_AND_RETURN";
|
||||||
|
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = APG_INTENT_PREFIX
|
||||||
|
+ "GENERATE_SIGNATURE_AND_RETURN";
|
||||||
|
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
|
||||||
|
+ "ENCRYPT_STREAM_AND_RETURN";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decrypt
|
||||||
|
*/
|
||||||
|
// without permission
|
||||||
|
public static final String ACTION_DECRYPT = APG_INTENT_PREFIX + "DECRYPT";
|
||||||
|
public static final String ACTION_DECRYPT_FILE = APG_INTENT_PREFIX + "DECRYPT_FILE";
|
||||||
|
|
||||||
|
// with permission
|
||||||
|
public static final String ACTION_DECRYPT_AND_RETURN = APG_INTENT_PREFIX + "DECRYPT_AND_RETURN";
|
||||||
|
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = APG_INTENT_PREFIX
|
||||||
|
+ "DECRYPT_STREAM_AND_RETURN";
|
||||||
|
|
||||||
public static final String ACTION_SELECT_PUBLIC_KEYS = APG_INTENT_PREFIX + "SELECT_PUBLIC_KEYS";
|
public static final String ACTION_SELECT_PUBLIC_KEYS = APG_INTENT_PREFIX + "SELECT_PUBLIC_KEYS";
|
||||||
public static final String ACTION_SELECT_SECRET_KEY = APG_INTENT_PREFIX + "SELECT_SECRET_KEY";
|
public static final String ACTION_SELECT_SECRET_KEY = APG_INTENT_PREFIX + "SELECT_SECRET_KEY";
|
||||||
public static final String ACTION_CREATE_KEY = APG_INTENT_PREFIX + "CREATE_KEY";
|
public static final String ACTION_CREATE_KEY = APG_INTENT_PREFIX + "CREATE_KEY";
|
||||||
@ -60,15 +80,19 @@ public class ApgIntentHelper {
|
|||||||
|
|
||||||
public static final String RESULT_EXTRA_MASTER_KEY_IDS = "masterKeyIds";
|
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_USER_IDS = "userIds";
|
||||||
|
|
||||||
|
// result from EditKey
|
||||||
|
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||||
|
public static final String RESULT_EXTRA_USER_ID = "userId";
|
||||||
|
|
||||||
public static final String INTENT_VERSION = "1";
|
public static final String INTENT_VERSION = "1";
|
||||||
|
|
||||||
public static final int DECRYPT_MESSAGE = 0x21070001;
|
public static final int DECRYPT_MESSAGE = 0x00007121;
|
||||||
public static final int ENCRYPT_MESSAGE = 0x21070002;
|
public static final int ENCRYPT_MESSAGE = 0x00007122;
|
||||||
public static final int SELECT_PUBLIC_KEYS = 0x21070003;
|
public static final int SELECT_PUBLIC_KEYS = 0x00007123;
|
||||||
public static final int SELECT_SECRET_KEY = 0x21070004;
|
public static final int SELECT_SECRET_KEY = 0x00007124;
|
||||||
public static final int CREATE_KEY = 0x21070005;
|
public static final int CREATE_KEY = 0x00007125;
|
||||||
public static final int EDIT_KEY = 0x21070006;
|
public static final int EDIT_KEY = 0x00007126;
|
||||||
|
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
|
||||||
@ -221,44 +245,53 @@ public class ApgIntentHelper {
|
|||||||
public boolean onActivityResult(int requestCode, int resultCode, Intent data, ApgData apgData) {
|
public boolean onActivityResult(int requestCode, int resultCode, Intent data, ApgData apgData) {
|
||||||
|
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
|
case CREATE_KEY:
|
||||||
|
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||||
|
// user canceled!
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
apgData.setSecretKeyId(data.getLongExtra(RESULT_EXTRA_MASTER_KEY_ID, 0));
|
||||||
|
apgData.setSecretKeyUserId(data.getStringExtra(RESULT_EXTRA_USER_ID));
|
||||||
|
|
||||||
|
break;
|
||||||
case SELECT_SECRET_KEY:
|
case SELECT_SECRET_KEY:
|
||||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||||
// user canceled!
|
// user canceled!
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apgData.setSignatureKeyId(data.getLongExtra(EXTRA_KEY_ID, 0));
|
apgData.setSecretKeyId(data.getLongExtra(EXTRA_KEY_ID, 0));
|
||||||
apgData.setSignatureUserId(data.getStringExtra(EXTRA_USER_ID));
|
apgData.setSecretKeyUserId(data.getStringExtra(EXTRA_USER_ID));
|
||||||
break;
|
|
||||||
|
|
||||||
|
break;
|
||||||
case SELECT_PUBLIC_KEYS:
|
case SELECT_PUBLIC_KEYS:
|
||||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||||
apgData.setEncryptionKeys(null);
|
apgData.setPublicKeys(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apgData.setEncryptionKeys(data.getLongArrayExtra(RESULT_EXTRA_MASTER_KEY_IDS));
|
apgData.setPublicKeys(data.getLongArrayExtra(RESULT_EXTRA_MASTER_KEY_IDS));
|
||||||
break;
|
|
||||||
|
|
||||||
|
break;
|
||||||
case ENCRYPT_MESSAGE:
|
case ENCRYPT_MESSAGE:
|
||||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||||
apgData.setEncryptionKeys(null);
|
apgData.setPublicKeys(null);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
apgData.setEncryptedData(data.getStringExtra(EXTRA_ENCRYPTED_MESSAGE));
|
apgData.setEncryptedData(data.getStringExtra(EXTRA_ENCRYPTED_MESSAGE));
|
||||||
break;
|
|
||||||
|
|
||||||
|
break;
|
||||||
case DECRYPT_MESSAGE:
|
case DECRYPT_MESSAGE:
|
||||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
apgData.setSignatureUserId(data.getStringExtra(EXTRA_SIGNATURE_USER_ID));
|
apgData.setSecretKeyUserId(data.getStringExtra(EXTRA_SIGNATURE_USER_ID));
|
||||||
apgData.setSignatureKeyId(data.getLongExtra(EXTRA_SIGNATURE_KEY_ID, 0));
|
apgData.setSecretKeyId(data.getLongExtra(EXTRA_SIGNATURE_KEY_ID, 0));
|
||||||
apgData.setSignatureSuccess(data.getBooleanExtra(EXTRA_SIGNATURE_SUCCESS, false));
|
apgData.setSignatureSuccess(data.getBooleanExtra(EXTRA_SIGNATURE_SUCCESS, false));
|
||||||
apgData.setSignatureUnknown(data.getBooleanExtra(EXTRA_SIGNATURE_UNKNOWN, false));
|
apgData.setSignatureUnknown(data.getBooleanExtra(EXTRA_SIGNATURE_UNKNOWN, false));
|
||||||
|
|
||||||
apgData.setDecryptedData(data.getStringExtra(EXTRA_DECRYPTED_MESSAGE));
|
apgData.setDecryptedData(data.getStringExtra(EXTRA_DECRYPTED_MESSAGE));
|
||||||
break;
|
|
||||||
|
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -273,8 +306,8 @@ public class ApgIntentHelper {
|
|||||||
* The emails that should be used for preselection.
|
* The emails that should be used for preselection.
|
||||||
* @return true when activity was found and executed successfully
|
* @return true when activity was found and executed successfully
|
||||||
*/
|
*/
|
||||||
public boolean selectEncryptionKeys(String emails) {
|
public boolean selectPublicKeys(String emails) {
|
||||||
return selectEncryptionKeys(emails, null);
|
return selectPublicKeys(emails, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,19 +319,17 @@ public class ApgIntentHelper {
|
|||||||
* ApgData with encryption keys and signature keys preselected
|
* ApgData with encryption keys and signature keys preselected
|
||||||
* @return true when activity was found and executed successfully
|
* @return true when activity was found and executed successfully
|
||||||
*/
|
*/
|
||||||
public boolean selectEncryptionKeys(String emails, ApgData apgData) {
|
public boolean selectPublicKeys(String emails, ApgData apgData) {
|
||||||
Intent intent = new Intent(ACTION_SELECT_PUBLIC_KEYS);
|
Intent intent = new Intent(ACTION_SELECT_PUBLIC_KEYS);
|
||||||
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
|
intent.putExtra(EXTRA_INTENT_VERSION, INTENT_VERSION);
|
||||||
|
|
||||||
long[] initialKeyIds = null;
|
long[] initialKeyIds = null;
|
||||||
if (apgData == null || !apgData.hasEncryptionKeys()) {
|
if (apgData == null || !apgData.hasPublicKeys()) {
|
||||||
|
|
||||||
ApgContentProviderHelper cPHelper = new ApgContentProviderHelper(activity);
|
ApgContentProviderHelper cPHelper = new ApgContentProviderHelper(activity);
|
||||||
|
|
||||||
initialKeyIds = cPHelper.getPublicKeyIdsFromEmail(emails);
|
initialKeyIds = cPHelper.getPublicKeyIdsFromEmail(emails);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
initialKeyIds = apgData.getEncryptionKeys();
|
initialKeyIds = apgData.getPublicKeys();
|
||||||
}
|
}
|
||||||
intent.putExtra(EXTRA_SELECTION, initialKeyIds);
|
intent.putExtra(EXTRA_SELECTION, initialKeyIds);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class Util {
|
public class ApgUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether APG is installed and at a high enough version.
|
* Check whether APG is installed and at a high enough version.
|
||||||
@ -48,4 +48,25 @@ public class Util {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits userId string into naming part and email part
|
||||||
|
*
|
||||||
|
* @param userId
|
||||||
|
* @return array with naming (0) and email (1)
|
||||||
|
*/
|
||||||
|
public static String[] splitUserId(String userId) {
|
||||||
|
String[] output = new String[2];
|
||||||
|
|
||||||
|
String chunks[] = userId.split(" <", 2);
|
||||||
|
userId = chunks[0];
|
||||||
|
if (chunks.length > 1) {
|
||||||
|
output[1] = "<" + chunks[1];
|
||||||
|
output[1] = output[1].replaceAll("<", "");
|
||||||
|
output[1] = output[1].replaceAll(">", "");
|
||||||
|
}
|
||||||
|
output[0] = userId;
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
}
|
}
|
@ -77,7 +77,7 @@
|
|||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.Sherlock.Light.ForceOverflow" >
|
android:theme="@style/Theme.Sherlock.Light" >
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.MainActivity"
|
android:name=".ui.MainActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
|
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 146 B |
Before Width: | Height: | Size: 153 B |
Before Width: | Height: | Size: 133 B |
Before Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 150 B |
Before Width: | Height: | Size: 157 B |
Before Width: | Height: | Size: 163 B |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1007 B |
Before Width: | Height: | Size: 148 B |
Before Width: | Height: | Size: 166 B |
@ -1,34 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
-->
|
|
||||||
|
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
|
||||||
<!-- Non focused states -->
|
|
||||||
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/abs__tab_unselected_holo" />
|
|
||||||
<item android:state_focused="false" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/abs__tab_selected_holo" />
|
|
||||||
|
|
||||||
<!-- Focused states -->
|
|
||||||
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/abs__tab_unselected_focused_holo" />
|
|
||||||
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/abs__tab_selected_focused_holo" />
|
|
||||||
|
|
||||||
<!-- Pressed -->
|
|
||||||
<!-- Non focused states -->
|
|
||||||
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/abs__tab_unselected_pressed_holo" />
|
|
||||||
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/abs__tab_selected_pressed_holo" />
|
|
||||||
|
|
||||||
<!-- Focused states -->
|
|
||||||
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/abs__tab_unselected_pressed_holo" />
|
|
||||||
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/abs__tab_selected_pressed_holo" />
|
|
||||||
</selector>
|
|
@ -1,144 +0,0 @@
|
|||||||
package android.support.v4.app;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.Window;
|
|
||||||
import com.actionbarsherlock.ActionBarSherlock.OnCreatePanelMenuListener;
|
|
||||||
import com.actionbarsherlock.ActionBarSherlock.OnMenuItemSelectedListener;
|
|
||||||
import com.actionbarsherlock.ActionBarSherlock.OnPreparePanelListener;
|
|
||||||
import com.actionbarsherlock.view.Menu;
|
|
||||||
import com.actionbarsherlock.view.MenuInflater;
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/** I'm in ur package. Stealing ur variables. */
|
|
||||||
public abstract class _ActionBarSherlockTrojanHorse extends FragmentActivity implements OnCreatePanelMenuListener, OnPreparePanelListener, OnMenuItemSelectedListener {
|
|
||||||
private static final boolean DEBUG = false;
|
|
||||||
private static final String TAG = "_ActionBarSherlockTrojanHorse";
|
|
||||||
|
|
||||||
/** Fragment interface for menu creation callback. */
|
|
||||||
public interface OnCreateOptionsMenuListener {
|
|
||||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater);
|
|
||||||
}
|
|
||||||
/** Fragment interface for menu preparation callback. */
|
|
||||||
public interface OnPrepareOptionsMenuListener {
|
|
||||||
public void onPrepareOptionsMenu(Menu menu);
|
|
||||||
}
|
|
||||||
/** Fragment interface for menu item selection callback. */
|
|
||||||
public interface OnOptionsItemSelectedListener {
|
|
||||||
public boolean onOptionsItemSelected(MenuItem item);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<Fragment> mCreatedMenus;
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// Sherlock menu handling
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
|
||||||
if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] featureId: " + featureId + ", menu: " + menu);
|
|
||||||
|
|
||||||
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
|
||||||
boolean result = onCreateOptionsMenu(menu);
|
|
||||||
if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] activity create result: " + result);
|
|
||||||
|
|
||||||
MenuInflater inflater = getSupportMenuInflater();
|
|
||||||
boolean show = false;
|
|
||||||
ArrayList<Fragment> newMenus = null;
|
|
||||||
if (mFragments.mActive != null) {
|
|
||||||
for (int i = 0; i < mFragments.mAdded.size(); i++) {
|
|
||||||
Fragment f = mFragments.mAdded.get(i);
|
|
||||||
if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnCreateOptionsMenuListener) {
|
|
||||||
show = true;
|
|
||||||
((OnCreateOptionsMenuListener)f).onCreateOptionsMenu(menu, inflater);
|
|
||||||
if (newMenus == null) {
|
|
||||||
newMenus = new ArrayList<Fragment>();
|
|
||||||
}
|
|
||||||
newMenus.add(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mCreatedMenus != null) {
|
|
||||||
for (int i = 0; i < mCreatedMenus.size(); i++) {
|
|
||||||
Fragment f = mCreatedMenus.get(i);
|
|
||||||
if (newMenus == null || !newMenus.contains(f)) {
|
|
||||||
f.onDestroyOptionsMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mCreatedMenus = newMenus;
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] fragments create result: " + show);
|
|
||||||
result |= show;
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "[onCreatePanelMenu] returning " + result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
|
||||||
if (DEBUG) Log.d(TAG, "[onPreparePanel] featureId: " + featureId + ", view: " + view + " menu: " + menu);
|
|
||||||
|
|
||||||
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
|
||||||
boolean result = onPrepareOptionsMenu(menu);
|
|
||||||
if (DEBUG) Log.d(TAG, "[onPreparePanel] activity prepare result: " + result);
|
|
||||||
|
|
||||||
boolean show = false;
|
|
||||||
if (mFragments.mActive != null) {
|
|
||||||
for (int i = 0; i < mFragments.mAdded.size(); i++) {
|
|
||||||
Fragment f = mFragments.mAdded.get(i);
|
|
||||||
if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnPrepareOptionsMenuListener) {
|
|
||||||
show = true;
|
|
||||||
((OnPrepareOptionsMenuListener)f).onPrepareOptionsMenu(menu);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (DEBUG) Log.d(TAG, "[onPreparePanel] fragments prepare result: " + show);
|
|
||||||
result |= show;
|
|
||||||
|
|
||||||
result &= menu.hasVisibleItems();
|
|
||||||
if (DEBUG) Log.d(TAG, "[onPreparePanel] returning " + result);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
|
||||||
if (DEBUG) Log.d(TAG, "[onMenuItemSelected] featureId: " + featureId + ", item: " + item);
|
|
||||||
|
|
||||||
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
|
||||||
if (onOptionsItemSelected(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mFragments.mActive != null) {
|
|
||||||
for (int i = 0; i < mFragments.mAdded.size(); i++) {
|
|
||||||
Fragment f = mFragments.mAdded.get(i);
|
|
||||||
if (f != null && !f.mHidden && f.mHasMenu && f.mMenuVisible && f instanceof OnOptionsItemSelectedListener) {
|
|
||||||
if (((OnOptionsItemSelectedListener)f).onOptionsItemSelected(item)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean onCreateOptionsMenu(Menu menu);
|
|
||||||
|
|
||||||
public abstract boolean onPrepareOptionsMenu(Menu menu);
|
|
||||||
|
|
||||||
public abstract boolean onOptionsItemSelected(MenuItem item);
|
|
||||||
|
|
||||||
public abstract MenuInflater getSupportMenuInflater();
|
|
||||||
}
|
|
@ -1,234 +0,0 @@
|
|||||||
package com.actionbarsherlock.internal.view.menu;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.view.ActionProvider;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
|
|
||||||
/** Used to carry an instance of our version of MenuItem through a native channel. */
|
|
||||||
public class MenuItemMule implements MenuItem {
|
|
||||||
private static final String ERROR = "Cannot interact with object designed for temporary "
|
|
||||||
+ "instance passing. Make sure you using both SherlockFragmentActivity and "
|
|
||||||
+ "SherlockFragment.";
|
|
||||||
|
|
||||||
|
|
||||||
private final com.actionbarsherlock.view.MenuItem mItem;
|
|
||||||
|
|
||||||
public MenuItemMule(com.actionbarsherlock.view.MenuItem item) {
|
|
||||||
mItem = item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public com.actionbarsherlock.view.MenuItem unwrap() {
|
|
||||||
return mItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean collapseActionView() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean expandActionView() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActionProvider getActionProvider() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getActionView() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public char getAlphabeticShortcut() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getGroupId() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Drawable getIcon() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intent getIntent() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getItemId() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContextMenuInfo getMenuInfo() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public char getNumericShortcut() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getOrder() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMenu getSubMenu() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getTitle() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CharSequence getTitleCondensed() {
|
|
||||||
return mItem.getTitleCondensed();
|
|
||||||
//throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasSubMenu() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isActionViewExpanded() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCheckable() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isChecked() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEnabled() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isVisible() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setActionProvider(ActionProvider arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setActionView(View arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setActionView(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setAlphabeticShortcut(char arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setCheckable(boolean arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setChecked(boolean arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setEnabled(boolean arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setIcon(Drawable arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setIcon(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setIntent(Intent arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setNumericShortcut(char arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setOnActionExpandListener(OnActionExpandListener arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setOnMenuItemClickListener(OnMenuItemClickListener arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setShortcut(char arg0, char arg1) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setShowAsAction(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setShowAsActionFlags(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setTitle(CharSequence arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setTitle(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setTitleCondensed(CharSequence arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem setVisible(boolean arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,151 +0,0 @@
|
|||||||
package com.actionbarsherlock.internal.view.menu;
|
|
||||||
|
|
||||||
import android.content.ComponentName;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
|
|
||||||
/** Used to carry an instance of our version of Menu through a native channel. */
|
|
||||||
public class MenuMule implements Menu {
|
|
||||||
private static final String ERROR = "Cannot interact with object designed for temporary "
|
|
||||||
+ "instance passing. Make sure you using both SherlockFragmentActivity and "
|
|
||||||
+ "SherlockFragment.";
|
|
||||||
|
|
||||||
|
|
||||||
private final com.actionbarsherlock.view.Menu mMenu;
|
|
||||||
public boolean mDispatchShow = false;
|
|
||||||
|
|
||||||
public MenuMule(com.actionbarsherlock.view.Menu menu) {
|
|
||||||
mMenu = menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public com.actionbarsherlock.view.Menu unwrap() {
|
|
||||||
return mMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem add(CharSequence arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem add(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem add(int arg0, int arg1, int arg2, CharSequence arg3) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem add(int arg0, int arg1, int arg2, int arg3) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int addIntentOptions(int arg0, int arg1, int arg2,
|
|
||||||
ComponentName arg3, Intent[] arg4, Intent arg5, int arg6,
|
|
||||||
MenuItem[] arg7) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMenu addSubMenu(CharSequence arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMenu addSubMenu(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMenu addSubMenu(int arg0, int arg1, int arg2, CharSequence arg3) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SubMenu addSubMenu(int arg0, int arg1, int arg2, int arg3) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void close() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem findItem(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MenuItem getItem(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasVisibleItems() {
|
|
||||||
return mMenu.hasVisibleItems();
|
|
||||||
//throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isShortcutKey(int arg0, KeyEvent arg1) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performIdentifierAction(int arg0, int arg1) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean performShortcut(int arg0, KeyEvent arg1, int arg2) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeGroup(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeItem(int arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGroupCheckable(int arg0, boolean arg1, boolean arg2) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGroupEnabled(int arg0, boolean arg1) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setGroupVisible(int arg0, boolean arg1) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setQwertyMode(boolean arg0) {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
throw new IllegalStateException(ERROR);
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,8 +22,8 @@
|
|||||||
<string name="title_mailInbox">Mail Inbox</string>
|
<string name="title_mailInbox">Mail Inbox</string>
|
||||||
<string name="title_managePublicKeys">Manage Public Keys</string>
|
<string name="title_managePublicKeys">Manage Public Keys</string>
|
||||||
<string name="title_manageSecretKeys">Manage Secret Keys</string>
|
<string name="title_manageSecretKeys">Manage Secret Keys</string>
|
||||||
<string name="title_selectRecipients">Select Recipients</string>
|
<string name="title_selectRecipients">Select Public Key</string>
|
||||||
<string name="title_selectSignature">Select Signature</string>
|
<string name="title_selectSignature">Select Secret Key</string>
|
||||||
<string name="title_encrypt">Encrypt</string>
|
<string name="title_encrypt">Encrypt</string>
|
||||||
<string name="title_decrypt">Decrypt</string>
|
<string name="title_decrypt">Decrypt</string>
|
||||||
<string name="title_authentication">Passphrase</string>
|
<string name="title_authentication">Passphrase</string>
|
||||||
@ -324,8 +324,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Dashboard -->
|
<!-- Dashboard -->
|
||||||
<string name="dashboard_manage_keys">Manage Keys</string>
|
<string name="dashboard_manage_keys">Manage Public Keys</string>
|
||||||
<string name="dashboard_my_keys">My Keys</string>
|
<string name="dashboard_my_keys">My Secret Keys</string>
|
||||||
<string name="dashboard_encrypt">Encrypt</string>
|
<string name="dashboard_encrypt">Encrypt</string>
|
||||||
<string name="dashboard_decrypt">Decrypt</string>
|
<string name="dashboard_decrypt">Decrypt</string>
|
||||||
<string name="dashboard_help">Help</string>
|
<string name="dashboard_help">Help</string>
|
||||||
|
@ -98,37 +98,37 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
public static final int TARGET_STREAM = 3;
|
public static final int TARGET_STREAM = 3;
|
||||||
|
|
||||||
// encrypt
|
// encrypt
|
||||||
public static final String SECRET_KEY_ID = "secretKeyId";
|
public static final String ENCRYPT_SECRET_KEY_ID = "secretKeyId";
|
||||||
public static final String USE_ASCII_AMOR = "useAsciiAmor";
|
public static final String ENCRYPT_USE_ASCII_AMOR = "useAsciiAmor";
|
||||||
public static final String ENCRYPTION_KEYS_IDS = "encryptionKeysIds";
|
public static final String ENCRYPT_ENCRYPTION_KEYS_IDS = "encryptionKeysIds";
|
||||||
public static final String COMPRESSION_ID = "compressionId";
|
public static final String ENCRYPT_COMPRESSION_ID = "compressionId";
|
||||||
public static final String GENERATE_SIGNATURE = "generateSignature";
|
public static final String ENCRYPT_GENERATE_SIGNATURE = "generateSignature";
|
||||||
public static final String SIGN_ONLY = "signOnly";
|
public static final String ENCRYPT_SIGN_ONLY = "signOnly";
|
||||||
public static final String MESSAGE_BYTES = "messageBytes";
|
public static final String ENCRYPT_MESSAGE_BYTES = "messageBytes";
|
||||||
public static final String INPUT_FILE = "inputFile";
|
public static final String ENCRYPT_INPUT_FILE = "inputFile";
|
||||||
public static final String OUTPUT_FILE = "outputFile";
|
public static final String ENCRYPT_OUTPUT_FILE = "outputFile";
|
||||||
public static final String PROVIDER_URI = "providerUri";
|
public static final String ENCRYPT_PROVIDER_URI = "providerUri";
|
||||||
|
|
||||||
// decrypt/verify
|
// decrypt/verify
|
||||||
public static final String SIGNED_ONLY = "signedOnly";
|
public static final String DECRYPT_SIGNED_ONLY = "signedOnly";
|
||||||
public static final String RETURN_BYTES = "returnBinary";
|
public static final String DECRYPT_RETURN_BYTES = "returnBinary";
|
||||||
public static final String CIPHERTEXT_BYTES = "ciphertextBytes";
|
public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertextBytes";
|
||||||
public static final String ASSUME_SYMMETRIC = "assumeSymmetric";
|
public static final String DECRYPT_ASSUME_SYMMETRIC = "assumeSymmetric";
|
||||||
public static final String LOOKUP_UNKNOWN_KEY = "lookupUnknownKey";
|
public static final String DECRYPT_LOOKUP_UNKNOWN_KEY = "lookupUnknownKey";
|
||||||
|
|
||||||
// edit keys
|
// save keyring
|
||||||
public static final String NEW_PASSPHRASE = "newPassphrase";
|
public static final String SAVE_KEYRING_NEW_PASSPHRASE = "newPassphrase";
|
||||||
public static final String CURRENT_PASSPHRASE = "currentPassphrase";
|
public static final String SAVE_KEYRING_CURRENT_PASSPHRASE = "currentPassphrase";
|
||||||
public static final String USER_IDS = "userIds";
|
public static final String SAVE_KEYRING_USER_IDS = "userIds";
|
||||||
public static final String KEYS = "keys";
|
public static final String SAVE_KEYRING_KEYS = "keys";
|
||||||
public static final String KEYS_USAGES = "keysUsages";
|
public static final String SAVE_KEYRING_KEYS_USAGES = "keysUsages";
|
||||||
public static final String MASTER_KEY_ID = "masterKeyId";
|
public static final String SAVE_KEYRING_MASTER_KEY_ID = "masterKeyId";
|
||||||
|
|
||||||
// generate key
|
// generate key
|
||||||
public static final String ALGORITHM = "algorithm";
|
public static final String GENERATE_KEY_ALGORITHM = "algorithm";
|
||||||
public static final String KEY_SIZE = "keySize";
|
public static final String GENERATE_KEY_KEY_SIZE = "keySize";
|
||||||
public static final String SYMMETRIC_PASSPHRASE = "passphrase";
|
public static final String GENERATE_KEY_SYMMETRIC_PASSPHRASE = "passphrase";
|
||||||
public static final String MASTER_KEY = "masterKey";
|
public static final String GENERATE_KEY_MASTER_KEY = "masterKey";
|
||||||
|
|
||||||
// delete file securely
|
// delete file securely
|
||||||
public static final String DELETE_FILE = "deleteFile";
|
public static final String DELETE_FILE = "deleteFile";
|
||||||
@ -238,14 +238,14 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
/* Input */
|
/* Input */
|
||||||
int target = data.getInt(TARGET);
|
int target = data.getInt(TARGET);
|
||||||
|
|
||||||
long secretKeyId = data.getLong(SECRET_KEY_ID);
|
long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID);
|
||||||
String encryptionPassphrase = data.getString(SYMMETRIC_PASSPHRASE);
|
String encryptionPassphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
|
||||||
|
|
||||||
boolean useAsciiArmor = data.getBoolean(USE_ASCII_AMOR);
|
boolean useAsciiArmor = data.getBoolean(ENCRYPT_USE_ASCII_AMOR);
|
||||||
long encryptionKeyIds[] = data.getLongArray(ENCRYPTION_KEYS_IDS);
|
long encryptionKeyIds[] = data.getLongArray(ENCRYPT_ENCRYPTION_KEYS_IDS);
|
||||||
int compressionId = data.getInt(COMPRESSION_ID);
|
int compressionId = data.getInt(ENCRYPT_COMPRESSION_ID);
|
||||||
boolean generateSignature = data.getBoolean(GENERATE_SIGNATURE);
|
boolean generateSignature = data.getBoolean(ENCRYPT_GENERATE_SIGNATURE);
|
||||||
boolean signOnly = data.getBoolean(SIGN_ONLY);
|
boolean signOnly = data.getBoolean(ENCRYPT_SIGN_ONLY);
|
||||||
|
|
||||||
InputStream inStream = null;
|
InputStream inStream = null;
|
||||||
long inLength = -1;
|
long inLength = -1;
|
||||||
@ -254,7 +254,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
String streamFilename = null;
|
String streamFilename = null;
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case TARGET_BYTES: /* encrypting bytes directly */
|
case TARGET_BYTES: /* encrypting bytes directly */
|
||||||
byte[] bytes = data.getByteArray(MESSAGE_BYTES);
|
byte[] bytes = data.getByteArray(ENCRYPT_MESSAGE_BYTES);
|
||||||
|
|
||||||
inStream = new ByteArrayInputStream(bytes);
|
inStream = new ByteArrayInputStream(bytes);
|
||||||
inLength = bytes.length;
|
inLength = bytes.length;
|
||||||
@ -264,8 +264,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case TARGET_FILE: /* encrypting file */
|
case TARGET_FILE: /* encrypting file */
|
||||||
String inputFile = data.getString(INPUT_FILE);
|
String inputFile = data.getString(ENCRYPT_INPUT_FILE);
|
||||||
String outputFile = data.getString(OUTPUT_FILE);
|
String outputFile = data.getString(ENCRYPT_OUTPUT_FILE);
|
||||||
|
|
||||||
// check if storage is ready
|
// check if storage is ready
|
||||||
if (!FileHelper.isStorageMounted(inputFile)
|
if (!FileHelper.isStorageMounted(inputFile)
|
||||||
@ -284,7 +284,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TARGET_STREAM: /* Encrypting stream from content uri */
|
case TARGET_STREAM: /* Encrypting stream from content uri */
|
||||||
Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI);
|
Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI);
|
||||||
|
|
||||||
// InputStream
|
// InputStream
|
||||||
InputStream in = getContentResolver().openInputStream(providerUri);
|
InputStream in = getContentResolver().openInputStream(providerUri);
|
||||||
@ -390,13 +390,13 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
/* Input */
|
/* Input */
|
||||||
int target = data.getInt(TARGET);
|
int target = data.getInt(TARGET);
|
||||||
|
|
||||||
long secretKeyId = data.getLong(SECRET_KEY_ID);
|
long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID);
|
||||||
byte[] bytes = data.getByteArray(CIPHERTEXT_BYTES);
|
byte[] bytes = data.getByteArray(DECRYPT_CIPHERTEXT_BYTES);
|
||||||
boolean signedOnly = data.getBoolean(SIGNED_ONLY);
|
boolean signedOnly = data.getBoolean(DECRYPT_SIGNED_ONLY);
|
||||||
boolean returnBytes = data.getBoolean(RETURN_BYTES);
|
boolean returnBytes = data.getBoolean(DECRYPT_RETURN_BYTES);
|
||||||
boolean assumeSymmetricEncryption = data.getBoolean(ASSUME_SYMMETRIC);
|
boolean assumeSymmetricEncryption = data.getBoolean(DECRYPT_ASSUME_SYMMETRIC);
|
||||||
|
|
||||||
boolean lookupUnknownKey = data.getBoolean(LOOKUP_UNKNOWN_KEY);
|
boolean lookupUnknownKey = data.getBoolean(DECRYPT_LOOKUP_UNKNOWN_KEY);
|
||||||
|
|
||||||
InputStream inStream = null;
|
InputStream inStream = null;
|
||||||
long inLength = -1;
|
long inLength = -1;
|
||||||
@ -414,8 +414,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TARGET_FILE: /* decrypting file */
|
case TARGET_FILE: /* decrypting file */
|
||||||
String inputFile = data.getString(INPUT_FILE);
|
String inputFile = data.getString(ENCRYPT_INPUT_FILE);
|
||||||
String outputFile = data.getString(OUTPUT_FILE);
|
String outputFile = data.getString(ENCRYPT_OUTPUT_FILE);
|
||||||
|
|
||||||
// check if storage is ready
|
// check if storage is ready
|
||||||
if (!FileHelper.isStorageMounted(inputFile)
|
if (!FileHelper.isStorageMounted(inputFile)
|
||||||
@ -437,7 +437,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TARGET_STREAM: /* decrypting stream from content uri */
|
case TARGET_STREAM: /* decrypting stream from content uri */
|
||||||
Uri providerUri = (Uri) data.getParcelable(PROVIDER_URI);
|
Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI);
|
||||||
|
|
||||||
// InputStream
|
// InputStream
|
||||||
InputStream in = getContentResolver().openInputStream(providerUri);
|
InputStream in = getContentResolver().openInputStream(providerUri);
|
||||||
@ -521,16 +521,16 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
String oldPassPhrase = data.getString(CURRENT_PASSPHRASE);
|
String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE);
|
||||||
String newPassPhrase = data.getString(NEW_PASSPHRASE);
|
String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE);
|
||||||
if (newPassPhrase == null) {
|
if (newPassPhrase == null) {
|
||||||
newPassPhrase = oldPassPhrase;
|
newPassPhrase = oldPassPhrase;
|
||||||
}
|
}
|
||||||
ArrayList<String> userIds = data.getStringArrayList(USER_IDS);
|
ArrayList<String> userIds = data.getStringArrayList(SAVE_KEYRING_USER_IDS);
|
||||||
ArrayList<PGPSecretKey> keys = PGPConversionHelper.BytesToPGPSecretKeyList(data
|
ArrayList<PGPSecretKey> keys = PGPConversionHelper.BytesToPGPSecretKeyList(data
|
||||||
.getByteArray(KEYS));
|
.getByteArray(SAVE_KEYRING_KEYS));
|
||||||
ArrayList<Integer> keysUsages = data.getIntegerArrayList(KEYS_USAGES);
|
ArrayList<Integer> keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES);
|
||||||
long masterKeyId = data.getLong(MASTER_KEY_ID);
|
long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID);
|
||||||
|
|
||||||
/* Operation */
|
/* Operation */
|
||||||
PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
|
PGPMain.buildSecretKey(this, userIds, keys, keysUsages, masterKeyId, oldPassPhrase,
|
||||||
@ -549,13 +549,13 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
int algorithm = data.getInt(ALGORITHM);
|
int algorithm = data.getInt(GENERATE_KEY_ALGORITHM);
|
||||||
String passphrase = data.getString(SYMMETRIC_PASSPHRASE);
|
String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
|
||||||
int keysize = data.getInt(KEY_SIZE);
|
int keysize = data.getInt(GENERATE_KEY_KEY_SIZE);
|
||||||
PGPSecretKey masterKey = null;
|
PGPSecretKey masterKey = null;
|
||||||
if (data.containsKey(MASTER_KEY)) {
|
if (data.containsKey(GENERATE_KEY_MASTER_KEY)) {
|
||||||
masterKey = PGPConversionHelper.BytesToPGPSecretKey(data
|
masterKey = PGPConversionHelper.BytesToPGPSecretKey(data
|
||||||
.getByteArray(MASTER_KEY));
|
.getByteArray(GENERATE_KEY_MASTER_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Operation */
|
/* Operation */
|
||||||
@ -580,7 +580,7 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
// generate one RSA 2048 key for signing and one subkey for encrypting!
|
// generate one RSA 2048 key for signing and one subkey for encrypting!
|
||||||
try {
|
try {
|
||||||
/* Input */
|
/* Input */
|
||||||
String passphrase = data.getString(SYMMETRIC_PASSPHRASE);
|
String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE);
|
||||||
|
|
||||||
/* Operation */
|
/* Operation */
|
||||||
PGPSecretKeyRing masterKeyRing = PGPMain.createKey(this, Id.choice.algorithm.rsa,
|
PGPSecretKeyRing masterKeyRing = PGPMain.createKey(this, Id.choice.algorithm.rsa,
|
||||||
@ -739,7 +739,8 @@ public class ApgIntentService extends IntentService implements ProgressDialogUpd
|
|||||||
/* Operation */
|
/* Operation */
|
||||||
HkpKeyServer server = new HkpKeyServer(keyServer);
|
HkpKeyServer server = new HkpKeyServer(keyServer);
|
||||||
|
|
||||||
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByRowId(this, keyRingRowId);
|
PGPPublicKeyRing keyring = ProviderHelper.getPGPPublicKeyRingByRowId(this,
|
||||||
|
keyRingRowId);
|
||||||
if (keyring != null) {
|
if (keyring != null) {
|
||||||
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
|
boolean uploaded = PGPMain.uploadKeyRingToServer(server,
|
||||||
(PGPPublicKeyRing) keyring);
|
(PGPPublicKeyRing) keyring);
|
||||||
|
@ -76,27 +76,27 @@ public class ApgService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void encryptAndSignImplementation(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
|
private void encryptAndSignImplementation(byte[] inputBytes, String inputUri,
|
||||||
int compression, long[] encryptionKeyIds, String encryptionPassphrase,
|
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
|
||||||
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
|
String encryptionPassphrase, int symmetricEncryptionAlgorithm, long signatureKeyId,
|
||||||
boolean signatureForceV3, String signaturePassphrase, IApgEncryptDecryptHandler handler)
|
int signatureHashAlgorithm, boolean signatureForceV3, String signaturePassphrase,
|
||||||
throws RemoteException {
|
IApgEncryptSignHandler handler) throws RemoteException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO use inputUri
|
// TODO use inputUri
|
||||||
|
|
||||||
// InputStream inStream = null;
|
// InputStream inStream = null;
|
||||||
// if (isBlob) {
|
// if (isBlob) {
|
||||||
// ContentResolver cr = getContentResolver();
|
// ContentResolver cr = getContentResolver();
|
||||||
// try {
|
// try {
|
||||||
// inStream = cr.openInputStream(Uri.parse(pArgs.getString(arg.BLOB.name())));
|
// inStream = cr.openInputStream(Uri.parse(pArgs.getString(arg.BLOB.name())));
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// Log.e(TAG, "... exception on opening blob", e);
|
// Log.e(TAG, "... exception on opening blob", e);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes());
|
// inStream = new ByteArrayInputStream(pArgs.getString(arg.MESSAGE.name()).getBytes());
|
||||||
// }
|
// }
|
||||||
// InputData in = new InputData(inStream, 0); // XXX Size second param?
|
// InputData in = new InputData(inStream, 0); // XXX Size second param?
|
||||||
|
|
||||||
// build InputData and write into OutputStream
|
// build InputData and write into OutputStream
|
||||||
InputStream inputStream = new ByteArrayInputStream(inputBytes);
|
InputStream inputStream = new ByteArrayInputStream(inputBytes);
|
||||||
@ -110,20 +110,20 @@ public class ApgService extends Service {
|
|||||||
signatureKeyId, signatureHashAlgorithm, signatureForceV3, signaturePassphrase);
|
signatureKeyId, signatureHashAlgorithm, signatureForceV3, signaturePassphrase);
|
||||||
|
|
||||||
output.close();
|
output.close();
|
||||||
|
|
||||||
// if (isBlob) {
|
// if (isBlob) {
|
||||||
// ContentResolver cr = getContentResolver();
|
// ContentResolver cr = getContentResolver();
|
||||||
// try {
|
// try {
|
||||||
// OutputStream outStream = cr.openOutputStream(Uri.parse(pArgs.getString(arg.BLOB
|
// OutputStream outStream = cr.openOutputStream(Uri.parse(pArgs.getString(arg.BLOB
|
||||||
// .name())));
|
// .name())));
|
||||||
// writeToOutputStream(new ByteArrayInputStream(out.toString().getBytes()), outStream);
|
// writeToOutputStream(new ByteArrayInputStream(out.toString().getBytes()), outStream);
|
||||||
// outStream.close();
|
// outStream.close();
|
||||||
// } catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
// Log.e(TAG, "... exception on writing blob", e);
|
// Log.e(TAG, "... exception on writing blob", e);
|
||||||
// }
|
// }
|
||||||
// } else {
|
// } else {
|
||||||
// pReturn.putString(ret.RESULT.name(), out.toString());
|
// pReturn.putString(ret.RESULT.name(), out.toString());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
byte[] outputBytes = ((ByteArrayOutputStream) output).toByteArray();
|
byte[] outputBytes = ((ByteArrayOutputStream) output).toByteArray();
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ public class ApgService extends Service {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decryptAndVerifyImplementation(byte[] inputBytes, String inputUri,
|
private void decryptAndVerifyImplementation(byte[] inputBytes, String inputUri,
|
||||||
String passphrase, boolean assumeSymmetric, IApgEncryptDecryptHandler handler)
|
String passphrase, boolean assumeSymmetric, IApgDecryptVerifyHandler handler)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -232,7 +232,7 @@ public class ApgService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void encryptAsymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
|
public void encryptAsymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
|
||||||
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
|
int compression, long[] encryptionKeyIds, int symmetricEncryptionAlgorithm,
|
||||||
IApgEncryptDecryptHandler handler) throws RemoteException {
|
IApgEncryptSignHandler handler) throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
||||||
encryptionKeyIds, null, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
encryptionKeyIds, null, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
||||||
@ -242,7 +242,7 @@ public class ApgService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public void encryptSymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
|
public void encryptSymmetric(byte[] inputBytes, String inputUri, boolean useAsciiArmor,
|
||||||
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
|
int compression, String encryptionPassphrase, int symmetricEncryptionAlgorithm,
|
||||||
IApgEncryptDecryptHandler handler) throws RemoteException {
|
IApgEncryptSignHandler handler) throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
||||||
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
encryptionPassphrase, symmetricEncryptionAlgorithm, Id.key.none, 0, false,
|
||||||
@ -253,8 +253,8 @@ public class ApgService extends Service {
|
|||||||
public void encryptAndSignAsymmetric(byte[] inputBytes, String inputUri,
|
public void encryptAndSignAsymmetric(byte[] inputBytes, String inputUri,
|
||||||
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
|
boolean useAsciiArmor, int compression, long[] encryptionKeyIds,
|
||||||
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
|
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
|
||||||
boolean signatureForceV3, String signaturePassphrase,
|
boolean signatureForceV3, String signaturePassphrase, IApgEncryptSignHandler handler)
|
||||||
IApgEncryptDecryptHandler handler) throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression,
|
||||||
encryptionKeyIds, null, symmetricEncryptionAlgorithm, signatureKeyId,
|
encryptionKeyIds, null, symmetricEncryptionAlgorithm, signatureKeyId,
|
||||||
@ -265,8 +265,8 @@ public class ApgService extends Service {
|
|||||||
public void encryptAndSignSymmetric(byte[] inputBytes, String inputUri,
|
public void encryptAndSignSymmetric(byte[] inputBytes, String inputUri,
|
||||||
boolean useAsciiArmor, int compression, String encryptionPassphrase,
|
boolean useAsciiArmor, int compression, String encryptionPassphrase,
|
||||||
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
|
int symmetricEncryptionAlgorithm, long signatureKeyId, int signatureHashAlgorithm,
|
||||||
boolean signatureForceV3, String signaturePassphrase,
|
boolean signatureForceV3, String signaturePassphrase, IApgEncryptSignHandler handler)
|
||||||
IApgEncryptDecryptHandler handler) throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
encryptAndSignImplementation(inputBytes, inputUri, useAsciiArmor, compression, null,
|
||||||
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
|
encryptionPassphrase, symmetricEncryptionAlgorithm, signatureKeyId,
|
||||||
@ -275,14 +275,14 @@ public class ApgService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
|
public void decryptAndVerifyAsymmetric(byte[] inputBytes, String inputUri,
|
||||||
String keyPassphrase, IApgEncryptDecryptHandler handler) throws RemoteException {
|
String keyPassphrase, IApgDecryptVerifyHandler handler) throws RemoteException {
|
||||||
|
|
||||||
decryptAndVerifyImplementation(inputBytes, inputUri, keyPassphrase, false, handler);
|
decryptAndVerifyImplementation(inputBytes, inputUri, keyPassphrase, false, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
|
public void decryptAndVerifySymmetric(byte[] inputBytes, String inputUri,
|
||||||
String encryptionPassphrase, IApgEncryptDecryptHandler handler)
|
String encryptionPassphrase, IApgDecryptVerifyHandler handler)
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
|
|
||||||
decryptAndVerifyImplementation(inputBytes, inputUri, encryptionPassphrase, true,
|
decryptAndVerifyImplementation(inputBytes, inputUri, encryptionPassphrase, true,
|
||||||
|
@ -16,17 +16,15 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.service;
|
package org.thialfihar.android.apg.service;
|
||||||
|
|
||||||
interface IApgEncryptDecryptHandler {
|
interface IApgDecryptVerifyHandler {
|
||||||
/**
|
|
||||||
* Either output or streamUri is given. One of them is null
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
oneway void onSuccessEncrypt(in byte[] outputBytes, in String outputUri);
|
|
||||||
|
|
||||||
oneway void onSuccessDecrypt(in byte[] outputBytes, in String outputUri, in boolean signature,
|
oneway void onSuccessDecrypt(in byte[] outputBytes, in String outputUri, in boolean signature,
|
||||||
in long signatureKeyId, in String signatureUserId, in boolean signatureSuccess,
|
in long signatureKeyId, in String signatureUserId, in boolean signatureSuccess,
|
||||||
in boolean signatureUnknown);
|
in boolean signatureUnknown);
|
||||||
|
|
||||||
|
oneway void onSuccessVerify(in boolean signature, in long signatureKeyId,
|
||||||
|
in String signatureUserId, in boolean signatureSuccess, in boolean signatureUnknown);
|
||||||
|
|
||||||
|
|
||||||
oneway void onException(in int exceptionNumber, in String message);
|
oneway void onException(in int exceptionNumber, in String message);
|
||||||
}
|
}
|
@ -16,11 +16,14 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.service;
|
package org.thialfihar.android.apg.service;
|
||||||
|
|
||||||
interface IApgSignVerifyHandler {
|
interface IApgEncryptSignHandler {
|
||||||
oneway void onSuccessSign(in byte[] outputBytes, in String outputUri);
|
/**
|
||||||
|
* Either output or streamUri is given. One of them is null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
oneway void onSuccessEncrypt(in byte[] outputBytes, in String outputUri);
|
||||||
|
|
||||||
oneway void onSuccessVerify(in boolean signature, in long signatureKeyId,
|
oneway void onSuccessSign(in byte[] outputBytes, in String outputUri);
|
||||||
in String signatureUserId, in boolean signatureSuccess, in boolean signatureUnknown);
|
|
||||||
|
|
||||||
|
|
||||||
oneway void onException(in int exceptionNumber, in String message);
|
oneway void onException(in int exceptionNumber, in String message);
|
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.service;
|
package org.thialfihar.android.apg.service;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.service.IApgEncryptDecryptHandler;
|
import org.thialfihar.android.apg.service.IApgEncryptSignHandler;
|
||||||
import org.thialfihar.android.apg.service.IApgSignVerifyHandler;
|
import org.thialfihar.android.apg.service.IApgDecryptVerifyHandler;
|
||||||
import org.thialfihar.android.apg.service.IApgHelperHandler;
|
import org.thialfihar.android.apg.service.IApgHelperHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +50,7 @@ interface IApgService {
|
|||||||
*/
|
*/
|
||||||
oneway void encryptAsymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
|
oneway void encryptAsymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
|
||||||
in int compression, in long[] encryptionKeyIds, in int symmetricEncryptionAlgorithm,
|
in int compression, in long[] encryptionKeyIds, in int symmetricEncryptionAlgorithm,
|
||||||
in IApgEncryptDecryptHandler handler);
|
in IApgEncryptSignHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as encryptAsymmetric but using a passphrase for symmetric encryption
|
* Same as encryptAsymmetric but using a passphrase for symmetric encryption
|
||||||
@ -60,7 +60,7 @@ interface IApgService {
|
|||||||
*/
|
*/
|
||||||
oneway void encryptSymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
|
oneway void encryptSymmetric(in byte[] inputBytes, in String inputUri, in boolean useAsciiArmor,
|
||||||
in int compression, in String encryptionPassphrase, in int symmetricEncryptionAlgorithm,
|
in int compression, in String encryptionPassphrase, in int symmetricEncryptionAlgorithm,
|
||||||
in IApgEncryptDecryptHandler handler);
|
in IApgEncryptSignHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypt and sign
|
* Encrypt and sign
|
||||||
@ -97,7 +97,7 @@ interface IApgService {
|
|||||||
in boolean useAsciiArmor, in int compression, in long[] encryptionKeyIds,
|
in boolean useAsciiArmor, in int compression, in long[] encryptionKeyIds,
|
||||||
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
|
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
|
||||||
in boolean signatureForceV3, in String signaturePassphrase,
|
in boolean signatureForceV3, in String signaturePassphrase,
|
||||||
in IApgEncryptDecryptHandler handler);
|
in IApgEncryptSignHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as encryptAndSignAsymmetric but using a passphrase for symmetric encryption
|
* Same as encryptAndSignAsymmetric but using a passphrase for symmetric encryption
|
||||||
@ -109,7 +109,7 @@ interface IApgService {
|
|||||||
in boolean useAsciiArmor, in int compression, in String encryptionPassphrase,
|
in boolean useAsciiArmor, in int compression, in String encryptionPassphrase,
|
||||||
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
|
in int symmetricEncryptionAlgorithm, in long signatureKeyId, in int signatureHashAlgorithm,
|
||||||
in boolean signatureForceV3, in String signaturePassphrase,
|
in boolean signatureForceV3, in String signaturePassphrase,
|
||||||
in IApgEncryptDecryptHandler handler);
|
in IApgEncryptSignHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrypts and verifies given input bytes. If no signature is present this method
|
* Decrypts and verifies given input bytes. If no signature is present this method
|
||||||
@ -125,7 +125,7 @@ interface IApgService {
|
|||||||
* Handler where to return results to after successful encryption
|
* Handler where to return results to after successful encryption
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerifyAsymmetric(in byte[] inputBytes, in String inputUri,
|
oneway void decryptAndVerifyAsymmetric(in byte[] inputBytes, in String inputUri,
|
||||||
in String keyPassphrase, in IApgEncryptDecryptHandler handler);
|
in String keyPassphrase, in IApgDecryptVerifyHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Same as decryptAndVerifyAsymmetric but for symmetric decryption.
|
* Same as decryptAndVerifyAsymmetric but for symmetric decryption.
|
||||||
@ -134,7 +134,7 @@ interface IApgService {
|
|||||||
* Passphrase to decrypt
|
* Passphrase to decrypt
|
||||||
*/
|
*/
|
||||||
oneway void decryptAndVerifySymmetric(in byte[] inputBytes, in String inputUri,
|
oneway void decryptAndVerifySymmetric(in byte[] inputBytes, in String inputUri,
|
||||||
in String encryptionPassphrase, in IApgEncryptDecryptHandler handler);
|
in String encryptionPassphrase, in IApgDecryptVerifyHandler handler);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -68,16 +68,18 @@ import java.util.regex.Matcher;
|
|||||||
|
|
||||||
public class DecryptActivity extends SherlockFragmentActivity {
|
public class DecryptActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
// possible intent actions for this activity
|
/* Intents */
|
||||||
|
// without permission
|
||||||
public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT";
|
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
|
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "DECRYPT_AND_RETURN";
|
+ "DECRYPT_AND_RETURN";
|
||||||
|
|
||||||
public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
|
|
||||||
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
public static final String ACTION_DECRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "DECRYPT_STREAM_AND_RETURN";
|
+ "DECRYPT_STREAM_AND_RETURN";
|
||||||
|
|
||||||
// possible extra keys
|
/* EXTRA keys for input */
|
||||||
public static final String EXTRA_TEXT = "text";
|
public static final String EXTRA_TEXT = "text";
|
||||||
public static final String EXTRA_DATA = "data";
|
public static final String EXTRA_DATA = "data";
|
||||||
public static final String EXTRA_REPLY_TO = "replyTo";
|
public static final String EXTRA_REPLY_TO = "replyTo";
|
||||||
@ -755,32 +757,32 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
if (mContentUri != null) {
|
if (mContentUri != null) {
|
||||||
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
|
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
|
||||||
|
|
||||||
data.putParcelable(ApgIntentService.PROVIDER_URI, mContentUri);
|
data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mContentUri);
|
||||||
} else if (mDecryptTarget == Id.target.file) {
|
} else if (mDecryptTarget == Id.target.file) {
|
||||||
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
|
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_FILE);
|
||||||
|
|
||||||
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
||||||
+ mOutputFilename);
|
+ mOutputFilename);
|
||||||
|
|
||||||
data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
|
data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
|
||||||
data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
|
data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
|
||||||
} else {
|
} else {
|
||||||
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
|
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
|
||||||
|
|
||||||
if (mDataBytes != null) {
|
if (mDataBytes != null) {
|
||||||
data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, mDataBytes);
|
data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, mDataBytes);
|
||||||
} else {
|
} else {
|
||||||
String message = mMessage.getText().toString();
|
String message = mMessage.getText().toString();
|
||||||
data.putByteArray(ApgIntentService.CIPHERTEXT_BYTES, message.getBytes());
|
data.putByteArray(ApgIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
|
data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
|
||||||
|
|
||||||
data.putBoolean(ApgIntentService.SIGNED_ONLY, mSignedOnly);
|
data.putBoolean(ApgIntentService.DECRYPT_SIGNED_ONLY, mSignedOnly);
|
||||||
data.putBoolean(ApgIntentService.LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
|
data.putBoolean(ApgIntentService.DECRYPT_LOOKUP_UNKNOWN_KEY, mLookupUnknownKey);
|
||||||
data.putBoolean(ApgIntentService.RETURN_BYTES, mReturnBinary);
|
data.putBoolean(ApgIntentService.DECRYPT_RETURN_BYTES, mReturnBinary);
|
||||||
data.putBoolean(ApgIntentService.ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
|
data.putBoolean(ApgIntentService.DECRYPT_ASSUME_SYMMETRIC, mAssumeSymmetricEncryption);
|
||||||
|
|
||||||
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import org.thialfihar.android.apg.helper.OtherHelper;
|
|||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPMain;
|
import org.thialfihar.android.apg.helper.PGPMain;
|
||||||
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.PGPMain.ApgGeneralException;
|
||||||
import org.thialfihar.android.apg.provider.ProviderHelper;
|
import org.thialfihar.android.apg.provider.ProviderHelper;
|
||||||
import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
|
import org.thialfihar.android.apg.service.ApgIntentServiceHandler;
|
||||||
import org.thialfihar.android.apg.service.ApgIntentService;
|
import org.thialfihar.android.apg.service.ApgIntentService;
|
||||||
@ -75,6 +76,10 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys";
|
||||||
public static final String EXTRA_KEY_ID = "keyId";
|
public static final String EXTRA_KEY_ID = "keyId";
|
||||||
|
|
||||||
|
// results when saving key
|
||||||
|
public static final String RESULT_EXTRA_MASTER_KEY_ID = "masterKeyId";
|
||||||
|
public static final String RESULT_EXTRA_USER_ID = "userId";
|
||||||
|
|
||||||
private ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
|
|
||||||
private PGPSecretKeyRing mKeyRing = null;
|
private PGPSecretKeyRing mKeyRing = null;
|
||||||
@ -121,7 +126,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
case Id.menu.option.cancel:
|
case Id.menu.option.cancel:
|
||||||
finish();
|
cancelClicked();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -236,7 +241,8 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, mCurrentPassPhrase);
|
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE,
|
||||||
|
mCurrentPassPhrase);
|
||||||
|
|
||||||
serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
serviceIntent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
@ -424,14 +430,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
// fill values for this action
|
// fill values for this action
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
data.putString(ApgIntentService.CURRENT_PASSPHRASE, mCurrentPassPhrase);
|
data.putString(ApgIntentService.SAVE_KEYRING_CURRENT_PASSPHRASE, mCurrentPassPhrase);
|
||||||
data.putString(ApgIntentService.NEW_PASSPHRASE, mNewPassPhrase);
|
data.putString(ApgIntentService.SAVE_KEYRING_NEW_PASSPHRASE, mNewPassPhrase);
|
||||||
data.putStringArrayList(ApgIntentService.USER_IDS, getUserIds(mUserIdsView));
|
data.putStringArrayList(ApgIntentService.SAVE_KEYRING_USER_IDS,
|
||||||
|
getUserIds(mUserIdsView));
|
||||||
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
|
ArrayList<PGPSecretKey> keys = getKeys(mKeysView);
|
||||||
data.putByteArray(ApgIntentService.KEYS,
|
data.putByteArray(ApgIntentService.SAVE_KEYRING_KEYS,
|
||||||
PGPConversionHelper.PGPSecretKeyArrayListToBytes(keys));
|
PGPConversionHelper.PGPSecretKeyArrayListToBytes(keys));
|
||||||
data.putIntegerArrayList(ApgIntentService.KEYS_USAGES, getKeysUsages(mKeysView));
|
data.putIntegerArrayList(ApgIntentService.SAVE_KEYRING_KEYS_USAGES,
|
||||||
data.putLong(ApgIntentService.MASTER_KEY_ID, getMasterKeyId());
|
getKeysUsages(mKeysView));
|
||||||
|
data.putLong(ApgIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId());
|
||||||
|
|
||||||
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
@ -443,6 +451,16 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
super.handleMessage(message);
|
super.handleMessage(message);
|
||||||
|
|
||||||
if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
|
if (message.arg1 == ApgIntentServiceHandler.MESSAGE_OKAY) {
|
||||||
|
Intent data = new Intent();
|
||||||
|
data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, getMasterKeyId());
|
||||||
|
ArrayList<String> userIds = null;
|
||||||
|
try {
|
||||||
|
userIds = getUserIds(mUserIdsView);
|
||||||
|
} catch (ApgGeneralException e) {
|
||||||
|
Log.e(Constants.TAG, "exception while getting user ids", e);
|
||||||
|
}
|
||||||
|
data.putExtra(RESULT_EXTRA_USER_ID, userIds.get(0));
|
||||||
|
setResult(RESULT_OK, data);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -462,6 +480,11 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void cancelClicked() {
|
||||||
|
setResult(RESULT_CANCELED);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns user ids from the SectionView
|
* Returns user ids from the SectionView
|
||||||
*
|
*
|
||||||
|
@ -70,18 +70,20 @@ import java.util.Vector;
|
|||||||
|
|
||||||
public class EncryptActivity extends SherlockFragmentActivity {
|
public class EncryptActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
// possible intent actions for this activity
|
/* Intents */
|
||||||
|
// without permission
|
||||||
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
|
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
|
public static final String ACTION_ENCRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "ENCRYPT_AND_RETURN";
|
+ "ENCRYPT_AND_RETURN";
|
||||||
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX
|
public static final String ACTION_GENERATE_SIGNATURE_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "GENERATE_SIGNATURE";
|
+ "GENERATE_SIGNATURE_AND_RETURN";
|
||||||
|
|
||||||
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
|
|
||||||
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
public static final String ACTION_ENCRYPT_STREAM_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
+ "ENCRYPT_STREAM_AND_RETURN";
|
+ "ENCRYPT_STREAM_AND_RETURN";
|
||||||
|
|
||||||
// possible extra keys
|
/* EXTRA keys for input */
|
||||||
public static final String EXTRA_TEXT = "text";
|
public static final String EXTRA_TEXT = "text";
|
||||||
public static final String EXTRA_DATA = "data";
|
public static final String EXTRA_DATA = "data";
|
||||||
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
|
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
|
||||||
@ -339,7 +341,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
} else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
|
} else if (ACTION_ENCRYPT_STREAM_AND_RETURN.equals(action)) {
|
||||||
// TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
|
// TODO: Set mStreamAndReturnUri that is used later to encrypt a stream!
|
||||||
|
|
||||||
mStreamAndReturnUri = null;
|
mStreamAndReturnUri = uri;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -684,7 +686,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
passPhrase = null;
|
passPhrase = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
|
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
|
||||||
} else {
|
} else {
|
||||||
encryptionKeyIds = mEncryptionKeyIds;
|
encryptionKeyIds = mEncryptionKeyIds;
|
||||||
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
|
signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0);
|
||||||
@ -696,7 +698,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
if (mStreamAndReturnUri != null) {
|
if (mStreamAndReturnUri != null) {
|
||||||
// mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used
|
// mIntentDataUri is only defined when ACTION_ENCRYPT_STREAM_AND_RETURN is used
|
||||||
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
|
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_STREAM);
|
||||||
data.putParcelable(ApgIntentService.PROVIDER_URI, mStreamAndReturnUri);
|
data.putParcelable(ApgIntentService.ENCRYPT_PROVIDER_URI, mStreamAndReturnUri);
|
||||||
|
|
||||||
} else if (mEncryptTarget == Id.target.file) {
|
} else if (mEncryptTarget == Id.target.file) {
|
||||||
useAsciiArmor = mAsciiArmour.isChecked();
|
useAsciiArmor = mAsciiArmour.isChecked();
|
||||||
@ -707,8 +709,8 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename="
|
||||||
+ mOutputFilename);
|
+ mOutputFilename);
|
||||||
|
|
||||||
data.putString(ApgIntentService.INPUT_FILE, mInputFilename);
|
data.putString(ApgIntentService.ENCRYPT_INPUT_FILE, mInputFilename);
|
||||||
data.putString(ApgIntentService.OUTPUT_FILE, mOutputFilename);
|
data.putString(ApgIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
useAsciiArmor = true;
|
useAsciiArmor = true;
|
||||||
@ -717,13 +719,13 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
|
data.putInt(ApgIntentService.TARGET, ApgIntentService.TARGET_BYTES);
|
||||||
|
|
||||||
if (mData != null) {
|
if (mData != null) {
|
||||||
data.putByteArray(ApgIntentService.MESSAGE_BYTES, mData);
|
data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, mData);
|
||||||
} else {
|
} else {
|
||||||
String message = mMessage.getText().toString();
|
String message = mMessage.getText().toString();
|
||||||
if (signOnly && !mEncryptImmediately) {
|
if (signOnly && !mEncryptImmediately) {
|
||||||
fixBadCharactersForGmail(message);
|
fixBadCharactersForGmail(message);
|
||||||
}
|
}
|
||||||
data.putByteArray(ApgIntentService.MESSAGE_BYTES, message.getBytes());
|
data.putByteArray(ApgIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -731,12 +733,12 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
useAsciiArmor = mAsciiArmorDemand;
|
useAsciiArmor = mAsciiArmorDemand;
|
||||||
}
|
}
|
||||||
|
|
||||||
data.putLong(ApgIntentService.SECRET_KEY_ID, mSecretKeyId);
|
data.putLong(ApgIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId);
|
||||||
data.putBoolean(ApgIntentService.USE_ASCII_AMOR, useAsciiArmor);
|
data.putBoolean(ApgIntentService.ENCRYPT_USE_ASCII_AMOR, useAsciiArmor);
|
||||||
data.putLongArray(ApgIntentService.ENCRYPTION_KEYS_IDS, encryptionKeyIds);
|
data.putLongArray(ApgIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds);
|
||||||
data.putInt(ApgIntentService.COMPRESSION_ID, compressionId);
|
data.putInt(ApgIntentService.ENCRYPT_COMPRESSION_ID, compressionId);
|
||||||
data.putBoolean(ApgIntentService.GENERATE_SIGNATURE, mGenerateSignature);
|
data.putBoolean(ApgIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature);
|
||||||
data.putBoolean(ApgIntentService.SIGN_ONLY, signOnly);
|
data.putBoolean(ApgIntentService.ENCRYPT_SIGN_ONLY, signOnly);
|
||||||
|
|
||||||
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void handleMessage(Message message) {
|
public void handleMessage(Message message) {
|
||||||
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
|
if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
|
||||||
// refreshList();
|
// no further actions needed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -368,8 +368,6 @@ public class KeyListActivity extends SherlockFragmentActivity {
|
|||||||
.newInstance(mImportFilename);
|
.newInstance(mImportFilename);
|
||||||
deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
|
deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
|
||||||
}
|
}
|
||||||
// refreshList();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -262,14 +262,14 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
passPhrase = PassphraseCacheService
|
passPhrase = PassphraseCacheService
|
||||||
.getCachedPassphrase(mActivity, masterKey.getKeyID());
|
.getCachedPassphrase(mActivity, masterKey.getKeyID());
|
||||||
|
|
||||||
data.putByteArray(ApgIntentService.MASTER_KEY,
|
data.putByteArray(ApgIntentService.GENERATE_KEY_MASTER_KEY,
|
||||||
PGPConversionHelper.PGPSecretKeyToBytes(masterKey));
|
PGPConversionHelper.PGPSecretKeyToBytes(masterKey));
|
||||||
} else {
|
} else {
|
||||||
passPhrase = "";
|
passPhrase = "";
|
||||||
}
|
}
|
||||||
data.putString(ApgIntentService.SYMMETRIC_PASSPHRASE, passPhrase);
|
data.putString(ApgIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passPhrase);
|
||||||
data.putInt(ApgIntentService.ALGORITHM, mNewKeyAlgorithmChoice.getId());
|
data.putInt(ApgIntentService.GENERATE_KEY_ALGORITHM, mNewKeyAlgorithmChoice.getId());
|
||||||
data.putInt(ApgIntentService.KEY_SIZE, mNewKeySize);
|
data.putInt(ApgIntentService.GENERATE_KEY_KEY_SIZE, mNewKeySize);
|
||||||
|
|
||||||
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
intent.putExtra(ApgIntentService.EXTRA_DATA, data);
|
||||||
|
|
||||||
|