linked: basic shared element transition
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,25 +356,44 @@ 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();
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
@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);
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -125,6 +125,8 @@
|
||||
android:id="@+id/button_container"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginLeft="4dp"
|
||||
android:inAnimation="@anim/fade_in"
|
||||
android:outAnimation="@anim/fade_out"
|
||||
custom:initialView="2">
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="false"
|
||||
android:layout_above="@+id/create_key_button_divider">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:drawableLeft="@drawable/linked_github"
|
||||
android:drawablePadding="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_1_1" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_1_2" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_1_3" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/linked_create_github_handle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="actionNext"
|
||||
android:layout_marginTop="16dp"
|
||||
android:ems="10"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:hint="@string/linked_create_github_handle"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:id="@+id/create_key_button_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:layout_alignTop="@+id/create_key_buttons"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:id="@+id/create_key_buttons">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/back_button"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btn_back"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textAllCaps="true"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:drawableLeft="@drawable/ic_chevron_left_grey_24dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:clickable="true"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/next_button"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btn_next"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textAllCaps="true"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:drawableRight="@drawable/ic_chevron_right_grey_24dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical|right"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
@@ -1,153 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fillViewport="false"
|
||||
android:layout_above="@+id/create_key_button_divider">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_2_1" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_2_2" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
style="?android:buttonBarStyle">
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
style="?android:buttonBarButtonStyle"
|
||||
android:drawableLeft="@android:drawable/ic_menu_send"
|
||||
android:drawableStart="@android:drawable/ic_menu_send"
|
||||
android:text="Post Gist"
|
||||
android:id="@+id/button_send"
|
||||
/>
|
||||
|
||||
<Button
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
style="?android:buttonBarButtonStyle"
|
||||
android:drawableLeft="@android:drawable/ic_menu_share"
|
||||
android:drawableStart="@android:drawable/ic_menu_share"
|
||||
android:text="Share"
|
||||
android:id="@+id/button_share"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_2_3" />
|
||||
|
||||
<include layout="@layout/linked_create_verify" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:text="@string/linked_create_github_2_4" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<View
|
||||
android:id="@+id/create_key_button_divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:background="?android:attr/listDivider"
|
||||
android:layout_alignTop="@+id/create_key_buttons"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:id="@+id/create_key_buttons">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/back_button"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btn_back"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textAllCaps="true"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:drawableLeft="@drawable/ic_chevron_left_grey_24dp"
|
||||
android:drawablePadding="8dp"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
android:layout_gravity="center_vertical" />
|
||||
|
||||
<View
|
||||
android:layout_width="1dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/next_button"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/btn_finish"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textAllCaps="true"
|
||||
android:drawableRight="@drawable/ic_person_add_grey_24dp"
|
||||
android:drawablePadding="8dp"
|
||||
style="?android:attr/borderlessButtonStyle"
|
||||
android:gravity="center_vertical|right"
|
||||
android:layout_gravity="center_vertical" />
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -6,6 +6,7 @@
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:singleLine="true"
|
||||
android:background="#ffffff"
|
||||
tools:showIn="@layout/linked_id_view_fragment">
|
||||
|
||||
<ImageView
|
||||
|
||||
@@ -1565,15 +1565,6 @@
|
||||
<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>
|
||||
<string name="linked_create_github_1_2">"To do this, you publish a specific Gist on your timeline, then create a Linked Identity which links to this Gist."</string>
|
||||
<string name="linked_create_github_1_3">"Please enter your GitHub screen name to proceed."</string>
|
||||
<string name="linked_create_github_handle">GitHub Handle</string>
|
||||
<string name="linked_create_github_2_1">"Click either button to post the gist!"</string>
|
||||
<string name="linked_create_github_2_2">"You can edit the Gist before posting it, so long as the text inside the brackets is unmodified."</string>
|
||||
<string name="linked_create_github_2_3">"Once your Gist is published, click the Verify button to scan your timeline for it."</string>
|
||||
<string name="linked_create_github_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_dns_1_1">"By creating a Linked Identity of this type, you can link your key to a domain name you control."</string>
|
||||
<string name="linked_create_dns_1_2">"To do this, you create a specific TXT record for the domain, then create a Linked Identity which links to this record."</string>
|
||||
<!-- An Identity of this type is especially appropriate if your email address is at the same domain. -->
|
||||
@@ -1600,6 +1591,7 @@
|
||||
<item quantity="other">"There are %d more unknown identity types"</item>
|
||||
</plurals>
|
||||
|
||||
<!-- Other Linked Identity strings -->
|
||||
<string name="linked_select_1">"A \'linked identity\' connects your pgp key to a resource on the web."</string>
|
||||
<string name="linked_select_2">"Please select a type:"</string>
|
||||
<string name="linked_id_generic_text">"This file claims ownership of the OpenPGP key with long id %2$s.\n\nToken for proof:\n%1$s"</string>
|
||||
@@ -1609,7 +1601,7 @@
|
||||
<string name="linked_verify_error">"Verification error!"</string>
|
||||
<string name="linked_verify_pending">"Not yet verified"</string>
|
||||
<string name="linked_need_verify">The resource needs to be verified before you can proceed!</string>
|
||||
<string name="menu_linked_add_identity">"Add Linked Identity"</string>
|
||||
<string name="menu_linked_add_identity">"Link to Account"</string>
|
||||
<string name="section_linked_identities">"Linked Identities"</string>
|
||||
<string name="btn_finish">"Finish"</string>
|
||||
<string name="linked_title_https">Website (HTTPS)</string>
|
||||
|
||||
Reference in New Issue
Block a user