mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
api: handle passphrase entering correctly
This commit is contained in:
parent
03d9afffce
commit
11103623c5
@ -24,7 +24,6 @@ import org.openintents.crypto.CryptoServiceConnection;
|
|||||||
import org.openintents.crypto.CryptoSignatureResult;
|
import org.openintents.crypto.CryptoSignatureResult;
|
||||||
import org.openintents.crypto.ICryptoCallback;
|
import org.openintents.crypto.ICryptoCallback;
|
||||||
import org.openintents.crypto.ICryptoService;
|
import org.openintents.crypto.ICryptoService;
|
||||||
import org.sufficientlysecure.keychain.demo.R;
|
|
||||||
import org.sufficientlysecure.keychain.integration.Constants;
|
import org.sufficientlysecure.keychain.integration.Constants;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
@ -35,15 +34,14 @@ import android.content.pm.ResolveInfo;
|
|||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.text.method.ScrollingMovementMethod;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ListAdapter;
|
import android.widget.ListAdapter;
|
||||||
import android.widget.Scroller;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class CryptoProviderDemoActivity extends Activity {
|
public class CryptoProviderDemoActivity extends Activity {
|
||||||
Activity mActivity;
|
Activity mActivity;
|
||||||
@ -83,15 +81,13 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mCiphertext.setText(new String(outputBytes));
|
mCiphertext.setText(new String(outputBytes));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(CryptoError error) throws RemoteException {
|
public void onError(CryptoError error) throws RemoteException {
|
||||||
Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId());
|
handleError(error);
|
||||||
Log.e(Constants.TAG, "onError getMessage:" + error.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -116,12 +112,18 @@ public class CryptoProviderDemoActivity extends Activity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(CryptoError error) throws RemoteException {
|
public void onError(CryptoError error) throws RemoteException {
|
||||||
Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId());
|
handleError(error);
|
||||||
Log.e(Constants.TAG, "onError getMessage:" + error.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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) {
|
public void encryptOnClick(View view) {
|
||||||
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
byte[] inputBytes = mMessage.getText().toString().getBytes();
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
try {
|
try {
|
||||||
mServiceCallback.onRegistered(true, packageName);
|
mServiceCallback.onRegistered(true, packageName);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
try {
|
try {
|
||||||
mServiceCallback.onRegistered(false, packageName);
|
mServiceCallback.onRegistered(false, packageName);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
mServiceCallback.onSelectedPublicKeys(mSelectFragment
|
mServiceCallback.onSelectedPublicKeys(mSelectFragment
|
||||||
.getSelectedMasterKeyIds());
|
.getSelectedMasterKeyIds());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
mServiceCallback.onSelectedPublicKeys(mSelectFragment
|
mServiceCallback.onSelectedPublicKeys(mSelectFragment
|
||||||
.getSelectedMasterKeyIds());
|
.getSelectedMasterKeyIds());
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@ -266,14 +266,14 @@ public class CryptoServiceActivity extends SherlockFragmentActivity {
|
|||||||
try {
|
try {
|
||||||
mServiceCallback.onCachedPassphrase(true);
|
mServiceCallback.onCachedPassphrase(true);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
mServiceCallback.onCachedPassphrase(false);
|
mServiceCallback.onCachedPassphrase(false);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
Log.e(Constants.TAG, "ServiceActivity");
|
Log.e(Constants.TAG, "ServiceActivity", e);
|
||||||
}
|
}
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
|||||||
private static final String ARG_SECRET_KEY_ID = "secret_key_id";
|
private static final String ARG_SECRET_KEY_ID = "secret_key_id";
|
||||||
|
|
||||||
public static final int MESSAGE_OKAY = 1;
|
public static final int MESSAGE_OKAY = 1;
|
||||||
|
public static final int MESSAGE_CANCEL = 2;
|
||||||
|
|
||||||
private Messenger mMessenger;
|
private Messenger mMessenger;
|
||||||
private EditText mPassphraseEditText;
|
private EditText mPassphraseEditText;
|
||||||
@ -215,7 +216,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
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
|
* Associate the "done" button on the soft keyboard with the okay button in the view
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user