seperating intent action constants into activities as it is best practice, restructering...
This commit is contained in:
@@ -169,7 +169,7 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.GeneralActivity"
|
android:name=".deprecated.GeneralActivity"
|
||||||
android:configChanges="keyboardHidden|orientation|keyboard"
|
android:configChanges="keyboardHidden|orientation|keyboard"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@android:style/Theme.Dialog" >
|
android:theme="@android:style/Theme.Dialog" >
|
||||||
|
|||||||
@@ -21,6 +21,20 @@ import android.os.Environment;
|
|||||||
public final class Constants {
|
public final class Constants {
|
||||||
|
|
||||||
public static final String TAG = "APG";
|
public static final String TAG = "APG";
|
||||||
|
|
||||||
|
public static final String PACKAGE_NAME = "org.thialfihar.android.apg";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO:
|
||||||
|
*
|
||||||
|
* better naming scheme would be:
|
||||||
|
*
|
||||||
|
* - x.action.DECRYPT (with action as preferred in Android)
|
||||||
|
*
|
||||||
|
* - even better and shorter (without .android.): org.apg.action.DECRYPT
|
||||||
|
*/
|
||||||
|
public static final String INTENT_PREFIX = "org.thialfihar.android.apg.intent.";
|
||||||
|
|
||||||
|
|
||||||
public static final class path {
|
public static final class path {
|
||||||
public static final String APP_DIR = Environment.getExternalStorageDirectory() + "/APG";
|
public static final String APP_DIR = Environment.getExternalStorageDirectory() + "/APG";
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ import java.util.Iterator;
|
|||||||
|
|
||||||
import org.thialfihar.android.apg.deprecated.IApgService2;
|
import org.thialfihar.android.apg.deprecated.IApgService2;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.deprecated.IApgService2.Stub;
|
import org.thialfihar.android.apg.deprecated.IApgService2.Stub;
|
||||||
import org.thialfihar.android.apg.Id.database;
|
import org.thialfihar.android.apg.Id.database;
|
||||||
import org.thialfihar.android.apg.R.string;
|
import org.thialfihar.android.apg.R.string;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
||||||
import org.thialfihar.android.apg.provider.KeyRings;
|
import org.thialfihar.android.apg.provider.KeyRings;
|
||||||
import org.thialfihar.android.apg.provider.Keys;
|
import org.thialfihar.android.apg.provider.Keys;
|
||||||
|
|||||||
@@ -0,0 +1,196 @@
|
|||||||
|
///*
|
||||||
|
// * 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.
|
||||||
|
// */
|
||||||
|
//
|
||||||
|
//package org.thialfihar.android.apg.deprecated;
|
||||||
|
//
|
||||||
|
//import java.io.ByteArrayInputStream;
|
||||||
|
//import java.io.FileNotFoundException;
|
||||||
|
//import java.io.IOException;
|
||||||
|
//import java.io.InputStream;
|
||||||
|
//import java.util.Vector;
|
||||||
|
//
|
||||||
|
//import org.thialfihar.android.apg.R;
|
||||||
|
//import org.thialfihar.android.apg.Id;
|
||||||
|
//import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
//import org.thialfihar.android.apg.ui.BaseActivity;
|
||||||
|
//import org.thialfihar.android.apg.ui.DecryptActivity;
|
||||||
|
//import org.thialfihar.android.apg.ui.EncryptActivity;
|
||||||
|
//import org.thialfihar.android.apg.ui.PublicKeyListActivity;
|
||||||
|
//import org.thialfihar.android.apg.ui.SecretKeyListActivity;
|
||||||
|
//import org.thialfihar.android.apg.util.Choice;
|
||||||
|
//
|
||||||
|
//import android.content.Intent;
|
||||||
|
//import android.net.Uri;
|
||||||
|
//import android.os.Bundle;
|
||||||
|
//import android.view.View;
|
||||||
|
//import android.view.View.OnClickListener;
|
||||||
|
//import android.widget.AdapterView;
|
||||||
|
//import android.widget.AdapterView.OnItemClickListener;
|
||||||
|
//import android.widget.ArrayAdapter;
|
||||||
|
//import android.widget.Button;
|
||||||
|
//import android.widget.ListView;
|
||||||
|
//import android.widget.Toast;
|
||||||
|
//
|
||||||
|
//public class GeneralActivity extends BaseActivity {
|
||||||
|
// private Intent mIntent;
|
||||||
|
// private ArrayAdapter<Choice> mAdapter;
|
||||||
|
// private ListView mList;
|
||||||
|
// private Button mCancelButton;
|
||||||
|
// private String mDataString;
|
||||||
|
// private Uri mDataUri;
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
// super.onCreate(savedInstanceState);
|
||||||
|
//
|
||||||
|
// setContentView(R.layout.general);
|
||||||
|
//
|
||||||
|
// mIntent = getIntent();
|
||||||
|
//
|
||||||
|
// InputStream inStream = null;
|
||||||
|
// {
|
||||||
|
// String data = mIntent.getStringExtra(Intent.EXTRA_TEXT);
|
||||||
|
// if (data != null) {
|
||||||
|
// mDataString = data;
|
||||||
|
// inStream = new ByteArrayInputStream(data.getBytes());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (inStream == null) {
|
||||||
|
// Uri data = mIntent.getData();
|
||||||
|
// if (data != null) {
|
||||||
|
// mDataUri = data;
|
||||||
|
// try {
|
||||||
|
// inStream = getContentResolver().openInputStream(data);
|
||||||
|
// } catch (FileNotFoundException e) {
|
||||||
|
// // didn't work
|
||||||
|
// Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT).show();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (inStream == null) {
|
||||||
|
// Toast.makeText(this, "no data found", Toast.LENGTH_SHORT).show();
|
||||||
|
// finish();
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// int contentType = Id.content.unknown;
|
||||||
|
// try {
|
||||||
|
// contentType = PGPHelper.getStreamContent(this, inStream);
|
||||||
|
// inStream.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// // just means that there's no PGP data in there
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// mList = (ListView) findViewById(R.id.options);
|
||||||
|
// Vector<Choice> choices = new Vector<Choice>();
|
||||||
|
//
|
||||||
|
// if (contentType == Id.content.keys) {
|
||||||
|
// choices.add(new Choice(Id.choice.action.import_public,
|
||||||
|
// getString(R.string.action_importPublic)));
|
||||||
|
// choices.add(new Choice(Id.choice.action.import_secret,
|
||||||
|
// getString(R.string.action_importSecret)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (contentType == Id.content.encrypted_data) {
|
||||||
|
// choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (contentType == Id.content.unknown) {
|
||||||
|
// choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// mAdapter = new ArrayAdapter<Choice>(this, android.R.layout.simple_list_item_1, choices);
|
||||||
|
// mList.setAdapter(mAdapter);
|
||||||
|
//
|
||||||
|
// mList.setOnItemClickListener(new OnItemClickListener() {
|
||||||
|
// public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
||||||
|
// clicked(mAdapter.getItem(arg2).getId());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// mCancelButton = (Button) findViewById(R.id.btn_cancel);
|
||||||
|
// mCancelButton.setOnClickListener(new OnClickListener() {
|
||||||
|
// public void onClick(View v) {
|
||||||
|
// GeneralActivity.this.finish();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// if (choices.size() == 1) {
|
||||||
|
// clicked(choices.get(0).getId());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private void clicked(int id) {
|
||||||
|
// Intent intent = new Intent();
|
||||||
|
// switch (id) {
|
||||||
|
// case Id.choice.action.encrypt: {
|
||||||
|
// intent.setClass(this, EncryptActivity.class);
|
||||||
|
// if (mDataString != null) {
|
||||||
|
// intent.setAction(EncryptActivity.ENCRYPT);
|
||||||
|
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
||||||
|
// } else if (mDataUri != null) {
|
||||||
|
// intent.setAction(EncryptActivity.ENCRYPT_FILE);
|
||||||
|
// intent.setDataAndType(mDataUri, mIntent.getType());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case Id.choice.action.decrypt: {
|
||||||
|
// intent.setClass(this, DecryptActivity.class);
|
||||||
|
// if (mDataString != null) {
|
||||||
|
// intent.setAction(DecryptActivity.DECRYPT);
|
||||||
|
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
||||||
|
// } else if (mDataUri != null) {
|
||||||
|
// intent.setAction(DecryptActivity.DECRYPT_FILE);
|
||||||
|
// intent.setDataAndType(mDataUri, mIntent.getType());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case Id.choice.action.import_public: {
|
||||||
|
// intent.setClass(this, PublicKeyListActivity.class);
|
||||||
|
// intent.setAction(PublicKeyListActivity.IMPORT);
|
||||||
|
// if (mDataString != null) {
|
||||||
|
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
||||||
|
// } else if (mDataUri != null) {
|
||||||
|
// intent.setDataAndType(mDataUri, mIntent.getType());
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// case Id.choice.action.import_secret: {
|
||||||
|
// intent.setClass(this, SecretKeyListActivity.class);
|
||||||
|
// intent.setAction(SecretKeyListActivity.IMPORT);
|
||||||
|
// if (mDataString != null) {
|
||||||
|
// intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
||||||
|
// } else if (mDataUri != null) {
|
||||||
|
// intent.setDataAndType(mDataUri, mIntent.getType());
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// default: {
|
||||||
|
// // shouldn't happen
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// startActivity(intent);
|
||||||
|
// finish();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg.deprecated;
|
||||||
|
|
||||||
public class PausableThread extends Thread {
|
public class PausableThread extends Thread {
|
||||||
private boolean mPaused = false;
|
private boolean mPaused = false;
|
||||||
@@ -72,7 +72,6 @@ import org.thialfihar.android.apg.Id.type;
|
|||||||
import org.thialfihar.android.apg.Id.choice.algorithm;
|
import org.thialfihar.android.apg.Id.choice.algorithm;
|
||||||
import org.thialfihar.android.apg.Id.choice.compression;
|
import org.thialfihar.android.apg.Id.choice.compression;
|
||||||
import org.thialfihar.android.apg.Id.choice.usage;
|
import org.thialfihar.android.apg.Id.choice.usage;
|
||||||
import org.thialfihar.android.apg.KeyServer.AddKeyException;
|
|
||||||
import org.thialfihar.android.apg.R.string;
|
import org.thialfihar.android.apg.R.string;
|
||||||
import org.thialfihar.android.apg.passphrase.CachedPassPhrase;
|
import org.thialfihar.android.apg.passphrase.CachedPassPhrase;
|
||||||
import org.thialfihar.android.apg.provider.DataProvider;
|
import org.thialfihar.android.apg.provider.DataProvider;
|
||||||
@@ -85,14 +84,15 @@ import org.thialfihar.android.apg.ui.BaseActivity;
|
|||||||
import org.thialfihar.android.apg.ui.widget.KeyEditor;
|
import org.thialfihar.android.apg.ui.widget.KeyEditor;
|
||||||
import org.thialfihar.android.apg.ui.widget.SectionView;
|
import org.thialfihar.android.apg.ui.widget.SectionView;
|
||||||
import org.thialfihar.android.apg.ui.widget.UserIdEditor;
|
import org.thialfihar.android.apg.ui.widget.UserIdEditor;
|
||||||
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
import org.thialfihar.android.apg.util.InputData;
|
import org.thialfihar.android.apg.util.InputData;
|
||||||
import org.thialfihar.android.apg.util.IterableIterator;
|
import org.thialfihar.android.apg.util.IterableIterator;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer;
|
||||||
import org.thialfihar.android.apg.util.PositionAwareInputStream;
|
import org.thialfihar.android.apg.util.PositionAwareInputStream;
|
||||||
import org.thialfihar.android.apg.util.Primes;
|
import org.thialfihar.android.apg.util.Primes;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.AddKeyException;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.HkpKeyServer;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.KeyServer;
|
|
||||||
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|
||||||
@@ -155,30 +155,6 @@ public class PGPHelper {
|
|||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String PACKAGE_NAME = "org.thialfihar.android.apg";
|
|
||||||
|
|
||||||
private static final String INTENT_PREFIX = "org.thialfihar.android.apg.intent.";
|
|
||||||
|
|
||||||
public static class Intent {
|
|
||||||
public static final String DECRYPT = INTENT_PREFIX + "DECRYPT";
|
|
||||||
public static final String ENCRYPT = INTENT_PREFIX + "ENCRYPT";
|
|
||||||
public static final String DECRYPT_FILE = INTENT_PREFIX + "DECRYPT_FILE";
|
|
||||||
public static final String ENCRYPT_FILE = INTENT_PREFIX + "ENCRYPT_FILE";
|
|
||||||
public static final String DECRYPT_AND_RETURN = INTENT_PREFIX + "DECRYPT_AND_RETURN";
|
|
||||||
public static final String ENCRYPT_AND_RETURN = INTENT_PREFIX + "ENCRYPT_AND_RETURN";
|
|
||||||
public static final String SELECT_PUBLIC_KEYS = INTENT_PREFIX + "SELECT_PUBLIC_KEYS";
|
|
||||||
public static final String SELECT_SECRET_KEY = INTENT_PREFIX + "SELECT_SECRET_KEY";
|
|
||||||
public static final String IMPORT = INTENT_PREFIX + "IMPORT";
|
|
||||||
public static final String LOOK_UP_KEY_ID = INTENT_PREFIX + "LOOK_UP_KEY_ID";
|
|
||||||
public static final String LOOK_UP_KEY_ID_AND_RETURN = INTENT_PREFIX
|
|
||||||
+ "LOOK_UP_KEY_ID_AND_RETURN";
|
|
||||||
public static final String GENERATE_SIGNATURE = INTENT_PREFIX + "GENERATE_SIGNATURE";
|
|
||||||
public static final String EXPORT_KEY_TO_SERVER = INTENT_PREFIX + "EXPORT_KEY_TO_SERVER";
|
|
||||||
public static final String IMPORT_FROM_QR_CODE = INTENT_PREFIX + "IMPORT_FROM_QR_CODE";
|
|
||||||
public static final String CREATE_KEY = INTENT_PREFIX + "CREATE_KEY";
|
|
||||||
public static final String EDIT_KEY = INTENT_PREFIX + "EDIT_KEY";
|
|
||||||
}
|
|
||||||
|
|
||||||
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_ERROR = "error";
|
public static final String EXTRA_ERROR = "error";
|
||||||
@@ -2267,7 +2243,7 @@ public class PGPHelper {
|
|||||||
|
|
||||||
public static boolean isReleaseVersion(Context context) {
|
public static boolean isReleaseVersion(Context context) {
|
||||||
try {
|
try {
|
||||||
PackageInfo pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
|
PackageInfo pi = context.getPackageManager().getPackageInfo(Constants.PACKAGE_NAME, 0);
|
||||||
if (pi.versionCode % 100 == 99) {
|
if (pi.versionCode % 100 == 99) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -2284,7 +2260,7 @@ public class PGPHelper {
|
|||||||
return VERSION;
|
return VERSION;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
PackageInfo pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, 0);
|
PackageInfo pi = context.getPackageManager().getPackageInfo(Constants.PACKAGE_NAME, 0);
|
||||||
VERSION = pi.versionName;
|
VERSION = pi.versionName;
|
||||||
return VERSION;
|
return VERSION;
|
||||||
} catch (NameNotFoundException e) {
|
} catch (NameNotFoundException e) {
|
||||||
|
|||||||
@@ -15,10 +15,16 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg.helper;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
|
import org.thialfihar.android.apg.Constants;
|
||||||
|
import org.thialfihar.android.apg.Id;
|
||||||
|
import org.thialfihar.android.apg.Constants.defaults;
|
||||||
|
import org.thialfihar.android.apg.Constants.pref;
|
||||||
|
import org.thialfihar.android.apg.Id.choice;
|
||||||
|
import org.thialfihar.android.apg.Id.choice.compression;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.passphrase;
|
package org.thialfihar.android.apg.passphrase;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
|
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
|||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.helper.FileHelper;
|
import org.thialfihar.android.apg.helper.FileHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper.GeneralException;
|
import org.thialfihar.android.apg.helper.PGPHelper.GeneralException;
|
||||||
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
import org.thialfihar.android.apg.helper.PGPConversionHelper;
|
||||||
import org.thialfihar.android.apg.provider.DataProvider;
|
import org.thialfihar.android.apg.provider.DataProvider;
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ import java.io.IOException;
|
|||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.PausableThread;
|
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
import org.thialfihar.android.apg.ProgressDialogUpdater;
|
||||||
|
import org.thialfihar.android.apg.deprecated.PausableThread;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.AskForPassphrase;
|
import org.thialfihar.android.apg.passphrase.AskForPassphrase;
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
||||||
|
|
||||||
|
|||||||
@@ -16,17 +16,11 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.ui;
|
package org.thialfihar.android.apg.ui;
|
||||||
|
|
||||||
import org.spongycastle.jce.provider.BouncyCastleProvider;
|
|
||||||
import org.spongycastle.openpgp.PGPException;
|
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.PausableThread;
|
|
||||||
import org.thialfihar.android.apg.helper.FileHelper;
|
import org.thialfihar.android.apg.helper.FileHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
import org.thialfihar.android.apg.helper.OtherHelper;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper.GeneralException;
|
|
||||||
import org.thialfihar.android.apg.provider.DataProvider;
|
|
||||||
import org.thialfihar.android.apg.service.ApgHandler;
|
import org.thialfihar.android.apg.service.ApgHandler;
|
||||||
import org.thialfihar.android.apg.service.ApgService;
|
import org.thialfihar.android.apg.service.ApgService;
|
||||||
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
||||||
@@ -34,7 +28,6 @@ import org.thialfihar.android.apg.ui.dialog.FileDialogFragment;
|
|||||||
import org.thialfihar.android.apg.ui.dialog.PassphraseDialogFragment;
|
import org.thialfihar.android.apg.ui.dialog.PassphraseDialogFragment;
|
||||||
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
import org.thialfihar.android.apg.ui.dialog.ProgressDialogFragment;
|
||||||
import org.thialfihar.android.apg.util.Compatibility;
|
import org.thialfihar.android.apg.util.Compatibility;
|
||||||
import org.thialfihar.android.apg.util.InputData;
|
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|
||||||
import com.actionbarsherlock.app.ActionBar;
|
import com.actionbarsherlock.app.ActionBar;
|
||||||
@@ -45,7 +38,6 @@ import com.actionbarsherlock.view.MenuItem;
|
|||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.ProgressDialog;
|
import android.app.ProgressDialog;
|
||||||
import android.content.ActivityNotFoundException;
|
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@@ -73,12 +65,16 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.security.Security;
|
|
||||||
import java.security.SignatureException;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
public class DecryptActivity extends SherlockFragmentActivity {
|
public class DecryptActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
|
// possible intent actions for this activity
|
||||||
|
public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT";
|
||||||
|
public static final String ACTION_DECRYPT_FILE = Constants.INTENT_PREFIX + "DECRYPT_FILE";
|
||||||
|
public static final String ACTION_DECRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
|
+ "DECRYPT_AND_RETURN";
|
||||||
|
|
||||||
private long mSignatureKeyId = 0;
|
private long mSignatureKeyId = 0;
|
||||||
|
|
||||||
private Intent mIntent;
|
private Intent mIntent;
|
||||||
@@ -191,7 +187,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
final ActionBar actionBar = getSupportActionBar();
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
|
Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
|
||||||
+ getCallingPackage());
|
+ getCallingPackage());
|
||||||
if (getCallingPackage() != null && getCallingPackage().equals(PGPHelper.PACKAGE_NAME)) {
|
if (getCallingPackage() != null && getCallingPackage().equals(Constants.PACKAGE_NAME)) {
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeButtonEnabled(true);
|
actionBar.setHomeButtonEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -282,7 +278,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore, then
|
// ignore, then
|
||||||
}
|
}
|
||||||
} else if (PGPHelper.Intent.DECRYPT.equals(mIntent.getAction())) {
|
} else if (ACTION_DECRYPT.equals(mIntent.getAction())) {
|
||||||
Log.d(Constants.TAG, "Apg Intent DECRYPT startet");
|
Log.d(Constants.TAG, "Apg Intent DECRYPT startet");
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
@@ -328,7 +324,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
mReplyTo = extras.getString(PGPHelper.EXTRA_REPLY_TO);
|
mReplyTo = extras.getString(PGPHelper.EXTRA_REPLY_TO);
|
||||||
mSubject = extras.getString(PGPHelper.EXTRA_SUBJECT);
|
mSubject = extras.getString(PGPHelper.EXTRA_SUBJECT);
|
||||||
} else if (PGPHelper.Intent.DECRYPT_FILE.equals(mIntent.getAction())) {
|
} else if (ACTION_DECRYPT_FILE.equals(mIntent.getAction())) {
|
||||||
mInputFilename = mIntent.getDataString();
|
mInputFilename = mIntent.getDataString();
|
||||||
if ("file".equals(mIntent.getScheme())) {
|
if ("file".equals(mIntent.getScheme())) {
|
||||||
mInputFilename = Uri.decode(mInputFilename.substring(7));
|
mInputFilename = Uri.decode(mInputFilename.substring(7));
|
||||||
@@ -340,7 +336,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
while (mSource.getCurrentView().getId() != R.id.sourceFile) {
|
||||||
mSource.showNext();
|
mSource.showNext();
|
||||||
}
|
}
|
||||||
} else if (PGPHelper.Intent.DECRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
} else if (ACTION_DECRYPT_AND_RETURN.equals(mIntent.getAction())) {
|
||||||
mContentUri = mIntent.getData();
|
mContentUri = mIntent.getData();
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
@@ -405,7 +401,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
PGPPublicKeyRing key = PGPHelper.getPublicKeyRing(mSignatureKeyId);
|
PGPPublicKeyRing key = PGPHelper.getPublicKeyRing(mSignatureKeyId);
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
|
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.LOOK_UP_KEY_ID);
|
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mSignatureKeyId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mSignatureKeyId);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
@@ -521,7 +517,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
mSignedOnly = false;
|
mSignedOnly = false;
|
||||||
|
|
||||||
getDecryptionKeyFromInputStream();
|
getDecryptionKeyFromInputStream();
|
||||||
|
|
||||||
Log.d(Constants.TAG, "secretKeyId: " + getSecretKeyId());
|
Log.d(Constants.TAG, "secretKeyId: " + getSecretKeyId());
|
||||||
|
|
||||||
// if we need a symmetric passphrase or a passphrase to use a sekret key ask for it
|
// if we need a symmetric passphrase or a passphrase to use a sekret key ask for it
|
||||||
@@ -633,7 +629,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
private void replyClicked() {
|
private void replyClicked() {
|
||||||
Intent intent = new Intent(this, EncryptActivity.class);
|
Intent intent = new Intent(this, EncryptActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.ENCRYPT);
|
intent.setAction(EncryptActivity.ACTION_ENCRYPT);
|
||||||
String data = mMessage.getText().toString();
|
String data = mMessage.getText().toString();
|
||||||
data = data.replaceAll("(?m)^", "> ");
|
data = data.replaceAll("(?m)^", "> ");
|
||||||
data = "\n\n" + data;
|
data = "\n\n" + data;
|
||||||
@@ -1047,7 +1043,7 @@ public class DecryptActivity extends SherlockFragmentActivity {
|
|||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
removeDialog(Id.dialog.lookup_unknown_key);
|
removeDialog(Id.dialog.lookup_unknown_key);
|
||||||
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
|
Intent intent = new Intent(DecryptActivity.this, KeyServerQueryActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.LOOK_UP_KEY_ID);
|
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mUnknownSignatureKeyId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, mUnknownSignatureKeyId);
|
||||||
startActivityForResult(intent, Id.request.look_up_key_id);
|
startActivityForResult(intent, Id.request.look_up_key_id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,11 @@ import java.util.Iterator;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class EditKeyActivity extends SherlockFragmentActivity {
|
public class EditKeyActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
|
// possible intent actions for this activity
|
||||||
|
public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEY";
|
||||||
|
public static final String ACTION_EDIT_KEY = Constants.INTENT_PREFIX + "EDIT_KEY";
|
||||||
|
|
||||||
private Intent mIntent = null;
|
private Intent mIntent = null;
|
||||||
private ActionBar mActionBar;
|
private ActionBar mActionBar;
|
||||||
|
|
||||||
@@ -133,7 +138,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
mActionBar.setDisplayShowTitleEnabled(true);
|
mActionBar.setDisplayShowTitleEnabled(true);
|
||||||
|
|
||||||
// set actionbar without home button if called from another app
|
// set actionbar without home button if called from another app
|
||||||
if (getCallingPackage() != null && getCallingPackage().equals(PGPHelper.PACKAGE_NAME)) {
|
if (getCallingPackage() != null && getCallingPackage().equals(Constants.PACKAGE_NAME)) {
|
||||||
mActionBar.setDisplayHomeAsUpEnabled(true);
|
mActionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
mActionBar.setHomeButtonEnabled(true);
|
mActionBar.setHomeButtonEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -154,8 +159,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
|
|
||||||
// Handle intents
|
// Handle intents
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (PGPHelper.Intent.CREATE_KEY.equals(mIntent.getAction())) {
|
if (ACTION_CREATE_KEY.equals(mIntent.getAction())) {
|
||||||
|
|
||||||
mActionBar.setTitle(R.string.title_createKey);
|
mActionBar.setTitle(R.string.title_createKey);
|
||||||
|
|
||||||
mCurrentPassPhrase = "";
|
mCurrentPassPhrase = "";
|
||||||
@@ -244,8 +248,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (PGPHelper.Intent.EDIT_KEY.equals(mIntent.getAction())) {
|
} else if (ACTION_EDIT_KEY.equals(mIntent.getAction())) {
|
||||||
|
|
||||||
mActionBar.setTitle(R.string.title_editKey);
|
mActionBar.setTitle(R.string.title_editKey);
|
||||||
|
|
||||||
mCurrentPassPhrase = PGPHelper.getEditPassPhrase();
|
mCurrentPassPhrase = PGPHelper.getEditPassPhrase();
|
||||||
@@ -468,8 +471,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
* @param userIdsView
|
* @param userIdsView
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Vector<String> getUserIds(SectionView userIdsView)
|
private Vector<String> getUserIds(SectionView userIdsView) throws PGPHelper.GeneralException {
|
||||||
throws PGPHelper.GeneralException {
|
|
||||||
Vector<String> userIds = new Vector<String>();
|
Vector<String> userIds = new Vector<String>();
|
||||||
|
|
||||||
ViewGroup userIdEditors = userIdsView.getEditors();
|
ViewGroup userIdEditors = userIdsView.getEditors();
|
||||||
@@ -507,8 +509,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!gotMainUserId) {
|
if (!gotMainUserId) {
|
||||||
throw new PGPHelper.GeneralException(
|
throw new PGPHelper.GeneralException(getString(R.string.error_mainUserIdMustNotBeEmpty));
|
||||||
getString(R.string.error_mainUserIdMustNotBeEmpty));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return userIds;
|
return userIds;
|
||||||
@@ -520,8 +521,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
* @param keysView
|
* @param keysView
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Vector<PGPSecretKey> getKeys(SectionView keysView)
|
private Vector<PGPSecretKey> getKeys(SectionView keysView) throws PGPHelper.GeneralException {
|
||||||
throws PGPHelper.GeneralException {
|
|
||||||
Vector<PGPSecretKey> keys = new Vector<PGPSecretKey>();
|
Vector<PGPSecretKey> keys = new Vector<PGPSecretKey>();
|
||||||
|
|
||||||
ViewGroup keyEditors = keysView.getEditors();
|
ViewGroup keyEditors = keysView.getEditors();
|
||||||
@@ -544,8 +544,7 @@ public class EditKeyActivity extends SherlockFragmentActivity {
|
|||||||
* @param keysView
|
* @param keysView
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Vector<Integer> getKeysUsages(SectionView keysView)
|
private Vector<Integer> getKeysUsages(SectionView keysView) throws PGPHelper.GeneralException {
|
||||||
throws PGPHelper.GeneralException {
|
|
||||||
Vector<Integer> getKeysUsages = new Vector<Integer>();
|
Vector<Integer> getKeysUsages = new Vector<Integer>();
|
||||||
|
|
||||||
ViewGroup keyEditors = keysView.getEditors();
|
ViewGroup keyEditors = keysView.getEditors();
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
|||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.helper.FileHelper;
|
import org.thialfihar.android.apg.helper.FileHelper;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.service.ApgHandler;
|
import org.thialfihar.android.apg.service.ApgHandler;
|
||||||
import org.thialfihar.android.apg.service.ApgService;
|
import org.thialfihar.android.apg.service.ApgService;
|
||||||
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
import org.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment;
|
||||||
@@ -67,6 +67,15 @@ import java.io.File;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class EncryptActivity extends SherlockFragmentActivity {
|
public class EncryptActivity extends SherlockFragmentActivity {
|
||||||
|
|
||||||
|
// possible intent actions for this activity
|
||||||
|
public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT";
|
||||||
|
public static final String ACTION_ENCRYPT_FILE = Constants.INTENT_PREFIX + "ENCRYPT_FILE";
|
||||||
|
public static final String ACTION_ENCRYPT_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
|
+ "ENCRYPT_AND_RETURN";
|
||||||
|
public static final String ACTION_GENERATE_SIGNATURE = Constants.INTENT_PREFIX
|
||||||
|
+ "GENERATE_SIGNATURE";
|
||||||
|
|
||||||
private Intent mIntent = null;
|
private Intent mIntent = null;
|
||||||
private String mSubject = null;
|
private String mSubject = null;
|
||||||
private String mSendTo = null;
|
private String mSendTo = null;
|
||||||
@@ -185,7 +194,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
final ActionBar actionBar = getSupportActionBar();
|
final ActionBar actionBar = getSupportActionBar();
|
||||||
Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
|
Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)="
|
||||||
+ getCallingPackage());
|
+ getCallingPackage());
|
||||||
if (getCallingPackage() != null && getCallingPackage().equals(PGPHelper.PACKAGE_NAME)) {
|
if (getCallingPackage() != null && getCallingPackage().equals(Constants.PACKAGE_NAME)) {
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
actionBar.setHomeButtonEnabled(true);
|
actionBar.setHomeButtonEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
@@ -335,22 +344,22 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
mIntent = getIntent();
|
mIntent = getIntent();
|
||||||
if (PGPHelper.Intent.ENCRYPT.equals(mIntent.getAction())
|
if (ACTION_ENCRYPT.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.ENCRYPT_FILE.equals(mIntent.getAction())
|
|| ACTION_ENCRYPT_FILE.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
|| ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||||
mContentUri = mIntent.getData();
|
mContentUri = mIntent.getData();
|
||||||
Bundle extras = mIntent.getExtras();
|
Bundle extras = mIntent.getExtras();
|
||||||
if (extras == null) {
|
if (extras == null) {
|
||||||
extras = new Bundle();
|
extras = new Bundle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PGPHelper.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
if (ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||||
mReturnResult = true;
|
mReturnResult = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PGPHelper.Intent.GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
if (ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||||
mGenerateSignature = true;
|
mGenerateSignature = true;
|
||||||
mOverrideAsciiArmour = true;
|
mOverrideAsciiArmour = true;
|
||||||
mAsciiArmourDemand = false;
|
mAsciiArmourDemand = false;
|
||||||
@@ -411,9 +420,9 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PGPHelper.Intent.ENCRYPT.equals(mIntent.getAction())
|
if (ACTION_ENCRYPT.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
|| ACTION_ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||||
|| PGPHelper.Intent.GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
|| ACTION_GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||||
if (textData != null) {
|
if (textData != null) {
|
||||||
mMessage.setText(textData);
|
mMessage.setText(textData);
|
||||||
}
|
}
|
||||||
@@ -422,7 +431,7 @@ public class EncryptActivity extends SherlockFragmentActivity {
|
|||||||
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
while (mSource.getCurrentView().getId() != R.id.sourceMessage) {
|
||||||
mSource.showNext();
|
mSource.showNext();
|
||||||
}
|
}
|
||||||
} else if (PGPHelper.Intent.ENCRYPT_FILE.equals(mIntent.getAction())) {
|
} else if (ACTION_ENCRYPT_FILE.equals(mIntent.getAction())) {
|
||||||
if ("file".equals(mIntent.getScheme())) {
|
if ("file".equals(mIntent.getScheme())) {
|
||||||
mInputFilename = Uri.decode(mIntent.getDataString().replace("file://", ""));
|
mInputFilename = Uri.decode(mIntent.getDataString().replace("file://", ""));
|
||||||
mFilename.setText(mInputFilename);
|
mFilename.setText(mInputFilename);
|
||||||
|
|||||||
@@ -1,191 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.thialfihar.android.apg.ui;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.thialfihar.android.apg.R;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
|
||||||
import org.thialfihar.android.apg.util.Choice;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
public class GeneralActivity extends BaseActivity {
|
|
||||||
private Intent mIntent;
|
|
||||||
private ArrayAdapter<Choice> mAdapter;
|
|
||||||
private ListView mList;
|
|
||||||
private Button mCancelButton;
|
|
||||||
private String mDataString;
|
|
||||||
private Uri mDataUri;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
setContentView(R.layout.general);
|
|
||||||
|
|
||||||
mIntent = getIntent();
|
|
||||||
|
|
||||||
InputStream inStream = null;
|
|
||||||
{
|
|
||||||
String data = mIntent.getStringExtra(Intent.EXTRA_TEXT);
|
|
||||||
if (data != null) {
|
|
||||||
mDataString = data;
|
|
||||||
inStream = new ByteArrayInputStream(data.getBytes());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inStream == null) {
|
|
||||||
Uri data = mIntent.getData();
|
|
||||||
if (data != null) {
|
|
||||||
mDataUri = data;
|
|
||||||
try {
|
|
||||||
inStream = getContentResolver().openInputStream(data);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
// didn't work
|
|
||||||
Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (inStream == null) {
|
|
||||||
Toast.makeText(this, "no data found", Toast.LENGTH_SHORT).show();
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int contentType = Id.content.unknown;
|
|
||||||
try {
|
|
||||||
contentType = PGPHelper.getStreamContent(this, inStream);
|
|
||||||
inStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
// just means that there's no PGP data in there
|
|
||||||
}
|
|
||||||
|
|
||||||
mList = (ListView) findViewById(R.id.options);
|
|
||||||
Vector<Choice> choices = new Vector<Choice>();
|
|
||||||
|
|
||||||
if (contentType == Id.content.keys) {
|
|
||||||
choices.add(new Choice(Id.choice.action.import_public,
|
|
||||||
getString(R.string.action_importPublic)));
|
|
||||||
choices.add(new Choice(Id.choice.action.import_secret,
|
|
||||||
getString(R.string.action_importSecret)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType == Id.content.encrypted_data) {
|
|
||||||
choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contentType == Id.content.unknown) {
|
|
||||||
choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt)));
|
|
||||||
}
|
|
||||||
|
|
||||||
mAdapter = new ArrayAdapter<Choice>(this, android.R.layout.simple_list_item_1, choices);
|
|
||||||
mList.setAdapter(mAdapter);
|
|
||||||
|
|
||||||
mList.setOnItemClickListener(new OnItemClickListener() {
|
|
||||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
|
|
||||||
clicked(mAdapter.getItem(arg2).getId());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mCancelButton = (Button) findViewById(R.id.btn_cancel);
|
|
||||||
mCancelButton.setOnClickListener(new OnClickListener() {
|
|
||||||
public void onClick(View v) {
|
|
||||||
GeneralActivity.this.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (choices.size() == 1) {
|
|
||||||
clicked(choices.get(0).getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void clicked(int id) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
switch (id) {
|
|
||||||
case Id.choice.action.encrypt: {
|
|
||||||
intent.setClass(this, EncryptActivity.class);
|
|
||||||
if (mDataString != null) {
|
|
||||||
intent.setAction(PGPHelper.Intent.ENCRYPT);
|
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
|
||||||
} else if (mDataUri != null) {
|
|
||||||
intent.setAction(PGPHelper.Intent.ENCRYPT_FILE);
|
|
||||||
intent.setDataAndType(mDataUri, mIntent.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Id.choice.action.decrypt: {
|
|
||||||
intent.setClass(this, DecryptActivity.class);
|
|
||||||
if (mDataString != null) {
|
|
||||||
intent.setAction(PGPHelper.Intent.DECRYPT);
|
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
|
||||||
} else if (mDataUri != null) {
|
|
||||||
intent.setAction(PGPHelper.Intent.DECRYPT_FILE);
|
|
||||||
intent.setDataAndType(mDataUri, mIntent.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Id.choice.action.import_public: {
|
|
||||||
intent.setClass(this, PublicKeyListActivity.class);
|
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT);
|
|
||||||
if (mDataString != null) {
|
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
|
||||||
} else if (mDataUri != null) {
|
|
||||||
intent.setDataAndType(mDataUri, mIntent.getType());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Id.choice.action.import_secret: {
|
|
||||||
intent.setClass(this, SecretKeyListActivity.class);
|
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT);
|
|
||||||
if (mDataString != null) {
|
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mDataString);
|
|
||||||
} else if (mDataUri != null) {
|
|
||||||
intent.setDataAndType(mDataUri, mIntent.getType());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
|
||||||
// shouldn't happen
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startActivity(intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,10 +22,10 @@ import java.io.IOException;
|
|||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
import org.spongycastle.openpgp.PGPKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.HkpKeyServer;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.KeyServer.QueryException;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.QueryException;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -38,6 +38,11 @@ import com.google.zxing.integration.android.IntentIntegrator;
|
|||||||
import com.google.zxing.integration.android.IntentResult;
|
import com.google.zxing.integration.android.IntentResult;
|
||||||
|
|
||||||
public class ImportFromQRCodeActivity extends BaseActivity {
|
public class ImportFromQRCodeActivity extends BaseActivity {
|
||||||
|
|
||||||
|
// Not used in sourcode, but listed in AndroidManifest!
|
||||||
|
public static final String IMPORT_FROM_QR_CODE = Constants.INTENT_PREFIX
|
||||||
|
+ "IMPORT_FROM_QR_CODE";
|
||||||
|
|
||||||
private static final String TAG = "ImportFromQRCodeActivity";
|
private static final String TAG = "ImportFromQRCodeActivity";
|
||||||
|
|
||||||
private final Bundle status = new Bundle();
|
private final Bundle status = new Bundle();
|
||||||
@@ -52,34 +57,46 @@ public class ImportFromQRCodeActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void importAndSign(final long keyId, final String expectedFingerprint) {
|
private void importAndSign(final long keyId, final String expectedFingerprint) {
|
||||||
if (expectedFingerprint != null && expectedFingerprint.length() > 0) {
|
if (expectedFingerprint != null && expectedFingerprint.length() > 0) {
|
||||||
|
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
// TODO: display some sort of spinner here while the user waits
|
// TODO: display some sort of spinner here while the user waits
|
||||||
|
|
||||||
HkpKeyServer server = new HkpKeyServer(mPreferences.getKeyServers()[0]); // TODO: there should be only 1
|
HkpKeyServer server = new HkpKeyServer(mPreferences.getKeyServers()[0]); // TODO:
|
||||||
|
// there
|
||||||
|
// should
|
||||||
|
// be
|
||||||
|
// only
|
||||||
|
// 1
|
||||||
String encodedKey = server.get(keyId);
|
String encodedKey = server.get(keyId);
|
||||||
|
|
||||||
PGPKeyRing keyring = PGPHelper.decodeKeyRing(new ByteArrayInputStream(encodedKey.getBytes()));
|
PGPKeyRing keyring = PGPHelper.decodeKeyRing(new ByteArrayInputStream(
|
||||||
|
encodedKey.getBytes()));
|
||||||
if (keyring != null && keyring instanceof PGPPublicKeyRing) {
|
if (keyring != null && keyring instanceof PGPPublicKeyRing) {
|
||||||
PGPPublicKeyRing publicKeyRing = (PGPPublicKeyRing) keyring;
|
PGPPublicKeyRing publicKeyRing = (PGPPublicKeyRing) keyring;
|
||||||
|
|
||||||
// make sure the fingerprints match before we cache this thing
|
// make sure the fingerprints match before we cache this thing
|
||||||
String actualFingerprint = PGPHelper.convertToHex(publicKeyRing.getPublicKey().getFingerprint());
|
String actualFingerprint = PGPHelper.convertToHex(publicKeyRing
|
||||||
|
.getPublicKey().getFingerprint());
|
||||||
if (expectedFingerprint.equals(actualFingerprint)) {
|
if (expectedFingerprint.equals(actualFingerprint)) {
|
||||||
// store the signed key in our local cache
|
// store the signed key in our local cache
|
||||||
int retval = PGPHelper.storeKeyRingInCache(publicKeyRing);
|
int retval = PGPHelper.storeKeyRingInCache(publicKeyRing);
|
||||||
if (retval != Id.return_value.ok && retval != Id.return_value.updated) {
|
if (retval != Id.return_value.ok
|
||||||
status.putString(PGPHelper.EXTRA_ERROR, "Failed to store signed key in local cache");
|
&& retval != Id.return_value.updated) {
|
||||||
|
status.putString(PGPHelper.EXTRA_ERROR,
|
||||||
|
"Failed to store signed key in local cache");
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(ImportFromQRCodeActivity.this, SignKeyActivity.class);
|
Intent intent = new Intent(ImportFromQRCodeActivity.this,
|
||||||
|
SignKeyActivity.class);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
||||||
startActivityForResult(intent, Id.request.sign_key);
|
startActivityForResult(intent, Id.request.sign_key);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status.putString(PGPHelper.EXTRA_ERROR, "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
status.putString(
|
||||||
|
PGPHelper.EXTRA_ERROR,
|
||||||
|
"Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (QueryException e) {
|
} catch (QueryException e) {
|
||||||
@@ -103,48 +120,52 @@ public class ImportFromQRCodeActivity extends BaseActivity {
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case IntentIntegrator.REQUEST_CODE: {
|
case IntentIntegrator.REQUEST_CODE: {
|
||||||
boolean debug = true; // TODO: remove this!!!
|
boolean debug = true; // TODO: remove this!!!
|
||||||
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode, data);
|
IntentResult scanResult = IntentIntegrator.parseActivityResult(requestCode, resultCode,
|
||||||
if (debug || (scanResult != null && scanResult.getFormatName() != null)) {
|
data);
|
||||||
String[] bits = debug ? new String[] { "5993515643896327656", "0816 F68A 6816 68FB 01BF 2CA5 532D 3EB9 1E2F EDE8" } : scanResult.getContents().split(",");
|
if (debug || (scanResult != null && scanResult.getFormatName() != null)) {
|
||||||
if (bits.length != 2) {
|
String[] bits = debug ? new String[] { "5993515643896327656",
|
||||||
return; // dont know how to handle this. Not a valid code
|
"0816 F68A 6816 68FB 01BF 2CA5 532D 3EB9 1E2F EDE8" } : scanResult
|
||||||
}
|
.getContents().split(",");
|
||||||
|
if (bits.length != 2) {
|
||||||
long keyId = Long.parseLong(bits[0]);
|
return; // dont know how to handle this. Not a valid code
|
||||||
String expectedFingerprint = bits[1];
|
|
||||||
|
|
||||||
importAndSign(keyId, expectedFingerprint);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
long keyId = Long.parseLong(bits[0]);
|
||||||
case Id.request.sign_key: {
|
String expectedFingerprint = bits[1];
|
||||||
// signals the end of processing. Signature was either applied, or it wasnt
|
|
||||||
status.putInt(Constants.extras.STATUS, Id.message.done);
|
importAndSign(keyId, expectedFingerprint);
|
||||||
|
|
||||||
msg.setData(status);
|
|
||||||
sendMessage(msg);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
case Id.request.sign_key: {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
// signals the end of processing. Signature was either applied, or it wasnt
|
||||||
}
|
status.putInt(Constants.extras.STATUS, Id.message.done);
|
||||||
|
|
||||||
|
msg.setData(status);
|
||||||
|
sendMessage(msg);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doneCallback(Message msg) {
|
public void doneCallback(Message msg) {
|
||||||
super.doneCallback(msg);
|
super.doneCallback(msg);
|
||||||
|
|
||||||
Bundle data = msg.getData();
|
Bundle data = msg.getData();
|
||||||
String error = data.getString(PGPHelper.EXTRA_ERROR);
|
String error = data.getString(PGPHelper.EXTRA_ERROR);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
|
||||||
|
.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ import java.io.OutputStream;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class KeyListActivity extends BaseActivity {
|
public class KeyListActivity extends BaseActivity {
|
||||||
|
|
||||||
|
public static final String ACTION_IMPORT = Constants.INTENT_PREFIX + "IMPORT";
|
||||||
|
|
||||||
protected ExpandableListView mList;
|
protected ExpandableListView mList;
|
||||||
protected KeyListAdapter mListAdapter;
|
protected KeyListAdapter mListAdapter;
|
||||||
protected View mFilterLayout;
|
protected View mFilterLayout;
|
||||||
@@ -139,7 +142,7 @@ public class KeyListActivity extends BaseActivity {
|
|||||||
mListAdapter = new KeyListAdapter(this, searchString);
|
mListAdapter = new KeyListAdapter(this, searchString);
|
||||||
mList.setAdapter(mListAdapter);
|
mList.setAdapter(mListAdapter);
|
||||||
|
|
||||||
if (PGPHelper.Intent.IMPORT.equals(intent.getAction())) {
|
if (ACTION_IMPORT.equals(intent.getAction())) {
|
||||||
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
|
if ("file".equals(intent.getScheme()) && intent.getDataString() != null) {
|
||||||
mImportFilename = Uri.decode(intent.getDataString().replace("file://", ""));
|
mImportFilename = Uri.decode(intent.getDataString().replace("file://", ""));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ package org.thialfihar.android.apg.ui;
|
|||||||
import org.spongycastle.openpgp.PGPKeyRing;
|
import org.spongycastle.openpgp.PGPKeyRing;
|
||||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.HkpKeyServer;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
@@ -43,6 +43,10 @@ import android.widget.Toast;
|
|||||||
*/
|
*/
|
||||||
public class KeyServerExportActivity extends BaseActivity {
|
public class KeyServerExportActivity extends BaseActivity {
|
||||||
|
|
||||||
|
// Not used in sourcode, but listed in AndroidManifest!
|
||||||
|
public static final String ACTION_EXPORT_KEY_TO_SERVER = Constants.INTENT_PREFIX
|
||||||
|
+ "EXPORT_KEY_TO_SERVER";
|
||||||
|
|
||||||
private Button export;
|
private Button export;
|
||||||
private Spinner keyServer;
|
private Spinner keyServer;
|
||||||
|
|
||||||
|
|||||||
@@ -19,13 +19,13 @@ import java.util.Vector;
|
|||||||
|
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.HkpKeyServer;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.KeyServer.InsufficientQuery;
|
|
||||||
import org.thialfihar.android.apg.KeyServer.KeyInfo;
|
|
||||||
import org.thialfihar.android.apg.KeyServer.QueryException;
|
|
||||||
import org.thialfihar.android.apg.KeyServer.TooManyResponses;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.InsufficientQuery;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.KeyInfo;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.QueryException;
|
||||||
|
import org.thialfihar.android.apg.util.KeyServer.TooManyResponses;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
@@ -54,6 +54,12 @@ import android.widget.TextView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class KeyServerQueryActivity extends BaseActivity {
|
public class KeyServerQueryActivity extends BaseActivity {
|
||||||
|
|
||||||
|
// possible intent actions for this activity
|
||||||
|
public static final String ACTION_LOOK_UP_KEY_ID = Constants.INTENT_PREFIX + "LOOK_UP_KEY_ID";
|
||||||
|
public static final String ACTION_LOOK_UP_KEY_ID_AND_RETURN = Constants.INTENT_PREFIX
|
||||||
|
+ "LOOK_UP_KEY_ID_AND_RETURN";
|
||||||
|
|
||||||
private ListView mList;
|
private ListView mList;
|
||||||
private EditText mQuery;
|
private EditText mQuery;
|
||||||
private Button mSearch;
|
private Button mSearch;
|
||||||
@@ -121,8 +127,8 @@ public class KeyServerQueryActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (PGPHelper.Intent.LOOK_UP_KEY_ID.equals(intent.getAction())
|
if (ACTION_LOOK_UP_KEY_ID.equals(intent.getAction())
|
||||||
|| PGPHelper.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) {
|
|| ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(intent.getAction())) {
|
||||||
long keyId = intent.getLongExtra(PGPHelper.EXTRA_KEY_ID, 0);
|
long keyId = intent.getLongExtra(PGPHelper.EXTRA_KEY_ID, 0);
|
||||||
if (keyId != 0) {
|
if (keyId != 0) {
|
||||||
String query = "0x" + PGPHelper.keyToHex(keyId);
|
String query = "0x" + PGPHelper.keyToHex(keyId);
|
||||||
@@ -208,7 +214,7 @@ public class KeyServerQueryActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
} else if (mQueryType == Id.keyserver.get) {
|
} else if (mQueryType == Id.keyserver.get) {
|
||||||
Intent orgIntent = getIntent();
|
Intent orgIntent = getIntent();
|
||||||
if (PGPHelper.Intent.LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) {
|
if (ACTION_LOOK_UP_KEY_ID_AND_RETURN.equals(orgIntent.getAction())) {
|
||||||
if (mKeyData != null) {
|
if (mKeyData != null) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData);
|
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData);
|
||||||
@@ -220,7 +226,7 @@ public class KeyServerQueryActivity extends BaseActivity {
|
|||||||
} else {
|
} else {
|
||||||
if (mKeyData != null) {
|
if (mKeyData != null) {
|
||||||
Intent intent = new Intent(this, PublicKeyListActivity.class);
|
Intent intent = new Intent(this, PublicKeyListActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT);
|
intent.setAction(KeyListActivity.ACTION_IMPORT);
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData);
|
intent.putExtra(PGPHelper.EXTRA_TEXT, mKeyData);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import java.util.Vector;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
|
|
||||||
import android.app.ListActivity;
|
import android.app.ListActivity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@@ -149,7 +149,7 @@ public class MailListActivity extends ListActivity {
|
|||||||
getListView().setOnItemClickListener(new OnItemClickListener() {
|
getListView().setOnItemClickListener(new OnItemClickListener() {
|
||||||
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
|
||||||
Intent intent = new Intent(MailListActivity.this, DecryptActivity.class);
|
Intent intent = new Intent(MailListActivity.this, DecryptActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.DECRYPT);
|
intent.setAction(DecryptActivity.ACTION_DECRYPT);
|
||||||
Message message = (Message) ((MailboxAdapter) getListAdapter()).getItem(position);
|
Message message = (Message) ((MailboxAdapter) getListAdapter()).getItem(position);
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, message.data);
|
intent.putExtra(PGPHelper.EXTRA_TEXT, message.data);
|
||||||
intent.putExtra(PGPHelper.EXTRA_SUBJECT, message.subject);
|
intent.putExtra(PGPHelper.EXTRA_SUBJECT, message.subject);
|
||||||
|
|||||||
@@ -48,19 +48,19 @@ public class MainActivity extends SherlockActivity {
|
|||||||
|
|
||||||
public void encryptOnClick(View view) {
|
public void encryptOnClick(View view) {
|
||||||
Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
|
Intent intent = new Intent(MainActivity.this, EncryptActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.ENCRYPT);
|
intent.setAction(EncryptActivity.ACTION_ENCRYPT);
|
||||||
startActivityForResult(intent, 0); // used instead of startActivity to get callingPackage
|
startActivityForResult(intent, 0); // used instead of startActivity to get callingPackage
|
||||||
}
|
}
|
||||||
|
|
||||||
public void decryptOnClick(View view) {
|
public void decryptOnClick(View view) {
|
||||||
Intent intent = new Intent(MainActivity.this, DecryptActivity.class);
|
Intent intent = new Intent(MainActivity.this, DecryptActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.DECRYPT);
|
intent.setAction(DecryptActivity.ACTION_DECRYPT);
|
||||||
startActivityForResult(intent, 0); // used instead of startActivity to get callingPackage
|
startActivityForResult(intent, 0); // used instead of startActivity to get callingPackage
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scanQrcodeOnClick(View view) {
|
public void scanQrcodeOnClick(View view) {
|
||||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT_FROM_QR_CODE);
|
intent.setAction(ImportFromQRCodeActivity.IMPORT_FROM_QR_CODE);
|
||||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ import org.spongycastle.bcpg.HashAlgorithmTags;
|
|||||||
import org.spongycastle.openpgp.PGPEncryptedData;
|
import org.spongycastle.openpgp.PGPEncryptedData;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.Preferences;
|
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.helper.Preferences;
|
||||||
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
import org.thialfihar.android.apg.passphrase.PassphraseCacheService;
|
||||||
import org.thialfihar.android.apg.ui.widget.IntegerListPreference;
|
import org.thialfihar.android.apg.ui.widget.IntegerListPreference;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class PublicKeyListActivity extends KeyListActivity {
|
|||||||
}
|
}
|
||||||
case Id.menu.option.scanQRCode: {
|
case Id.menu.option.scanQRCode: {
|
||||||
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
Intent intent = new Intent(this, ImportFromQRCodeActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT_FROM_QR_CODE);
|
intent.setAction(ImportFromQRCodeActivity.IMPORT_FROM_QR_CODE);
|
||||||
startActivityForResult(intent, Id.request.import_from_qr_code);
|
startActivityForResult(intent, Id.request.import_from_qr_code);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -124,7 +124,7 @@ public class PublicKeyListActivity extends KeyListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(this, KeyServerQueryActivity.class);
|
Intent intent = new Intent(this, KeyServerQueryActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.LOOK_UP_KEY_ID_AND_RETURN);
|
intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID_AND_RETURN);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
||||||
startActivityForResult(intent, Id.request.look_up_key_id);
|
startActivityForResult(intent, Id.request.look_up_key_id);
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ public class PublicKeyListActivity extends KeyListActivity {
|
|||||||
final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
|
final int keyRingId = mListAdapter.getKeyRingId(groupPosition);
|
||||||
|
|
||||||
Intent intent = new Intent(this, KeyServerExportActivity.class);
|
Intent intent = new Intent(this, KeyServerExportActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.EXPORT_KEY_TO_SERVER);
|
intent.setAction(KeyServerExportActivity.ACTION_EXPORT_KEY_TO_SERVER);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyRingId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyRingId);
|
||||||
startActivityForResult(intent, Id.request.export_to_server);
|
startActivityForResult(intent, Id.request.export_to_server);
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ public class PublicKeyListActivity extends KeyListActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = new Intent(this, PublicKeyListActivity.class);
|
Intent intent = new Intent(this, PublicKeyListActivity.class);
|
||||||
intent.setAction(PGPHelper.Intent.IMPORT);
|
intent.setAction(PublicKeyListActivity.ACTION_IMPORT);
|
||||||
intent.putExtra(PGPHelper.EXTRA_TEXT, data.getStringExtra(PGPHelper.EXTRA_TEXT));
|
intent.putExtra(PGPHelper.EXTRA_TEXT, data.getStringExtra(PGPHelper.EXTRA_TEXT));
|
||||||
handleIntent(intent);
|
handleIntent(intent);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -164,13 +164,13 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli
|
|||||||
|
|
||||||
private void createKey() {
|
private void createKey() {
|
||||||
PGPHelper.setEditPassPhrase("");
|
PGPHelper.setEditPassPhrase("");
|
||||||
Intent intent = new Intent(PGPHelper.Intent.CREATE_KEY);
|
Intent intent = new Intent(EditKeyActivity.ACTION_CREATE_KEY);
|
||||||
startActivityForResult(intent, Id.message.create_key);
|
startActivityForResult(intent, Id.message.create_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editKey() {
|
private void editKey() {
|
||||||
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
|
long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem);
|
||||||
Intent intent = new Intent(PGPHelper.Intent.EDIT_KEY);
|
Intent intent = new Intent(EditKeyActivity.ACTION_EDIT_KEY);
|
||||||
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
intent.putExtra(PGPHelper.EXTRA_KEY_ID, keyId);
|
||||||
startActivityForResult(intent, Id.message.edit_key);
|
startActivityForResult(intent, Id.message.edit_key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.thialfihar.android.apg.ui;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
@@ -37,6 +38,11 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class SelectPublicKeyListActivity extends BaseActivity {
|
public class SelectPublicKeyListActivity extends BaseActivity {
|
||||||
|
|
||||||
|
// Not used in sourcode, but listed in AndroidManifest!
|
||||||
|
public static final String ACTION_SELECT_PUBLIC_KEYS = Constants.INTENT_PREFIX
|
||||||
|
+ "SELECT_PUBLIC_KEYS";
|
||||||
|
|
||||||
protected ListView mList;
|
protected ListView mList;
|
||||||
protected SelectPublicKeyListAdapter mListAdapter;
|
protected SelectPublicKeyListAdapter mListAdapter;
|
||||||
protected View mFilterLayout;
|
protected View mFilterLayout;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.thialfihar.android.apg.ui;
|
package org.thialfihar.android.apg.ui;
|
||||||
|
|
||||||
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
@@ -36,6 +37,11 @@ import android.widget.ListView;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class SelectSecretKeyListActivity extends BaseActivity {
|
public class SelectSecretKeyListActivity extends BaseActivity {
|
||||||
|
|
||||||
|
// Not used in sourcode, but listed in AndroidManifest!
|
||||||
|
public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX
|
||||||
|
+ "SELECT_SECRET_KEY";
|
||||||
|
|
||||||
protected ListView mList;
|
protected ListView mList;
|
||||||
protected SelectSecretKeyListAdapter mListAdapter;
|
protected SelectSecretKeyListAdapter mListAdapter;
|
||||||
protected View mFilterLayout;
|
protected View mFilterLayout;
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator;
|
|||||||
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
import org.spongycastle.openpgp.PGPSignatureSubpacketVector;
|
||||||
import org.spongycastle.openpgp.PGPUtil;
|
import org.spongycastle.openpgp.PGPUtil;
|
||||||
import org.thialfihar.android.apg.Constants;
|
import org.thialfihar.android.apg.Constants;
|
||||||
import org.thialfihar.android.apg.HkpKeyServer;
|
|
||||||
import org.thialfihar.android.apg.Id;
|
import org.thialfihar.android.apg.Id;
|
||||||
import org.thialfihar.android.apg.R;
|
import org.thialfihar.android.apg.R;
|
||||||
import org.thialfihar.android.apg.helper.PGPHelper;
|
import org.thialfihar.android.apg.helper.PGPHelper;
|
||||||
|
import org.thialfihar.android.apg.util.HkpKeyServer;
|
||||||
|
|
||||||
import com.actionbarsherlock.view.MenuItem;
|
import com.actionbarsherlock.view.MenuItem;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg.util;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.thialfihar.android.apg;
|
package org.thialfihar.android.apg.util;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
Reference in New Issue
Block a user