mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-12 05:58:07 -05:00
Fix to passphrase dialog and Issue #207
This commit is contained in:
parent
db05b3043a
commit
7d2c3f860e
@ -24,10 +24,13 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityOptions;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@ -40,6 +43,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
|
||||
private TextView mKeyUserId;
|
||||
private TextView mKeyUserIdRest;
|
||||
private TextView mKeyMasterKeyIdHex;
|
||||
private BootstrapButton mSelectKeyButton;
|
||||
private Boolean mFilterCertify;
|
||||
|
||||
@ -61,26 +65,58 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
|
||||
public void selectKey(long secretKeyId) {
|
||||
if (secretKeyId == Id.key.none) {
|
||||
mKeyUserId.setText(R.string.api_settings_no_key);
|
||||
mKeyMasterKeyIdHex.setText(R.string.api_settings_no_key);
|
||||
mKeyUserIdRest.setText("");
|
||||
mKeyUserId.setVisibility(View.GONE);
|
||||
mKeyUserIdRest.setVisibility(View.GONE);
|
||||
|
||||
} else {
|
||||
String uid = getResources().getString(R.string.user_id_no_name);
|
||||
String uidExtra = "";
|
||||
String masterkeyIdHex = "";
|
||||
|
||||
PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(
|
||||
getActivity(), secretKeyId);
|
||||
if (keyRing != null) {
|
||||
PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing);
|
||||
masterkeyIdHex = PgpKeyHelper.convertKeyIdToHex(secretKeyId);
|
||||
|
||||
if (key != null) {
|
||||
String userId = PgpKeyHelper.getMainUserIdSafe(getActivity(), key);
|
||||
String chunks[] = userId.split(" <", 2);
|
||||
/*String chunks[] = mUserId.split(" <", 2);
|
||||
uid = chunks[0];
|
||||
if (chunks.length > 1) {
|
||||
uidExtra = "<" + chunks[1];
|
||||
}
|
||||
}*/
|
||||
String[] userIdSplit = PgpKeyHelper.splitUserId(userId);
|
||||
String userName, userEmail;
|
||||
|
||||
if (userIdSplit[0] != null) { userName = userIdSplit[0]; }
|
||||
else { userName = "No Name"; }
|
||||
|
||||
if (userIdSplit[1] != null) { userEmail = userIdSplit[1]; }
|
||||
else { userEmail = "No Email"; }
|
||||
|
||||
mKeyMasterKeyIdHex.setText(masterkeyIdHex);
|
||||
mKeyUserId.setText(userName);
|
||||
mKeyUserIdRest.setText(userEmail);
|
||||
mKeyUserId.setVisibility(View.VISIBLE);
|
||||
mKeyUserIdRest.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else{
|
||||
mKeyMasterKeyIdHex.setText("No key found for KeyRing");
|
||||
mKeyUserId.setVisibility(View.GONE);
|
||||
mKeyUserIdRest.setVisibility(View.GONE);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
mKeyUserId.setText(uid);
|
||||
mKeyUserIdRest.setText(uidExtra);
|
||||
else{
|
||||
mKeyMasterKeyIdHex.setText("No KeyRings found for MasterId: "+secretKeyId);
|
||||
mKeyUserId.setVisibility(View.GONE);
|
||||
mKeyUserIdRest.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,6 +134,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
|
||||
mKeyUserId = (TextView) view.findViewById(R.id.select_secret_key_user_id);
|
||||
mKeyUserIdRest = (TextView) view.findViewById(R.id.select_secret_key_user_id_rest);
|
||||
mKeyMasterKeyIdHex = (TextView) view.findViewById(R.id.select_secret_key_master_key_hex);
|
||||
mSelectKeyButton = (BootstrapButton) view
|
||||
.findViewById(R.id.select_secret_key_select_key_button);
|
||||
mFilterCertify = false;
|
||||
@ -117,6 +154,8 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
startActivityForResult(intent, REQUEST_CODE_SELECT_KEY);
|
||||
}
|
||||
|
||||
//Select Secret Key Activity delivers the intent which was sent by it using interface to Select
|
||||
// Secret Key Fragment.Intent contains Master Key Id, User Email, User Name, Master Key Id Hex.
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode & 0xFFFF) {
|
||||
@ -125,7 +164,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment {
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
Bundle bundle = data.getExtras();
|
||||
secretKeyId = bundle.getLong(SelectSecretKeyActivity.RESULT_EXTRA_MASTER_KEY_ID);
|
||||
|
||||
selectKey(secretKeyId);
|
||||
|
||||
// remove displayed errors
|
||||
|
@ -6,7 +6,9 @@
|
||||
android:paddingRight="16dp"
|
||||
android:stretchColumns="1" >
|
||||
|
||||
<TableRow>
|
||||
<TableRow
|
||||
android:layout_marginBottom="5dip"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/passphrase_label_passphrase"
|
||||
@ -24,7 +26,9 @@
|
||||
android:padding="4dp" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow>
|
||||
<TableRow
|
||||
android:layout_marginBottom="10dip"
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/passphrase_label_passphrase_again"
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="vertical" >
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/select_secret_key_select_key_button"
|
||||
@ -28,28 +28,41 @@
|
||||
android:paddingLeft="16dp" >
|
||||
|
||||
<!-- Has been made focusable to display error messages with setError -->
|
||||
<TextView
|
||||
android:id="@+id/select_secret_key_master_key_hex"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/api_settings_no_key"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_secret_key_user_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="left"
|
||||
android:ellipsize="end"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:singleLine="true"
|
||||
android:text="@string/api_settings_no_key"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
android:visibility="gone"
|
||||
android:text=""
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/select_secret_key_user_id_rest"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_gravity="left"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:text=""
|
||||
android:visibility="gone"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user