Fix for crash to DateControlSet / TaskEdit activity because of invalid format specifier. How the heck did it get in there? Sad times on the Android platform.

pull/14/head
Tim Su 16 years ago
parent a48ebe5d9c
commit 219f39dd39

@ -159,15 +159,6 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
long taskId = 0;
try {
taskId = intent.getExtras().getLong("id");
} catch (Exception e) {
e.printStackTrace();
}
// Log.d("astrid", "id = " + taskId);
tagController = new TagController(this);
tagController.open();
alertController = new AlertController(this);

@ -1,5 +1,6 @@
package com.timsu.astrid.utilities;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
@ -23,7 +24,6 @@ public class Preferences {
private static final String P_SYNC_LAST_SYNC_ATTEMPT = "lastsyncattempt";
private static final String P_LOCALE_LAST_NOTIFY = "locnot";
private static final String P_DID_ANDROID_AND_ME_SURVEY = "aamsurvey";
private static final String P_TAG_LIST_SORT = "tgsort";
// pref values
public static final int ICON_SET_PINK = 0;
@ -129,24 +129,34 @@ public class Preferences {
return b24;
}
public static String getTimeFormat(Context context) {
public static SimpleDateFormat getTimeFormat(Context context) {
String value;
if (is24HourFormat(context)) {
return "H:mm";
value = "H:mm";
} else {
return "h:mm a";
value = "h:mm a";
}
return new SimpleDateFormat(value);
}
public static String getDateFormat(Context context) {
public static SimpleDateFormat getDateFormat(Context context) {
String value = android.provider.Settings.System.getString(context.getContentResolver(),
android.provider.Settings.System.DATE_FORMAT);
if(value == null) {
value = "MMM d, yyyy";
}
// if there is not already day-of-week indicator, add this
if(!value.contains("E"))
value = "EEE, " + value;
return value;
try {
return new SimpleDateFormat(value);
} catch (IllegalArgumentException e) {
return new SimpleDateFormat("EEE, MMM d, yyyy");
}
}
// --- notification settings

@ -20,7 +20,6 @@
package com.timsu.astrid.widget;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.app.Activity;
@ -48,8 +47,8 @@ public class DateControlSet implements OnTimeSetListener,
protected DateControlSet(Activity activity) {
this.activity = activity;
this.dateFormatter = new SimpleDateFormat(Preferences.getDateFormat(this.activity));
this.timeFormatter = new SimpleDateFormat(Preferences.getTimeFormat(this.activity));
this.dateFormatter = Preferences.getDateFormat(this.activity);
this.timeFormatter = Preferences.getTimeFormat(this.activity);
}
public DateControlSet(Activity activity, Button dateButton, Button timeButton) {

Loading…
Cancel
Save