update uris and cookie patterns, plus some stylings

This commit is contained in:
Vincent Breitmoser 2015-04-25 03:40:38 +02:00
parent 608b66d192
commit d6d678dae3
11 changed files with 65 additions and 33 deletions

View file

@ -35,7 +35,7 @@ public abstract class LinkedCookieResource extends LinkedResource {
public URI toUri () {
StringBuilder b = new StringBuilder();
b.append("pgpid+cookie:");
b.append("openpgpid+cookie:");
// add flags
if (mFlags != null) {
@ -73,12 +73,12 @@ public abstract class LinkedCookieResource extends LinkedResource {
}
public static String generate (Context context, byte[] fingerprint) {
return String.format("[Verifying my PGP key: openpgp4fpr:%s]",
return String.format("[Verifying my OpenPGP key: openpgp4fpr:%s]",
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
}
public static String generatePreview () {
return "[Verifying my PGP key: openpgp4fpr:0x…]";
return "[Verifying my OpenPGP key: openpgp4fpr:0x…]";
}
public LinkedVerifyResult verify(byte[] fingerprint) {

View file

@ -26,7 +26,7 @@ public abstract class LinkedResource {
protected final HashMap<String,String> mParams;
public static Pattern magicPattern =
Pattern.compile("\\[Verifying my PGP key: openpgp4fpr:([a-zA-Z0-9]+)]");
Pattern.compile("\\[Verifying my (?:Open)?PGP key: openpgp4fpr:([a-zA-Z0-9]+)]");
protected LinkedResource(Set<String> flags, HashMap<String, String> params, URI uri) {
mFlags = flags;
@ -44,7 +44,7 @@ public abstract class LinkedResource {
protected static LinkedCookieResource fromUri (URI uri) {
if (!"pgpid+cookie".equals(uri.getScheme())) {
if (!"openpgpid+cookie".equals(uri.getScheme())) {
Log.e(Constants.TAG, "unknown uri scheme in (suspected) linked id packet");
return null;
}

View file

@ -27,7 +27,7 @@ import de.measite.minidns.record.TXT;
public class DnsResource extends LinkedCookieResource {
final static Pattern magicPattern =
Pattern.compile("pgpid\\+cookie=([a-zA-Z0-9]+)(?:#|;)([a-zA-Z0-9]+)");
Pattern.compile("openpgpid\\+cookie=([a-zA-Z0-9]+)(?:#|;)([a-zA-Z0-9]+)");
String mFqdn;
CLASS mClass;
@ -44,7 +44,7 @@ public class DnsResource extends LinkedCookieResource {
public static String generateText (Context context, byte[] fingerprint) {
return String.format("pgpid+cookie=%s",
return String.format("openpgpid+cookie=%s",
KeyFormattingUtils.convertFingerprintToHex(fingerprint));
}

View file

@ -162,7 +162,7 @@ public abstract class LinkedIdCreateFinalFragment extends CryptoOperationFragmen
} else {
setVerifyProgress(false, false);
// on error, show error message
result.createNotify(getActivity()).show();
result.createNotify(getActivity()).show(LinkedIdCreateFinalFragment.this);
}
}
}.execute();
@ -172,7 +172,8 @@ public abstract class LinkedIdCreateFinalFragment extends CryptoOperationFragmen
protected void cryptoOperation(CryptoInputParcel cryptoInput) {
if (mVerifiedResource == null) {
Notify.create(getActivity(), R.string.linked_need_verify, Notify.Style.ERROR).show();
Notify.create(getActivity(), R.string.linked_need_verify, Notify.Style.ERROR)
.show(LinkedIdCreateFinalFragment.this);
return;
}
@ -206,7 +207,7 @@ public abstract class LinkedIdCreateFinalFragment extends CryptoOperationFragmen
// if bad -> display here!
if (!result.success()) {
result.createNotify(getActivity()).show();
result.createNotify(getActivity()).show(LinkedIdCreateFinalFragment.this);
return;
}

View file

@ -66,11 +66,17 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
final String handle = mEditHandle.getText().toString();
if ("".equals(handle)) {
mEditHandle.setError("Please input a Twitter handle!");
return;
}
new AsyncTask<Void,Void,Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
return true; // return checkHandle(handle);
return true;
// return checkHandle(handle);
}
@Override
@ -79,13 +85,15 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
if (result == null) {
Notify.create(getActivity(),
"Connection error while checking username!", Notify.Style.ERROR);
"Connection error while checking username!",
Notify.Style.ERROR).show(LinkedIdCreateTwitterStep1Fragment.this);
return;
}
if (!result) {
Notify.create(getActivity(),
"This handle does not exist on Twitter!", Notify.Style.ERROR);
"This handle does not exist on Twitter!",
Notify.Style.ERROR).show(LinkedIdCreateTwitterStep1Fragment.this);
return;
}
@ -107,7 +115,6 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
});
mEditHandle = (EditText) view.findViewById(R.id.linked_create_twitter_handle);
mEditHandle.setText("");
return view;
}
@ -117,9 +124,9 @@ public class LinkedIdCreateTwitterStep1Fragment extends Fragment {
HttpURLConnection nection =
(HttpURLConnection) new URL("https://twitter.com/" + handle).openConnection();
nection.setRequestMethod("HEAD");
nection.setRequestProperty("User-Agent", "OpenKeychain");
return nection.getResponseCode() == 200;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}

View file

@ -25,6 +25,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog;
@ -79,6 +80,10 @@ public class LinkedIdCreateTwitterStep2Fragment extends LinkedIdCreateFinalFragm
}
});
((TextView) view.findViewById(R.id.linked_tweet_published)).setText(
getString(R.string.linked_create_twitter_2_3, mResourceHandle)
);
return view;
}

View file

@ -17,11 +17,14 @@
package org.sufficientlysecure.keychain.ui.linked;
import android.content.Context;
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 android.view.View;
import android.view.inputmethod.InputMethodManager;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
@ -29,9 +32,10 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.ui.base.BaseActivity;
import org.sufficientlysecure.keychain.util.Log;
public class LinkedIdWizard extends ActionBarActivity {
public class LinkedIdWizard extends BaseActivity {
public static final int FRAG_ACTION_START = 0;
public static final int FRAG_ACTION_TO_RIGHT = 1;
@ -44,7 +48,7 @@ public class LinkedIdWizard extends ActionBarActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.create_key_activity);
setTitle(getString(R.string.title_linked_id_create));
try {
Uri uri = getIntent().getData();
@ -69,6 +73,11 @@ public class LinkedIdWizard extends ActionBarActivity {
loadFragment(null, frag, FRAG_ACTION_START);
}
@Override
protected void initLayout() {
setContentView(R.layout.create_key_activity);
}
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
@ -77,6 +86,8 @@ public class LinkedIdWizard extends ActionBarActivity {
return;
}
hideKeyboard();
// Add the fragment to the 'fragment_container' FrameLayout
// NOTE: We use commitAllowingStateLoss() to prevent weird crashes!
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
@ -103,4 +114,16 @@ public class LinkedIdWizard extends ActionBarActivity {
getSupportFragmentManager().executePendingTransactions();
}
private void hideKeyboard() {
InputMethodManager inputManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
// check if no view has focus
View v = getCurrentFocus();
if (v == null)
return;
inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
}

View file

@ -105,14 +105,6 @@
android:layout_height="wrap_content"
android:text="@string/btn_decrypt_clipboard" />
<TextView
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/tertiary_text_light"
android:text="@string/btn_decrypt_and_verify"
android:gravity="center_vertical" />
</LinearLayout>
<ImageView

View file

@ -47,6 +47,7 @@
android:layout_marginTop="16dp"
android:ems="10"
android:layout_gravity="center_horizontal"
android:inputType="text"
android:hint="@string/linked_create_twitter_handle"
custom:prefix="\@"
/>

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent">
@ -27,7 +28,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/linked_create_twitter_2_2" />
<LinearLayout
@ -66,11 +67,12 @@
</LinearLayout>
<TextView
android:id="@+id/linked_tweet_published"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/linked_create_twitter_2_3" />
tools:text="@string/linked_create_twitter_2_3" />
<include layout="@layout/linked_create_verify" />

View file

@ -55,8 +55,8 @@
<string name="section_share_key">"Key"</string>
<string name="section_key_server">"Keyserver"</string>
<string name="section_fingerprint">"Fingerprint"</string>
<string name="section_encrypt">"Encrypt"</string>
<string name="section_decrypt">"Decrypt"</string>
<string name="section_encrypt">"Encrypt and/or sign"</string>
<string name="section_decrypt">"Decrypt and verify signatures"</string>
<string name="section_current_expiry">"Current expiry"</string>
<string name="section_new_expiry">"New expiry"</string>
@ -74,15 +74,15 @@
<string name="btn_back">"Back"</string>
<string name="btn_no">"No"</string>
<string name="btn_match">"Fingerprints match"</string>
<string name="btn_share_encrypted_signed">"Encrypt and share text"</string>
<string name="btn_copy_encrypted_signed">"Encrypt and copy text"</string>
<string name="btn_share_encrypted_signed">"Encrypt/sign and share text"</string>
<string name="btn_copy_encrypted_signed">"Encrypt/sign and copy text"</string>
<string name="btn_view_cert_key">"View certification key"</string>
<string name="btn_create_key">"Create key"</string>
<string name="btn_add_files">"Add file(s)"</string>
<string name="btn_share_decrypted_text">"Share decrypted text"</string>
<string name="btn_copy_decrypted_text">"Copy decrypted text"</string>
<string name="btn_decrypt_clipboard">"Decrypt text from clipboard"</string>
<string name="btn_decrypt_and_verify">"and verify signatures"</string>
<string name="btn_decrypt_and_verify">""</string>
<string name="btn_decrypt_files">"Decrypt files"</string>
<string name="btn_encrypt_files">"Encrypt files"</string>
<string name="btn_encrypt_text">"Encrypt text"</string>
@ -1309,7 +1309,7 @@
<string name="linked_create_twitter_handle">Twitter Handle</string>
<string name="linked_create_twitter_2_1">"Click either button to tweet the message!"</string>
<string name="linked_create_twitter_2_2">"You can edit the Tweet before posting it, so long as the text inside the brackets is unmodified."</string>
<string name="linked_create_twitter_2_3">"Once your Tweet is published, click the Verify button to scan your timeline for it."</string>
<string name="linked_create_twitter_2_3">"Once your Tweet is published as <b>@%s</b>, click the Verify button to scan your timeline for it."</string>
<string name="linked_create_twitter_2_4">"After successful verification, press the Finish button to add the Linked Identity to your keyring and finish the process."</string>
<string name="linked_create_github_1_1">"By creating a Linked Identity of this type, you can link your key to a Github account you control."</string>
@ -1372,5 +1372,6 @@
<string name="linked_text_error">Error</string>
<string name="linked_text_confirming">Confirming…</string>
<string name="linked_ids_more_unknown">%d more unknown identity types</string>
<string name="title_linked_id_create">Create Linked Identity</string>
</resources>