From d0f46f1efb33de4a9735c9f01e61c8277761e720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 4 Sep 2014 12:54:16 +0200 Subject: Integrate safeslinger share --- .../org/sufficientlysecure/keychain/Constants.java | 4 +++- .../keychain/ui/ViewKeyShareFragment.java | 26 +++++++++++++++++----- .../main/res/layout/view_key_share_fragment.xml | 17 ++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 7a6bd89be..623991097 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -53,7 +53,9 @@ public final class Constants { public static final String CUSTOM_CONTACT_DATA_MIME_TYPE = "vnd.android.cursor.item/vnd.org.sufficientlysecure.keychain.key"; - public static int TEMPFILE_TTL = 24 * 60 * 60 * 1000; // 1 day + public static final int TEMPFILE_TTL = 24 * 60 * 60 * 1000; // 1 day + + public static final String SAFESLINGER_SERVER = "safeslinger-openpgp.appspot.com"; public static final class Path { public static final File APP_DIR = new File(Environment.getExternalStorageDirectory(), "OpenKeychain"); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java index ae0bea5e9..b267db034 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyShareFragment.java @@ -56,6 +56,9 @@ import org.sufficientlysecure.keychain.util.QrCodeUtils; import java.io.IOException; +import edu.cmu.cylab.starslinger.exchange.ExchangeActivity; +import edu.cmu.cylab.starslinger.exchange.ExchangeConfig; + public class ViewKeyShareFragment extends LoaderFragment implements LoaderManager.LoaderCallbacks { @@ -68,6 +71,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements private View mFingerprintClipboardButton; private View mKeyShareButton; private View mKeyClipboardButton; + private View mKeySafeSlingerButton; private View mNfcHelpButton; private View mNfcPrefsButton; private View mKeyUploadButton; @@ -93,6 +97,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard); mKeyShareButton = view.findViewById(R.id.view_key_action_key_share); mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard); + mKeySafeSlingerButton = view.findViewById(R.id.view_key_action_key_safeslinger); mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help); mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs); mKeyUploadButton = view.findViewById(R.id.view_key_action_upload); @@ -113,25 +118,31 @@ public class ViewKeyShareFragment extends LoaderFragment implements mFingerprintShareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - share(mDataUri, mProviderHelper, true, false); + share(mDataUri, mProviderHelper, true, false, false); } }); mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - share(mDataUri, mProviderHelper, true, true); + share(mDataUri, mProviderHelper, true, true, false); } }); mKeyShareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - share(mDataUri, mProviderHelper, false, false); + share(mDataUri, mProviderHelper, false, false, false); } }); mKeyClipboardButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - share(mDataUri, mProviderHelper, false, true); + share(mDataUri, mProviderHelper, false, true, false); + } + }); + mKeySafeSlingerButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + share(mDataUri, mProviderHelper, false, false, true); } }); mNfcHelpButton.setOnClickListener(new View.OnClickListener() { @@ -157,7 +168,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements } private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly, - boolean toClipboard) { + boolean toClipboard, boolean toSafeSlinger) { try { String content; if (fingerprintOnly) { @@ -185,6 +196,11 @@ public class ViewKeyShareFragment extends LoaderFragment implements message = getResources().getString(R.string.key_copied_to_clipboard); } Notify.showNotify(getActivity(), message, Notify.Style.OK); + } else if (toSafeSlinger) { + Intent slingerIntent = new Intent(getActivity(), ExchangeActivity.class); + slingerIntent.putExtra(ExchangeConfig.extra.USER_DATA, content.getBytes("UTF-8")); + slingerIntent.putExtra(ExchangeConfig.extra.HOST_NAME, Constants.SAFESLINGER_SERVER); + startActivity(slingerIntent); } else { // Android will fail with android.os.TransactionTooLargeException if key is too big // see http://www.lonestarprod.com/?p=34 diff --git a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml index 0895098d4..29a6fc5b1 100644 --- a/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_share_fragment.xml @@ -122,6 +122,23 @@ android:layout_gravity="center_vertical" style="@style/SelectableItem" /> + + + +