aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-06 00:49:19 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-06 00:49:19 +0200
commit60e9141b8612ee8d0344e3c66109dfb9877e108a (patch)
tree5dbe71c421b37d061c9c37699e6ae6ebeb23b9cc /OpenKeychain/src/main/java/org
parent2cda48642722069c7e26d0a25d196e8a41128290 (diff)
downloadopen-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')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java21
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java58
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java5
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubFragment.java48
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep1Fragment.java125
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdCreateGithubStep2Fragment.java116
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/linked/LinkedIdViewFragment.java2
7 files changed, 105 insertions, 270 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
index 2ffb7227e..a15dc74ca 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java
@@ -18,6 +18,11 @@
package org.sufficientlysecure.keychain.ui;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+
import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
import android.annotation.SuppressLint;
@@ -55,7 +60,6 @@ import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
-
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
@@ -68,9 +72,10 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
-import org.sufficientlysecure.keychain.ui.linked.LinkedIdWizard;
+import org.sufficientlysecure.keychain.ui.ViewKeyFragment.PostponeType;
import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity;
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
+import org.sufficientlysecure.keychain.ui.linked.LinkedIdWizard;
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
@@ -84,9 +89,6 @@ import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.NfcHelper;
import org.sufficientlysecure.keychain.util.Preferences;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
public class ViewKeyActivity extends BaseNfcActivity implements
LoaderManager.LoaderCallbacks<Cursor>,
@@ -102,6 +104,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
static final int REQUEST_DELETE = 4;
public static final String EXTRA_DISPLAY_RESULT = "display_result";
+ public static final String EXTRA_LINKED_TRANSITION = "linked_transition";
ProviderHelper mProviderHelper;
@@ -294,9 +297,15 @@ public class ViewKeyActivity extends BaseNfcActivity implements
return;
}
+ boolean linkedTransition = getIntent().getBooleanExtra(EXTRA_LINKED_TRANSITION, false);
+ if (linkedTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ postponeEnterTransition();
+ }
+
FragmentManager manager = getSupportFragmentManager();
// Create an instance of the fragment
- final ViewKeyFragment frag = ViewKeyFragment.newInstance(mDataUri);
+ final ViewKeyFragment frag = ViewKeyFragment.newInstance(mDataUri,
+ linkedTransition ? PostponeType.LINKED : PostponeType.NONE);
manager.beginTransaction()
.replace(R.id.view_key_fragment, frag)
.commit();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java
index 32e2d2def..7be695de0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java
@@ -18,7 +18,11 @@
package org.sufficientlysecure.keychain.ui;
+
import java.io.IOException;
+import java.util.List;
+
+import android.annotation.TargetApi;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
@@ -26,6 +30,7 @@ import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
+import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Handler;
import android.provider.ContactsContract;
@@ -39,17 +44,20 @@ import android.transition.TransitionInflater;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.OnPreDrawListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;
-import android.widget.*;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
-import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
import org.sufficientlysecure.keychain.provider.KeychainContract;
+import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
import org.sufficientlysecure.keychain.ui.dialog.UserIdInfoDialogFragment;
import org.sufficientlysecure.keychain.ui.linked.LinkedIdViewFragment;
@@ -58,22 +66,20 @@ import org.sufficientlysecure.keychain.util.ContactHelper;
import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Preferences;
-import java.util.List;
-
public class ViewKeyFragment extends LoaderFragment implements
LoaderManager.LoaderCallbacks<Cursor> {
public static final String ARG_DATA_URI = "uri";
+ public static final String ARG_POSTPONE_TYPE = "postpone_type";
private ListView mUserIds;
//private ListView mLinkedSystemContact;
- boolean mIsSecret = false;
+ enum PostponeType {
+ NONE, LINKED;
+ }
- CardView mSystemContactCard;
- LinearLayout mSystemContactLayout;
- ImageView mSystemContactPicture;
- TextView mSystemContactName;
+ boolean mIsSecret = false;
private static final int LOADER_ID_UNIFIED = 0;
private static final int LOADER_ID_USER_IDS = 1;
@@ -89,6 +95,13 @@ public class ViewKeyFragment extends LoaderFragment implements
private LinkedIdsAdapter mLinkedIdsAdapter;
private Uri mDataUri;
+ private PostponeType mPostponeType;
+
+ private CardView mSystemContactCard;
+ private LinearLayout mSystemContactLayout;
+ private ImageView mSystemContactPicture;
+ private TextView mSystemContactName;
+
private ListView mLinkedIds;
private CardView mLinkedIdsCard;
private byte[] mFingerprint;
@@ -97,10 +110,11 @@ public class ViewKeyFragment extends LoaderFragment implements
/**
* Creates new instance of this fragment
*/
- public static ViewKeyFragment newInstance(Uri dataUri) {
+ public static ViewKeyFragment newInstance(Uri dataUri, PostponeType postponeType) {
ViewKeyFragment frag = new ViewKeyFragment();
Bundle args = new Bundle();
args.putParcelable(ARG_DATA_URI, dataUri);
+ args.putInt(ARG_POSTPONE_TYPE, postponeType.ordinal());
frag.setArguments(args);
@@ -271,6 +285,7 @@ public class ViewKeyFragment extends LoaderFragment implements
super.onActivityCreated(savedInstanceState);
Uri dataUri = getArguments().getParcelable(ARG_DATA_URI);
+ mPostponeType = PostponeType.values()[getArguments().getInt(ARG_POSTPONE_TYPE, 0)];
if (dataUri == null) {
Log.e(Constants.TAG, "Data missing. Should be Uri of key!");
getActivity().finish();
@@ -325,10 +340,10 @@ public class ViewKeyFragment extends LoaderFragment implements
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
- setContentShown(false);
switch (id) {
case LOADER_ID_UNIFIED: {
+ setContentShown(false, false);
Uri baseUri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri);
return new CursorLoader(getActivity(), baseUri, UNIFIED_PROJECTION, null, null, null);
}
@@ -390,6 +405,7 @@ public class ViewKeyFragment extends LoaderFragment implements
mIsSecret = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
mFingerprint = data.getBlob(INDEX_FINGERPRINT);
+ long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
// load user ids after we know if it's a secret key
mUserIdsAdapter = new UserIdsAdapter(getActivity(), null, 0, !mIsSecret, null);
@@ -403,13 +419,6 @@ public class ViewKeyFragment extends LoaderFragment implements
getLoaderManager().initLoader(LOADER_ID_LINKED_IDS, null, this);
}
- long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
- // we need to load linked contact here to prevent lag introduced by loader
- // for the linked contact
- long contactId = ContactHelper.findContactId(
- getActivity().getContentResolver(),
- masterKeyId);
- loadLinkedSystemContact(contactId);
Bundle linkedContactData = new Bundle();
linkedContactData.putLong(LOADER_EXTRA_LINKED_CONTACT_MASTER_KEY_ID, masterKeyId);
@@ -423,6 +432,7 @@ public class ViewKeyFragment extends LoaderFragment implements
}
case LOADER_ID_USER_IDS: {
+ setContentShown(true, false);
mUserIdsAdapter.swapCursor(data);
break;
}
@@ -430,6 +440,17 @@ public class ViewKeyFragment extends LoaderFragment implements
case LOADER_ID_LINKED_IDS: {
mLinkedIdsAdapter.swapCursor(data);
mLinkedIdsCard.setVisibility(mLinkedIdsAdapter.getCount() > 0 ? View.VISIBLE : View.GONE);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mPostponeType == PostponeType.LINKED) {
+ mLinkedIdsCard.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
+ @TargetApi(VERSION_CODES.LOLLIPOP)
+ @Override
+ public boolean onPreDraw() {
+ mLinkedIdsCard.getViewTreeObserver().removeOnPreDrawListener(this);
+ getActivity().startPostponedEnterTransition();
+ return true;
+ }
+ });
+ }
break;
}
@@ -442,7 +463,6 @@ public class ViewKeyFragment extends LoaderFragment implements
}
}
- setContentShown(true);
}
/**
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java
index 805666bb2..5cf0e6e08 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java
@@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
+import android.os.Build;
import android.support.v4.content.CursorLoader;
import android.util.Log;
import android.view.LayoutInflater;
@@ -135,6 +136,10 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
UriAttribute id = getItemAtPosition(cursor);
holder.setData(mContext, id);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+ view.setTransitionName(id.mUri.toString());
+ }
+
}
public UriAttribute getItemAtPosition(Cursor cursor) {
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);