changed notification date style

This commit is contained in:
danijoo
2016-01-09 01:42:45 +01:00
parent cb2d9a6499
commit cd3bc60759
3 changed files with 15 additions and 2 deletions

View File

@@ -55,7 +55,13 @@ public class NotificationListAdapter extends CursorRecyclerViewAdapter<Notificat
tvMessage.setText(n.message);
tvTitle.setText(n.title);
tvAppName.setText(n.appName);
CharSequence formattedDate = DateUtils.getRelativeTimeSpanString(n.date, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_ALL);
CharSequence formattedDate;
if(DateUtils.isToday(n.date))
formattedDate = DateUtils.formatDateTime(context, n.date, DateUtils.FORMAT_SHOW_TIME);
else
formattedDate = DateUtils.formatDateTime(context, n.date, DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE);
tvDate.setText(formattedDate);
Drawable appIcon = PackageUtils.getApplicationLauncherIcon(context, n.packageName);

View File

@@ -70,7 +70,13 @@ public class ListWidgetViewFactory implements RemoteViewsService.RemoteViewsFact
titleSpan.setSpan(new StyleSpan(Typeface.BOLD), 0, title.length(), 0);
rv.setTextViewText(R.id.widget_list_item_notification, titleSpan);
rv.setTextViewText(R.id.widget_list_item_date, DateUtils.formatDateTime(mContext, notification.date, DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE));
CharSequence formattedDate;
if(DateUtils.isToday(notification.date))
formattedDate = DateUtils.formatDateTime(mContext, notification.date, DateUtils.FORMAT_SHOW_TIME);
else
formattedDate = DateUtils.formatDateTime(mContext, notification.date, DateUtils.FORMAT_NUMERIC_DATE | DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE);
rv.setTextViewText(R.id.widget_list_item_date, formattedDate);
Intent intent = new Intent();
intent.putExtra(Logged_notificationTable.FIELD__ID, notification.id);