mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-24 16:48:50 -05:00
Eliminate use of Android-private APIs for getting user-selected
date/time formats. With this change, K-9 can run on original master or cupcake versions for the platform. This seems like an excessive amount of code. Perhaps there is a public API that accomplishes this work. Alternatively, the code in MessageView.java and FolderMessageList.java should be consolidated into a utility class used by both of the classes needing this functionality.
This commit is contained in:
parent
0706b7de45
commit
a5de5ceb0e
@ -143,6 +143,11 @@ public class Email extends Application {
|
||||
public static final int FETCHING_EMAIL_NOTIFICATION_ID = -4;
|
||||
public static final int FETCHING_EMAIL_NOTIFICATION_MULTI_ACCOUNT_ID = -1;
|
||||
public static final int FETCHING_EMAIL_NOTIFICATION_NO_ACCOUNT = -2;
|
||||
|
||||
// Backup formats in case they can't be fetched from the system
|
||||
public static final String BACKUP_DATE_FORMAT = "MM-dd-yyyy";
|
||||
public static final String TIME_FORMAT_12 = "h:mm a";
|
||||
public static final String TIME_FORMAT_24 = "H:mm";
|
||||
|
||||
/**
|
||||
* Called throughout the application when the number of accounts has changed. This method
|
||||
|
@ -148,7 +148,15 @@ public class FolderMessageList extends ExpandableListActivity
|
||||
{
|
||||
if (dateFormat == null)
|
||||
{
|
||||
dateFormat = android.pim.DateFormat.getDateFormat(getApplication());
|
||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.DATE_FORMAT);
|
||||
if (dateFormatS != null) {
|
||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
||||
}
|
||||
}
|
||||
return dateFormat;
|
||||
}
|
||||
@ -156,8 +164,11 @@ public class FolderMessageList extends ExpandableListActivity
|
||||
private DateFormat getTimeFormat()
|
||||
{
|
||||
if (timeFormat == null)
|
||||
{
|
||||
timeFormat = android.pim.DateFormat.getTimeFormat(getApplication());
|
||||
{
|
||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.TIME_12_24);
|
||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
||||
timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12);
|
||||
}
|
||||
return timeFormat;
|
||||
}
|
||||
|
@ -100,18 +100,29 @@ public class MessageView extends Activity
|
||||
|
||||
private DateFormat getDateFormat()
|
||||
{
|
||||
if (dateFormat == null)
|
||||
{
|
||||
dateFormat = android.pim.DateFormat.getDateFormat(getApplication());
|
||||
}
|
||||
if (dateFormat == null)
|
||||
{
|
||||
String dateFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.DATE_FORMAT);
|
||||
if (dateFormatS != null) {
|
||||
dateFormat = new java.text.SimpleDateFormat(dateFormatS);
|
||||
}
|
||||
else
|
||||
{
|
||||
dateFormat = new java.text.SimpleDateFormat(Email.BACKUP_DATE_FORMAT);
|
||||
}
|
||||
}
|
||||
return dateFormat;
|
||||
}
|
||||
private DateFormat getTimeFormat()
|
||||
{
|
||||
if (timeFormat == null)
|
||||
{
|
||||
timeFormat = android.pim.DateFormat.getTimeFormat(getApplication());
|
||||
}
|
||||
if (timeFormat == null)
|
||||
{
|
||||
String timeFormatS = android.provider.Settings.System.getString(getContentResolver(),
|
||||
android.provider.Settings.System.TIME_12_24);
|
||||
boolean b24 = !(timeFormatS == null || timeFormatS.equals("12"));
|
||||
timeFormat = new java.text.SimpleDateFormat(b24 ? Email.TIME_FORMAT_24 : Email.TIME_FORMAT_12);
|
||||
}
|
||||
return timeFormat;
|
||||
}
|
||||
private void clearFormats()
|
||||
|
Loading…
Reference in New Issue
Block a user