Edit identities design
This commit is contained in:
@@ -56,7 +56,6 @@ import org.sufficientlysecure.keychain.ui.base.QueueingCryptoOperationFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.AddUserIdDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.EditUserIdDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.util.Date;
|
||||
@@ -99,9 +98,9 @@ public class EditIdentitiesFragment extends QueueingCryptoOperationFragment<Save
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup superContainer, Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.edit_identities_fragment, null);
|
||||
|
||||
mUserIdsList = (ListView) view.findViewById(R.id.edit_key_user_ids);
|
||||
mUserIdsAddedList = (ListView) view.findViewById(R.id.edit_key_user_ids_added);
|
||||
mAddUserId = view.findViewById(R.id.edit_key_action_add_user_id);
|
||||
mUserIdsList = (ListView) view.findViewById(R.id.edit_identities_user_ids);
|
||||
mUserIdsAddedList = (ListView) view.findViewById(R.id.edit_identities_user_ids_added);
|
||||
mAddUserId = view.findViewById(R.id.edit_identities_add_user_id);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -114,12 +113,7 @@ public class EditIdentitiesFragment extends QueueingCryptoOperationFragment<Save
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// if we are working on an Uri, save directly
|
||||
if (mDataUri == null) {
|
||||
returnKeyringParcel();
|
||||
} else {
|
||||
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||
}
|
||||
cryptoOperation(new CryptoInputParcel(new Date()));
|
||||
}
|
||||
}, new OnClickListener() {
|
||||
@Override
|
||||
@@ -302,27 +296,11 @@ public class EditIdentitiesFragment extends QueueingCryptoOperationFragment<Save
|
||||
// pre-fill out primary name
|
||||
String predefinedName = KeyRing.splitUserId(mPrimaryUserId).name;
|
||||
AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger,
|
||||
predefinedName);
|
||||
predefinedName, false);
|
||||
|
||||
addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog");
|
||||
}
|
||||
|
||||
|
||||
protected void returnKeyringParcel() {
|
||||
if (mSaveKeyringParcel.mAddUserIds.size() == 0) {
|
||||
Notify.create(getActivity(), R.string.edit_key_error_add_identity, Notify.Style.ERROR).show();
|
||||
return;
|
||||
}
|
||||
|
||||
// use first user id as primary
|
||||
mSaveKeyringParcel.mChangePrimaryUserId = mSaveKeyringParcel.mAddUserIds.get(0);
|
||||
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EditKeyActivity.EXTRA_SAVE_KEYRING_PARCEL, mSaveKeyringParcel);
|
||||
getActivity().setResult(Activity.RESULT_OK, returnIntent);
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes this activity, returning a result parcel with a single error log entry.
|
||||
*/
|
||||
@@ -333,7 +311,7 @@ public class EditIdentitiesFragment extends QueueingCryptoOperationFragment<Save
|
||||
new SingletonResult(SingletonResult.RESULT_ERROR, reason));
|
||||
|
||||
// Finish with result
|
||||
getActivity().setResult(EditKeyActivity.RESULT_OK, intent);
|
||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
@@ -351,7 +329,7 @@ public class EditIdentitiesFragment extends QueueingCryptoOperationFragment<Save
|
||||
// if good -> finish, return result to showkey and display there!
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(OperationResult.EXTRA_RESULT, result);
|
||||
activity.setResult(EditKeyActivity.RESULT_OK, intent);
|
||||
activity.setResult(Activity.RESULT_OK, intent);
|
||||
activity.finish();
|
||||
|
||||
}
|
||||
|
||||
@@ -556,7 +556,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
// pre-fill out primary name
|
||||
String predefinedName = KeyRing.splitUserId(mPrimaryUserId).name;
|
||||
AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger,
|
||||
predefinedName);
|
||||
predefinedName, true);
|
||||
|
||||
addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog");
|
||||
}
|
||||
@@ -612,7 +612,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
new SingletonResult(SingletonResult.RESULT_ERROR, reason));
|
||||
|
||||
// Finish with result
|
||||
getActivity().setResult(EditKeyActivity.RESULT_OK, intent);
|
||||
getActivity().setResult(Activity.RESULT_OK, intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
|
||||
@@ -630,7 +630,7 @@ public class EditKeyFragment extends QueueingCryptoOperationFragment<SaveKeyring
|
||||
// if good -> finish, return result to showkey and display there!
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(OperationResult.EXTRA_RESULT, result);
|
||||
activity.setResult(EditKeyActivity.RESULT_OK, intent);
|
||||
activity.setResult(Activity.RESULT_OK, intent);
|
||||
activity.finish();
|
||||
|
||||
}
|
||||
|
||||
@@ -210,7 +210,8 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
|
||||
Messenger messenger = new Messenger(returnHandler);
|
||||
|
||||
// pre-fill out primary name
|
||||
AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger, "");
|
||||
AddUserIdDialogFragment addUserIdDialog =
|
||||
AddUserIdDialogFragment.newInstance(messenger, "", true);
|
||||
|
||||
addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog");
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import android.widget.TextView;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||
import org.sufficientlysecure.keychain.operations.results.OperationResult;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
|
||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
||||
@@ -311,6 +312,17 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
loadData(dataUri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
// if a result has been returned, display a notify
|
||||
if (data != null && data.hasExtra(OperationResult.EXTRA_RESULT)) {
|
||||
OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT);
|
||||
result.createNotify(getActivity()).show();
|
||||
} else {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
// These are the rows that we will retrieve.
|
||||
static final String[] UNIFIED_PROJECTION = new String[]{
|
||||
KeychainContract.KeyRings._ID,
|
||||
|
||||
@@ -48,6 +48,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
public class AddUserIdDialogFragment extends DialogFragment implements OnEditorActionListener {
|
||||
private static final String ARG_MESSENGER = "messenger";
|
||||
private static final String ARG_NAME = "name";
|
||||
private static final String ARG_ALLOW_COMMENT = "allow_comment";
|
||||
|
||||
public static final int MESSAGE_OKAY = 1;
|
||||
public static final int MESSAGE_CANCEL = 2;
|
||||
@@ -59,12 +60,14 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
private EmailEditText mEmail;
|
||||
private EditText mComment;
|
||||
|
||||
public static AddUserIdDialogFragment newInstance(Messenger messenger, String predefinedName) {
|
||||
public static AddUserIdDialogFragment newInstance(Messenger messenger, String predefinedName,
|
||||
boolean allowComment) {
|
||||
|
||||
AddUserIdDialogFragment frag = new AddUserIdDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ARG_MESSENGER, messenger);
|
||||
args.putString(ARG_NAME, predefinedName);
|
||||
args.putBoolean(ARG_ALLOW_COMMENT, allowComment);
|
||||
frag.setArguments(args);
|
||||
|
||||
return frag;
|
||||
@@ -78,6 +81,7 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
final Activity activity = getActivity();
|
||||
mMessenger = getArguments().getParcelable(ARG_MESSENGER);
|
||||
String predefinedName = getArguments().getString(ARG_NAME);
|
||||
boolean allowComment = getArguments().getBoolean(ARG_ALLOW_COMMENT);
|
||||
|
||||
CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);
|
||||
|
||||
@@ -91,6 +95,12 @@ public class AddUserIdDialogFragment extends DialogFragment implements OnEditorA
|
||||
mEmail = (EmailEditText) view.findViewById(R.id.add_user_id_address);
|
||||
mComment = (EditText) view.findViewById(R.id.add_user_id_comment);
|
||||
|
||||
if (allowComment) {
|
||||
mComment.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mComment.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
mName.setText(predefinedName);
|
||||
|
||||
alert.setPositiveButton(android.R.string.ok, new OnClickListener() {
|
||||
|
||||
Reference in New Issue
Block a user