mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Integrate safeslinger share
This commit is contained in:
parent
10e96dff43
commit
d0f46f1efb
@ -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 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 class Path {
|
||||||
public static final File APP_DIR = new File(Environment.getExternalStorageDirectory(), "OpenKeychain");
|
public static final File APP_DIR = new File(Environment.getExternalStorageDirectory(), "OpenKeychain");
|
||||||
|
@ -56,6 +56,9 @@ import org.sufficientlysecure.keychain.util.QrCodeUtils;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import edu.cmu.cylab.starslinger.exchange.ExchangeActivity;
|
||||||
|
import edu.cmu.cylab.starslinger.exchange.ExchangeConfig;
|
||||||
|
|
||||||
|
|
||||||
public class ViewKeyShareFragment extends LoaderFragment implements
|
public class ViewKeyShareFragment extends LoaderFragment implements
|
||||||
LoaderManager.LoaderCallbacks<Cursor> {
|
LoaderManager.LoaderCallbacks<Cursor> {
|
||||||
@ -68,6 +71,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
private View mFingerprintClipboardButton;
|
private View mFingerprintClipboardButton;
|
||||||
private View mKeyShareButton;
|
private View mKeyShareButton;
|
||||||
private View mKeyClipboardButton;
|
private View mKeyClipboardButton;
|
||||||
|
private View mKeySafeSlingerButton;
|
||||||
private View mNfcHelpButton;
|
private View mNfcHelpButton;
|
||||||
private View mNfcPrefsButton;
|
private View mNfcPrefsButton;
|
||||||
private View mKeyUploadButton;
|
private View mKeyUploadButton;
|
||||||
@ -93,6 +97,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
|
mFingerprintClipboardButton = view.findViewById(R.id.view_key_action_fingerprint_clipboard);
|
||||||
mKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
|
mKeyShareButton = view.findViewById(R.id.view_key_action_key_share);
|
||||||
mKeyClipboardButton = view.findViewById(R.id.view_key_action_key_clipboard);
|
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);
|
mNfcHelpButton = view.findViewById(R.id.view_key_action_nfc_help);
|
||||||
mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs);
|
mNfcPrefsButton = view.findViewById(R.id.view_key_action_nfc_prefs);
|
||||||
mKeyUploadButton = view.findViewById(R.id.view_key_action_upload);
|
mKeyUploadButton = view.findViewById(R.id.view_key_action_upload);
|
||||||
@ -113,25 +118,31 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
mFingerprintShareButton.setOnClickListener(new View.OnClickListener() {
|
mFingerprintShareButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
share(mDataUri, mProviderHelper, true, false);
|
share(mDataUri, mProviderHelper, true, false, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() {
|
mFingerprintClipboardButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
share(mDataUri, mProviderHelper, true, true);
|
share(mDataUri, mProviderHelper, true, true, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mKeyShareButton.setOnClickListener(new View.OnClickListener() {
|
mKeyShareButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
share(mDataUri, mProviderHelper, false, false);
|
share(mDataUri, mProviderHelper, false, false, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mKeyClipboardButton.setOnClickListener(new View.OnClickListener() {
|
mKeyClipboardButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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() {
|
mNfcHelpButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@ -157,7 +168,7 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly,
|
private void share(Uri dataUri, ProviderHelper providerHelper, boolean fingerprintOnly,
|
||||||
boolean toClipboard) {
|
boolean toClipboard, boolean toSafeSlinger) {
|
||||||
try {
|
try {
|
||||||
String content;
|
String content;
|
||||||
if (fingerprintOnly) {
|
if (fingerprintOnly) {
|
||||||
@ -185,6 +196,11 @@ public class ViewKeyShareFragment extends LoaderFragment implements
|
|||||||
message = getResources().getString(R.string.key_copied_to_clipboard);
|
message = getResources().getString(R.string.key_copied_to_clipboard);
|
||||||
}
|
}
|
||||||
Notify.showNotify(getActivity(), message, Notify.Style.OK);
|
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 {
|
} else {
|
||||||
// Android will fail with android.os.TransactionTooLargeException if key is too big
|
// Android will fail with android.os.TransactionTooLargeException if key is too big
|
||||||
// see http://www.lonestarprod.com/?p=34
|
// see http://www.lonestarprod.com/?p=34
|
||||||
|
@ -122,6 +122,23 @@
|
|||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
style="@style/SelectableItem" />
|
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>
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
Loading…
Reference in New Issue
Block a user