color experiments

This commit is contained in:
Dominik Schürmann 2014-10-15 12:48:54 +02:00
parent c7e2b8424e
commit be9b483ee8
4 changed files with 82 additions and 76 deletions

View File

@ -647,30 +647,34 @@ public class KeyListFragment extends LoaderFragment
// Note: order is important! // Note: order is important!
if (isRevoked) { if (isRevoked) {
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_REVOKED); KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_REVOKED, true);
h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setVisibility(View.VISIBLE);
h.mSlinger.setVisibility(View.GONE); h.mSlinger.setVisibility(View.GONE);
h.mMainUserId.setTextColor(context.getResources().getColor(R.color.bg_gray));
h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.bg_gray));
} else if (isExpired) { } else if (isExpired) {
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_EXPIRED); KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_EXPIRED, true);
h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setVisibility(View.VISIBLE);
h.mSlinger.setVisibility(View.GONE); h.mSlinger.setVisibility(View.GONE);
h.mMainUserId.setTextColor(context.getResources().getColor(R.color.bg_gray));
h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.bg_gray));
} else if (isSecret) { } else if (isSecret) {
h.mStatus.setVisibility(View.GONE); h.mStatus.setVisibility(View.GONE);
h.mSlinger.setVisibility(View.VISIBLE); h.mSlinger.setVisibility(View.VISIBLE);
} else { h.mMainUserId.setTextColor(context.getResources().getColor(R.color.black));
if (isVerified) { h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.black));
if (cursor.getInt(KeyListFragment.INDEX_HAS_ANY_SECRET) != 0) {
// this is a secret key
h.mStatus.setVisibility(View.GONE);
} else { } else {
// this is a public key - show if it's verified // this is a public key - show if it's verified
if (isVerified) {
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_VERIFIED); KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_VERIFIED);
h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setVisibility(View.VISIBLE);
}
} else { } else {
h.mStatus.setVisibility(View.GONE); KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_UNVERIFIED);
h.mStatus.setVisibility(View.VISIBLE);
} }
h.mSlinger.setVisibility(View.GONE); h.mSlinger.setVisibility(View.GONE);
h.mMainUserId.setTextColor(context.getResources().getColor(R.color.black));
h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.black));
} }
} }
@ -867,7 +871,7 @@ public class KeyListFragment extends LoaderFragment
return; return;
} }
if ( ! result.success()) { if (!result.success()) {
result.createNotify(activity).show(); result.createNotify(activity).show();
return; return;
} }

View File

@ -486,20 +486,12 @@ public class ViewKeyActivity extends ActionBarActivity implements
// Note: order is important // Note: order is important
if (isRevoked) { if (isRevoked) {
mStatusText.setText(R.string.view_key_revoked); mStatusText.setText(R.string.view_key_revoked);
mStatusText.setTextColor(getResources().getColor(R.color.android_red_dark)); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED);
mStatusImage.setImageDrawable(
getResources().getDrawable(R.drawable.status_signature_revoked_cutout));
mStatusImage.setColorFilter(getResources().getColor(R.color.android_red_dark),
PorterDuff.Mode.SRC_ATOP);
mStatusDivider.setVisibility(View.VISIBLE); mStatusDivider.setVisibility(View.VISIBLE);
mStatusLayout.setVisibility(View.VISIBLE); mStatusLayout.setVisibility(View.VISIBLE);
} else if (isExpired) { } else if (isExpired) {
mStatusText.setText(R.string.view_key_expired); mStatusText.setText(R.string.view_key_expired);
mStatusText.setTextColor(getResources().getColor(R.color.android_orange_dark)); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED);
mStatusImage.setImageDrawable(
getResources().getDrawable(R.drawable.status_signature_expired_cutout));
mStatusImage.setColorFilter(getResources().getColor(R.color.android_orange_dark),
PorterDuff.Mode.SRC_ATOP);
mStatusDivider.setVisibility(View.VISIBLE); mStatusDivider.setVisibility(View.VISIBLE);
mStatusLayout.setVisibility(View.VISIBLE); mStatusLayout.setVisibility(View.VISIBLE);
} else { } else {

View File

@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs; import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import java.util.ArrayList; import java.util.ArrayList;
@ -163,10 +164,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
if (isRevoked) { if (isRevoked) {
// set revocation icon (can this even be primary?) // set revocation icon (can this even be primary?)
vVerified.setImageResource(R.drawable.status_signature_revoked_cutout); KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_REVOKED, true);
vVerified.setColorFilter(
mContext.getResources().getColor(R.color.bg_gray),
PorterDuff.Mode.SRC_IN);
// disable and strike through text for revoked user ids // disable and strike through text for revoked user ids
vName.setEnabled(false); vName.setEnabled(false);
@ -191,22 +189,13 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
int isVerified = cursor.getInt(INDEX_VERIFIED); int isVerified = cursor.getInt(INDEX_VERIFIED);
switch (isVerified) { switch (isVerified) {
case Certs.VERIFIED_SECRET: case Certs.VERIFIED_SECRET:
vVerified.setImageResource(R.drawable.status_signature_verified_cutout); KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_VERIFIED, false);
vVerified.setColorFilter(
mContext.getResources().getColor(R.color.android_green_dark),
PorterDuff.Mode.SRC_IN);
break; break;
case Certs.VERIFIED_SELF: case Certs.VERIFIED_SELF:
vVerified.setImageResource(R.drawable.status_signature_unverified_cutout); KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_UNVERIFIED, false);
vVerified.setColorFilter(
mContext.getResources().getColor(R.color.bg_gray),
PorterDuff.Mode.SRC_IN);
break; break;
default: default:
vVerified.setImageResource(R.drawable.status_signature_invalid_cutout); KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_INVALID, false);
vVerified.setColorFilter(
mContext.getResources().getColor(R.color.android_red_dark),
PorterDuff.Mode.SRC_IN);
break; break;
} }
} }

