ImportKeys: Fix text color and refactoring
This commit is contained in:
parent
b56ca19206
commit
61e047d7e9
|
@ -7,6 +7,7 @@ import android.graphics.Color;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.FormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.util.LruCache;
|
import org.sufficientlysecure.keychain.util.LruCache;
|
||||||
|
@ -30,10 +31,9 @@ public class ImportKeysAdapterBinding {
|
||||||
userId = highlighter.highlight(userId);
|
userId = highlighter.highlight(userId);
|
||||||
}
|
}
|
||||||
textView.setText(userId);
|
textView.setText(userId);
|
||||||
|
textView.setTextColor(getColor(context, revokedOrExpired));
|
||||||
|
|
||||||
if (revokedOrExpired) {
|
if (secret) {
|
||||||
textView.setTextColor(resources.getColor(R.color.key_flag_gray));
|
|
||||||
} else if (secret) {
|
|
||||||
textView.setTextColor(Color.RED);
|
textView.setTextColor(Color.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,11 +49,7 @@ public class ImportKeysAdapterBinding {
|
||||||
|
|
||||||
Highlighter highlighter = getHighlighter(context, query);
|
Highlighter highlighter = getHighlighter(context, query);
|
||||||
textView.setText(highlighter.highlight(userEmail));
|
textView.setText(highlighter.highlight(userEmail));
|
||||||
|
textView.setTextColor(getColor(context, revokedOrExpired));
|
||||||
if (revokedOrExpired) {
|
|
||||||
Resources resources = context.getResources();
|
|
||||||
textView.setTextColor(resources.getColor(R.color.key_flag_gray));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@BindingAdapter({"app:keyId", "app:revokedOrExpired"})
|
@BindingAdapter({"app:keyId", "app:revokedOrExpired"})
|
||||||
|
@ -63,11 +59,16 @@ public class ImportKeysAdapterBinding {
|
||||||
if (keyId == null)
|
if (keyId == null)
|
||||||
keyId = "";
|
keyId = "";
|
||||||
|
|
||||||
if (revokedOrExpired) {
|
|
||||||
Resources resources = context.getResources();
|
|
||||||
textView.setTextColor(resources.getColor(R.color.key_flag_gray));
|
|
||||||
}
|
|
||||||
textView.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(keyId));
|
textView.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(keyId));
|
||||||
|
textView.setTextColor(getColor(context, revokedOrExpired));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getColor(Context context, boolean revokedOrExpired) {
|
||||||
|
if (revokedOrExpired) {
|
||||||
|
return context.getResources().getColor(R.color.key_flag_gray);
|
||||||
|
} else {
|
||||||
|
return FormattingUtils.getColorFromAttr(context, R.attr.colorText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LruCache<String, Highlighter> highlighterCache = new LruCache<>(1);
|
private static LruCache<String, Highlighter> highlighterCache = new LruCache<>(1);
|
||||||
|
|
|
@ -53,7 +53,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
android:textColor="?attr/colorText"
|
|
||||||
app:query="@{entry.query}"
|
app:query="@{entry.query}"
|
||||||
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
||||||
app:secret="@{entry.secretKey}"
|
app:secret="@{entry.secretKey}"
|
||||||
|
@ -64,7 +63,6 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="4dp"
|
android:layout_marginTop="4dp"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textColor="?attr/colorText"
|
|
||||||
app:query="@{entry.query}"
|
app:query="@{entry.query}"
|
||||||
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
app:revokedOrExpired="@{entry.revokedOrExpired}"
|
||||||
app:userEmail="@{entry.primaryUserId.email}" />
|
app:userEmail="@{entry.primaryUserId.email}" />
|
||||||
|
@ -73,7 +71,6 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
android:textColor="?attr/colorText"
|
|
||||||
app:keyId="@{entry.keyIdHex}"
|
app:keyId="@{entry.keyIdHex}"
|
||||||
app:revokedOrExpired="@{entry.revokedOrExpired}" />
|
app:revokedOrExpired="@{entry.revokedOrExpired}" />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue