diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-06 00:49:19 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2015-09-06 00:49:19 +0200 |
commit | 60e9141b8612ee8d0344e3c66109dfb9877e108a (patch) | |
tree | 5dbe71c421b37d061c9c37699e6ae6ebeb23b9cc /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked | |
parent | 2cda48642722069c7e26d0a25d196e8a41128290 (diff) | |
download | open-keychain-60e9141b8612ee8d0344e3c66109dfb9877e108a.tar.gz open-keychain-60e9141b8612ee8d0344e3c66109dfb9877e108a.tar.bz2 open-keychain-60e9141b8612ee8d0344e3c66109dfb9877e108a.zip |
linked: basic shared element transition
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked')
4 files changed, 46 insertions, 245 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java index f04e10529..0cc21f448 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java @@ -44,10 +44,13 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.v4.app.ActivityOptionsCompat; +import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; +import android.webkit.CookieManager; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ImageView; @@ -83,6 +86,7 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe long mMasterKeyId; private SaveKeyringParcel mSaveKeyringParcel; private TextView mLinkedIdTitle, mLinkedIdComment; + private boolean mFinishOnStop; public static LinkedIdCreateGithubFragment newInstance() { return new LinkedIdCreateGithubFragment(); @@ -107,10 +111,23 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe mLinkedIdTitle = (TextView) view.findViewById(R.id.linked_id_title); mLinkedIdComment = (TextView) view.findViewById(R.id.linked_id_comment); + view.findViewById(R.id.back_button).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + LinkedIdWizard activity = (LinkedIdWizard) getActivity(); + if (activity == null) { + return; + } + activity.loadFragment(null, null, LinkedIdWizard.FRAG_ACTION_TO_LEFT); + } + }); + view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { step1GetOAuthCode(); + // for animation testing + // onCryptoOperationSuccess(null); } }); @@ -263,6 +280,11 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe URI uri = URI.create("https://gist.github.com/" + gistLogin + "/" + gistId); GithubResource resource = GithubResource.create(uri); + View linkedItem = mButtonContainer.getChildAt(2); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + linkedItem.setTransitionName(resource.toUri().toString()); + } + revokeToken(accessToken); mStatus2.setDisplayedChild(2); @@ -334,19 +356,28 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe @Override public void onCryptoOperationSuccess(EditKeyResult result) { mStatus3.setDisplayedChild(2); + + mButtonContainer.getInAnimation().setDuration(750); mButtonContainer.setDisplayedChild(2); new Handler().postDelayed(new Runnable() { @Override public void run() { - Activity activity = getActivity(); + FragmentActivity activity = getActivity(); Intent intent = new Intent(activity, ViewKeyActivity.class); intent.setData(KeyRings.buildGenericKeyRingUri(mMasterKeyId)); + // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - mButtonContainer.getCurrentView().setTransitionName("linked_item"); - activity.finishAfterTransition(); + intent.putExtra(ViewKeyActivity.EXTRA_LINKED_TRANSITION, true); + View linkedItem = mButtonContainer.getChildAt(2); + + Bundle options = ActivityOptionsCompat.makeSceneTransitionAnimation( + activity, linkedItem, linkedItem.getTransitionName()).toBundle(); + activity.startActivity(intent, options); + mFinishOnStop = true; } else { + activity.startActivity(intent); activity.finish(); } } @@ -354,6 +385,16 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe } @Override + public void onStop() { + super.onStop(); + if (mFinishOnStop) { + Activity activity = getActivity(); + activity.setResult(Activity.RESULT_OK); + activity.finish(); + } + } + + @Override public void onCryptoOperationError(EditKeyResult result) { result.createNotify(getActivity()).show(this); mStatus3.setDisplayedChild(3); @@ -365,7 +406,6 @@ public class LinkedIdCreateGithubFragment extends CryptoOperationFragment<SaveKe mStatus3.setDisplayedChild(3); } - private String mOAuthCode, mOAuthState; @SuppressLint("SetJavaScriptEnabled") // trusted https website, it's ok diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep1Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep1Fragment.java deleted file mode 100644 index b166b3e4f..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep1Fragment.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.linked; - -import android.os.AsyncTask; -import android.os.Bundle; -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 org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.util.Notify; - - -public class LinkedIdCreateGithubStep1Fragment extends Fragment { - - LinkedIdWizard mLinkedIdWizard; - - EditText mEditHandle; - - public static LinkedIdCreateGithubStep1Fragment newInstance() { - LinkedIdCreateGithubStep1Fragment frag = new LinkedIdCreateGithubStep1Fragment(); - - Bundle args = new Bundle(); - frag.setArguments(args); - - return frag; - } - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - mLinkedIdWizard = (LinkedIdWizard) getActivity(); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - final View view = inflater.inflate(R.layout.linked_create_github_fragment_step1, container, false); - - view.findViewById(R.id.next_button).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - - final String handle = mEditHandle.getText().toString(); - - new AsyncTask<Void,Void,Boolean>() { - - @Override - protected Boolean doInBackground(Void... params) { - return true; // return checkHandle(handle); - } - - @Override - protected void onPostExecute(Boolean result) { - super.onPostExecute(result); - - if (result == null) { - Notify.create(getActivity(), - "Connection error while checking username!", Notify.Style.ERROR).show(); - return; - } - - if (!result) { - Notify.create(getActivity(), - "This handle does not exist on Github!", Notify.Style.ERROR).show(); - return; - } - - LinkedIdCreateGithubStep2Fragment frag = - LinkedIdCreateGithubStep2Fragment.newInstance(handle); - - mLinkedIdWizard.loadFragment(null, frag, LinkedIdWizard.FRAG_ACTION_TO_RIGHT); - } - }.execute(); - - } - }); - - view.findViewById(R.id.back_button).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - mLinkedIdWizard.loadFragment(null, null, LinkedIdWizard.FRAG_ACTION_TO_LEFT); - } - }); - - mEditHandle = (EditText) view.findViewById(R.id.linked_create_github_handle); - - return view; - } - - /* not used at this point, too much hassle - private static Boolean checkHandle(String handle) { - try { - HttpURLConnection nection = - (HttpURLConnection) new URL("https://api.github.com/" + handle).openConnection(); - nection.setRequestMethod("HEAD"); - return nection.getResponseCode() == 200; - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - */ - -} diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java deleted file mode 100644 index a3a8c779f..000000000 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * 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.linked; - -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.view.LayoutInflater; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewGroup; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.operations.results.OperationResult.OperationLog; -import org.sufficientlysecure.keychain.linked.LinkedTokenResource; -import org.sufficientlysecure.keychain.linked.resources.GithubResource; - - -public class LinkedIdCreateGithubStep2Fragment extends LinkedIdCreateFinalFragment { - - public static final String ARG_HANDLE = "handle"; - - String mResourceHandle; - String mResourceString; - - public static LinkedIdCreateGithubStep2Fragment newInstance - (String handle) { - - LinkedIdCreateGithubStep2Fragment frag = new LinkedIdCreateGithubStep2Fragment(); - - Bundle args = new Bundle(); - args.putString(ARG_HANDLE, handle); - frag.setArguments(args); - - return frag; - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - mResourceString = - GithubResource.generate(getActivity(), mLinkedIdWizard.mFingerprint); - - mResourceHandle = getArguments().getString(ARG_HANDLE); - - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = super.onCreateView(inflater, container, savedInstanceState); - - if (view != null) { - - view.findViewById(R.id.button_send).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - proofSend(); - } - }); - - view.findViewById(R.id.button_share).setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - proofShare(); - } - }); - - } - - return view; - } - - @Override - LinkedTokenResource getResource(OperationLog log) { - return GithubResource.searchInGithubStream(getActivity(), mResourceHandle, mResourceString, log); - } - - @Override - protected View newView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - return inflater.inflate(R.layout.linked_create_github_fragment_step2, container, false); - } - - private void proofShare() { - Intent sendIntent = new Intent(); - sendIntent.setAction(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_TEXT, mResourceString); - sendIntent.setType("text/plain"); - startActivity(sendIntent); - } - - private void proofSend() { - Uri.Builder builder = Uri.parse("https://gist.github.com/").buildUpon(); - builder.appendQueryParameter("text", mResourceString); - Uri uri = builder.build(); - - Intent intent = new Intent(Intent.ACTION_VIEW, uri); - getActivity().startActivity(intent); - } - -} 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 7007fa50c..5630932b4 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 @@ -211,6 +211,8 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements null, State.INVALID, KeyFormattingUtils.DEFAULT_COLOR); break; } + } else { + mViewHolder.mLinkedIdHolder.vVerified.setImageResource(R.drawable.octo_link_24dp); } mViewHolder.mLinkedIdHolder.setData(mContext, mLinkedId); |