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