diff --git a/api/res/values/strings.xml b/api/res/values/strings.xml index 934835327..178a739e7 100644 --- a/api/res/values/strings.xml +++ b/api/res/values/strings.xml @@ -92,6 +92,12 @@ Yesterday + + Tmrw + + + Yest + diff --git a/api/src/com/todoroo/andlib/utility/DateUtilities.java b/api/src/com/todoroo/andlib/utility/DateUtilities.java index 464981476..cf97ba3eb 100644 --- a/api/src/com/todoroo/andlib/utility/DateUtilities.java +++ b/api/src/com/todoroo/andlib/utility/DateUtilities.java @@ -99,7 +99,10 @@ public class DateUtilities { String value; if (is24HourFormat(context)) { value = "H:mm"; - } else { + } else if (date.getMinutes() == 0){ + value = "h a"; + } + else { value = "h:mm a"; } return new SimpleDateFormat(value).format(date); @@ -124,6 +127,29 @@ public class DateUtilities { return new SimpleDateFormat(value).format(date).replace("#", month); } + /** + * @param context android context + * @param date date to format + * @return date, with month, day, and year + */ + @SuppressWarnings("nls") + public static String getDateStringHideYear(Context context, Date date) { + String month = DateUtils.getMonthString(date.getMonth() + + Calendar.JANUARY, DateUtils.LENGTH_MEDIUM); + String value; + // united states, you are special + if (Locale.US.equals(Locale.getDefault()) + || Locale.CANADA.equals(Locale.getDefault())) + value = "'#' d"; + else + value = "d '#'"; + + if (date.getYear() != (new Date()).getYear()) { + value = value + "\nyyyy"; + } + return new SimpleDateFormat(value).format(date).replace("#", month); + } + /** * @return date format as getDateFormat with weekday */ @@ -141,6 +167,15 @@ public class DateUtilities { DateUtils.LENGTH_LONG); } + + /** + * @return weekday + */ + public static String getWeekdayShort(Date date) { + return DateUtils.getDayOfWeekString(date.getDay() + Calendar.SUNDAY, + DateUtils.LENGTH_MEDIUM); + } + /** * @return date format as getDateFormat with weekday */ @@ -168,16 +203,16 @@ public class DateUtilities { return context.getString(R.string.today).toLowerCase(); if(today + ONE_DAY == input) - return context.getString(R.string.tomorrow).toLowerCase(); + return context.getString(R.string.tmrw).toLowerCase(); if(today == input + ONE_DAY) - return context.getString(R.string.yesterday).toLowerCase(); + return context.getString(R.string.yest).toLowerCase(); if(today + DateUtilities.ONE_WEEK >= input && today - DateUtilities.ONE_WEEK <= input) - return DateUtilities.getWeekday(new Date(date)); + return DateUtilities.getWeekdayShort(new Date(date)); - return DateUtilities.getDateString(context, new Date(date)); + return DateUtilities.getDateStringHideYear(context, new Date(date)); } private static long clearTime(Date date) { diff --git a/astrid/res/layout/task_adapter_row.xml b/astrid/res/layout/task_adapter_row.xml index 7f1b1de8c..ed007bb13 100644 --- a/astrid/res/layout/task_adapter_row.xml +++ b/astrid/res/layout/task_adapter_row.xml @@ -17,11 +17,12 @@ @@ -48,13 +49,15 @@ android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="100" + android:maxLines="2" style="@style/TextAppearance.TAd_ItemTitle"/> diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 7ad0a63d2..08d60497c 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -263,6 +263,12 @@ -1 + + p_show_details + + + p_show_decorations + diff --git a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java index 0a9f2a57f..a57424424 100644 --- a/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java +++ b/astrid/src/com/todoroo/astrid/adapter/TaskAdapter.java @@ -202,8 +202,10 @@ public class TaskAdapter extends CursorAdapter implements Filterable { displayMetrics = new DisplayMetrics(); fragment.getActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); - detailLoader = new DetailLoaderThread(); - detailLoader.start(); + if (Preferences.getBoolean(R.string.p_default_showdetails_key, false)) { + detailLoader = new DetailLoaderThread(); + detailLoader.start(); + } decorationManager = new DecorationManager(); taskActionManager = new TaskActionManager(); @@ -409,7 +411,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable { if(TextUtils.isEmpty(details) || DETAIL_SEPARATOR.equals(details) || task.isCompleted()) { viewHolder.details1.setVisibility(View.GONE); viewHolder.details2.setVisibility(View.GONE); - } else { + } else if (Preferences.getBoolean(R.string.p_default_showdetails_key, false)) { viewHolder.details1.setVisibility(View.VISIBLE); if (details.startsWith(DETAIL_SEPARATOR)) { StringBuffer buffer = new StringBuffer(details); @@ -426,7 +428,12 @@ public class TaskAdapter extends CursorAdapter implements Filterable { mostRecentlyMade = task.getId(); // // details and decorations, expanded - decorationManager.request(viewHolder); + + + if (Preferences.getBoolean(R.string.p_default_showdecorations_key, false)) { + decorationManager.request(viewHolder); + } + } @SuppressWarnings("nls")