display creation dates for ambiguous user ids

This commit is contained in:
Vincent Breitmoser 2015-04-27 17:45:50 +02:00
parent 40834d1fcd
commit 4ba2e4bcdd
4 changed files with 43 additions and 16 deletions

View File

@ -27,6 +27,7 @@ import android.database.Cursor;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.support.v4.widget.CursorAdapter; import android.support.v4.widget.CursorAdapter;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -88,6 +89,7 @@ public class KeyAdapter extends CursorAdapter {
public Long mMasterKeyId; public Long mMasterKeyId;
public TextView mMainUserId; public TextView mMainUserId;
public TextView mMainUserIdRest; public TextView mMainUserIdRest;
public TextView mCreationDate;
public ImageView mStatus; public ImageView mStatus;
public View mSlinger; public View mSlinger;
public ImageButton mSlingerButton; public ImageButton mSlingerButton;
@ -98,6 +100,7 @@ public class KeyAdapter extends CursorAdapter {
mStatus = (ImageView) view.findViewById(R.id.key_list_item_status_icon); mStatus = (ImageView) view.findViewById(R.id.key_list_item_status_icon);
mSlinger = view.findViewById(R.id.key_list_item_slinger_view); mSlinger = view.findViewById(R.id.key_list_item_slinger_view);
mSlingerButton = (ImageButton) view.findViewById(R.id.key_list_item_slinger_button); 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) { 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 isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0; boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 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; mMasterKeyId = masterKeyId;
@ -165,6 +168,22 @@ public class KeyAdapter extends CursorAdapter {
mMainUserId.setTextColor(context.getResources().getColor(R.color.black)); mMainUserId.setTextColor(context.getResources().getColor(R.color.black));
mMainUserIdRest.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);
}
} }
} }

View File

@ -20,7 +20,7 @@ package org.sufficientlysecure.keychain.ui.adapter;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.support.v4.widget.CursorAdapter; import android.support.v4.widget.CursorAdapter;
import android.text.format.DateFormat; import android.text.format.DateUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; 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;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State; 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! * Yes this class is abstract!
@ -138,14 +134,14 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
boolean duplicate = cursor.getLong(mIndexDuplicateUserId) > 0; boolean duplicate = cursor.getLong(mIndexDuplicateUserId) > 0;
if (duplicate) { if (duplicate) {
Date creationDate = new Date(cursor.getLong(mIndexCreation) * 1000); String dateTime = DateUtils.formatDateTime(context,
Calendar creationCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cursor.getLong(mIndexCreation) * 1000,
creationCal.setTime(creationDate); DateUtils.FORMAT_SHOW_DATE
// convert from UTC to time zone of device | DateUtils.FORMAT_SHOW_TIME
creationCal.setTimeZone(TimeZone.getDefault()); | DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_ABBREV_MONTH);
h.creation.setText(context.getString(R.string.label_creation) + ": " h.creation.setText(context.getString(R.string.label_creation, dateTime));
+ DateFormat.getDateFormat(context).format(creationCal.getTime()));
h.creation.setVisibility(View.VISIBLE); h.creation.setVisibility(View.VISIBLE);
} else { } else {
h.creation.setVisibility(View.GONE); h.creation.setVisibility(View.GONE);

View File

@ -26,7 +26,7 @@
android:id="@+id/key_list_item_name" android:id="@+id/key_list_item_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/label_main_user_id" tools:text="@string/label_main_user_id"
android:textAppearance="?android:attr/textAppearanceMedium" /> android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView <TextView
@ -35,8 +35,20 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" android:singleLine="true"
android:ellipsize="end" android:ellipsize="end"
android:text="user@example.com" tools:text="user@example.com"
android:textAppearance="?android:attr/textAppearanceSmall" /> android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/key_list_item_creation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"
tools:visibility="visible"
tools:text="Created on 10/10/2010 10:00"
/>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout

View File

@ -137,7 +137,7 @@
<string name="label_file_compression">"File compression"</string> <string name="label_file_compression">"File compression"</string>
<string name="label_keyservers">"Keyservers"</string> <string name="label_keyservers">"Keyservers"</string>
<string name="label_key_id">"Key ID"</string> <string name="label_key_id">"Key ID"</string>
<string name="label_creation">"Creation"</string> <string name="label_creation">"Key created %s"</string>
<string name="label_expiry">"Expiry"</string> <string name="label_expiry">"Expiry"</string>
<string name="label_usage">"Usage"</string> <string name="label_usage">"Usage"</string>
<string name="label_key_size">"Key Size"</string> <string name="label_key_size">"Key Size"</string>