more (subtle) ui work

This commit is contained in:
Vincent Breitmoser
2015-03-26 17:52:18 +01:00
parent dc8b04a793
commit ab5a7d4094
4 changed files with 65 additions and 39 deletions

View File

@@ -3,13 +3,18 @@ package org.sufficientlysecure.keychain.ui.linked;
import java.io.IOException;
import java.util.Arrays;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
@@ -53,6 +58,7 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.ui.util.SubtleAttentionSeeker;
import org.sufficientlysecure.keychain.ui.widget.CertListWidget;
import org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner;
import org.sufficientlysecure.keychain.util.Log;
@@ -241,6 +247,7 @@ public class LinkedIdViewFragment extends Fragment implements
private final View vButtonView;
private final ViewAnimator vVerifyingContainer;
private final ViewAnimator vItemCertified;
private final View vKeySpinnerContainer;
LinkedIdsAdapter.ViewHolder mLinkedIdHolder;
private ViewAnimator vButtonSwitcher;
@@ -257,6 +264,7 @@ public class LinkedIdViewFragment extends Fragment implements
ViewHolder(View root) {
vLinkedCerts = (CertListWidget) root.findViewById(R.id.linked_id_certs);
vKeySpinner = (CertifyKeySpinner) root.findViewById(R.id.cert_key_spinner);
vKeySpinnerContainer = root.findViewById(R.id.cert_key_spincontainer);
vButtonSwitcher = (ViewAnimator) root.findViewById(R.id.button_animator);
mLinkedIdHolder = new LinkedIdsAdapter.ViewHolder(root);
@@ -283,17 +291,17 @@ public class LinkedIdViewFragment extends Fragment implements
case VERIFYING:
vProgress.setDisplayedChild(0);
vText.setText(context.getString(R.string.linked_text_verifying));
vKeySpinner.setVisibility(View.GONE);
vKeySpinnerContainer.setVisibility(View.GONE);
break;
case VERIFY_OK:
vProgress.setDisplayedChild(1);
if (!isSecret) {
showButton(2);
vKeySpinner.setVisibility(View.VISIBLE);
vKeySpinnerContainer.setVisibility(View.VISIBLE);
} else {
showButton(1);
vKeySpinner.setVisibility(View.GONE);
vKeySpinnerContainer.setVisibility(View.GONE);
}
break;
@@ -301,13 +309,13 @@ public class LinkedIdViewFragment extends Fragment implements
showButton(1);
vProgress.setDisplayedChild(2);
vText.setText(context.getString(R.string.linked_text_error));
vKeySpinner.setVisibility(View.GONE);
vKeySpinnerContainer.setVisibility(View.GONE);
break;
case CERTIFYING:
vProgress.setDisplayedChild(0);
vText.setText(context.getString(R.string.linked_text_confirming));
vKeySpinner.setVisibility(View.GONE);
vKeySpinnerContainer.setVisibility(View.GONE);
break;
}
}
@@ -364,7 +372,7 @@ public class LinkedIdViewFragment extends Fragment implements
mVerificationState = false;
mViewHolder.showButton(0);
mViewHolder.vKeySpinner.setVisibility(View.GONE);
mViewHolder.vKeySpinnerContainer.setVisibility(View.GONE);
mViewHolder.showVerifyingContainer(mContext, false, mIsSecret);
return;
}
@@ -450,7 +458,7 @@ public class LinkedIdViewFragment extends Fragment implements
setShowVerifying(true);
mViewHolder.vKeySpinner.setVisibility(View.GONE);
mViewHolder.vKeySpinnerContainer.setVisibility(View.GONE);
mViewHolder.setVerifyingState(mContext, VerifyState.VERIFYING, mIsSecret);
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
@@ -478,7 +486,9 @@ public class LinkedIdViewFragment extends Fragment implements
if (result.success()) {
mViewHolder.vText.setText(getString(mLinkedResource.getVerifiedText(mIsSecret)));
mViewHolder.setVerifyingState(mContext, VerifyState.VERIFY_OK, mIsSecret);
ObjectAnimator anim = SubtleAttentionSeeker.tada(mViewHolder.vButtonConfirm, 0.6f, 1000);
anim.setStartDelay(800);
anim.start();
} else {
mViewHolder.setVerifyingState(mContext, VerifyState.VERIFY_ERROR, mIsSecret);
result.createNotify(getActivity()).show();
@@ -498,6 +508,9 @@ public class LinkedIdViewFragment extends Fragment implements
// get the user's passphrase for this key (if required)
long certifyKeyId = mViewHolder.vKeySpinner.getSelectedItemId();
if (certifyKeyId == key.none || certifyKeyId == key.symmetric) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
SubtleAttentionSeeker.tint(mViewHolder.vKeySpinnerContainer, 600).start();
}
Notify.create(getActivity(), R.string.select_key_to_certify, Style.ERROR).show();
return;
}