View File

@ -392,29 +392,36 @@ public class KeyFormattingUtils {
setStatusImage(context, statusIcon, null, state); setStatusImage(context, statusIcon, null, state);
} }
public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, int state) {
setStatusImage(context, statusIcon, statusText, state, false);
}
/** /**
* Sets status image based on constant * Sets status image based on constant
*/ */
public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText, int state) { public static void setStatusImage(Context context, ImageView statusIcon, TextView statusText,
int state, boolean unobtrusive) {
switch (state) { switch (state) {
/** GREEN: everything is good **/ /** GREEN: everything is good **/
case STATE_VERIFIED: { case STATE_VERIFIED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_verified_cutout)); context.getResources().getDrawable(R.drawable.status_signature_verified_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_green_dark), int color = R.color.android_green_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_green_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
case STATE_ENCRYPTED: { case STATE_ENCRYPTED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_lock_closed)); context.getResources().getDrawable(R.drawable.status_lock_closed));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_green_dark), int color = R.color.android_green_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_green_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
@ -422,30 +429,22 @@ public class KeyFormattingUtils {
case STATE_UNVERIFIED: { case STATE_UNVERIFIED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout)); context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_orange_dark), int color = R.color.android_orange_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_orange_dark)); statusText.setTextColor(context.getResources().getColor(color));
}
break;
}
case STATE_EXPIRED: {
statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_expired_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_orange_dark),
PorterDuff.Mode.SRC_ATOP);
if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_orange_dark));
} }
break; break;
} }
case STATE_UNKNOWN_KEY: { case STATE_UNKNOWN_KEY: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_orange_dark), int color = R.color.android_orange_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_orange_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
@ -453,40 +452,61 @@ public class KeyFormattingUtils {
case STATE_REVOKED: { case STATE_REVOKED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout)); context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark), int color = R.color.android_red_light;
PorterDuff.Mode.SRC_ATOP); if (unobtrusive) {
color = R.color.bg_gray;
}
statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark)); statusText.setTextColor(context.getResources().getColor(color));
}
break;
}
case STATE_EXPIRED: {
statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_expired_cutout));
int color = R.color.android_red_light;
if (unobtrusive) {
color = R.color.bg_gray;
}
statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
case STATE_NOT_ENCRYPTED: { case STATE_NOT_ENCRYPTED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_lock_open)); context.getResources().getDrawable(R.drawable.status_lock_open));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark), int color = R.color.android_red_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
case STATE_NOT_SIGNED: { case STATE_NOT_SIGNED: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout)); context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark), int color = R.color.android_red_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
case STATE_INVALID: { case STATE_INVALID: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark), int color = R.color.android_red_light;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }
@ -494,10 +514,11 @@ public class KeyFormattingUtils {
case STATE_UNAVAILABLE: { case STATE_UNAVAILABLE: {
statusIcon.setImageDrawable( statusIcon.setImageDrawable(
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout)); context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout));
statusIcon.setColorFilter(context.getResources().getColor(R.color.bg_gray), int color = R.color.bg_gray;
PorterDuff.Mode.SRC_ATOP); statusIcon.setColorFilter(context.getResources().getColor(color),
PorterDuff.Mode.SRC_IN);
if (statusText != null) { if (statusText != null) {
statusText.setTextColor(context.getResources().getColor(R.color.bg_gray)); statusText.setTextColor(context.getResources().getColor(color));
} }
break; break;
} }