From 2cda48642722069c7e26d0a25d196e8a41128290 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 2 Sep 2015 04:13:32 +0200 Subject: linked: use webview instead of app, and some minor layoutings --- OpenKeychain/src/main/AndroidManifest.xml | 9 - .../ui/linked/LinkedIdCreateGithubFragment.java | 216 ++++++++++++++++----- .../keychain/ui/linked/LinkedIdWizard.java | 54 ------ .../res/layout/linked_create_github_fragment.xml | 13 +- OpenKeychain/src/main/res/layout/loader_layout.xml | 10 +- OpenKeychain/src/main/res/layout/oauth_webview.xml | 12 ++ OpenKeychain/src/main/res/values/strings.xml | 9 +- 7 files changed, 197 insertions(+), 126 deletions(-) create mode 100644 OpenKeychain/src/main/res/layout/oauth_webview.xml (limited to 'OpenKeychain/src') diff --git a/OpenKeychain/src/main/AndroidManifest.xml b/OpenKeychain/src/main/AndroidManifest.xml index cb886ed50..d2e953f8a 100644 --- a/OpenKeychain/src/main/AndroidManifest.xml +++ b/OpenKeychain/src/main/AndroidManifest.xml @@ -113,16 +113,7 @@ - - - - - - () { @Override protected JSONObject doInBackground(Void... dummy) { try { - long timer = System.currentTimeMillis(); - JSONObject params = new JSONObject(); params.put("client_id", "7a011b66275f244d3f21"); params.put("client_secret", "eaced8a6655719d8c6848396de97b3f5d7a89fec"); params.put("code", oAuthCode); params.put("state", oAuthState); - JSONObject result = jsonHttpRequest("https://github.com/login/oauth/access_token", params, null); - - // ux flow: this operation should take at last a second - timer = System.currentTimeMillis() -timer; - if (timer < 1000) try { - Thread.sleep(1000 -timer); - } catch (InterruptedException e) { - // never mind - } - - return result; + return jsonHttpRequest("https://github.com/login/oauth/access_token", params, null); } catch (IOException e) { Log.e(Constants.TAG, "error in request", e); @@ -165,29 +202,6 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment() { + @Override + protected Void doInBackground(Void... dummy) { + try { + HttpsURLConnection nection = (HttpsURLConnection) new URL( + "https://api.github.com/applications/7a011b66275f244d3f21/tokens/" + token) + .openConnection(); + nection.setRequestMethod("DELETE"); + nection.connect(); + } catch (IOException e) { + // nvm + } + return null; + } + }.execute(); + + } + private void step3EditKey(final GithubResource resource) { + // set item data while we're there + { + Context context = getActivity(); + mLinkedIdTitle.setText(resource.getDisplayTitle(context)); + mLinkedIdComment.setText(resource.getDisplayComment(context)); + } + mStatus3.setDisplayedChild(1); new Handler().postDelayed(new Runnable() { @@ -291,6 +334,23 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment= Build.VERSION_CODES.LOLLIPOP) { + mButtonContainer.getCurrentView().setTransitionName("linked_item"); + activity.finishAfterTransition(); + } else { + activity.finish(); + } + } + }, 1000); } @Override @@ -305,6 +365,72 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment + android:layout_height="match_parent" + xmlns:custom="http://schemas.android.com/apk/res-auto"> + android:layout_marginTop="16dp" + android:layout_marginBottom="16dp" + android:inAnimation="@anim/fade_in" + android:outAnimation="@anim/fade_out" + custom:initialView="2">