Fix key creation string and display

This commit is contained in:
Dominik Schürmann 2015-04-30 18:57:51 +02:00
parent 7c275fed9d
commit c88d2e42b7
4 changed files with 12 additions and 26 deletions

View File

@ -173,11 +173,10 @@ public class KeyAdapter extends CursorAdapter {
String dateTime = DateUtils.formatDateTime(context, String dateTime = DateUtils.formatDateTime(context,
cursor.getLong(INDEX_CREATION) * 1000, cursor.getLong(INDEX_CREATION) * 1000,
DateUtils.FORMAT_SHOW_DATE DateUtils.FORMAT_SHOW_DATE
| DateUtils.FORMAT_SHOW_TIME
| DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_ABBREV_MONTH); | DateUtils.FORMAT_ABBREV_MONTH);
mCreationDate.setText(context.getString(R.string.label_creation, mCreationDate.setText(context.getString(R.string.label_key_created,
dateTime)); dateTime));
mCreationDate.setVisibility(View.VISIBLE); mCreationDate.setVisibility(View.VISIBLE);
} else { } else {
@ -281,20 +280,6 @@ public class KeyAdapter extends CursorAdapter {
} }
} }
public boolean hasDuplicate() {
return mHasDuplicate;
}
public String getCreationDate(Context context) {
Calendar creationCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
creationCal.setTime(mCreation);
// convert from UTC to time zone of device
creationCal.setTimeZone(TimeZone.getDefault());
return context.getString(R.string.label_creation) + ": "
+ DateFormat.getDateFormat(context).format(creationCal.getTime());
}
} }
} }

View File

@ -141,7 +141,7 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
| DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_YEAR
| DateUtils.FORMAT_ABBREV_MONTH); | DateUtils.FORMAT_ABBREV_MONTH);
h.creation.setText(context.getString(R.string.label_creation, dateTime)); h.creation.setText(context.getString(R.string.label_key_created, dateTime));
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,6 +26,7 @@ import android.support.v4.content.Loader;
import android.support.v4.widget.CursorAdapter; import android.support.v4.widget.CursorAdapter;
import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.AppCompatSpinner;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.text.format.DateUtils;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -167,14 +168,13 @@ public abstract class KeySpinner extends AppCompatSpinner implements LoaderManag
boolean duplicate = cursor.getLong(mIndexDuplicate) > 0; boolean duplicate = cursor.getLong(mIndexDuplicate) > 0;
if (duplicate) { if (duplicate) {
Date creationDate = new Date(cursor.getLong(mIndexCreationDate) * 1000); String dateTime = DateUtils.formatDateTime(context,
Calendar creationCal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); cursor.getLong(mIndexCreationDate) * 1000,
creationCal.setTime(creationDate); DateUtils.FORMAT_SHOW_DATE
// convert from UTC to time zone of device | DateUtils.FORMAT_SHOW_YEAR
creationCal.setTimeZone(TimeZone.getDefault()); | DateUtils.FORMAT_ABBREV_MONTH);
vDuplicate.setText(context.getString(R.string.label_creation) + ": " vDuplicate.setText(context.getString(R.string.label_key_created, dateTime));
+ DateFormat.getDateFormat(context).format(creationCal.getTime()));
vDuplicate.setVisibility(View.VISIBLE); vDuplicate.setVisibility(View.VISIBLE);
} else { } else {
vDuplicate.setVisibility(View.GONE); vDuplicate.setVisibility(View.GONE);

View File

@ -137,7 +137,8 @@
<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">"Key created %s"</string> <string name="label_key_created">"Key created %s"</string>
<string name="label_creation">"Creation"</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>
@ -503,7 +504,7 @@
<string name="api_settings_delete_account">"Delete account"</string> <string name="api_settings_delete_account">"Delete account"</string>
<string name="api_settings_package_name">"Package Name"</string> <string name="api_settings_package_name">"Package Name"</string>
<string name="api_settings_package_signature">"SHA-256 of Package Signature"</string> <string name="api_settings_package_signature">"SHA-256 of Package Signature"</string>
<string name="api_settings_accounts">"Accounts (deprecated API)"</string> <string name="api_settings_accounts">"Accounts (old API)"</string>
<string name="api_settings_advanced">"Extended Information"</string> <string name="api_settings_advanced">"Extended Information"</string>
<string name="api_settings_allowed_keys">"Allowed Keys"</string> <string name="api_settings_allowed_keys">"Allowed Keys"</string>
<string name="api_settings_settings">"Settings"</string> <string name="api_settings_settings">"Settings"</string>