intermediate state, nothing really working yet
This commit is contained in:
@@ -107,6 +107,10 @@
|
|||||||
android:name=".ui.EditKeyActivity"
|
android:name=".ui.EditKeyActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
android:label="@string/title_edit_key" />
|
android:label="@string/title_edit_key" />
|
||||||
|
<activity
|
||||||
|
android:name=".ui.affirmations.AffirmationWizard"
|
||||||
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
|
android:label="@string/title_affirmation" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.QrCodeViewActivity"
|
android:name=".ui.QrCodeViewActivity"
|
||||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation;
|
||||||
|
|
||||||
|
import org.spongycastle.bcpg.UserAttributeSubpacket;
|
||||||
|
import org.spongycastle.util.Strings;
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Affirmation {
|
||||||
|
|
||||||
|
protected byte[] mData;
|
||||||
|
public final long mNonce;
|
||||||
|
public final URI mSubUri;
|
||||||
|
final Set<String> mFlags;
|
||||||
|
final HashMap<String,String> mParams;
|
||||||
|
|
||||||
|
protected Affirmation(byte[] data, long nonce, Set<String> flags,
|
||||||
|
HashMap<String,String> params, URI subUri) {
|
||||||
|
mData = data;
|
||||||
|
mNonce = nonce;
|
||||||
|
mFlags = flags;
|
||||||
|
mParams = params;
|
||||||
|
mSubUri = subUri;
|
||||||
|
}
|
||||||
|
|
||||||
|
Affirmation(long nonce, Set<String> flags,
|
||||||
|
HashMap<String,String> params, URI subUri) {
|
||||||
|
this(null, nonce, flags, params, subUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] encode() {
|
||||||
|
if (mData != null) {
|
||||||
|
return mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append("pgpid:");
|
||||||
|
|
||||||
|
// add flags
|
||||||
|
if (mFlags != null) {
|
||||||
|
boolean first = true;
|
||||||
|
for (String flag : mFlags) {
|
||||||
|
if (!first) {
|
||||||
|
b.append(";");
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
b.append(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add parameters
|
||||||
|
if (mParams != null) {
|
||||||
|
boolean first = true;
|
||||||
|
Iterator<Entry<String, String>> it = mParams.entrySet().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
if (!first) {
|
||||||
|
b.append(";");
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
Entry<String, String> entry = it.next();
|
||||||
|
b.append(entry.getKey()).append("=").append(entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.append("@");
|
||||||
|
b.append(mSubUri);
|
||||||
|
|
||||||
|
byte[] data = Strings.toUTF8ByteArray(b.toString());
|
||||||
|
|
||||||
|
byte[] result = new byte[data.length+4];
|
||||||
|
result[0] = (byte) (mNonce >> 24 & 255);
|
||||||
|
result[1] = (byte) (mNonce >> 16 & 255);
|
||||||
|
result[2] = (byte) (mNonce >> 8 & 255);
|
||||||
|
result[3] = (byte) (mNonce & 255);
|
||||||
|
|
||||||
|
System.arraycopy(data, 0, result, 4, result.length);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This method parses an affirmation from a UserAttributeSubpacket, or returns null if the
|
||||||
|
* subpacket can not be parsed as a valid affirmation.
|
||||||
|
*/
|
||||||
|
public static Affirmation parseAffirmation(UserAttributeSubpacket subpacket) {
|
||||||
|
if (subpacket.getType() != 100) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] data = subpacket.getData();
|
||||||
|
|
||||||
|
long nonce = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
|
||||||
|
|
||||||
|
try {
|
||||||
|
return parseUri(nonce, Strings.fromUTF8ByteArray(Arrays.copyOfRange(data, 4, data.length)));
|
||||||
|
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Log.e(Constants.TAG, "error parsing uri in (suspected) affirmation packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Affirmation generateForUri(String uri) {
|
||||||
|
return parseUri(generateNonce(), uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Affirmation parseUri (long nonce, String uriString) {
|
||||||
|
URI uri = URI.create(uriString);
|
||||||
|
|
||||||
|
if ("pgpid".equals(uri.getScheme())) {
|
||||||
|
Log.e(Constants.TAG, "unknown uri scheme in (suspected) affirmation packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uri.isOpaque()) {
|
||||||
|
Log.e(Constants.TAG, "non-opaque uri in (suspected) affirmation packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String specific = uri.getSchemeSpecificPart();
|
||||||
|
if (!specific.contains("@")) {
|
||||||
|
Log.e(Constants.TAG, "unknown uri scheme in affirmation packet");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] pieces = specific.split("@", 2);
|
||||||
|
URI subUri = URI.create(pieces[1]);
|
||||||
|
|
||||||
|
Set<String> flags = new HashSet<String>();
|
||||||
|
HashMap<String,String> params = new HashMap<String,String>();
|
||||||
|
{
|
||||||
|
String[] rawParams = pieces[0].split(";");
|
||||||
|
for (String param : rawParams) {
|
||||||
|
String[] p = param.split("=", 2);
|
||||||
|
if (p.length == 1) {
|
||||||
|
flags.add(param);
|
||||||
|
} else {
|
||||||
|
params.put(p[0], p[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Affirmation(null, nonce, flags, params, subUri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long generateNonce() {
|
||||||
|
return 1234567890L; // new SecureRandom().nextLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.resources.GenericHttpsResource;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.resources.UnknownResource;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class AffirmationResource {
|
||||||
|
|
||||||
|
protected final URI mUri;
|
||||||
|
protected final Set<String> mFlags;
|
||||||
|
protected final HashMap<String,String> mParams;
|
||||||
|
|
||||||
|
protected AffirmationResource(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
|
mFlags = flags;
|
||||||
|
mParams = params;
|
||||||
|
mUri = uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean verify();
|
||||||
|
|
||||||
|
public static AffirmationResource findResourceType
|
||||||
|
(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
|
|
||||||
|
AffirmationResource res;
|
||||||
|
|
||||||
|
res = GenericHttpsResource.create(flags, params, uri);
|
||||||
|
if (res != null) {
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UnknownResource(flags, params, uri);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long generateNonce() {
|
||||||
|
return 1234567890L; // new SecureRandom().nextLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation.resources;
|
||||||
|
|
||||||
|
public class DnsResouce {
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation.resources;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.textuality.keybase.lib.Search;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.AffirmationResource;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
|
import org.sufficientlysecure.keychain.util.InputData;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
public class GenericHttpsResource extends AffirmationResource {
|
||||||
|
|
||||||
|
GenericHttpsResource(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
|
super(flags, params, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean verify() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String generate (byte[] fingerprint, String uri) {
|
||||||
|
long nonce = generateNonce();
|
||||||
|
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
b.append("---\r\n");
|
||||||
|
|
||||||
|
b.append("fingerprint=");
|
||||||
|
b.append(KeyFormattingUtils.convertFingerprintToHex(fingerprint));
|
||||||
|
b.append('\r').append('\n');
|
||||||
|
|
||||||
|
b.append("nonce=");
|
||||||
|
b.append(nonce);
|
||||||
|
b.append('\r').append('\n');
|
||||||
|
|
||||||
|
if (uri != null) {
|
||||||
|
b.append("uri=");
|
||||||
|
b.append(uri);
|
||||||
|
b.append('\r').append('\n');
|
||||||
|
}
|
||||||
|
b.append("---\r\n");
|
||||||
|
|
||||||
|
return b.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecryptVerifyResult verify
|
||||||
|
(Context context, ProviderHelper providerHelper, Progressable progress)
|
||||||
|
throws IOException {
|
||||||
|
|
||||||
|
byte[] data = fetchResource(mUri).getBytes();
|
||||||
|
InputData input = new InputData(new ByteArrayInputStream(data), data.length);
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
PgpDecryptVerify.Builder b =
|
||||||
|
new PgpDecryptVerify.Builder(context, providerHelper, progress, input, out);
|
||||||
|
PgpDecryptVerify op = b.build();
|
||||||
|
|
||||||
|
Log.d(Constants.TAG, new String(out.toByteArray()));
|
||||||
|
|
||||||
|
return op.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static String fetchResource (URI uri) throws IOException {
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpsURLConnection conn = null;
|
||||||
|
URL url = uri.toURL();
|
||||||
|
int status = 0;
|
||||||
|
int redirects = 0;
|
||||||
|
while (redirects < 5) {
|
||||||
|
conn = (HttpsURLConnection) url.openConnection();
|
||||||
|
conn.addRequestProperty("User-Agent", "OpenKeychain");
|
||||||
|
conn.setConnectTimeout(5000);
|
||||||
|
conn.setReadTimeout(25000);
|
||||||
|
conn.connect();
|
||||||
|
status = conn.getResponseCode();
|
||||||
|
if (status == 301) {
|
||||||
|
redirects++;
|
||||||
|
url = new URL(conn.getHeaderFields().get("Location").get(0));
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (status >= 200 && status < 300) {
|
||||||
|
return Search.snarf(conn.getInputStream());
|
||||||
|
} else {
|
||||||
|
throw new IOException("Fetch failed, status " + status + ": " + Search.snarf(conn.getErrorStream()));
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenericHttpsResource createNew (URI uri) {
|
||||||
|
HashSet<String> flags = new HashSet<String>();
|
||||||
|
flags.add("generic");
|
||||||
|
HashMap<String,String> params = new HashMap<String,String>();
|
||||||
|
return create(flags, params, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GenericHttpsResource create(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
|
if ( ! ("https".equals(uri.getScheme())
|
||||||
|
&& flags != null && flags.size() == 1 && flags.contains("generic")
|
||||||
|
&& (params == null || params.isEmpty()))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new GenericHttpsResource(flags, params, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation.resources;
|
||||||
|
|
||||||
|
public class TwitterResource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.sufficientlysecure.keychain.pgp.affirmation.resources;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.AffirmationResource;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class UnknownResource extends AffirmationResource {
|
||||||
|
|
||||||
|
public UnknownResource(Set<String> flags, HashMap<String,String> params, URI uri) {
|
||||||
|
super(flags, params, uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean verify() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.Constants;
|
|||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
|
||||||
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
|
import org.sufficientlysecure.keychain.ui.affirmations.AffirmationWizard;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
@@ -55,6 +56,7 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
|
|
||||||
public static final String ARG_DATA_URI = "uri";
|
public static final String ARG_DATA_URI = "uri";
|
||||||
|
|
||||||
|
private View mActionLink, mActionLinkDivider;
|
||||||
private View mActionEdit;
|
private View mActionEdit;
|
||||||
private View mActionEditDivider;
|
private View mActionEditDivider;
|
||||||
private View mActionEncryptFiles;
|
private View mActionEncryptFiles;
|
||||||
@@ -83,6 +85,8 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer());
|
View view = inflater.inflate(R.layout.view_key_main_fragment, getContainer());
|
||||||
|
|
||||||
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
|
mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids);
|
||||||
|
mActionLink = view.findViewById(R.id.view_key_action_link);
|
||||||
|
mActionLinkDivider = view.findViewById(R.id.view_key_action_link);
|
||||||
mActionEdit = view.findViewById(R.id.view_key_action_edit);
|
mActionEdit = view.findViewById(R.id.view_key_action_edit);
|
||||||
mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider);
|
mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider);
|
||||||
mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text);
|
mActionEncryptText = view.findViewById(R.id.view_key_action_encrypt_text);
|
||||||
@@ -156,6 +160,11 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
certify(mDataUri);
|
certify(mDataUri);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
mActionLink.setOnClickListener(new View.OnClickListener() {
|
||||||
|
public void onClick(View view) {
|
||||||
|
linkKey(mDataUri);
|
||||||
|
}
|
||||||
|
});
|
||||||
mActionEdit.setOnClickListener(new View.OnClickListener() {
|
mActionEdit.setOnClickListener(new View.OnClickListener() {
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
editKey(mDataUri);
|
editKey(mDataUri);
|
||||||
@@ -224,10 +233,14 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
if (data.moveToFirst()) {
|
if (data.moveToFirst()) {
|
||||||
if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) {
|
if (data.getInt(INDEX_UNIFIED_HAS_ANY_SECRET) != 0) {
|
||||||
// edit button
|
// edit button
|
||||||
|
mActionLink.setVisibility(View.VISIBLE);
|
||||||
|
mActionLinkDivider.setVisibility(View.VISIBLE);
|
||||||
mActionEdit.setVisibility(View.VISIBLE);
|
mActionEdit.setVisibility(View.VISIBLE);
|
||||||
mActionEditDivider.setVisibility(View.VISIBLE);
|
mActionEditDivider.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
// edit button
|
// edit button
|
||||||
|
mActionLink.setVisibility(View.GONE);
|
||||||
|
mActionLinkDivider.setVisibility(View.GONE);
|
||||||
mActionEdit.setVisibility(View.GONE);
|
mActionEdit.setVisibility(View.GONE);
|
||||||
mActionEditDivider.setVisibility(View.GONE);
|
mActionEditDivider.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
@@ -347,4 +360,10 @@ public class ViewKeyMainFragment extends LoaderFragment implements
|
|||||||
startActivityForResult(editIntent, 0);
|
startActivityForResult(editIntent, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void linkKey(Uri dataUri) {
|
||||||
|
Intent editIntent = new Intent(getActivity(), AffirmationWizard.class);
|
||||||
|
editIntent.setData(KeyRings.buildUnifiedKeyRingUri(dataUri));
|
||||||
|
startActivityForResult(editIntent, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,275 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.ui.affirmations;
|
||||||
|
|
||||||
|
import android.app.ProgressDialog;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.os.Messenger;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.text.Editable;
|
||||||
|
import android.text.TextWatcher;
|
||||||
|
import android.util.Patterns;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.SignEncryptResult;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.resources.GenericHttpsResource;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
|
import org.sufficientlysecure.keychain.ui.NfcActivity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class AffirmationCreateHttpsStep1Fragment extends Fragment {
|
||||||
|
|
||||||
|
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
||||||
|
public static final int REQUEST_CODE_NFC = 0x00008002;
|
||||||
|
|
||||||
|
AffirmationWizard mAffirmationWizard;
|
||||||
|
|
||||||
|
String mProofUri, mProofText;
|
||||||
|
|
||||||
|
EditText mEditUri;
|
||||||
|
|
||||||
|
// For NFC data
|
||||||
|
protected String mSigningKeyPassphrase = null;
|
||||||
|
protected Date mNfcTimestamp = null;
|
||||||
|
protected byte[] mNfcHash = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new instance of this fragment
|
||||||
|
*/
|
||||||
|
public static AffirmationCreateHttpsStep1Fragment newInstance() {
|
||||||
|
AffirmationCreateHttpsStep1Fragment frag = new AffirmationCreateHttpsStep1Fragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
frag.setArguments(args);
|
||||||
|
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
mAffirmationWizard = (AffirmationWizard) getActivity();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
final View view = inflater.inflate(R.layout.affirmation_create_https_fragment_step1, container, false);
|
||||||
|
|
||||||
|
view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
String uri = "https://" + mEditUri.getText();
|
||||||
|
|
||||||
|
if (!checkUri(uri)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mProofUri = uri;
|
||||||
|
mProofText = GenericHttpsResource.generate(mAffirmationWizard.mFingerprint, null);
|
||||||
|
|
||||||
|
generateResourceAndNext();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mEditUri = (EditText) view.findViewById(R.id.affirmation_create_https_uri);
|
||||||
|
|
||||||
|
mEditUri.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable editable) {
|
||||||
|
String uri = "https://" + editable;
|
||||||
|
if (uri.length() > 0) {
|
||||||
|
if (checkUri(uri)) {
|
||||||
|
mEditUri.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||||
|
R.drawable.uid_mail_ok, 0);
|
||||||
|
} else {
|
||||||
|
mEditUri.setCompoundDrawablesWithIntrinsicBounds(0, 0,
|
||||||
|
R.drawable.uid_mail_bad, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// remove drawable if email is empty
|
||||||
|
mEditUri.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mEditUri.setText("mugenguild.com/pgpkey.txt");
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateResourceAndNext () {
|
||||||
|
|
||||||
|
// Send all information needed to service to edit key in other thread
|
||||||
|
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
|
||||||
|
intent.setAction(KeychainIntentService.ACTION_SIGN_ENCRYPT);
|
||||||
|
intent.putExtra(KeychainIntentService.EXTRA_DATA, createEncryptBundle());
|
||||||
|
|
||||||
|
// Message is received after encrypting is done in KeychainIntentService
|
||||||
|
KeychainIntentServiceHandler serviceHandler = new KeychainIntentServiceHandler(
|
||||||
|
mAffirmationWizard, getString(R.string.progress_encrypting),
|
||||||
|
ProgressDialog.STYLE_HORIZONTAL) {
|
||||||
|
public void handleMessage(Message message) {
|
||||||
|
// handle messages by standard KeychainIntentServiceHandler first
|
||||||
|
super.handleMessage(message);
|
||||||
|
|
||||||
|
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
|
||||||
|
SignEncryptResult pgpResult =
|
||||||
|
message.getData().getParcelable(SignEncryptResult.EXTRA_RESULT);
|
||||||
|
|
||||||
|
if (pgpResult.isPending()) {
|
||||||
|
if ((pgpResult.getResult() & SignEncryptResult.RESULT_PENDING_PASSPHRASE) ==
|
||||||
|
SignEncryptResult.RESULT_PENDING_PASSPHRASE) {
|
||||||
|
startPassphraseDialog(pgpResult.getKeyIdPassphraseNeeded());
|
||||||
|
} else if ((pgpResult.getResult() & SignEncryptResult.RESULT_PENDING_NFC) ==
|
||||||
|
SignEncryptResult.RESULT_PENDING_NFC) {
|
||||||
|
|
||||||
|
mNfcTimestamp = pgpResult.getNfcTimestamp();
|
||||||
|
startNfcSign(pgpResult.getNfcKeyId(), pgpResult.getNfcPassphrase(), pgpResult.getNfcHash(), pgpResult.getNfcAlgo());
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Unhandled pending result!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pgpResult.success()) {
|
||||||
|
String proofText = new String(
|
||||||
|
message.getData().getByteArray(KeychainIntentService.RESULT_BYTES));
|
||||||
|
|
||||||
|
AffirmationCreateHttpsStep2Fragment frag =
|
||||||
|
AffirmationCreateHttpsStep2Fragment.newInstance(mProofUri, proofText);
|
||||||
|
|
||||||
|
mAffirmationWizard.loadFragment(null, frag, AffirmationWizard.FRAG_ACTION_TO_RIGHT);
|
||||||
|
} else {
|
||||||
|
pgpResult.createNotify(getActivity()).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// no matter the result, reset parameters
|
||||||
|
mSigningKeyPassphrase = null;
|
||||||
|
mNfcHash = null;
|
||||||
|
mNfcTimestamp = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Create a new Messenger for the communication back
|
||||||
|
Messenger messenger = new Messenger(serviceHandler);
|
||||||
|
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
|
||||||
|
|
||||||
|
// show progress dialog
|
||||||
|
serviceHandler.showProgressDialog(getActivity());
|
||||||
|
|
||||||
|
// start service with intent
|
||||||
|
getActivity().startService(intent);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Bundle createEncryptBundle() {
|
||||||
|
// fill values for this action
|
||||||
|
Bundle data = new Bundle();
|
||||||
|
|
||||||
|
data.putInt(KeychainIntentService.SOURCE, KeychainIntentService.IO_BYTES);
|
||||||
|
data.putInt(KeychainIntentService.TARGET, KeychainIntentService.IO_BYTES);
|
||||||
|
data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, mProofText.getBytes());
|
||||||
|
|
||||||
|
// Always use armor for messages
|
||||||
|
data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, true);
|
||||||
|
|
||||||
|
data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_MASTER_ID, mAffirmationWizard.mMasterKeyId);
|
||||||
|
data.putString(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_PASSPHRASE, mSigningKeyPassphrase);
|
||||||
|
data.putSerializable(KeychainIntentService.ENCRYPT_SIGNATURE_NFC_TIMESTAMP, mNfcTimestamp);
|
||||||
|
data.putByteArray(KeychainIntentService.ENCRYPT_SIGNATURE_NFC_HASH, mNfcHash);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startPassphraseDialog(long subkeyId) {
|
||||||
|
Intent intent = new Intent(getActivity(), PassphraseDialogActivity.class);
|
||||||
|
intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, subkeyId);
|
||||||
|
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void startNfcSign(long keyId, String pin, byte[] hashToSign, int hashAlgo) {
|
||||||
|
// build PendingIntent for Yubikey NFC operations
|
||||||
|
Intent intent = new Intent(getActivity(), NfcActivity.class);
|
||||||
|
intent.setAction(NfcActivity.ACTION_SIGN_HASH);
|
||||||
|
|
||||||
|
// pass params through to activity that it can be returned again later to repeat pgp operation
|
||||||
|
intent.putExtra(NfcActivity.EXTRA_DATA, new Intent()); // not used, only relevant to OpenPgpService
|
||||||
|
intent.putExtra(NfcActivity.EXTRA_KEY_ID, keyId);
|
||||||
|
intent.putExtra(NfcActivity.EXTRA_PIN, pin);
|
||||||
|
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign);
|
||||||
|
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo);
|
||||||
|
|
||||||
|
startActivityForResult(intent, REQUEST_CODE_NFC);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean checkUri(String uri) {
|
||||||
|
return Patterns.WEB_URL.matcher(uri).matches();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CODE_PASSPHRASE: {
|
||||||
|
if (resultCode == AffirmationWizard.RESULT_OK && data != null) {
|
||||||
|
mSigningKeyPassphrase = data.getStringExtra(PassphraseDialogActivity.MESSAGE_DATA_PASSPHRASE);
|
||||||
|
generateResourceAndNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case REQUEST_CODE_NFC: {
|
||||||
|
if (resultCode == AffirmationWizard.RESULT_OK && data != null) {
|
||||||
|
mNfcHash = data.getByteArrayExtra(OpenPgpApi.EXTRA_NFC_SIGNED_HASH);
|
||||||
|
generateResourceAndNext();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,256 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.ui.affirmations;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.graphics.PorterDuff;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.affirmation.resources.GenericHttpsResource;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||||
|
import org.sufficientlysecure.keychain.util.FileHelper;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
|
public class AffirmationCreateHttpsStep2Fragment extends Fragment {
|
||||||
|
|
||||||
|
private static final int REQUEST_CODE_OUTPUT = 0x00007007;
|
||||||
|
|
||||||
|
public static final String URI = "uri", TEXT = "text";
|
||||||
|
|
||||||
|
AffirmationWizard mAffirmationWizard;
|
||||||
|
|
||||||
|
EditText mEditUri;
|
||||||
|
ImageView mVerifyImage;
|
||||||
|
View mVerifyProgress;
|
||||||
|
|
||||||
|
String mResourceUri;
|
||||||
|
String mProofString;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new instance of this fragment
|
||||||
|
*/
|
||||||
|
public static AffirmationCreateHttpsStep2Fragment newInstance(String uri, String proofText) {
|
||||||
|
AffirmationCreateHttpsStep2Fragment frag = new AffirmationCreateHttpsStep2Fragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(URI, uri);
|
||||||
|
args.putString(TEXT, proofText);
|
||||||
|
frag.setArguments(args);
|
||||||
|
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
final View view = inflater.inflate(R.layout.affirmation_create_https_fragment_step2, container, false);
|
||||||
|
|
||||||
|
mResourceUri = getArguments().getString(URI);
|
||||||
|
mProofString = getArguments().getString(TEXT);
|
||||||
|
|
||||||
|
view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
|
||||||
|
// AffirmationCreateHttpsStep2Fragment frag =
|
||||||
|
// AffirmationCreateHttpsStep2Fragment.newInstance();
|
||||||
|
|
||||||
|
// mAffirmationWizard.loadFragment(null, frag, AffirmationWizard.FRAG_ACTION_TO_RIGHT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mVerifyImage = (ImageView) view.findViewById(R.id.verify_image);
|
||||||
|
mVerifyProgress = view.findViewById(R.id.verify_progress);
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofSend();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_save).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofSave();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_verify).setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
proofVerify();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mEditUri = (EditText) view.findViewById(R.id.affirmation_create_https_uri);
|
||||||
|
mEditUri.setText(mResourceUri);
|
||||||
|
|
||||||
|
setVerifyProgress(false, null);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
mAffirmationWizard = (AffirmationWizard) getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVerifyProgress(boolean on, Boolean success) {
|
||||||
|
mVerifyProgress.setVisibility(on ? View.VISIBLE : View.GONE);
|
||||||
|
mVerifyImage.setVisibility(on ? View.GONE : View.VISIBLE);
|
||||||
|
if (success == null) {
|
||||||
|
mVerifyImage.setImageResource(R.drawable.status_signature_unverified_cutout);
|
||||||
|
mVerifyImage.setColorFilter(getResources().getColor(R.color.tertiary_text_light),
|
||||||
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
} else if (success) {
|
||||||
|
mVerifyImage.setImageResource(R.drawable.status_signature_verified_cutout);
|
||||||
|
mVerifyImage.setColorFilter(getResources().getColor(R.color.android_green_dark),
|
||||||
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
} else {
|
||||||
|
mVerifyImage.setImageResource(R.drawable.status_signature_unknown_cutout);
|
||||||
|
mVerifyImage.setColorFilter(getResources().getColor(R.color.android_red_dark),
|
||||||
|
PorterDuff.Mode.SRC_IN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void proofVerify() {
|
||||||
|
setVerifyProgress(true, null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
final GenericHttpsResource resource = GenericHttpsResource.createNew(new URI(mResourceUri));
|
||||||
|
|
||||||
|
new AsyncTask<Void,Void,DecryptVerifyResult>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected DecryptVerifyResult doInBackground(Void... params) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return resource.verify(getActivity(), new ProviderHelper(getActivity()), null);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(DecryptVerifyResult result) {
|
||||||
|
super.onPostExecute(result);
|
||||||
|
if (result.success()) {
|
||||||
|
switch (result.getSignatureResult().getStatus()) {
|
||||||
|
case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED:
|
||||||
|
setVerifyProgress(false, true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
setVerifyProgress(false, false);
|
||||||
|
// on error, show error message
|
||||||
|
result.createNotify(getActivity()).show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setVerifyProgress(false, false);
|
||||||
|
// on error, show error message
|
||||||
|
result.createNotify(getActivity()).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void proofSend() {
|
||||||
|
Intent sendIntent = new Intent();
|
||||||
|
sendIntent.setAction(Intent.ACTION_SEND);
|
||||||
|
sendIntent.putExtra(Intent.EXTRA_TEXT, mProofString);
|
||||||
|
sendIntent.setType("text/plain");
|
||||||
|
startActivity(sendIntent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void proofSave () {
|
||||||
|
String state = Environment.getExternalStorageState();
|
||||||
|
if (!Environment.MEDIA_MOUNTED.equals(state)) {
|
||||||
|
Notify.showNotify(getActivity(), "External storage not available!", Style.ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetName = "pgpkey.txt";
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||||
|
File targetFile = new File(Constants.Path.APP_DIR, targetName);
|
||||||
|
FileHelper.saveFile(this, getString(R.string.title_decrypt_to_file),
|
||||||
|
getString(R.string.specify_file_to_decrypt_to), targetFile, REQUEST_CODE_OUTPUT);
|
||||||
|
} else {
|
||||||
|
FileHelper.saveDocument(this, "text/plain", targetName, REQUEST_CODE_OUTPUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveFile(Uri uri) {
|
||||||
|
try {
|
||||||
|
PrintWriter out =
|
||||||
|
new PrintWriter(getActivity().getContentResolver().openOutputStream(uri));
|
||||||
|
out.print(mProofString);
|
||||||
|
if (out.checkError()) {
|
||||||
|
Notify.showNotify(getActivity(), "Error writing file!", Style.ERROR);
|
||||||
|
}
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Notify.showNotify(getActivity(), "File could not be opened for writing!", Style.ERROR);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CODE_OUTPUT:
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Uri uri = data.getData();
|
||||||
|
saveFile(uri);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.ui.affirmations;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
|
public class AffirmationSelectFragment extends Fragment {
|
||||||
|
|
||||||
|
AffirmationWizard mAffirmationWizard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new instance of this fragment
|
||||||
|
*/
|
||||||
|
public static AffirmationSelectFragment newInstance() {
|
||||||
|
AffirmationSelectFragment frag = new AffirmationSelectFragment();
|
||||||
|
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
frag.setArguments(args);
|
||||||
|
|
||||||
|
return frag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
View view = inflater.inflate(R.layout.affirmation_select_fragment, container, false);
|
||||||
|
|
||||||
|
view.findViewById(R.id.affirmation_create_https_button)
|
||||||
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
AffirmationCreateHttpsStep1Fragment frag =
|
||||||
|
AffirmationCreateHttpsStep1Fragment.newInstance();
|
||||||
|
|
||||||
|
mAffirmationWizard.loadFragment(null, frag, AffirmationWizard.FRAG_ACTION_TO_RIGHT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
|
super.onActivityCreated(savedInstanceState);
|
||||||
|
|
||||||
|
mAffirmationWizard = (AffirmationWizard) getActivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.sufficientlysecure.keychain.ui.affirmations;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
import android.support.v7.app.ActionBarActivity;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
|
||||||
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
|
public class AffirmationWizard extends ActionBarActivity {
|
||||||
|
|
||||||
|
public static final int FRAG_ACTION_START = 0;
|
||||||
|
public static final int FRAG_ACTION_TO_RIGHT = 1;
|
||||||
|
public static final int FRAG_ACTION_TO_LEFT = 2;
|
||||||
|
|
||||||
|
long mMasterKeyId;
|
||||||
|
byte[] mFingerprint;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
setContentView(R.layout.create_key_activity);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Uri uri = getIntent().getData();
|
||||||
|
CachedPublicKeyRing ring = new ProviderHelper(this).getCachedPublicKeyRing(uri);
|
||||||
|
mMasterKeyId = ring.extractOrGetMasterKeyId();
|
||||||
|
mFingerprint = ring.getFingerprint();
|
||||||
|
} catch (PgpKeyNotFoundException e) {
|
||||||
|
Log.e(Constants.TAG, "Invalid uri given, key does not exist!");
|
||||||
|
finish();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pass extras into fragment
|
||||||
|
AffirmationSelectFragment frag = AffirmationSelectFragment.newInstance();
|
||||||
|
loadFragment(null, frag, FRAG_ACTION_START);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFragment(Bundle savedInstanceState, Fragment fragment, int action) {
|
||||||
|
// However, if we're being restored from a previous state,
|
||||||
|
// then we don't need to do anything and should return or else
|
||||||
|
// we could end up with overlapping fragments.
|
||||||
|
if (savedInstanceState != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the fragment to the 'fragment_container' FrameLayout
|
||||||
|
// NOTE: We use commitAllowingStateLoss() to prevent weird crashes!
|
||||||
|
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case FRAG_ACTION_START:
|
||||||
|
transaction.setCustomAnimations(0, 0);
|
||||||
|
transaction.replace(R.id.create_key_fragment_container, fragment)
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
break;
|
||||||
|
case FRAG_ACTION_TO_LEFT:
|
||||||
|
getSupportFragmentManager().popBackStackImmediate();
|
||||||
|
break;
|
||||||
|
case FRAG_ACTION_TO_RIGHT:
|
||||||
|
transaction.setCustomAnimations(R.anim.frag_slide_in_from_right, R.anim.frag_slide_out_to_left,
|
||||||
|
R.anim.frag_slide_in_from_left, R.anim.frag_slide_out_to_right);
|
||||||
|
transaction.addToBackStack(null);
|
||||||
|
transaction.replace(R.id.create_key_fragment_container, fragment)
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
// do it immediately!
|
||||||
|
getSupportFragmentManager().executePendingTransactions();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.*;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.util.AttributeSet;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public class HttpsPrefixedText extends EditText {
|
||||||
|
|
||||||
|
private String mPrefix; // can be hardcoded for demo purposes
|
||||||
|
private Rect mPrefixRect = new Rect();
|
||||||
|
|
||||||
|
public HttpsPrefixedText(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
mPrefix = "https://";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
|
getPaint().getTextBounds(mPrefix, 0, mPrefix.length(), mPrefixRect);
|
||||||
|
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(@NonNull Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
canvas.drawText(mPrefix, super.getCompoundPaddingLeft(), getBaseline(), getPaint());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCompoundPaddingLeft() {
|
||||||
|
return super.getCompoundPaddingLeft() + mPrefixRect.width();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
OpenKeychain/src/main/res/drawable/ssl_lock.png
Normal file
BIN
OpenKeychain/src/main/res/drawable/ssl_lock.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 479 B |
BIN
OpenKeychain/src/main/res/drawable/twitter.png
Normal file
BIN
OpenKeychain/src/main/res/drawable/twitter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.0 KiB |
@@ -0,0 +1,121 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fillViewport="false"
|
||||||
|
android:layout_above="@+id/create_key_button_divider">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_1_1" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.HttpsPrefixedText
|
||||||
|
android:id="@+id/affirmation_create_https_uri"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:ems="10"
|
||||||
|
android:inputType="textUri"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_1_2" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_1_3" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/create_key_button_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
|
android:layout_alignTop="@+id/create_key_buttons"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:id="@+id/create_key_buttons">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/create_key_back_button"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text=""
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/next_button"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/btn_next"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:drawableRight="@drawable/ic_action_play"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<ScrollView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:fillViewport="false"
|
||||||
|
android:layout_above="@+id/create_key_button_divider">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_2_1" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/affirmation_create_https_uri"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionNext"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:hint="uri"
|
||||||
|
android:ems="10"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:inputType="textUri|none"
|
||||||
|
android:enabled="false"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_2_2" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_gravity="center_horizontal">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Share"
|
||||||
|
android:id="@+id/button_send"
|
||||||
|
android:layout_marginRight="8dip"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Save"
|
||||||
|
android:id="@+id/button_save"
|
||||||
|
android:layout_marginLeft="8dip"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_2_3" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/verify_image"
|
||||||
|
android:src="@drawable/status_signature_unverified_cutout"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="16dip"/>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/verify_progress"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:indeterminateOnly="true"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="Not verified"
|
||||||
|
android:layout_marginLeft="16dip"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:id="@+id/verify_status"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Verify"
|
||||||
|
android:id="@+id/button_verify"
|
||||||
|
android:layout_marginRight="16dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="@string/aff_create_https_2_4" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/create_key_button_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
|
android:layout_alignTop="@+id/create_key_buttons"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_alignParentBottom="true"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:id="@+id/create_key_buttons">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/create_key_back_button"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text=""
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="1dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/next_button"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/btn_next"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:drawableRight="@drawable/ic_action_play"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:clickable="true"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
</LinearLayout>
|
||||||
|
</RelativeLayout>
|
||||||
118
OpenKeychain/src/main/res/layout/affirmation_select_fragment.xml
Normal file
118
OpenKeychain/src/main/res/layout/affirmation_select_fragment.xml
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="An 'affirmation' connects your pgp key to a resource on the web."
|
||||||
|
android:id="@+id/textView"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="8dp"
|
||||||
|
android:layout_marginLeft="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:text="Please select a type:"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||||
|
android:id="@+id/view_key_user_ids"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/affirmation_create_https_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:clickable="true"
|
||||||
|
android:paddingRight="4dp"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- separate ImageView required for recoloring -->
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/certify_key_action_certify_image"
|
||||||
|
android:layout_width="60dip"
|
||||||
|
android:layout_height="60dip"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:src="@drawable/ssl_lock"
|
||||||
|
android:layout_gravity="center_vertical" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Website"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/affirmation_create_twitter_button"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
|
android:clickable="true"
|
||||||
|
android:paddingRight="4dp"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- separate ImageView required for recoloring -->
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="60dip"
|
||||||
|
android:layout_height="60dip"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:src="@drawable/twitter"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="0dip"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:text="Twitter"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:layout_marginBottom="4dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</ScrollView>
|
||||||
@@ -71,6 +71,28 @@
|
|||||||
android:layout_height="1dip"
|
android:layout_height="1dip"
|
||||||
android:background="?android:attr/listDivider" />
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/view_key_action_link"
|
||||||
|
android:paddingLeft="8dp"
|
||||||
|
android:paddingRight="8dp"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
|
android:clickable="true"
|
||||||
|
style="@style/SelectableItem"
|
||||||
|
android:text="Link to Resource"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:drawableRight="@drawable/ic_action_add_person"
|
||||||
|
android:drawablePadding="8dp"
|
||||||
|
android:gravity="center_vertical" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/view_key_action_link_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dip"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/view_key_action_edit"
|
android:id="@+id/view_key_action_edit"
|
||||||
android:paddingLeft="8dp"
|
android:paddingLeft="8dp"
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
<string name="title_unlock">"Unlock Key"</string>
|
<string name="title_unlock">"Unlock Key"</string>
|
||||||
<string name="title_add_subkey">"Add subkey"</string>
|
<string name="title_add_subkey">"Add subkey"</string>
|
||||||
<string name="title_edit_key">"Edit Key"</string>
|
<string name="title_edit_key">"Edit Key"</string>
|
||||||
|
<string name="title_affirmation">"Create Affirmation"</string>
|
||||||
<string name="title_preferences">"Preferences"</string>
|
<string name="title_preferences">"Preferences"</string>
|
||||||
<string name="title_cloud_search_preferences">"Cloud Search Preferences"</string>
|
<string name="title_cloud_search_preferences">"Cloud Search Preferences"</string>
|
||||||
<string name="title_api_registered_apps">"Apps"</string>
|
<string name="title_api_registered_apps">"Apps"</string>
|
||||||
@@ -1099,4 +1100,13 @@
|
|||||||
<string name="unlocked">Unlocked</string>
|
<string name="unlocked">Unlocked</string>
|
||||||
<string name="nfc_settings">Settings</string>
|
<string name="nfc_settings">Settings</string>
|
||||||
|
|
||||||
|
<string name="aff_create_https_1_1">"You can connect your key to a website you own. This website must support https! Please enter a url where you are able to place a text file for proof:"</string>
|
||||||
|
<string name="aff_create_https_1_2">"Example: https://example.com/pgpkey.txt"</string>
|
||||||
|
<string name="aff_create_https_1_3">"In the next step, a proof text file will be generated and signed with your key. After that, you will then be asked to upload the proof file for verification."</string>
|
||||||
|
<string name="aff_create_https_created">"The proof file has been created. For the next step, you should save and upload it to the URI you indicated:"</string>
|
||||||
|
<string name="aff_create_https_2_1">"A proof file for this URI has been created:"</string>
|
||||||
|
<string name="aff_create_https_2_2">"For the next step, you should save and upload this file."</string>
|
||||||
|
<string name="aff_create_https_2_3">"Make sure the file is reachable at the correct URI, then verify your setup."</string>
|
||||||
|
<string name="aff_create_https_2_4">"After verification is successful, hit next to finish the process."</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user