mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -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
@ -144,6 +144,11 @@ public class Email extends Application {
|
|||||||
public static final int FETCHING_EMAIL_NOTIFICATION_MULTI_ACCOUNT_ID = -1;
|
public static final int FETCHING_EMAIL_NOTIFICATION_MULTI_ACCOUNT_ID = -1;
|
||||||
public static final int FETCHING_EMAIL_NOTIFICATION_NO_ACCOUNT = -2;
|
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
|
* Called throughout the application when the number of accounts has changed. This method
|
||||||
* enables or disables the Compose activity, the boot receiver and the service based on
|
* enables or disables the Compose activity, the boot receiver and the service based on
|
||||||
|
@ -148,7 +148,15 @@ public class FolderMessageList extends ExpandableListActivity
|
|||||||
{
|
{
|
||||||
if (dateFormat == null)
|
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;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@ -157,7 +165,10 @@ public class FolderMessageList extends ExpandableListActivity
|
|||||||
{
|
{
|
||||||
if (timeFormat == null)
|
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;
|
return timeFormat;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,15 @@ public class MessageView extends Activity
|
|||||||
{
|
{
|
||||||
if (dateFormat == null)
|
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;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
@ -110,7 +118,10 @@ public class MessageView extends Activity
|
|||||||
{
|
{
|
||||||
if (timeFormat == null)
|
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;
|
return timeFormat;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user