mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 16:38:50 -05:00
Fix custom key configuration for primary user ids
This commit is contained in:
parent
f50c0e1905
commit
db7da6525e
@ -66,6 +66,7 @@ import org.sufficientlysecure.keychain.ui.dialog.EditSubkeyExpiryDialogFragment;
|
|||||||
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
|
||||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class EditKeyFragment extends LoaderFragment implements
|
public class EditKeyFragment extends LoaderFragment implements
|
||||||
@ -190,10 +191,10 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mPrimaryUserId = saveKeyringParcel.mChangePrimaryUserId;
|
mPrimaryUserId = saveKeyringParcel.mChangePrimaryUserId;
|
||||||
mCurrentPassphrase = saveKeyringParcel.mNewPassphrase;
|
mCurrentPassphrase = saveKeyringParcel.mNewPassphrase;
|
||||||
|
|
||||||
mUserIdsAddedAdapter = new UserIdsAddedAdapter(getActivity(), mSaveKeyringParcel.mAddUserIds);
|
mUserIdsAddedAdapter = new UserIdsAddedAdapter(getActivity(), mSaveKeyringParcel.mAddUserIds, true);
|
||||||
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
||||||
|
|
||||||
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.mAddSubKeys);
|
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.mAddSubKeys, true);
|
||||||
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
||||||
|
|
||||||
// show directly
|
// show directly
|
||||||
@ -270,13 +271,13 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
mUserIdsList.setAdapter(mUserIdsAdapter);
|
mUserIdsList.setAdapter(mUserIdsAdapter);
|
||||||
|
|
||||||
// TODO: SaveParcel from savedInstance?!
|
// TODO: SaveParcel from savedInstance?!
|
||||||
mUserIdsAddedAdapter = new UserIdsAddedAdapter(getActivity(), mSaveKeyringParcel.mAddUserIds);
|
mUserIdsAddedAdapter = new UserIdsAddedAdapter(getActivity(), mSaveKeyringParcel.mAddUserIds, false);
|
||||||
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
|
||||||
|
|
||||||
mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0, mSaveKeyringParcel);
|
mSubkeysAdapter = new SubkeysAdapter(getActivity(), null, 0, mSaveKeyringParcel);
|
||||||
mSubkeysList.setAdapter(mSubkeysAdapter);
|
mSubkeysList.setAdapter(mSubkeysAdapter);
|
||||||
|
|
||||||
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.mAddSubKeys);
|
mSubkeysAddedAdapter = new SubkeysAddedAdapter(getActivity(), mSaveKeyringParcel.mAddSubKeys, false);
|
||||||
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
mSubkeysAddedList.setAdapter(mSubkeysAddedAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,6 +567,18 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void returnKeyringParcel() {
|
private void returnKeyringParcel() {
|
||||||
|
if (mSaveKeyringParcel.mAddUserIds.size() == 0) {
|
||||||
|
Notify.showNotify(getActivity(), R.string.edit_key_error_add_identity, Notify.Style.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mSaveKeyringParcel.mAddSubKeys.size() == 0) {
|
||||||
|
Notify.showNotify(getActivity(), R.string.edit_key_error_add_subkey, Notify.Style.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// use first user id as primary
|
||||||
|
mSaveKeyringParcel.mChangePrimaryUserId = mSaveKeyringParcel.mAddUserIds.get(0);
|
||||||
|
|
||||||
Intent returnIntent = new Intent();
|
Intent returnIntent = new Intent();
|
||||||
returnIntent.putExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
returnIntent.putExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
||||||
getActivity().setResult(Activity.RESULT_OK, returnIntent);
|
getActivity().setResult(Activity.RESULT_OK, returnIntent);
|
||||||
@ -638,7 +651,6 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
* Closes this activity, returning a result parcel with a single error log entry.
|
* Closes this activity, returning a result parcel with a single error log entry.
|
||||||
*/
|
*/
|
||||||
void finishWithError(LogType reason) {
|
void finishWithError(LogType reason) {
|
||||||
|
|
||||||
// Prepare an intent with an EXTRA_RESULT
|
// Prepare an intent with an EXTRA_RESULT
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(OperationResult.EXTRA_RESULT,
|
intent.putExtra(OperationResult.EXTRA_RESULT,
|
||||||
|
@ -42,11 +42,14 @@ import java.util.TimeZone;
|
|||||||
public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAdd> {
|
public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAdd> {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
private Activity mActivity;
|
private Activity mActivity;
|
||||||
|
private boolean mNewKeyring;
|
||||||
|
|
||||||
public SubkeysAddedAdapter(Activity activity, List<SaveKeyringParcel.SubkeyAdd> data) {
|
public SubkeysAddedAdapter(Activity activity, List<SaveKeyringParcel.SubkeyAdd> data,
|
||||||
|
boolean newKeyring) {
|
||||||
super(activity, -1, data);
|
super(activity, -1, data);
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
|
mNewKeyring = newKeyring;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ViewHolder {
|
static class ViewHolder {
|
||||||
@ -107,7 +110,7 @@ public class SubkeysAddedAdapter extends ArrayAdapter<SaveKeyringParcel.SubkeyAd
|
|||||||
holder.mModel.mCurve
|
holder.mModel.mCurve
|
||||||
);
|
);
|
||||||
|
|
||||||
boolean isMasterKey = position == 0;
|
boolean isMasterKey = mNewKeyring && position == 0;
|
||||||
if (isMasterKey) {
|
if (isMasterKey) {
|
||||||
holder.vKeyId.setTypeface(null, Typeface.BOLD);
|
holder.vKeyId.setTypeface(null, Typeface.BOLD);
|
||||||
} else {
|
} else {
|
||||||
|
@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.graphics.Typeface;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -35,14 +36,16 @@ import java.util.List;
|
|||||||
|
|
||||||
public class UserIdsAddedAdapter extends ArrayAdapter<String> {
|
public class UserIdsAddedAdapter extends ArrayAdapter<String> {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
private boolean mNewKeyring;
|
||||||
|
|
||||||
// hold a private reference to the underlying data List
|
// hold a private reference to the underlying data List
|
||||||
private List<String> mData;
|
private List<String> mData;
|
||||||
|
|
||||||
public UserIdsAddedAdapter(Activity activity, List<String> data) {
|
public UserIdsAddedAdapter(Activity activity, List<String> data, boolean newKeyring) {
|
||||||
super(activity, -1, data);
|
super(activity, -1, data);
|
||||||
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mData = data;
|
mData = data;
|
||||||
|
mNewKeyring = newKeyring;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getData() {
|
public List<String> getData() {
|
||||||
@ -111,6 +114,15 @@ public class UserIdsAddedAdapter extends ArrayAdapter<String> {
|
|||||||
holder.vComment.setVisibility(View.GONE);
|
holder.vComment.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isPrimary = mNewKeyring && position == 0;
|
||||||
|
if (isPrimary) {
|
||||||
|
holder.vName.setTypeface(null, Typeface.BOLD);
|
||||||
|
holder.vAddress.setTypeface(null, Typeface.BOLD);
|
||||||
|
} else {
|
||||||
|
holder.vName.setTypeface(null, Typeface.NORMAL);
|
||||||
|
holder.vAddress.setTypeface(null, Typeface.NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,6 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
|||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
super.onDismiss(dialog);
|
super.onDismiss(dialog);
|
||||||
Log.d(Constants.TAG, "onDismiss");
|
|
||||||
|
|
||||||
// hide keyboard on dismiss
|
// hide keyboard on dismiss
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
|
@ -130,7 +130,6 @@ public class ContactHelper {
|
|||||||
Set<String> currNames = new HashSet<String>();
|
Set<String> currNames = new HashSet<String>();
|
||||||
while (profileCursor.moveToNext()) {
|
while (profileCursor.moveToNext()) {
|
||||||
String name = profileCursor.getString(1);
|
String name = profileCursor.getString(1);
|
||||||
Log.d(Constants.TAG, "name" + name);
|
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
currNames.add(name);
|
currNames.add(name);
|
||||||
}
|
}
|
||||||
|
@ -497,6 +497,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<string name="edit_key_new_subkey">"new subkey"</string>
|
<string name="edit_key_new_subkey">"new subkey"</string>
|
||||||
<string name="edit_key_select_flag">"Please select at least one flag!"</string>
|
<string name="edit_key_select_flag">"Please select at least one flag!"</string>
|
||||||
|
<string name="edit_key_error_add_identity">"Add at least one identity!"</string>
|
||||||
|
<string name="edit_key_error_add_subkey">"Add at least one subkey!"</string>
|
||||||
|
|
||||||
<!-- Create key -->
|
<!-- Create key -->
|
||||||
<string name="create_key_upload">"Upload key to keyserver"</string>
|
<string name="create_key_upload">"Upload key to keyserver"</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user