linked: work on github design
This commit is contained in:
@@ -36,7 +36,6 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ViewAnimator;
|
import android.widget.ViewAnimator;
|
||||||
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
@@ -51,8 +50,7 @@ import org.sufficientlysecure.keychain.util.Log;
|
|||||||
|
|
||||||
public class LinkedIdCreateGithubFragment extends Fragment {
|
public class LinkedIdCreateGithubFragment extends Fragment {
|
||||||
|
|
||||||
ViewAnimator mProceedContainer;
|
ViewAnimator mButtonContainer;
|
||||||
EditText mGithubUsername, mGithubPassword;
|
|
||||||
|
|
||||||
StatusIndicator mStatus1, mStatus2, mStatus3;
|
StatusIndicator mStatus1, mStatus2, mStatus3;
|
||||||
|
|
||||||
@@ -64,10 +62,7 @@ public class LinkedIdCreateGithubFragment extends Fragment {
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.linked_create_github_fragment, container, false);
|
View view = inflater.inflate(R.layout.linked_create_github_fragment, container, false);
|
||||||
|
|
||||||
mProceedContainer = (ViewAnimator) view.findViewById(R.id.proceed_container);
|
mButtonContainer = (ViewAnimator) view.findViewById(R.id.button_container);
|
||||||
|
|
||||||
mGithubUsername = (EditText) view.findViewById(R.id.username);
|
|
||||||
mGithubPassword = (EditText) view.findViewById(R.id.password);
|
|
||||||
|
|
||||||
mStatus1 = (StatusIndicator) view.findViewById(R.id.linked_status_step1);
|
mStatus1 = (StatusIndicator) view.findViewById(R.id.linked_status_step1);
|
||||||
mStatus2 = (StatusIndicator) view.findViewById(R.id.linked_status_step2);
|
mStatus2 = (StatusIndicator) view.findViewById(R.id.linked_status_step2);
|
||||||
@@ -102,13 +97,25 @@ public class LinkedIdCreateGithubFragment extends Fragment {
|
|||||||
protected JSONObject doInBackground(Void... dummy) {
|
protected JSONObject doInBackground(Void... dummy) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
long timer = System.currentTimeMillis();
|
||||||
|
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
params.put("client_id", "7a011b66275f244d3f21");
|
params.put("client_id", "7a011b66275f244d3f21");
|
||||||
params.put("client_secret", "eaced8a6655719d8c6848396de97b3f5d7a89fec");
|
params.put("client_secret", "eaced8a6655719d8c6848396de97b3f5d7a89fec");
|
||||||
params.put("code", oAuthCode);
|
params.put("code", oAuthCode);
|
||||||
params.put("state", oAuthState);
|
params.put("state", oAuthState);
|
||||||
|
|
||||||
return jsonHttpRequest("https://github.com/login/oauth/access_token", params, null);
|
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;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "error in request", e);
|
Log.e(Constants.TAG, "error in request", e);
|
||||||
@@ -143,10 +150,30 @@ public class LinkedIdCreateGithubFragment extends Fragment {
|
|||||||
mStatus2.setDisplayedChild(0);
|
mStatus2.setDisplayedChild(0);
|
||||||
mStatus3.setDisplayedChild(0);
|
mStatus3.setDisplayedChild(0);
|
||||||
|
|
||||||
mProceedContainer.setDisplayedChild(1);
|
mButtonContainer.setDisplayedChild(1);
|
||||||
|
|
||||||
LinkedIdWizard wizard = (LinkedIdWizard) getActivity();
|
new AsyncTask<Void,Void,Void>() {
|
||||||
wizard.oAuthRequest("github.com/login/oauth/authorize", "7a011b66275f244d3f21", "gist");
|
@Override
|
||||||
|
protected Void doInBackground(Void... params) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(250);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
// never mind
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(Void aVoid) {
|
||||||
|
super.onPostExecute(aVoid);
|
||||||
|
LinkedIdWizard wizard = (LinkedIdWizard) getActivity();
|
||||||
|
if (wizard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
wizard.oAuthRequest("github.com/login/oauth/authorize", "7a011b66275f244d3f21", "gist");
|
||||||
|
}
|
||||||
|
}.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +186,8 @@ public class LinkedIdCreateGithubFragment extends Fragment {
|
|||||||
protected JSONObject doInBackground(Void... dummy) {
|
protected JSONObject doInBackground(Void... dummy) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
long timer = System.currentTimeMillis();
|
||||||
|
|
||||||
JSONObject file = new JSONObject();
|
JSONObject file = new JSONObject();
|
||||||
file.put("content", "hello!");
|
file.put("content", "hello!");
|
||||||
|
|
||||||
@@ -170,7 +199,17 @@ public class LinkedIdCreateGithubFragment extends Fragment {
|
|||||||
params.put("description", "OpenKeychain API Tests");
|
params.put("description", "OpenKeychain API Tests");
|
||||||
params.put("files", files);
|
params.put("files", files);
|
||||||
|
|
||||||
return jsonHttpRequest("https://api.github.com/gists", params, accessToken);
|
JSONObject result = jsonHttpRequest("https://api.github.com/gists", params, accessToken);
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(Constants.TAG, "error in request", e);
|
Log.e(Constants.TAG, "error in request", e);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.animation.AnimationUtils;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
|
||||||
@@ -14,12 +15,16 @@ public class StatusIndicator extends ToolableViewAnimator {
|
|||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
LayoutInflater.from(context).inflate(R.layout.status_indicator, this, true);
|
LayoutInflater.from(context).inflate(R.layout.status_indicator, this, true);
|
||||||
|
setInAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
|
||||||
|
setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
public StatusIndicator(Context context, AttributeSet attrs) {
|
public StatusIndicator(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
LayoutInflater.from(context).inflate(R.layout.status_indicator, this, true);
|
LayoutInflater.from(context).inflate(R.layout.status_indicator, this, true);
|
||||||
|
setInAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_in));
|
||||||
|
setOutAnimation(AnimationUtils.loadAnimation(context, R.anim.fade_out));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
xmlns:custom="http://schemas.android.com/apk/res-auto">
|
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -29,54 +27,35 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
android:text="This login data will be used to post a gist, verifying this account and key belongs to you!"
|
android:text="This operation links your key to your GitHub account."
|
||||||
style="?android:textAppearanceSmall"/>
|
style="?android:textAppearanceSmall"/>
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/proceed_container"
|
android:orientation="vertical"
|
||||||
custom:initialView="1">
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginBottom="8dp">
|
||||||
<Button
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:layout_marginTop="16dp"
|
|
||||||
android:layout_marginBottom="16dp"
|
|
||||||
style="?android:buttonBarButtonStyle"
|
|
||||||
android:drawableLeft="@drawable/ic_mode_edit_grey_24dp"
|
|
||||||
android:drawableStart="@drawable/ic_mode_edit_grey_24dp"
|
|
||||||
android:drawablePadding="12dp"
|
|
||||||
android:text="Post Gist & Link Key"
|
|
||||||
android:id="@+id/button_send"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
<org.sufficientlysecure.keychain.ui.widget.StatusIndicator
|
||||||
android:layout_width="match_parent"
|
android:layout_width="24dp"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="24dp"
|
||||||
|
android:id="@+id/linked_status_step1"
|
||||||
|
android:layout_margin="4dp" />
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.StatusIndicator
|
<TextView
|
||||||
android:layout_width="24dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="24dp"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/linked_status_step1"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_margin="4dp">
|
android:text="Login at GitHub…"
|
||||||
</org.sufficientlysecure.keychain.ui.widget.StatusIndicator>
|
style="?android:textAppearanceMedium"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
</LinearLayout>
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:text="Login at GitHub…"
|
|
||||||
style="?android:textAppearanceMedium"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -86,8 +65,7 @@
|
|||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:id="@+id/linked_status_step2"
|
android:id="@+id/linked_status_step2"
|
||||||
android:layout_margin="4dp">
|
android:layout_margin="4dp" />
|
||||||
</org.sufficientlysecure.keychain.ui.widget.StatusIndicator>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -107,8 +85,7 @@
|
|||||||
android:layout_width="24dp"
|
android:layout_width="24dp"
|
||||||
android:layout_height="24dp"
|
android:layout_height="24dp"
|
||||||
android:id="@+id/linked_status_step3"
|
android:id="@+id/linked_status_step3"
|
||||||
android:layout_margin="4dp">
|
android:layout_margin="4dp" />
|
||||||
</org.sufficientlysecure.keychain.ui.widget.StatusIndicator>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -121,6 +98,30 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/button_container"
|
||||||
|
android:outAnimation="@anim/fade_out">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
style="?android:buttonBarButtonStyle"
|
||||||
|
android:drawableLeft="@drawable/ic_person_add_grey_24dp"
|
||||||
|
android:drawableStart="@drawable/ic_person_add_grey_24dp"
|
||||||
|
android:drawablePadding="12dp"
|
||||||
|
android:text="Link to Github Account"
|
||||||
|
android:id="@+id/button_send"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
</org.sufficientlysecure.keychain.ui.widget.ToolableViewAnimator>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|||||||
Reference in New Issue
Block a user