Show absolute time in Notifications tab
This commit is contained in:
parent
ca3a5791e3
commit
1d657a65a7
|
@ -16,10 +16,12 @@
|
||||||
package com.keylesspalace.tusky.adapter;
|
package com.keylesspalace.tusky.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
|
@ -50,9 +52,11 @@ import com.keylesspalace.tusky.viewdata.NotificationViewData;
|
||||||
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
import com.keylesspalace.tusky.viewdata.StatusViewData;
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class NotificationsAdapter extends RecyclerView.Adapter {
|
public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
private static final int VIEW_TYPE_MENTION = 0;
|
private static final int VIEW_TYPE_MENTION = 0;
|
||||||
|
@ -365,7 +369,21 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
username.setText(usernameText);
|
username.setText(usernameText);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setCreatedAt(@Nullable Date createdAt) {
|
protected void setCreatedAt(@Nullable Date createdAt) {
|
||||||
|
SharedPreferences defPrefs = PreferenceManager.getDefaultSharedPreferences(timestampInfo.getContext());
|
||||||
|
if (defPrefs.getBoolean("absoluteTimeView", true)) {
|
||||||
|
String time = "ERROR!";
|
||||||
|
if (createdAt != null) {
|
||||||
|
SimpleDateFormat sdf;
|
||||||
|
if (new Date().getTime() - createdAt.getTime() > 86400000L) {
|
||||||
|
sdf = new SimpleDateFormat("MM/dd HH:mm:ss", Locale.getDefault());
|
||||||
|
} else {
|
||||||
|
sdf = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
|
||||||
|
}
|
||||||
|
time = sdf.format(createdAt);
|
||||||
|
timestampInfo.setText(time);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// This is the visible timestampInfo.
|
// This is the visible timestampInfo.
|
||||||
String readout;
|
String readout;
|
||||||
/* This one is for screen-readers. Frequently, they would mispronounce timestamps like "17m"
|
/* This one is for screen-readers. Frequently, they would mispronounce timestamps like "17m"
|
||||||
|
@ -386,6 +404,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter {
|
||||||
timestampInfo.setText(readout);
|
timestampInfo.setText(readout);
|
||||||
timestampInfo.setContentDescription(readoutAloud);
|
timestampInfo.setContentDescription(readoutAloud);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void setMessage(NotificationViewData.Concrete notificationViewData, LinkListener listener, BidiFormatter bidiFormatter) {
|
void setMessage(NotificationViewData.Concrete notificationViewData, LinkListener listener, BidiFormatter bidiFormatter) {
|
||||||
this.statusViewData = notificationViewData.getStatusViewData();
|
this.statusViewData = notificationViewData.getStatusViewData();
|
||||||
|
|
Loading…
Reference in New Issue