aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-04-27 17:45:50 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-04-27 17:45:50 +0200
commit32db4e393b823759380ebdcdac28bfd950cd41e4 (patch)
tree785b9b6581836163d1a86f26bb8b81b0b9fcf08f /OpenKeychain/src/main/java/org
parent0ad66eb510772a5731fa97d1745082b43a71215e (diff)
downloadopen-keychain-32db4e393b823759380ebdcdac28bfd950cd41e4.tar.gz
open-keychain-32db4e393b823759380ebdcdac28bfd950cd41e4.tar.bz2
open-keychain-32db4e393b823759380ebdcdac28bfd950cd41e4.zip
display creation dates for ambiguous user ids
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java21
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java22
2 files changed, 29 insertions, 14 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java
index 6f19fc6ed..f09dc1a4f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java
@@ -27,6 +27,7 @@ import android.database.Cursor;
import android.graphics.PorterDuff;
import android.support.v4.widget.CursorAdapter;
import android.text.format.DateFormat;
+import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -88,6 +89,7 @@ public class KeyAdapter extends CursorAdapter {
public Long mMasterKeyId;
public TextView mMainUserId;
public TextView mMainUserIdRest;
+ public TextView mCreationDate;
public ImageView mStatus;
public View mSlinger;
public ImageButton mSlingerButton;
@@ -98,6 +100,7 @@ public class KeyAdapter extends CursorAdapter {
mStatus = (ImageView) view.findViewById(R.id.key_list_item_status_icon);
mSlinger = view.findViewById(R.id.key_list_item_slinger_view);
mSlingerButton = (ImageButton) view.findViewById(R.id.key_list_item_slinger_button);
+ mCreationDate = (TextView) view.findViewById(R.id.key_list_item_creation);
}
public void setData(Context context, Cursor cursor, Highlighter highlighter) {
@@ -125,7 +128,7 @@ public class KeyAdapter extends CursorAdapter {
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
- // boolean hasDuplicate = cursor.getInt(INDEX_HAS_DUPLICATE_USER_ID) == 1;
+ boolean hasDuplicate = cursor.getInt(INDEX_HAS_DUPLICATE_USER_ID) != 0;
mMasterKeyId = masterKeyId;
@@ -165,6 +168,22 @@ public class KeyAdapter extends CursorAdapter {
mMainUserId.setTextColor(context.getResources().getColor(R.color.black));
mMainUserIdRest.setTextColor(context.getResources().getColor(R.color.black));
}
+
+ if (hasDuplicate) {
+ String dateTime = DateUtils.formatDateTime(context,
+ cursor.getLong(INDEX_CREATION) * 1000,
+ DateUtils.FORMAT_SHOW_DATE
+ | DateUtils.FORMAT_SHOW_TIME
+ | DateUtils.FORMAT_SHOW_YEAR
+ | DateUtils.FORMAT_ABBREV_MONTH);
+
+ mCreationDate.setText(context.getString(R.string.label_creation,
+ dateTime));
+ mCreationDate.setVisibility(View.VISIBLE);
+ } else {
+ mCreationDate.setVisibility(View.GONE);
+ }
+
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
index 3308a4500..1ccb910d0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
@@ -20,7 +20,7 @@ package org.sufficientlysecure.keychain.ui.adapter;
import android.content.Context;
import android.database.Cursor;
import android.support.v4.widget.CursorAdapter;
-import android.text.format.DateFormat;
+import android.text.format.DateUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -36,10 +36,6 @@ import org.sufficientlysecure.keychain.ui.util.Highlighter;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
/**
* Yes this class is abstract!
@@ -138,14 +134,14 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
boolean duplicate = cursor.getLong(mIndexDuplicateUserId) > 0;
if (duplicate) {
- Date creationDate = new Date(cursor.getLong(mIndexCreation) * 1000);
- Calendar creationCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- creationCal.setTime(creationDate);
- // convert from UTC to time zone of device
- creationCal.setTimeZone(TimeZone.getDefault());
-
- h.creation.setText(context.getString(R.string.label_creation) + ": "
- + DateFormat.getDateFormat(context).format(creationCal.getTime()));
+ String dateTime = DateUtils.formatDateTime(context,
+ cursor.getLong(mIndexCreation) * 1000,
+ DateUtils.FORMAT_SHOW_DATE
+ | DateUtils.FORMAT_SHOW_TIME
+ | DateUtils.FORMAT_SHOW_YEAR
+ | DateUtils.FORMAT_ABBREV_MONTH);
+
+ h.creation.setText(context.getString(R.string.label_creation, dateTime));
h.creation.setVisibility(View.VISIBLE);
} else {
h.creation.setVisibility(View.GONE);