Always show creation time for own keys, and show as "just now" for new keys
This commit is contained in:
@@ -63,6 +63,8 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
private static final short VIEW_SECTION_TYPE_PRIVATE = 0x0;
|
private static final short VIEW_SECTION_TYPE_PRIVATE = 0x0;
|
||||||
private static final short VIEW_SECTION_TYPE_PUBLIC = 0x1;
|
private static final short VIEW_SECTION_TYPE_PUBLIC = 0x1;
|
||||||
|
|
||||||
|
private static final long JUST_NOW_TIMESPAN = DateUtils.MINUTE_IN_MILLIS * 5;
|
||||||
|
|
||||||
private String mQuery;
|
private String mQuery;
|
||||||
private List<Integer> mSelected;
|
private List<Integer> mSelected;
|
||||||
private KeyListListener mListener;
|
private KeyListListener mListener;
|
||||||
@@ -483,15 +485,8 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
mMainUserId.setTextColor(textColor);
|
mMainUserId.setTextColor(textColor);
|
||||||
mMainUserIdRest.setTextColor(textColor);
|
mMainUserIdRest.setTextColor(textColor);
|
||||||
|
|
||||||
if (keyItem.hasDuplicate()) {
|
if (keyItem.hasDuplicate() || keyItem.isSecret()) {
|
||||||
String dateTime = DateUtils.formatDateTime(context,
|
mCreationDate.setText(getSecretKeyReadableTime(context, keyItem));
|
||||||
keyItem.getCreationTime(),
|
|
||||||
DateUtils.FORMAT_SHOW_DATE
|
|
||||||
| DateUtils.FORMAT_SHOW_TIME
|
|
||||||
| DateUtils.FORMAT_SHOW_YEAR
|
|
||||||
| DateUtils.FORMAT_ABBREV_MONTH);
|
|
||||||
mCreationDate.setText(context.getString(R.string.label_key_created,
|
|
||||||
dateTime));
|
|
||||||
mCreationDate.setTextColor(textColor);
|
mCreationDate.setTextColor(textColor);
|
||||||
mCreationDate.setVisibility(View.VISIBLE);
|
mCreationDate.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
@@ -517,6 +512,27 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private String getSecretKeyReadableTime(Context context, KeyListCursor keyItem) {
|
||||||
|
long creationMillis = keyItem.getCreationTime();
|
||||||
|
|
||||||
|
boolean allowRelativeTimestamp = keyItem.hasDuplicate();
|
||||||
|
if (allowRelativeTimestamp) {
|
||||||
|
long creationAgeMillis = System.currentTimeMillis() - creationMillis;
|
||||||
|
if (creationAgeMillis < JUST_NOW_TIMESPAN) {
|
||||||
|
return context.getString(R.string.label_key_created_just_now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String dateTime = DateUtils.formatDateTime(context,
|
||||||
|
creationMillis,
|
||||||
|
DateUtils.FORMAT_SHOW_DATE
|
||||||
|
| DateUtils.FORMAT_SHOW_TIME
|
||||||
|
| DateUtils.FORMAT_SHOW_YEAR
|
||||||
|
| DateUtils.FORMAT_ABBREV_MONTH);
|
||||||
|
return context.getString(R.string.label_key_created, dateTime);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
int pos = getAdapterPosition();
|
int pos = getAdapterPosition();
|
||||||
|
|||||||
@@ -167,7 +167,8 @@
|
|||||||
<string name="label_keyservers">"Manage OpenPGP keyservers"</string>
|
<string name="label_keyservers">"Manage OpenPGP keyservers"</string>
|
||||||
<string name="label_key_id">"Key ID"</string>
|
<string name="label_key_id">"Key ID"</string>
|
||||||
<string name="label_key_id_colon">"Key ID:"</string>
|
<string name="label_key_id_colon">"Key ID:"</string>
|
||||||
<string name="label_key_created">"Key created %s"</string>
|
<string name="label_key_created">"Created %s"</string>
|
||||||
|
<string name="label_key_created_just_now">"Created just now"</string>
|
||||||
<string name="label_key_type">"Type"</string>
|
<string name="label_key_type">"Type"</string>
|
||||||
<string name="label_creation">"Creation"</string>
|
<string name="label_creation">"Creation"</string>
|
||||||
<string name="label_creation_colon">"Creation:"</string>
|
<string name="label_creation_colon">"Creation:"</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user