Use relative time for unified widget

This commit is contained in:
M66B 2019-07-25 15:42:52 +02:00
parent ceee4166de
commit 120a837c32
2 changed files with 6 additions and 13 deletions

View File

@ -32,8 +32,6 @@ import android.widget.RemoteViewsService;
import androidx.lifecycle.Observer;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -42,17 +40,14 @@ import static android.os.Looper.getMainLooper;
public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory {
private Context context;
private DateFormat DTF;
private Handler handler;
private TwoStateOwner owner;
private List<EntityMessage> messages = new ArrayList<>();
WidgetUnifiedRemoteViewsFactory(final Context context) {
this.context = context;
this.DTF = Helper.getDateTimeInstance(context, SimpleDateFormat.SHORT, SimpleDateFormat.SHORT);
this.handler = new Handler(getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
@ -135,7 +130,7 @@ public class WidgetUnifiedRemoteViewsFactory implements RemoteViewsService.Remot
views.setOnClickFillInIntent(R.id.llMessage, thread);
SpannableString from = new SpannableString(MessageHelper.formatAddressesShort(message.from));
SpannableString time = new SpannableString(DTF.format(message.received));
SpannableString time = new SpannableString(Helper.getRelativeTimeSpanString(context, message.received));
SpannableString subject = new SpannableString(TextUtils.isEmpty(message.subject) ? "" : message.subject);
if (!message.ui_seen) {

View File

@ -24,13 +24,11 @@
<TextView
android:id="@+id/tvTime"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="start"
android:gravity="end"
android:singleLine="true"
android:text="To"
android:layout_marginStart="6dp"
android:maxLines="1"
android:text="12:34"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="@color/colorWidgetForeground" />
</LinearLayout>