aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-11-02 22:14:21 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2015-12-27 14:59:50 +0100
commit4ec51fcd9fc1a0871436cdb3d44428d6af23afac (patch)
tree6967c2e267f6a7236cab7617177eb1a4c6078b3d /OpenKeychain
parenta041acab65b916e3727ec679edc0f5583847a96c (diff)
downloadopen-keychain-4ec51fcd9fc1a0871436cdb3d44428d6af23afac.tar.gz
open-keychain-4ec51fcd9fc1a0871436cdb3d44428d6af23afac.tar.bz2
open-keychain-4ec51fcd9fc1a0871436cdb3d44428d6af23afac.zip
extend-uid: button and list to add user ids
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java51
-rw-r--r--OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml43
2 files changed, 91 insertions, 3 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java
index fdaf188ca..6186e1440 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyAdvUserIdsFragment.java
@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui;
+
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
@@ -45,7 +46,10 @@ import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserPackets;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
+import org.sufficientlysecure.keychain.ui.adapter.UserIdsAddedAdapter;
+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.dialog.UserIdInfoDialogFragment;
import org.sufficientlysecure.keychain.util.Log;
@@ -55,11 +59,14 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
public static final String ARG_DATA_URI = "uri";
public static final String ARG_HAS_SECRET = "has_secret";
- private ListView mUserIds;
-
private static final int LOADER_ID_USER_IDS = 0;
+ private ListView mUserIds;
+ private ListView mUserIdsAddedList;
+ private View mUserIdsAddedLayout;
+
private UserIdsAdapter mUserIdsAdapter;
+ private UserIdsAddedAdapter mUserIdsAddedAdapter;
private Uri mDataUri;
private boolean mHasSecret;
@@ -71,6 +78,8 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
View view = inflater.inflate(R.layout.view_key_adv_main_fragment, getContainer());
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
+ mUserIdsAddedList = (ListView) view.findViewById(R.id.view_key_user_ids_added);
+ mUserIdsAddedLayout = view.findViewById(R.id.view_key_user_ids_add_layout);
mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@@ -79,6 +88,13 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
}
});
+ view.findViewById(R.id.view_key_action_add_user_id).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ addUserId();
+ }
+ });
+
return root;
}
@@ -153,6 +169,29 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
});
}
+ private void addUserId() {
+ Handler returnHandler = new Handler() {
+ @Override
+ public void handleMessage(Message message) {
+ if (message.what == SetPassphraseDialogFragment.MESSAGE_OKAY) {
+ Bundle data = message.getData();
+
+ // add new user id
+ mUserIdsAddedAdapter.add(data
+ .getString(AddUserIdDialogFragment.MESSAGE_DATA_USER_ID));
+ }
+ }
+ };
+
+ // Create a new Messenger for the communication back
+ Messenger messenger = new Messenger(returnHandler);
+
+ // pre-fill out primary name
+ AddUserIdDialogFragment addUserIdDialog = AddUserIdDialogFragment.newInstance(messenger, "");
+
+ addUserIdDialog.show(getActivity().getSupportFragmentManager(), "addUserIdDialog");
+ }
+
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -237,7 +276,14 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
activity.startActionMode(new Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+
mEditModeSaveKeyringParcel = new SaveKeyringParcel(0L, new byte[0]);
+
+ mUserIdsAddedAdapter =
+ new UserIdsAddedAdapter(getActivity(), mEditModeSaveKeyringParcel.mAddUserIds, false);
+ mUserIdsAddedList.setAdapter(mUserIdsAddedAdapter);
+ mUserIdsAddedLayout.setVisibility(View.VISIBLE);
+
mUserIdsAdapter.setEditMode(mEditModeSaveKeyringParcel);
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
@@ -262,6 +308,7 @@ public class ViewKeyAdvUserIdsFragment extends LoaderFragment implements
public void onDestroyActionMode(ActionMode mode) {
mEditModeSaveKeyringParcel = null;
mUserIdsAdapter.setEditMode(null);
+ mUserIdsAddedLayout.setVisibility(View.GONE);
getLoaderManager().restartLoader(LOADER_ID_USER_IDS, null, ViewKeyAdvUserIdsFragment.this);
}
});
diff --git a/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml
index 3347a514c..d36c09ea1 100644
--- a/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml
+++ b/OpenKeychain/src/main/res/layout/view_key_adv_main_fragment.xml
@@ -1,6 +1,7 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ xmlns:tools="http://schemas.android.com/tools">
<!-- focusable and related properties to workaround http://stackoverflow.com/q/16182331-->
<LinearLayout
@@ -28,6 +29,46 @@
android:layout_marginBottom="4dp"
android:layout_weight="1" />
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:id="@+id/view_key_user_ids_add_layout"
+ android:visibility="gone"
+ tools:visibility="visible">
+
+ <View
+ android:layout_width="match_parent"
+ android:layout_height="1dip"
+ android:background="?android:attr/listDivider" />
+
+ <org.sufficientlysecure.keychain.ui.widget.FixedListView
+ android:id="@+id/view_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" />
+
+ <TextView
+ android:id="@+id/view_key_action_add_user_id"
+ android:paddingLeft="8dp"
+ android:paddingRight="8dp"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="@string/edit_key_action_add_identity"
+ android:minHeight="?android:attr/listPreferredItemHeight"
+ android:drawableRight="@drawable/ic_person_add_grey_24dp"
+ android:drawablePadding="8dp"
+ android:gravity="center_vertical"
+ android:clickable="true"
+ style="?android:attr/borderlessButtonStyle" />
+
+ </LinearLayout>
+
</LinearLayout>
</ScrollView>