diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-06 16:24:48 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-03-06 16:24:48 +0100 |
commit | a3ac2738ea6140c6a181f9b685249ad2f766f904 (patch) | |
tree | 1edcd1967a49639841a1ab24f658eccbc7d2300a /OpenKeychain/src/main/java | |
parent | 6e17d5244dcbfaad5c4de902e1f4c2cd913fd596 (diff) | |
download | open-keychain-a3ac2738ea6140c6a181f9b685249ad2f766f904.tar.gz open-keychain-a3ac2738ea6140c6a181f9b685249ad2f766f904.tar.bz2 open-keychain-a3ac2738ea6140c6a181f9b685249ad2f766f904.zip |
prepare superclass extraction for final linked id creation fragment
Diffstat (limited to 'OpenKeychain/src/main/java')
5 files changed, 42 insertions, 34 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java index 4b01d8135..84b79920a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/LinkedCookieResource.java @@ -62,7 +62,7 @@ public abstract class LinkedCookieResource extends LinkedResource { } public static String generate (Context context, byte[] fingerprint, int nonce) { - return String.format("\"[Verifying my PGP key: openpgp4fpr:%s#%08x]\"", + return String.format("[Verifying my PGP key: openpgp4fpr:%s#%08x]", KeyFormattingUtils.convertFingerprintToHex(fingerprint), nonce); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/RawLinkedIdentity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/RawLinkedIdentity.java index 8b014db1d..8f0467734 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/RawLinkedIdentity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/RawLinkedIdentity.java @@ -44,7 +44,7 @@ public class RawLinkedIdentity { // return Hex.toHexString(data); // debug for now - return 1234567; + return 0x8a9bad32; } public @DrawableRes int getDisplayIcon() { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java index 0ab90af75..eebe0b5ec 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/linked/resources/GenericHttpsResource.java @@ -88,9 +88,9 @@ public class GenericHttpsResource extends LinkedCookieResource { } public static GenericHttpsResource createNew (URI uri) { - HashSet<String> flags = new HashSet<String>(); + HashSet<String> flags = new HashSet<>(); flags.add("generic"); - HashMap<String,String> params = new HashMap<String,String>(); + HashMap<String,String> params = new HashMap<>(); return create(flags, params, uri); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java index 7d2f3dfdb..6a0c1cac0 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateHttpsStep2Fragment.java @@ -42,6 +42,7 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.LinkedVerifyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.WrappedUserAttribute; +import org.sufficientlysecure.keychain.pgp.linked.LinkedCookieResource; import org.sufficientlysecure.keychain.pgp.linked.LinkedIdentity; import org.sufficientlysecure.keychain.pgp.linked.RawLinkedIdentity; import org.sufficientlysecure.keychain.pgp.linked.resources.GenericHttpsResource; @@ -73,12 +74,12 @@ public class LinkedIdCreateHttpsStep2Fragment extends Fragment { View mVerifyProgress; TextView mVerifyStatus; - String mResourceUri; int mResourceNonce; + URI mResourceUri; String mResourceString; // This is a resource, set AFTER it has been verified - GenericHttpsResource mVerifiedResource = null; + LinkedCookieResource mVerifiedResource = null; /** * Creates new instance of this fragment @@ -97,13 +98,15 @@ public class LinkedIdCreateHttpsStep2Fragment extends Fragment { return frag; } + GenericHttpsResource getResource() { + return GenericHttpsResource.createNew(mResourceUri); + } + @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.linked_create_https_fragment_step2, container, false); - mResourceUri = getArguments().getString(URI); mResourceNonce = getArguments().getInt(NONCE); - mResourceString = getArguments().getString(TEXT); view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() { @Override @@ -144,8 +147,10 @@ public class LinkedIdCreateHttpsStep2Fragment extends Fragment { } }); + mResourceString = getArguments().getString(TEXT); + mEditUri = (EditText) view.findViewById(R.id.linked_create_https_uri); - mEditUri.setText(mResourceUri); + mEditUri.setText(mResourceUri.toString()); setVerifyProgress(false, null); mVerifyStatus.setText(R.string.linked_verify_pending); @@ -224,32 +229,28 @@ public class LinkedIdCreateHttpsStep2Fragment extends Fragment { public void proofVerify() { setVerifyProgress(true, null); - try { - final GenericHttpsResource resource = GenericHttpsResource.createNew(new URI(mResourceUri)); + final LinkedCookieResource resource = getResource(); - new AsyncTask<Void,Void,LinkedVerifyResult>() { + new AsyncTask<Void,Void,LinkedVerifyResult>() { - @Override - protected LinkedVerifyResult doInBackground(Void... params) { - return resource.verify(mLinkedIdWizard.mFingerprint, mResourceNonce); - } + @Override + protected LinkedVerifyResult doInBackground(Void... params) { + return resource.verify(mLinkedIdWizard.mFingerprint, mResourceNonce); + } - @Override - protected void onPostExecute(LinkedVerifyResult result) { - super.onPostExecute(result); - if (result.success()) { - setVerifyProgress(false, true); - mVerifiedResource = resource; - } else { - setVerifyProgress(false, false); - // on error, show error message - result.createNotify(getActivity()).show(); - } + @Override + protected void onPostExecute(LinkedVerifyResult result) { + super.onPostExecute(result); + if (result.success()) { + setVerifyProgress(false, true); + mVerifiedResource = resource; + } else { + setVerifyProgress(false, false); + // on error, show error message + result.createNotify(getActivity()).show(); } - }.execute(); - } catch (URISyntaxException e) { - e.printStackTrace(); - } + } + }.execute(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java index 5cf0ed115..fdc466f04 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java @@ -202,7 +202,14 @@ public class LinkedIdViewFragment extends Fragment { } } - public void verifyResource() { + void showButton(int which) { + if (mButtonSwitcher.getDisplayedChild() == which) { + return; + } + mButtonSwitcher.setDisplayedChild(which); + } + + void verifyResource() { // only one at a time synchronized (this) { @@ -241,10 +248,10 @@ public class LinkedIdViewFragment extends Fragment { protected void onPostExecute(LinkedVerifyResult result) { holder.setShowProgress(false); if (result.success()) { - mButtonSwitcher.setDisplayedChild(2); + showButton(2); holder.vText.setText("Ok"); } else { - mButtonSwitcher.setDisplayedChild(1); + showButton(1); holder.vText.setText("Error"); } mInProgress = false; |