aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog
diff options
context:
space:
mode:
authorTheo Franzén <franzen.theo@gmail.com>2016-01-14 13:32:00 +0100
committerTheo Franzén <franzen.theo@gmail.com>2016-01-15 17:14:21 +0100
commit25afe7bc86a92a0d5664efa4c254dbf11cb2964e (patch)
tree20be3798761055c3f9719293e81f30328076ea8b /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog
parentd8235e0013c759f0e32dc1c958deb4cb11c68a79 (diff)
downloadopen-keychain-25afe7bc86a92a0d5664efa4c254dbf11cb2964e.tar.gz
open-keychain-25afe7bc86a92a0d5664efa4c254dbf11cb2964e.tar.bz2
open-keychain-25afe7bc86a92a0d5664efa4c254dbf11cb2964e.zip
Handle not installed PGP applet
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoInstallDialog.java59
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java63
2 files changed, 122 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoInstallDialog.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoInstallDialog.java
new file mode 100644
index 000000000..76934c5d4
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoInstallDialog.java
@@ -0,0 +1,59 @@
+package org.sufficientlysecure.keychain.ui.dialog;
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+
+import org.sufficientlysecure.keychain.R;
+
+public class FidesmoInstallDialog extends DialogFragment {
+
+ // URLs for Google Play app and to install apps via browser
+ private final static String PLAY_STORE_URI = "market://details?id=";
+ private final static String PLAY_STORE_VIA_BROWSER_URI = "http://play.google.com/store/apps/details?id=";
+
+ // Fidesmo constants
+ private static final String FIDESMO_APP_PACKAGE = "com.fidesmo.sec.android";
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ CustomAlertDialogBuilder mCustomAlertDialogBuilder = new CustomAlertDialogBuilder(getActivity());
+ mCustomAlertDialogBuilder.setTitle(getString(R.string.prompt_fidesmo_app_install_title));
+ mCustomAlertDialogBuilder.setMessage(getString(R.string.prompt_fidesmo_app_install_message));
+ mCustomAlertDialogBuilder.setPositiveButton(
+ getString(R.string.prompt_fidesmo_app_install_button_positive),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ startPlayStoreFidesmoAppActivity();
+ }
+ });
+ mCustomAlertDialogBuilder.setNegativeButton(
+ getString(R.string.prompt_fidesmo_app_install_button_negative),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ }
+ });
+
+ return mCustomAlertDialogBuilder.show();
+ }
+
+ private void startPlayStoreFidesmoAppActivity() {
+ try {
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_URI +
+ FIDESMO_APP_PACKAGE)));
+ } catch (android.content.ActivityNotFoundException exception) {
+ // if the Google Play app is not installed, call the browser
+ startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(PLAY_STORE_VIA_BROWSER_URI +
+ FIDESMO_APP_PACKAGE)));
+ }
+ }
+}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java
new file mode 100644
index 000000000..cdf6e5c7c
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/FidesmoPgpInstallDialog.java
@@ -0,0 +1,63 @@
+package org.sufficientlysecure.keychain.ui.dialog;
+
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.v4.app.DialogFragment;
+
+import org.sufficientlysecure.keychain.Constants;
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.util.Log;
+
+public class FidesmoPgpInstallDialog extends DialogFragment {
+
+ // Fidesmo constants
+ private static final String FIDESMO_SERVICE_DELIVERY_CARD_ACTION = "com.fidesmo.sec.DELIVER_SERVICE";
+ private static final String FIDESMO_SERVICE_URI = "https://api.fidesmo.com/service/";
+ private static final String FIDESMO_PGP_APPLICATION_ID = "0cdc651e";
+ private static final String FIDESMO_PGP_SERVICE_ID = "OKC-install";
+
+ @NonNull
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ CustomAlertDialogBuilder mCustomAlertDialogBuilder = new CustomAlertDialogBuilder(getActivity());
+ mCustomAlertDialogBuilder.setTitle(getString(R.string.prompt_fidesmo_pgp_install_title));
+ mCustomAlertDialogBuilder.setMessage(getString(R.string.prompt_fidesmo_pgp_install_message));
+ mCustomAlertDialogBuilder.setPositiveButton(
+ getString(R.string.prompt_fidesmo_pgp_install_button_positive),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ startFidesmoPgpAppletActivity();
+ }
+ });
+ mCustomAlertDialogBuilder.setNegativeButton(
+ getString(R.string.prompt_fidesmo_pgp_install_button_negative),
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dismiss();
+ }
+ });
+
+ return mCustomAlertDialogBuilder.show();
+ }
+
+ private void startFidesmoPgpAppletActivity() {
+ try {
+ // Call the Fidesmo app with the PGP applet as parameter to
+ // send the user straight to it
+ final String mPgpInstallServiceUrl = FIDESMO_SERVICE_URI + FIDESMO_PGP_APPLICATION_ID
+ + "/" + FIDESMO_PGP_SERVICE_ID;
+ Intent mPgpServiceIntent = new Intent(FIDESMO_SERVICE_DELIVERY_CARD_ACTION,
+ Uri.parse(mPgpInstallServiceUrl));
+ startActivity(mPgpServiceIntent);
+ } catch (IllegalArgumentException e) {
+ Log.e(Constants.TAG, "Error when parsing URI");
+ }
+ }
+}