diff options
Diffstat (limited to 'APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java')
-rw-r--r-- | APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java b/APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java index e1a93602c..29c2823a1 100644 --- a/APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java +++ b/APG/src/org/thialfihar/android/apg/ui/KeyListPublicFragment.java @@ -17,6 +17,8 @@ package org.thialfihar.android.apg.ui; +import java.util.ArrayList; + import org.spongycastle.openpgp.PGPPublicKeyRing; import org.thialfihar.android.apg.Id; import org.thialfihar.android.apg.R; @@ -26,6 +28,8 @@ import org.thialfihar.android.apg.provider.ApgContract.KeyRings; import org.thialfihar.android.apg.provider.ApgContract.UserIds; import org.thialfihar.android.apg.ui.widget.KeyListAdapter; +import com.google.zxing.integration.android.IntentIntegrator; + import android.content.Intent; import android.database.Cursor; import android.net.Uri; @@ -37,6 +41,7 @@ import android.view.ContextMenu; import android.view.View; import android.view.ContextMenu.ContextMenuInfo; import android.widget.ExpandableListView; +import android.widget.Toast; import android.widget.ExpandableListView.ExpandableListContextMenuInfo; public class KeyListPublicFragment extends KeyListFragment implements @@ -74,8 +79,10 @@ public class KeyListPublicFragment extends KeyListFragment implements public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.add(0, Id.menu.update, 1, R.string.menu_updateKey); - menu.add(0, Id.menu.exportToServer, 1, R.string.menu_exportKeyToServer); - menu.add(0, Id.menu.signKey, 1, R.string.menu_signKey); + menu.add(0, Id.menu.signKey, 2, R.string.menu_signKey); + menu.add(0, Id.menu.exportToServer, 3, R.string.menu_exportKeyToServer); + menu.add(0, Id.menu.share_qr_code, 6, R.string.menu_share); + } @Override @@ -90,8 +97,8 @@ public class KeyListPublicFragment extends KeyListFragment implements switch (item.getItemId()) { case Id.menu.update: long updateKeyId = 0; - PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, - keyRingRowId); + PGPPublicKeyRing updateKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId( + mKeyListActivity, keyRingRowId); if (updateKeyRing != null) { updateKeyId = PGPHelper.getMasterKey(updateKeyRing).getKeyID(); } @@ -119,8 +126,8 @@ public class KeyListPublicFragment extends KeyListFragment implements case Id.menu.signKey: long keyId = 0; - PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId(mKeyListActivity, - keyRingRowId); + PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByRowId( + mKeyListActivity, keyRingRowId); if (signKeyRing != null) { keyId = PGPHelper.getMasterKey(signKeyRing).getKeyID(); } @@ -135,12 +142,25 @@ public class KeyListPublicFragment extends KeyListFragment implements return true; + case Id.menu.share_qr_code: + // get master key id using row id + long masterKeyId = ProviderHelper.getPublicMasterKeyId(mKeyListActivity, keyRingRowId); + shareByQrCode(masterKeyId); + + return true; + default: return super.onContextItemSelected(item); } } + private void shareByQrCode(long masterKeyId) { + ArrayList<String> keyringArmored = ProviderHelper.getPublicKeyRingsAsArmoredString( + mKeyListActivity, new long[] { masterKeyId }); + new IntentIntegrator(mKeyListActivity).shareText(keyringArmored.get(0)); + } + // These are the rows that we will retrieve. static final String[] PROJECTION = new String[] { KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID }; |