Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5de5ceb authored by Daniel Applebaum's avatar Daniel Applebaum
Browse files

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. 

parent 0706b7de
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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_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
     * enables or disables the Compose activity, the boot receiver and the service based on
+14 −3
Original line number Diff line number Diff line
@@ -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;
	}
@@ -157,7 +165,10 @@ public class FolderMessageList extends ExpandableListActivity
	{
		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;
	}
+19 −8
Original line number Diff line number Diff line
@@ -102,7 +102,15 @@ public class MessageView extends Activity
    {
      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;
    }
@@ -110,7 +118,10 @@ public class MessageView extends Activity
    {
      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;
    }