diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-07 22:59:39 +0100 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2014-01-07 22:59:39 +0100 |
commit | a2f0667593be2f7ecd5b0e2445321a22a90eea9e (patch) | |
tree | 4bef45c713467ca6d146f71af3e177df25a224dc | |
parent | caf3b02042f94b7b2a9b019b01d45c41bf035140 (diff) | |
download | open-keychain-a2f0667593be2f7ecd5b0e2445321a22a90eea9e.tar.gz open-keychain-a2f0667593be2f7ecd5b0e2445321a22a90eea9e.tar.bz2 open-keychain-a2f0667593be2f7ecd5b0e2445321a22a90eea9e.zip |
action encrypt to contact in view and multi select
-rw-r--r-- | OpenPGP-Keychain/res/layout/key_view_activity.xml | 13 | ||||
-rw-r--r-- | OpenPGP-Keychain/res/menu/key_list_public_multi.xml (renamed from OpenPGP-Keychain/res/menu/key_list_multi_selection.xml) | 5 | ||||
-rw-r--r-- | OpenPGP-Keychain/res/values/strings.xml | 7 | ||||
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java | 49 | ||||
-rw-r--r-- | OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyViewActivity.java | 20 |
5 files changed, 77 insertions, 17 deletions
diff --git a/OpenPGP-Keychain/res/layout/key_view_activity.xml b/OpenPGP-Keychain/res/layout/key_view_activity.xml index 326959e97..8c6281d5b 100644 --- a/OpenPGP-Keychain/res/layout/key_view_activity.xml +++ b/OpenPGP-Keychain/res/layout/key_view_activity.xml @@ -113,4 +113,17 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" /> + <TextView + style="@style/SectionHeader" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="4dp" + android:text="@string/section_actions" /> + + <Button + android:id="@+id/action_encrypt" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/key_view_action_encrypt" /> + </LinearLayout>
\ No newline at end of file diff --git a/OpenPGP-Keychain/res/menu/key_list_multi_selection.xml b/OpenPGP-Keychain/res/menu/key_list_public_multi.xml index 64f8564c1..92481e9cb 100644 --- a/OpenPGP-Keychain/res/menu/key_list_multi_selection.xml +++ b/OpenPGP-Keychain/res/menu/key_list_public_multi.xml @@ -2,7 +2,10 @@ <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item - android:id="@+id/delete_entry" + android:id="@+id/menu_key_list_public_multi_encrypt" + android:title="@string/menu_encrypt_to"/> + <item + android:id="@+id/menu_key_list_public_multi_delete" android:icon="@android:drawable/ic_menu_delete" android:title="@string/menu_delete_key"/> diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml index d870c1289..62beb64f7 100644 --- a/OpenPGP-Keychain/res/values/strings.xml +++ b/OpenPGP-Keychain/res/values/strings.xml @@ -55,6 +55,7 @@ <string name="section_defaults">Defaults</string> <string name="section_advanced">Advanced</string> <string name="section_master_key">Master Key</string> + <string name="section_actions">Actions</string> <!-- button --> <string name="btn_sign_to_clipboard">Sign (Clipboard)</string> @@ -102,7 +103,8 @@ <string name="menu_sign_key">Sign key</string> <string name="menu_beam_preferences">Beam settings</string> <string name="menu_key_edit_cancel">Cancel</string> - + <string name="menu_encrypt_to">Encrypt to…</string> + <!-- label --> <string name="label_sign">Sign</string> <string name="label_message">Message</string> @@ -357,4 +359,7 @@ <item quantity="other">%d keys selected.</item> </plurals> + <!-- Key view --> + <string name="key_view_action_encrypt">Encrypt to this contact</string> + </resources>
\ No newline at end of file diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java index a21fa7ebd..d9fa0948a 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyListPublicFragment.java @@ -22,6 +22,7 @@ import java.util.Set; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.ui.adapter.KeyListPublicAdapter; @@ -56,7 +57,7 @@ import android.widget.ListView; public class KeyListPublicFragment extends Fragment implements AdapterView.OnItemClickListener, LoaderManager.LoaderCallbacks<Cursor> { -// private KeyListPublicActivity mKeyListPublicActivity; + // private KeyListPublicActivity mKeyListPublicActivity; private KeyListPublicAdapter mAdapter; private StickyListHeadersListView mStickyList; @@ -77,7 +78,7 @@ public class KeyListPublicFragment extends Fragment implements AdapterView.OnIte public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); -// mKeyListPublicActivity = (KeyListPublicActivity) getActivity(); + // mKeyListPublicActivity = (KeyListPublicActivity) getActivity(); mStickyList = (StickyListHeadersListView) getActivity().findViewById(R.id.list); mStickyList.setOnItemClickListener(this); @@ -105,7 +106,7 @@ public class KeyListPublicFragment extends Fragment implements AdapterView.OnIte @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { android.view.MenuInflater inflater = getActivity().getMenuInflater(); - inflater.inflate(R.menu.key_list_multi_selection, menu); + inflater.inflate(R.menu.key_list_public_multi, menu); return true; } @@ -117,20 +118,27 @@ public class KeyListPublicFragment extends Fragment implements AdapterView.OnIte @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { Set<Integer> positions = mAdapter.getCurrentCheckedPosition(); + + // get IDs for checked positions as long array + long[] ids = new long[positions.size()]; + int i = 0; + for (int pos : positions) { + ids[i] = mAdapter.getItemId(pos); + i++; + } + switch (item.getItemId()) { - case R.id.delete_entry: - - // get IDs for checked positions as long array - long[] ids = new long[positions.size()]; - int i = 0; - for (int pos : positions) { - ids[i] = mAdapter.getItemId(pos); - i++; - } + case R.id.menu_key_list_public_multi_encrypt: { + encrypt(ids); + + break; + } + case R.id.menu_key_list_public_multi_delete: { showDeleteKeyDialog(ids); break; } + } return false; } @@ -164,8 +172,7 @@ public class KeyListPublicFragment extends Fragment implements AdapterView.OnIte // setListShown(false); // Create an empty adapter we will use to display the loaded data. - mAdapter = new KeyListPublicAdapter(getActivity(), null, Id.type.public_key, - USER_ID_INDEX); + mAdapter = new KeyListPublicAdapter(getActivity(), null, Id.type.public_key, USER_ID_INDEX); mStickyList.setAdapter(mAdapter); // Prepare the loader. Either re-connect with an existing one, @@ -227,6 +234,20 @@ public class KeyListPublicFragment extends Fragment implements AdapterView.OnIte startActivity(detailsIntent); } + public void encrypt(long[] keyRingRowIds) { + // get master key ids from row ids + long[] keyRingIds = new long[keyRingRowIds.length]; + for (int i = 0; i < keyRingRowIds.length; i++) { + keyRingIds[i] = ProviderHelper.getPublicMasterKeyId(getActivity(), keyRingRowIds[i]); + } + + Intent intent = new Intent(getActivity(), EncryptActivity.class); + intent.setAction(EncryptActivity.ACTION_ENCRYPT); + intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, keyRingIds); + // used instead of startActivity set actionbar based on callingPackage + startActivityForResult(intent, 0); + } + /** * Show dialog to delete key * diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyViewActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyViewActivity.java index d7e2b8063..7d51c2ff4 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyViewActivity.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/KeyViewActivity.java @@ -50,6 +50,9 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.text.format.DateFormat; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; import android.widget.TextView; import android.widget.Toast; @@ -67,6 +70,7 @@ public class KeyViewActivity extends KeyActivity implements CreateNdefMessageCal private TextView mFingerint; private TextView mExpiry; private TextView mCreation; + private Button mActionEncrypt; // NFC private NfcAdapter mNfcAdapter; @@ -86,6 +90,7 @@ public class KeyViewActivity extends KeyActivity implements CreateNdefMessageCal mExpiry = (TextView) this.findViewById(R.id.expiry); mCreation = (TextView) this.findViewById(R.id.creation); mAlgorithm = (TextView) this.findViewById(R.id.algorithm); + mActionEncrypt = (Button) this.findViewById(R.id.action_encrypt); Intent intent = getIntent(); mDataUri = intent.getData(); @@ -146,7 +151,7 @@ public class KeyViewActivity extends KeyActivity implements CreateNdefMessageCal } } }; - + deleteKey(mDataUri, Id.type.public_key, returnHandler); return true; } @@ -172,6 +177,19 @@ public class KeyViewActivity extends KeyActivity implements CreateNdefMessageCal mCreation.setText(DateFormat.getDateFormat(getApplicationContext()).format( PgpKeyHelper.getCreationDate(mPublicKey))); mAlgorithm.setText(PgpKeyHelper.getAlgorithmInfo(mPublicKey)); + + mActionEncrypt.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View v) { + long[] encryptionKeyIds = new long[] { mPublicKey.getKeyID() }; + Intent intent = new Intent(KeyViewActivity.this, EncryptActivity.class); + intent.setAction(EncryptActivity.ACTION_ENCRYPT); + intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); + // used instead of startActivity set actionbar based on callingPackage + startActivityForResult(intent, 0); + } + }); } /** |