ImportKeys: Move creation date in the top part of the card
This commit is contained in:
@@ -4,12 +4,13 @@ import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.graphics.Color;
|
||||
import android.widget.ImageView;
|
||||
import android.text.format.DateFormat;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ImportKeysBindings {
|
||||
|
||||
@@ -51,17 +52,19 @@ public class ImportKeysBindings {
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpired));
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyRevoked", "app:keyExpired"})
|
||||
public static void setStatus(ImageView imageView, boolean revoked, boolean expired) {
|
||||
Context context = imageView.getContext();
|
||||
@BindingAdapter({"app:keyCreation", "app:keyRevokedOrExpired"})
|
||||
public static void setCreation(TextView textView, Date creationDate, boolean revokedOrExpired) {
|
||||
Context context = textView.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);
|
||||
String text;
|
||||
if (creationDate != null) {
|
||||
text = DateFormat.getDateFormat(context).format(creationDate);
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
text = resources.getString(R.string.unknown);
|
||||
}
|
||||
textView.setText(text);
|
||||
textView.setTextColor(ImportKeysBindingsUtils.getColor(context, revokedOrExpired));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package org.sufficientlysecure.keychain.ui.bindings;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.databinding.BindingAdapter;
|
||||
import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
@@ -14,30 +14,29 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter;
|
||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
public class ImportKeysExtraBindings {
|
||||
|
||||
@BindingAdapter({"app:keyCreation"})
|
||||
public static void setCreation(TextView textView, Date creationDate) {
|
||||
Context context = textView.getContext();
|
||||
String text;
|
||||
if (creationDate != null) {
|
||||
text = DateFormat.getDateFormat(context).format(creationDate);
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
text = resources.getString(R.string.unknown);
|
||||
@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);
|
||||
}
|
||||
textView.setText(text);
|
||||
}
|
||||
|
||||
@BindingAdapter({"app:keyId"})
|
||||
public static void setKeyId(TextView textView, String keyId) {
|
||||
Context context = textView.getContext();
|
||||
String text;
|
||||
if (keyId != null){
|
||||
if (keyId != null) {
|
||||
text = KeyFormattingUtils.beautifyKeyId(keyId);
|
||||
} else {
|
||||
Resources resources = context.getResources();
|
||||
|
||||
@@ -28,39 +28,39 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingBottom="16dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingTop="24dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
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:textAppearance="?android:attr/textAppearanceMedium"
|
||||
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:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keyUserEmail="@{entry.primaryUserId.email}"
|
||||
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:keyRevokedOrExpired="@{entry.revokedOrExpired}"
|
||||
app:keyUserEmail="@{entry.primaryUserId.email}"
|
||||
app:query="@{entry.query}" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
app:keyCreation="@{entry.date}"
|
||||
app:keyRevokedOrExpired="@{entry.revokedOrExpired}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -77,27 +77,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/label_creation_colon"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?attr/colorText" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?attr/colorText"
|
||||
app:keyCreation="@{entry.date}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
|
||||
Reference in New Issue
Block a user