ImportKeys: Use data binding for key status image
This commit is contained in:
parent
61e047d7e9
commit
6ecc53d0a6
|
@ -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) {
|
||||
|
|
|
@ -53,26 +53,26 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
app:query="@{entry.query}"
|
||||
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:secret="@{entry.secretKey}"
|
||||
app:userId="@{entry.primaryUserId.name}" />
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keySecret="@{entry.secretKey}"
|
||||
app:keyUserId="@{entry.primaryUserId.name}"
|
||||
app:query="@{entry.query}" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:query="@{entry.query}"
|
||||
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:userEmail="@{entry.primaryUserId.email}" />
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keyUserEmail="@{entry.primaryUserId.email}"
|
||||
app:query="@{entry.query}" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:keyId="@{entry.keyIdHex}"
|
||||
app:revokedOrExpired="@{entry.revokedOrExpired}" />
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -82,7 +82,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:visibility="@{entry.revokedOrExpired ? View.VISIBLE : View.GONE}" />
|
||||
android:visibility="@{entry.revokedOrExpired ? View.VISIBLE : View.GONE}"
|
||||
app:keyExpired="@{entry.expired}"
|
||||
app:keyRevoked="@{entry.revoked}" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue