ImportKeys: Use data binding for key status image
This commit is contained in:
@@ -40,8 +40,6 @@ import org.sufficientlysecure.keychain.operations.results.ImportKeyResult;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedKeyRing;
|
||||
import org.sufficientlysecure.keychain.service.ImportKeyringParcel;
|
||||
import org.sufficientlysecure.keychain.ui.base.CryptoOperationHelper;
|
||||
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.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.ParcelableFileCache;
|
||||
@@ -130,14 +128,6 @@ public class ImportKeysAdapter extends RecyclerView.Adapter<ImportKeysAdapter.Vi
|
||||
final ImportKeysListEntry entry = mData.get(position);
|
||||
b.setEntry(entry);
|
||||
|
||||
if (entry.isRevoked()) {
|
||||
KeyFormattingUtils.setStatusImage(mActivity, b.status, null,
|
||||
State.REVOKED, R.color.key_flag_gray);
|
||||
} else if (entry.isExpired()) {
|
||||
KeyFormattingUtils.setStatusImage(mActivity, b.status, null,
|
||||
State.EXPIRED, R.color.key_flag_gray);
|
||||
}
|
||||
|
||||
final KeyState keyState = mKeyStates[position];
|
||||
final boolean downloaded = keyState.mDownloaded;
|
||||
final boolean showed = keyState.mShowed;
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.graphics.Color;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@@ -14,7 +15,7 @@ import org.sufficientlysecure.keychain.util.LruCache;
|
||||
|
||||
public class ImportKeysAdapterBinding {
|
||||
|
||||
@BindingAdapter({"app:userId", "app:secret", "app:revokedOrExpired", "app:query"})
|
||||
@BindingAdapter({"app:keyUserId", "app:keySecret", "app:keyRevokedOrExpired", "app:query"})
|
||||
public static void setUserId(TextView textView, CharSequence userId, boolean secret,
|
||||
boolean revokedOrExpired, String query) {
|
||||
|
||||
@@ -38,7 +39,7 @@ public class ImportKeysAdapterBinding {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:userEmail", "app:revokedOrExpired", "app:query"})
|
||||
@BindingAdapter({"app:keyUserEmail", "app:keyRevokedOrExpired", "app:query"})
|
||||
public static void setUserEmail(TextView textView, CharSequence userEmail,
|
||||
boolean revokedOrExpired, String query) {
|
||||
|
||||
@@ -52,7 +53,7 @@ public class ImportKeysAdapterBinding {
|
||||
textView.setTextColor(getColor(context, revokedOrExpired));
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyId", "app:revokedOrExpired"})
|
||||
@BindingAdapter({"app:keyId", "app:keyRevokedOrExpired"})
|
||||
public static void setKeyId(TextView textView, String keyId, boolean revokedOrExpired) {
|
||||
Context context = textView.getContext();
|
||||
|
||||
@@ -71,6 +72,19 @@ public class ImportKeysAdapterBinding {
|
||||
}
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyRevoked", "app:keyExpired"})
|
||||
public static void setStatus(ImageView imageView, boolean revoked, boolean expired) {
|
||||
Context context = imageView.getContext();
|
||||
|
||||
if (revoked) {
|
||||
KeyFormattingUtils.setStatusImage(context, imageView, null,
|
||||
KeyFormattingUtils.State.REVOKED, R.color.key_flag_gray);
|
||||
} else if (expired) {
|
||||
KeyFormattingUtils.setStatusImage(context, imageView, null,
|
||||
KeyFormattingUtils.State.EXPIRED, R.color.key_flag_gray);
|
||||
}
|
||||
}
|
||||
|
||||
private static LruCache<String, Highlighter> highlighterCache = new LruCache<>(1);
|
||||
|
||||
private static Highlighter getHighlighter(Context context, String query) {
|
||||
|
||||
Reference in New Issue
Block a user