mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
fix signature view, cleanup
This commit is contained in:
parent
86bcdc046e
commit
3995c96149
@ -124,58 +124,58 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ViewFlipper>
|
||||
|
||||
<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"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/signed_large" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ic_signature_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/overlay_error" />
|
||||
</RelativeLayout>
|
||||
|
||||
<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>
|
||||
</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"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/signed_large" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ic_signature_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/overlay_error" />
|
||||
</RelativeLayout>
|
||||
|
||||
<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>
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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, "------------------------------");
|
||||
}
|
||||
|
@ -32,6 +32,10 @@ public class ApgHandler extends Handler {
|
||||
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";
|
||||
public static final String DATA_PROGRESS = "progress";
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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()) {
|
||||
|
Loading…
Reference in New Issue
Block a user