diff --git a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java index cbd829578..8a5d37c8f 100644 --- a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java +++ b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java @@ -24,7 +24,6 @@ import org.openintents.crypto.CryptoServiceConnection; import org.openintents.crypto.CryptoSignatureResult; import org.openintents.crypto.ICryptoCallback; import org.openintents.crypto.ICryptoService; -import org.sufficientlysecure.keychain.demo.R; import org.sufficientlysecure.keychain.integration.Constants; import android.app.Activity; @@ -35,15 +34,14 @@ import android.content.pm.ResolveInfo; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.RemoteException; -import android.text.method.ScrollingMovementMethod; import android.util.Log; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListAdapter; -import android.widget.Scroller; import android.widget.TextView; +import android.widget.Toast; public class CryptoProviderDemoActivity extends Activity { Activity mActivity; @@ -83,15 +81,13 @@ public class CryptoProviderDemoActivity extends Activity { @Override public void run() { mCiphertext.setText(new String(outputBytes)); - } }); } @Override public void onError(CryptoError error) throws RemoteException { - Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId()); - Log.e(Constants.TAG, "onError getMessage:" + error.getMessage()); + handleError(error); } }; @@ -116,12 +112,18 @@ public class CryptoProviderDemoActivity extends Activity { @Override public void onError(CryptoError error) throws RemoteException { - Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId()); - Log.e(Constants.TAG, "onError getMessage:" + error.getMessage()); + handleError(error); } }; + private void handleError(CryptoError error) { + Toast.makeText(mActivity, "onError id:" + error.getErrorId() + "\n\n" + error.getMessage(), + Toast.LENGTH_LONG).show(); + Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId()); + Log.e(Constants.TAG, "onError getMessage:" + error.getMessage()); + } + public void encryptOnClick(View view) { byte[] inputBytes = mMessage.getText().toString().getBytes(); diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java index 9487a34c5..2ea3f530a 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoServiceActivity.java @@ -161,7 +161,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity { try { mServiceCallback.onRegistered(true, packageName); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } @@ -174,7 +174,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity { try { mServiceCallback.onRegistered(false, packageName); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } @@ -205,7 +205,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity { mServiceCallback.onSelectedPublicKeys(mSelectFragment .getSelectedMasterKeyIds()); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } @@ -219,7 +219,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity { mServiceCallback.onSelectedPublicKeys(mSelectFragment .getSelectedMasterKeyIds()); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } @@ -266,14 +266,14 @@ public class CryptoServiceActivity extends SherlockFragmentActivity { try { mServiceCallback.onCachedPassphrase(true); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } else { try { mServiceCallback.onCachedPassphrase(false); } catch (RemoteException e) { - Log.e(Constants.TAG, "ServiceActivity"); + Log.e(Constants.TAG, "ServiceActivity", e); } finish(); } diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java index cbb663f15..80b6e5834 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java @@ -60,6 +60,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor private static final String ARG_SECRET_KEY_ID = "secret_key_id"; public static final int MESSAGE_OKAY = 1; + public static final int MESSAGE_CANCEL = 2; private Messenger mMessenger; private EditText mPassphraseEditText; @@ -215,7 +216,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor @Override public void onClick(DialogInterface dialog, int id) { - dismiss(); + dialog.cancel(); } }); @@ -235,6 +236,14 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor } } + @Override + public void onCancel(DialogInterface dialog) { + super.onCancel(dialog); + + dismiss(); + sendMessageToHandler(MESSAGE_CANCEL); + } + /** * Associate the "done" button on the soft keyboard with the okay button in the view */