Integrate safeslinger share

This commit is contained in:
Dominik Schürmann 2014-09-04 12:54:16 +02:00
parent 10e96dff43
commit d0f46f1efb
4 changed files with 42 additions and 7 deletions

View File

@ -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");

View File

@ -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<Cursor> {
@ -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

View File

@ -122,6 +122,23 @@
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
<View
android:layout_width="1dip"
android:layout_height="match_parent"
android:gravity="right"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="?android:attr/listDivider" />
<ImageButton
android:id="@+id/view_key_action_key_safeslinger"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="8dp"
android:src="@drawable/ic_action_secure"
android:layout_gravity="center_vertical"
style="@style/SelectableItem" />
</LinearLayout>
<View

View File

@ -14,4 +14,4 @@ include ':extern:minidns'
include ':extern:KeybaseLib:Lib'
include ':extern:TokenAutoComplete:library'
include ':extern:openpgp-card-nfc-lib:library'
include ':extern:safeslinger-exchange'
include ':extern:safeslinger-exchange'