Edit identities design
This commit is contained in:
parent
269330f04f
commit
373a3fc3f5
|
@ -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() {
|
||||
|
|
|
@ -1,77 +1,78 @@
|
|||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:card_view="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.EditIdentitiesActivity">
|
||||
|
||||
<LinearLayout
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="16dp">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/view_key_card_user_ids"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
card_view:cardBackgroundColor="?attr/colorCardViewBackground"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
card_view:cardElevation="2dp"
|
||||
card_view:cardUseCompatPadding="true">
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="96dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="16dp">
|
||||
|
||||
<LinearLayout
|
||||
<android.support.v7.widget.CardView
|
||||
android:id="@+id/edit_identities_user_ids_card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:layout_gravity="center"
|
||||
card_view:cardBackgroundColor="?attr/colorCardViewBackground"
|
||||
card_view:cardCornerRadius="4dp"
|
||||
card_view:cardElevation="2dp"
|
||||
card_view:cardUseCompatPadding="true">
|
||||
|
||||
<TextView
|
||||
style="@style/CardViewHeader"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/section_linked_identities" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/edit_key_user_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<TextView
|
||||
style="@style/CardViewHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/section_user_ids" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/edit_identities_user_ids"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/edit_key_user_ids_added"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||
android:id="@+id/edit_identities_user_ids_added"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/edit_key_action_add_user_id"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:drawablePadding="8dp"
|
||||
android:drawableRight="@drawable/ic_person_add_grey_24dp"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:text="@string/edit_key_action_add_identity"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
</android.support.v7.widget.CardView>
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<android.support.design.widget.FloatingActionButton
|
||||
android:id="@+id/edit_identities_add_user_id"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginBottom="24dp"
|
||||
android:layout_marginRight="24dp"
|
||||
android:src="@drawable/ic_add_white_24dp" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in a new issue