mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-24 01:32:16 -05:00
color experiments
This commit is contained in:
parent
c7e2b8424e
commit
be9b483ee8
@ -647,30 +647,34 @@ public class KeyListFragment extends LoaderFragment
|
||||
|
||||
// Note: order is important!
|
||||
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.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) {
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_EXPIRED);
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, null, KeyFormattingUtils.STATE_EXPIRED, true);
|
||||
h.mStatus.setVisibility(View.VISIBLE);
|
||||
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) {
|
||||
h.mStatus.setVisibility(View.GONE);
|
||||
h.mSlinger.setVisibility(View.VISIBLE);
|
||||
h.mMainUserId.setTextColor(context.getResources().getColor(R.color.black));
|
||||
h.mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.black));
|
||||
} else {
|
||||
// this is a public key - show if it's verified
|
||||
if (isVerified) {
|
||||
if (cursor.getInt(KeyListFragment.INDEX_HAS_ANY_SECRET) != 0) {
|
||||
// this is a secret key
|
||||
h.mStatus.setVisibility(View.GONE);
|
||||
} else {
|
||||
// this is a public key - show if it's verified
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_VERIFIED);
|
||||
h.mStatus.setVisibility(View.VISIBLE);
|
||||
}
|
||||
KeyFormattingUtils.setStatusImage(getActivity(), h.mStatus, KeyFormattingUtils.STATE_VERIFIED);
|
||||
h.mStatus.setVisibility(View.VISIBLE);
|
||||
} 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.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;
|
||||
}
|
||||
|
||||
if ( ! result.success()) {
|
||||
if (!result.success()) {
|
||||
result.createNotify(activity).show();
|
||||
return;
|
||||
}
|
||||
|
@ -486,20 +486,12 @@ public class ViewKeyActivity extends ActionBarActivity implements
|
||||
// Note: order is important
|
||||
if (isRevoked) {
|
||||
mStatusText.setText(R.string.view_key_revoked);
|
||||
mStatusText.setTextColor(getResources().getColor(R.color.android_red_dark));
|
||||
mStatusImage.setImageDrawable(
|
||||
getResources().getDrawable(R.drawable.status_signature_revoked_cutout));
|
||||
mStatusImage.setColorFilter(getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_REVOKED);
|
||||
mStatusDivider.setVisibility(View.VISIBLE);
|
||||
mStatusLayout.setVisibility(View.VISIBLE);
|
||||
} else if (isExpired) {
|
||||
mStatusText.setText(R.string.view_key_expired);
|
||||
mStatusText.setTextColor(getResources().getColor(R.color.android_orange_dark));
|
||||
mStatusImage.setImageDrawable(
|
||||
getResources().getDrawable(R.drawable.status_signature_expired_cutout));
|
||||
mStatusImage.setColorFilter(getResources().getColor(R.color.android_orange_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, KeyFormattingUtils.STATE_EXPIRED);
|
||||
mStatusDivider.setVisibility(View.VISIBLE);
|
||||
mStatusLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
@ -37,6 +37,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||
import org.sufficientlysecure.keychain.service.SaveKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -163,10 +164,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
||||
|
||||
if (isRevoked) {
|
||||
// set revocation icon (can this even be primary?)
|
||||
vVerified.setImageResource(R.drawable.status_signature_revoked_cutout);
|
||||
vVerified.setColorFilter(
|
||||
mContext.getResources().getColor(R.color.bg_gray),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_REVOKED, true);
|
||||
|
||||
// disable and strike through text for revoked user ids
|
||||
vName.setEnabled(false);
|
||||
@ -191,22 +189,13 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC
|
||||
int isVerified = cursor.getInt(INDEX_VERIFIED);
|
||||
switch (isVerified) {
|
||||
case Certs.VERIFIED_SECRET:
|
||||
vVerified.setImageResource(R.drawable.status_signature_verified_cutout);
|
||||
vVerified.setColorFilter(
|
||||
mContext.getResources().getColor(R.color.android_green_dark),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_VERIFIED, false);
|
||||
break;
|
||||
case Certs.VERIFIED_SELF:
|
||||
vVerified.setImageResource(R.drawable.status_signature_unverified_cutout);
|
||||
vVerified.setColorFilter(
|
||||
mContext.getResources().getColor(R.color.bg_gray),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_UNVERIFIED, false);
|
||||
break;
|
||||
default:
|
||||
vVerified.setImageResource(R.drawable.status_signature_invalid_cutout);
|
||||
vVerified.setColorFilter(
|
||||
mContext.getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
KeyFormattingUtils.setStatusImage(mContext, vVerified, null, KeyFormattingUtils.STATE_INVALID, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -392,29 +392,36 @@ public class KeyFormattingUtils {
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
/** GREEN: everything is good **/
|
||||
case STATE_VERIFIED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_verified_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_green_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_green_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_green_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATE_ENCRYPTED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_lock_closed));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_green_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_green_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_green_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -422,30 +429,22 @@ public class KeyFormattingUtils {
|
||||
case STATE_UNVERIFIED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_unverified_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_orange_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_orange_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_orange_dark));
|
||||
}
|
||||
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));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATE_UNKNOWN_KEY: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_orange_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_orange_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_orange_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -453,40 +452,61 @@ public class KeyFormattingUtils {
|
||||
case STATE_REVOKED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_revoked_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
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(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;
|
||||
}
|
||||
case STATE_NOT_ENCRYPTED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_lock_open));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_red_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATE_NOT_SIGNED: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_unknown_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_red_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case STATE_INVALID: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.android_red_dark),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.android_red_light;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.android_red_dark));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -494,10 +514,11 @@ public class KeyFormattingUtils {
|
||||
case STATE_UNAVAILABLE: {
|
||||
statusIcon.setImageDrawable(
|
||||
context.getResources().getDrawable(R.drawable.status_signature_invalid_cutout));
|
||||
statusIcon.setColorFilter(context.getResources().getColor(R.color.bg_gray),
|
||||
PorterDuff.Mode.SRC_ATOP);
|
||||
int color = R.color.bg_gray;
|
||||
statusIcon.setColorFilter(context.getResources().getColor(color),
|
||||
PorterDuff.Mode.SRC_IN);
|
||||
if (statusText != null) {
|
||||
statusText.setTextColor(context.getResources().getColor(R.color.bg_gray));
|
||||
statusText.setTextColor(context.getResources().getColor(color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user