diff options
author | Dominik Schürmann <dominik@dominikschuermann.de> | 2016-05-07 12:20:03 +0300 |
---|---|---|
committer | Dominik Schürmann <dominik@dominikschuermann.de> | 2016-05-07 12:20:03 +0300 |
commit | e908a2122c717463ebed21e850f5ef8770dfb9de (patch) | |
tree | db66c395f3c9cb1b5b4e2452b5802b0ab8953aa3 /example/src | |
parent | ab5fec23d751a017ab0fdac93950c00ce7b8c1dc (diff) | |
parent | deb09151190336097078a5b8738b9aa235cc1aa7 (diff) | |
download | openpgp-api-e908a2122c717463ebed21e850f5ef8770dfb9de.tar.gz openpgp-api-e908a2122c717463ebed21e850f5ef8770dfb9de.tar.bz2 openpgp-api-e908a2122c717463ebed21e850f5ef8770dfb9de.zip |
Merge branch 'master' of github.com:open-keychain/openpgp-api
Diffstat (limited to 'example/src')
-rw-r--r-- | example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java | 29 | ||||
-rw-r--r-- | example/src/main/res/layout/openpgp_provider.xml | 8 |
2 files changed, 34 insertions, 3 deletions
diff --git a/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java b/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java index 823c202..00a8f7d 100644 --- a/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java +++ b/example/src/main/java/org/openintents/openpgp/example/OpenPgpApiActivity.java @@ -49,6 +49,7 @@ public class OpenPgpApiActivity extends Activity { private EditText mDetachedSignature; private EditText mEncryptUserIds; private EditText mGetKeyEdit; + private EditText mGetKeyIdsEdit; private OpenPgpServiceConnection mServiceConnection; @@ -62,6 +63,7 @@ public class OpenPgpApiActivity extends Activity { public static final int REQUEST_CODE_GET_KEY_IDS = 9915; public static final int REQUEST_CODE_DETACHED_SIGN = 9916; public static final int REQUEST_CODE_DECRYPT_AND_VERIFY_DETACHED = 9917; + public static final int REQUEST_CODE_BACKUP = 9918; @Override public void onCreate(Bundle savedInstanceState) { @@ -79,9 +81,10 @@ public class OpenPgpApiActivity extends Activity { Button decryptAndVerify = (Button) findViewById(R.id.crypto_provider_demo_decrypt_and_verify); Button verifyDetachedSignature = (Button) findViewById(R.id.crypto_provider_demo_verify_detached_signature); mGetKeyEdit = (EditText) findViewById(R.id.crypto_provider_demo_get_key_edit); - EditText getKeyIdsEdit = (EditText) findViewById(R.id.crypto_provider_demo_get_key_ids_edit); + mGetKeyIdsEdit = (EditText) findViewById(R.id.crypto_provider_demo_get_key_ids_edit); Button getKey = (Button) findViewById(R.id.crypto_provider_demo_get_key); Button getKeyIds = (Button) findViewById(R.id.crypto_provider_demo_get_key_ids); + Button backup = (Button) findViewById(R.id.crypto_provider_demo_backup); cleartextSign.setOnClickListener(new View.OnClickListener() { @Override @@ -131,6 +134,12 @@ public class OpenPgpApiActivity extends Activity { getKeyIds(new Intent()); } }); + backup.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + backup(new Intent()); + } + }); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); String providerPackageName = settings.getString("openpgp_provider_list", ""); @@ -387,6 +396,7 @@ public class OpenPgpApiActivity extends Activity { public void getKeyIds(Intent data) { data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS); + data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mGetKeyIdsEdit.getText().toString().split(",")); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS)); @@ -394,12 +404,23 @@ public class OpenPgpApiActivity extends Activity { public void getAnyKeyIds(Intent data) { data.setAction(OpenPgpApi.ACTION_GET_KEY_IDS); -// data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mGetKeyIdsEdit.getText().toString().split(",")); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, null, null, new MyCallback(false, null, REQUEST_CODE_GET_KEY_IDS)); } + public void backup(Intent data) { + data.setAction(OpenPgpApi.ACTION_BACKUP); + data.putExtra(OpenPgpApi.EXTRA_KEY_IDS, new long[]{Long.decode(mGetKeyEdit.getText().toString())}); + data.putExtra(OpenPgpApi.EXTRA_BACKUP_SECRET, true); + data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + + OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); + api.executeApiAsync(data, null, os, new MyCallback(true, os, REQUEST_CODE_BACKUP)); + } + @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); @@ -446,6 +467,10 @@ public class OpenPgpApiActivity extends Activity { getKeyIds(data); break; } + case REQUEST_CODE_BACKUP: { + backup(data); + break; + } } } } diff --git a/example/src/main/res/layout/openpgp_provider.xml b/example/src/main/res/layout/openpgp_provider.xml index 13096b4..d2b4572 100644 --- a/example/src/main/res/layout/openpgp_provider.xml +++ b/example/src/main/res/layout/openpgp_provider.xml @@ -153,7 +153,7 @@ <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="Get key:" + android:text="Get key/backup key:" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText @@ -168,6 +168,12 @@ android:layout_height="wrap_content" android:text="Get key" /> + <Button + android:id="@+id/crypto_provider_demo_backup" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="Backup" /> + <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" |