diff options
Diffstat (limited to 'org_apg')
9 files changed, 87 insertions, 274 deletions
diff --git a/org_apg/res/layout/decrypt.xml b/org_apg/res/layout/decrypt.xml index d31c3bdec..055436abd 100644 --- a/org_apg/res/layout/decrypt.xml +++ b/org_apg/res/layout/decrypt.xml @@ -124,58 +124,58 @@ </LinearLayout> </LinearLayout> </ViewFlipper> - </LinearLayout> - </ScrollView> - <LinearLayout - android:id="@+id/signature" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:clickable="true" - android:orientation="horizontal" - android:padding="4dp" - android:paddingLeft="10dp" - android:paddingRight="10dp" > - - <RelativeLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" > - - <ImageView - android:id="@+id/ic_signature" - android:layout_width="wrap_content" + <LinearLayout + android:id="@+id/signature" + android:layout_width="fill_parent" android:layout_height="wrap_content" - android:src="@drawable/signed_large" /> + android:clickable="true" + android:orientation="horizontal" + android:padding="4dp" + android:paddingLeft="10dp" + android:paddingRight="10dp" > - <ImageView - android:id="@+id/ic_signature_status" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:src="@drawable/overlay_error" /> - </RelativeLayout> + <RelativeLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" > - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:orientation="vertical" - android:paddingLeft="5dip" > + <ImageView + android:id="@+id/ic_signature" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/signed_large" /> - <TextView - android:id="@+id/mainUserId" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="left" - android:text="Main User Id" - android:textAppearance="?android:attr/textAppearanceMedium" /> + <ImageView + android:id="@+id/ic_signature_status" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:src="@drawable/overlay_error" /> + </RelativeLayout> - <TextView - android:id="@+id/mainUserIdRest" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_gravity="left" - android:text="Main User Id Rest" - android:textAppearance="?android:attr/textAppearanceSmall" /> + <LinearLayout + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="vertical" + android:paddingLeft="5dip" > + + <TextView + android:id="@+id/mainUserId" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left" + android:text="Main User Id" + android:textAppearance="?android:attr/textAppearanceMedium" /> + + <TextView + android:id="@+id/mainUserIdRest" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="left" + android:text="Main User Id Rest" + android:textAppearance="?android:attr/textAppearanceSmall" /> + </LinearLayout> + </LinearLayout> </LinearLayout> - </LinearLayout> + </ScrollView> </LinearLayout>
\ No newline at end of file diff --git a/org_apg/src/org/thialfihar/android/apg/ApgApplication.java b/org_apg/src/org/thialfihar/android/apg/ApgApplication.java index 149a40b54..9a77efb74 100644 --- a/org_apg/src/org/thialfihar/android/apg/ApgApplication.java +++ b/org_apg/src/org/thialfihar/android/apg/ApgApplication.java @@ -16,6 +16,7 @@ package org.thialfihar.android.apg; +import org.thialfihar.android.apg.helper.PGPMain; import org.thialfihar.android.apg.service.PassphraseCacheService; import android.app.Application; @@ -28,6 +29,10 @@ public class ApgApplication extends Application { /* Start passphrase cache service */ PassphraseCacheService.startCacheService(this); + + // TODO: Do it better than this! + // this initializes the database to be used in PGPMain + PGPMain.initialize(this); } } diff --git a/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java b/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java index 73a587f07..571c61b27 100644 --- a/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java +++ b/org_apg/src/org/thialfihar/android/apg/deprecated/ApgService2.java @@ -428,7 +428,7 @@ public class ApgService2 extends PassphraseCacheService { } private boolean prepareArgs(String pCall, Bundle pArgs, Bundle pReturn) { - PGPMain.initialize(getBaseContext()); + // PGPMain.initialize(getBaseContext()); /* add default return values for all functions */ addDefaultReturns(pReturn); diff --git a/org_apg/src/org/thialfihar/android/apg/helper/OtherHelper.java b/org_apg/src/org/thialfihar/android/apg/helper/OtherHelper.java index 8192331a4..67b4d9c9f 100644 --- a/org_apg/src/org/thialfihar/android/apg/helper/OtherHelper.java +++ b/org_apg/src/org/thialfihar/android/apg/helper/OtherHelper.java @@ -95,7 +95,11 @@ public class OtherHelper { String key = iterator.next(); Object value = bundle.get(key); - Log.d(Constants.TAG, key + " : " + value.toString()); + if (value != null) { + Log.d(Constants.TAG, key + " : " + value.toString()); + } else { + Log.d(Constants.TAG, key + " : null"); + } } Log.d(Constants.TAG, "------------------------------"); } diff --git a/org_apg/src/org/thialfihar/android/apg/service/ApgHandler.java b/org_apg/src/org/thialfihar/android/apg/service/ApgHandler.java index bb9e94938..d69d3fd4b 100644 --- a/org_apg/src/org/thialfihar/android/apg/service/ApgHandler.java +++ b/org_apg/src/org/thialfihar/android/apg/service/ApgHandler.java @@ -31,6 +31,10 @@ public class ApgHandler extends Handler { public static final int MESSAGE_OKAY = 1; public static final int MESSAGE_EXCEPTION = 2; public static final int MESSAGE_UPDATE_PROGRESS = 3; + + // used in decrypt + public static final int MESSAGE_UNKOWN_KEY = 4; + // possible data keys for messages public static final String DATA_ERROR = "error"; diff --git a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java index 59b7d038d..5e7daa48c 100644 --- a/org_apg/src/org/thialfihar/android/apg/service/ApgService.java +++ b/org_apg/src/org/thialfihar/android/apg/service/ApgService.java @@ -320,6 +320,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { break; } + OtherHelper.logDebugBundle(resultData, "resultData"); + sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { sendErrorToHandler(e); @@ -448,6 +450,8 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { break; } + OtherHelper.logDebugBundle(resultData, "resultData"); + sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { sendErrorToHandler(e); @@ -507,6 +511,9 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { Bundle resultData = new Bundle(); resultData.putByteArray(RESULT_NEW_KEY, PGPConversionHelper.PGPSecretKeyRingToBytes(newKeyRing)); + + OtherHelper.logDebugBundle(resultData, "resultData"); + sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { sendErrorToHandler(e); @@ -533,6 +540,9 @@ public class ApgService extends IntentService implements ProgressDialogUpdater { PGPConversionHelper.PGPSecretKeyRingToBytes(masterKeyRing)); resultData.putByteArray(RESULT_NEW_KEY2, PGPConversionHelper.PGPSecretKeyRingToBytes(subKeyRing)); + + OtherHelper.logDebugBundle(resultData, "resultData"); + sendMessageToHandler(ApgHandler.MESSAGE_OKAY, resultData); } catch (Exception e) { sendErrorToHandler(e); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java index 888bb8eda..fa508399d 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/BaseActivity.java @@ -71,7 +71,7 @@ public class BaseActivity extends SherlockFragmentActivity implements Runnable, // not needed later: mPreferences = Preferences.getPreferences(this); - PGPMain.initialize(this); + // PGPMain.initialize(this); if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { File dir = new File(Constants.path.APP_DIR); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java index c3380962c..0c8ef4738 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/DecryptActivity.java @@ -522,7 +522,7 @@ public class DecryptActivity extends SherlockFragmentActivity { 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 secret key ask for it if (getSecretKeyId() == Id.key.symmetric || PGPMain.getCachedPassPhrase(getSecretKeyId()) == null) { showPassphraseDialog(); @@ -664,7 +664,6 @@ public class DecryptActivity extends SherlockFragmentActivity { Id.request.output_filename); mFileDialog.show(getSupportFragmentManager(), "fileDialog"); - } private void decryptStart() { @@ -724,7 +723,7 @@ public class DecryptActivity extends SherlockFragmentActivity { if (message.arg1 == ApgHandler.MESSAGE_OKAY) { // get returned data bundle - Bundle data = message.getData(); + Bundle returnData = message.getData(); mSignatureKeyId = 0; mSignatureLayout.setVisibility(View.GONE); @@ -737,15 +736,15 @@ public class DecryptActivity extends SherlockFragmentActivity { Toast.LENGTH_SHORT).show(); if (mReturnResult) { Intent intent = new Intent(); - intent.putExtras(data); + intent.putExtras(returnData); setResult(RESULT_OK, intent); finish(); return; } switch (mDecryptTarget) { - case Id.target.message: { - String decryptedMessage = data + case Id.target.message: + String decryptedMessage = returnData .getString(ApgService.RESULT_DECRYPTED_MESSAGE); mMessage.setText(decryptedMessage); mMessage.setHorizontallyScrolling(false); @@ -754,9 +753,8 @@ public class DecryptActivity extends SherlockFragmentActivity { // build new action bar invalidateOptionsMenu(); break; - } - case Id.target.file: { + case Id.target.file: if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment @@ -764,17 +762,16 @@ public class DecryptActivity extends SherlockFragmentActivity { deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); } break; - } - default: { + default: // shouldn't happen break; - } + } - if (data.getBoolean(ApgService.RESULT_SIGNATURE)) { - String userId = data.getString(ApgService.RESULT_SIGNATURE_USER_ID); - mSignatureKeyId = data.getLong(ApgService.RESULT_SIGNATURE_KEY_ID); + if (returnData.getBoolean(ApgService.RESULT_SIGNATURE)) { + String userId = returnData.getString(ApgService.RESULT_SIGNATURE_USER_ID); + mSignatureKeyId = returnData.getLong(ApgService.RESULT_SIGNATURE_KEY_ID); mUserIdRest .setText("id: " + PGPHelper.getSmallFingerPrint(mSignatureKeyId)); if (userId == null) { @@ -787,9 +784,9 @@ public class DecryptActivity extends SherlockFragmentActivity { } mUserId.setText(userId); - if (data.getBoolean(ApgService.RESULT_SIGNATURE_SUCCESS)) { + if (returnData.getBoolean(ApgService.RESULT_SIGNATURE_SUCCESS)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - } else if (data.getBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN)) { + } else if (returnData.getBoolean(ApgService.RESULT_SIGNATURE_UNKNOWN)) { mSignatureStatusImage.setImageResource(R.drawable.overlay_error); Toast.makeText(DecryptActivity.this, R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG) @@ -814,159 +811,6 @@ public class DecryptActivity extends SherlockFragmentActivity { startService(intent); } - // @Override - // public void run() { - // String error = null; - // Security.addProvider(new BouncyCastleProvider()); - // - // Bundle data = new Bundle(); - // Message msg = new Message(); - // fillDataSource(); - // fillDataDestination(); - // try { - // InputData in = mDataSource.getInputData(this, true); - // OutputStream out = mDataDestination.getOutputStream(this); - // - // if (mSignedOnly) { - // data = Apg.verifyText(this, in, out, this); - // } else { - // data = Apg.decrypt(this, in, out, Apg.getCachedPassPhrase(getSecretKeyId()), this, - // mAssumeSymmetricEncryption); - // } - // - // out.close(); - // - // if (mDataDestination.getStreamFilename() != null) { - // data.putString(Apg.EXTRA_RESULT_URI, "content://" + DataProvider.AUTHORITY - // + "/data/" + mDataDestination.getStreamFilename()); - // } else if (mDecryptTarget == Id.target.message) { - // if (mReturnBinary) { - // data.putByteArray(Apg.EXTRA_DECRYPTED_DATA, - // ((ByteArrayOutputStream) out).toByteArray()); - // } else { - // data.putString(Apg.EXTRA_DECRYPTED_MESSAGE, new String( - // ((ByteArrayOutputStream) out).toByteArray())); - // } - // } - // } catch (PGPException e) { - // error = "" + e; - // } catch (IOException e) { - // error = "" + e; - // } catch (SignatureException e) { - // error = "" + e; - // } catch (Apg.GeneralException e) { - // error = "" + e; - // } - // - // data.putInt(Constants.extras.STATUS, Id.message.done); - // - // if (error != null) { - // data.putString(Apg.EXTRA_ERROR, error); - // } - // - // msg.setData(data); - // sendMessage(msg); - // } - // - // @Override - // public void handlerCallback(Message msg) { - // Bundle data = msg.getData(); - // if (data == null) { - // return; - // } - // - // if (data.getInt(Constants.extras.STATUS) == Id.message.unknown_signature_key) { - // mUnknownSignatureKeyId = data.getLong(Constants.extras.KEY_ID); - // showDialog(Id.dialog.lookup_unknown_key); - // return; - // } - // - // super.handlerCallback(msg); - // } - // - // @Override - // public void doneCallback(Message msg) { - // super.doneCallback(msg); - // - // Bundle data = msg.getData(); - // removeDialog(Id.dialog.decrypting); - // mSignatureKeyId = 0; - // mSignatureLayout.setVisibility(View.GONE); - // mReplyEnabled = false; - // - // // build new action bar - // invalidateOptionsMenu(); - // - // String error = data.getString(Apg.EXTRA_ERROR); - // if (error != null) { - // Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT) - // .show(); - // return; - // } - // - // Toast.makeText(this, R.string.decryptionSuccessful, Toast.LENGTH_SHORT).show(); - // if (mReturnResult) { - // Intent intent = new Intent(); - // intent.putExtras(data); - // setResult(RESULT_OK, intent); - // finish(); - // return; - // } - // - // switch (mDecryptTarget) { - // case Id.target.message: { - // String decryptedMessage = data.getString(Apg.EXTRA_DECRYPTED_MESSAGE); - // mMessage.setText(decryptedMessage); - // mMessage.setHorizontallyScrolling(false); - // mReplyEnabled = false; - // - // // build new action bar - // invalidateOptionsMenu(); - // break; - // } - // - // case Id.target.file: { - // if (mDeleteAfter.isChecked()) { - // //TODO - // // setDeleteFile(mInputFilename); - // // showDialog(Id.dialog.delete_file); - // } - // break; - // } - // - // default: { - // // shouldn't happen - // break; - // } - // } - // - // if (data.getBoolean(Apg.EXTRA_SIGNATURE)) { - // String userId = data.getString(Apg.EXTRA_SIGNATURE_USER_ID); - // mSignatureKeyId = data.getLong(Apg.EXTRA_SIGNATURE_KEY_ID); - // mUserIdRest.setText("id: " + Apg.getSmallFingerPrint(mSignatureKeyId)); - // if (userId == null) { - // userId = getResources().getString(R.string.unknownUserId); - // } - // String chunks[] = userId.split(" <", 2); - // userId = chunks[0]; - // if (chunks.length > 1) { - // mUserIdRest.setText("<" + chunks[1]); - // } - // mUserId.setText(userId); - // - // if (data.getBoolean(Apg.EXTRA_SIGNATURE_SUCCESS)) { - // mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - // } else if (data.getBoolean(Apg.EXTRA_SIGNATURE_UNKNOWN)) { - // mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - // Toast.makeText(this, R.string.unknownSignatureKeyTouchToLookUp, Toast.LENGTH_LONG) - // .show(); - // } else { - // mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - // } - // mSignatureLayout.setVisibility(View.VISIBLE); - // } - // } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { @@ -998,6 +842,8 @@ public class DecryptActivity extends SherlockFragmentActivity { return; } + // this request is returned after the LookupUnknownKeyDialogFragment was displayed and the + // user choose okay case Id.request.look_up_key_id: { // TODO // PausableThread thread = getRunningThread(); diff --git a/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java b/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java index c151da07c..1e2423bd1 100644 --- a/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java +++ b/org_apg/src/org/thialfihar/android/apg/ui/EditKeyActivity.java @@ -397,62 +397,6 @@ public class EditKeyActivity extends SherlockFragmentActivity { } } - // @Override - // protected Dialog onCreateDialog(int id) { - // switch (id) { - // case Id.dialog.new_pass_phrase: { - // AlertDialog.Builder alert = new AlertDialog.Builder(this); - // - // if (isPassphraseSet()) { - // alert.setTitle(R.string.title_changePassPhrase); - // } else { - // alert.setTitle(R.string.title_setPassPhrase); - // } - // alert.setMessage(R.string.enterPassPhraseTwice); - // - // LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - // View view = inflater.inflate(R.layout.passphrase, null); - // final EditText input1 = (EditText) view.findViewById(R.id.passphrase_passphrase); - // final EditText input2 = (EditText) view.findViewById(R.id.passphrase_passphrase_again); - // - // alert.setView(view); - // - // alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { - // public void onClick(DialogInterface dialog, int id) { - // removeDialog(Id.dialog.new_pass_phrase); - // - // String passPhrase1 = "" + input1.getText(); - // String passPhrase2 = "" + input2.getText(); - // if (!passPhrase1.equals(passPhrase2)) { - // showDialog(Id.dialog.pass_phrases_do_not_match); - // return; - // } - // - // if (passPhrase1.equals("")) { - // showDialog(Id.dialog.no_pass_phrase); - // return; - // } - // - // mNewPassPhrase = passPhrase1; - // updatePassPhraseButtonText(); - // } - // }); - // - // alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { - // public void onClick(DialogInterface dialog, int id) { - // removeDialog(Id.dialog.new_pass_phrase); - // } - // }); - // - // return alert.create(); - // } - // - // default: { - // return super.onCreateDialog(id); - // } - // } - // } - private void saveClicked() { try { if (!isPassphraseSet()) { |