View File

@@ -17,13 +17,19 @@
package org.sufficientlysecure.keychain.ui.util;
import android.animation.AnimatorInflater;
import android.animation.ArgbEvaluator;
import android.animation.Keyframe;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build.VERSION_CODES;
import android.view.View;
import org.sufficientlysecure.keychain.R;
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
/** Simple animation helper for subtle attention seeker stuff.
*
@@ -36,6 +42,10 @@ public class SubtleAttentionSeeker {
}
public static ObjectAnimator tada(View view, float shakeFactor) {
return tada(view, shakeFactor, 1400);
}
public static ObjectAnimator tada(View view, float shakeFactor, int duration) {
PropertyValuesHolder pvhScaleX = PropertyValuesHolder.ofKeyframe(View.SCALE_X,
Keyframe.ofFloat(0f, 1f),
@@ -80,7 +90,13 @@ public class SubtleAttentionSeeker {
);
return ObjectAnimator.ofPropertyValuesHolder(view, pvhScaleX, pvhScaleY, pvhRotate).
setDuration(1400);
setDuration(duration);
}
@TargetApi(VERSION_CODES.LOLLIPOP)
public static ObjectAnimator tint(View view, int duration) {
return ObjectAnimator.ofArgb(view, "backgroundColor",
0x00FF0000, 0x33FF0000, 0x00FF0000).setDuration(duration);
}
}

View File

@@ -60,17 +60,18 @@
android:layout_marginBottom="4dp"
android:inAnimation="@anim/fade_in_quick"
android:outAnimation="@anim/fade_out_quick"
android:measureAllChildren="false"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
android:textAppearance="?android:attr/textAppearanceSmall" />
</TextSwitcher>
@@ -110,32 +111,28 @@
</ViewAnimator>
<org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cert_key_spinner"
android:visibility="gone">
</org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner>
android:id="@+id/cert_key_spincontainer"
android:visibility="gone"
>
<org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/cert_key_spinner">
</org.sufficientlysecure.keychain.ui.widget.CertifyKeySpinner>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_chevron_left_grey_24dp"
android:visibility="gone"
style="?android:attr/borderlessButtonStyle" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
android:orientation="horizontal"
android:gravity="right|end">
<Button
android:id="@+id/button_view"

View File

@@ -1327,14 +1327,14 @@
<string name="linked_create_verify">"Verify"</string>
<string name="linked_text_clipboard">Text has been copied to clipboard</string>
<string name="linked_verified_https">"The Website has been fetched and verified."</string>
<string name="linked_verified_github">"The Gist has been fetched and verified."</string>
<string name="linked_verified_dns">"The DNS record has been fetched and verified."</string>
<string name="linked_verified_twitter">"The Tweet has been fetched and verified."</string>
<string name="linked_verified_secret_https">"Your Website has been fetched and verified. Everything looks in order."</string>
<string name="linked_verified_secret_github">"Your Gist has been fetched and verified. Everything looks in order."</string>
<string name="linked_verified_secret_dns">"Your DNS record has been fetched and verified. Everything looks in order."</string>
<string name="linked_verified_secret_twitter">"Your Tweet has been fetched and verified. Everything looks in order."</string>
<string name="linked_verified_https">"The link between this Website and key was securely verified. If you believe the Website is genuine, you may confirm this Identity with your key."</string>
<string name="linked_verified_github">"The link between this Github account and key was securely verified. If you believe the account is genuine, you may confirm this Identity with your key."</string>
<string name="linked_verified_dns">"The link between this Domain Name and key was securely verified. If you believe the Domain is genuine, you may confirm this Identity with your key."</string>
<string name="linked_verified_twitter">"The link between this Twitter account and key was securely verified. If you believe the account is genuine, you may confirm this Identity with your key."</string>
<string name="linked_verified_secret_https">"The link between your Website and key was securely verified. Everything looks in order."</string>
<string name="linked_verified_secret_github">"The link between your Github account and key was securely verified. Everything looks in order."</string>
<string name="linked_verified_secret_dns">"The link between your Domain Name and key was securely verified. Everything looks in order."</string>
<string name="linked_verified_secret_twitter">"The link between this Twitter account and key was securely verified. Everything looks in order."</string>
<plurals name="linked_id_expand">
<item quantity="one">"There is one more unknown identity type"</item>