mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Better handling of user id revocation in UI code
This commit is contained in:
parent
160e6972d8
commit
d377d1f23d
@ -318,6 +318,8 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
private void editUserId(final int position) {
|
private void editUserId(final int position) {
|
||||||
final String userId = mUserIdsAdapter.getUserId(position);
|
final String userId = mUserIdsAdapter.getUserId(position);
|
||||||
|
final boolean isRevoked = mUserIdsAdapter.getIsRevoked(position);
|
||||||
|
final boolean isRevokedPending = mUserIdsAdapter.getIsRevokedPending(position);
|
||||||
|
|
||||||
Handler returnHandler = new Handler() {
|
Handler returnHandler = new Handler() {
|
||||||
@Override
|
@Override
|
||||||
@ -351,8 +353,7 @@ public class EditKeyFragment extends LoaderFragment implements
|
|||||||
DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() {
|
DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
EditUserIdDialogFragment dialogFragment =
|
EditUserIdDialogFragment dialogFragment =
|
||||||
EditUserIdDialogFragment.newInstance(messenger);
|
EditUserIdDialogFragment.newInstance(messenger, isRevoked, isRevokedPending);
|
||||||
|
|
||||||
dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog");
|
dialogFragment.show(getActivity().getSupportFragmentManager(), "editUserIdDialog");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -252,6 +252,26 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
|||||||
return mCursor.getString(INDEX_USER_ID);
|
return mCursor.getString(INDEX_USER_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getIsRevoked(int position) {
|
||||||
|
mCursor.moveToPosition(position);
|
||||||
|
return mCursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getIsRevokedPending(int position) {
|
||||||
|
mCursor.moveToPosition(position);
|
||||||
|
String userId = mCursor.getString(INDEX_USER_ID);
|
||||||
|
|
||||||
|
boolean isRevokedPending = false;
|
||||||
|
if (mSaveKeyringParcel != null) {
|
||||||
|
if (mSaveKeyringParcel.mRevokeUserIds.contains(userId)) {
|
||||||
|
isRevokedPending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return isRevokedPending;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||||
View view = mInflater.inflate(R.layout.view_key_user_id_item, null);
|
View view = mInflater.inflate(R.layout.view_key_user_id_item, null);
|
||||||
|
@ -29,9 +29,14 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class EditUserIdDialogFragment extends DialogFragment {
|
public class EditUserIdDialogFragment extends DialogFragment {
|
||||||
private static final String ARG_MESSENGER = "messenger";
|
private static final String ARG_MESSENGER = "messenger";
|
||||||
|
|
||||||
|
private static final String ARG_IS_REVOKED = "is_revoked";
|
||||||
|
private static final String ARG_IS_REVOKED_PENDING = "is_revoked_pending";
|
||||||
|
|
||||||
public static final int MESSAGE_CHANGE_PRIMARY_USER_ID = 1;
|
public static final int MESSAGE_CHANGE_PRIMARY_USER_ID = 1;
|
||||||
public static final int MESSAGE_REVOKE = 2;
|
public static final int MESSAGE_REVOKE = 2;
|
||||||
|
|
||||||
@ -40,10 +45,13 @@ public class EditUserIdDialogFragment extends DialogFragment {
|
|||||||
/**
|
/**
|
||||||
* Creates new instance of this dialog fragment
|
* Creates new instance of this dialog fragment
|
||||||
*/
|
*/
|
||||||
public static EditUserIdDialogFragment newInstance(Messenger messenger) {
|
public static EditUserIdDialogFragment newInstance(Messenger messenger, boolean isRevoked,
|
||||||
|
boolean isRevokedPending) {
|
||||||
EditUserIdDialogFragment frag = new EditUserIdDialogFragment();
|
EditUserIdDialogFragment frag = new EditUserIdDialogFragment();
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ARG_MESSENGER, messenger);
|
args.putParcelable(ARG_MESSENGER, messenger);
|
||||||
|
args.putBoolean(ARG_IS_REVOKED, isRevoked);
|
||||||
|
args.putBoolean(ARG_IS_REVOKED_PENDING, isRevokedPending);
|
||||||
|
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
|
|
||||||
@ -56,13 +64,33 @@ public class EditUserIdDialogFragment extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
||||||
|
boolean isRevoked = getArguments().getBoolean(ARG_IS_REVOKED);
|
||||||
|
boolean isRevokedPending = getArguments().getBoolean(ARG_IS_REVOKED_PENDING);
|
||||||
|
|
||||||
CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(getActivity());
|
CustomAlertDialogBuilder builder = new CustomAlertDialogBuilder(getActivity());
|
||||||
|
builder.setTitle(R.string.edit_key_edit_user_id_title);
|
||||||
|
|
||||||
|
if (isRevokedPending) {
|
||||||
|
CharSequence[] array = getResources().getStringArray(R.array.edit_key_edit_user_id_revert_revocation);
|
||||||
|
|
||||||
|
builder.setItems(array, new DialogInterface.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
|
switch (which) {
|
||||||
|
case 0:
|
||||||
|
sendMessageToHandler(MESSAGE_REVOKE, null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (isRevoked) {
|
||||||
|
builder.setMessage(R.string.edit_key_edit_user_id_revoked);
|
||||||
|
} else {
|
||||||
CharSequence[] array = getResources().getStringArray(R.array.edit_key_edit_user_id);
|
CharSequence[] array = getResources().getStringArray(R.array.edit_key_edit_user_id);
|
||||||
|
|
||||||
builder.setTitle(R.string.edit_key_edit_user_id_title);
|
|
||||||
builder.setItems(array, new DialogInterface.OnClickListener() {
|
builder.setItems(array, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
switch (which) {
|
switch (which) {
|
||||||
@ -77,6 +105,8 @@ public class EditUserIdDialogFragment extends DialogFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
|
@ -437,12 +437,17 @@
|
|||||||
<item>Change to Primary Identity</item>
|
<item>Change to Primary Identity</item>
|
||||||
<item>Revoke Identity</item>
|
<item>Revoke Identity</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string-array name="edit_key_edit_user_id_revert_revocation">
|
||||||
|
<item>Revert revocation</item>
|
||||||
|
</string-array>
|
||||||
|
<string name="edit_key_edit_user_id_revoked">This identity has been revoked. This cannot be undone.</string>
|
||||||
<string name="edit_key_edit_subkey_title">Select an action!</string>
|
<string name="edit_key_edit_subkey_title">Select an action!</string>
|
||||||
<string-array name="edit_key_edit_subkey">
|
<string-array name="edit_key_edit_subkey">
|
||||||
<item>Change Expiry</item>
|
<item>Change Expiry</item>
|
||||||
<item>Revoke Subkey</item>
|
<item>Revoke Subkey</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|
||||||
<!-- Create key -->
|
<!-- Create key -->
|
||||||
<string name="create_key_upload">Upload key to keyserver</string>
|
<string name="create_key_upload">Upload key to keyserver</string>
|
||||||
<string name="create_key_empty">This field is required</string>
|
<string name="create_key_empty">This field is required</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user