diff --git a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
index 67131089..36a4cd32 100644
--- a/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
+++ b/app/src/main/java/com/keylesspalace/tusky/PreferencesActivity.java
@@ -34,8 +34,10 @@ public class PreferencesActivity extends BaseActivity
implements SharedPreferences.OnSharedPreferenceChangeListener {
private boolean restartActivitiesOnExit;
- private @XmlRes int currentPreferences;
- private @StringRes int currentTitle;
+ private @XmlRes
+ int currentPreferences;
+ private @StringRes
+ int currentTitle;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -61,7 +63,7 @@ public class PreferencesActivity extends BaseActivity
preferences.registerOnSharedPreferenceChangeListener(this);
- if(savedInstanceState == null) {
+ if (savedInstanceState == null) {
currentPreferences = R.xml.preferences;
currentTitle = R.string.action_view_preferences;
} else {
@@ -124,6 +126,10 @@ public class PreferencesActivity extends BaseActivity
restartActivitiesOnExit = true;
break;
}
+ case "absoluteTimeView": {
+ restartActivitiesOnExit = true;
+ break;
+ }
case "notificationsEnabled": {
boolean enabled = sharedPreferences.getBoolean("notificationsEnabled", true);
if (enabled) {
@@ -145,14 +151,14 @@ public class PreferencesActivity extends BaseActivity
@Override
public void onBackPressed() {
//if we are not on the top level, show the top level. Else exit the activity
- if(currentPreferences != R.xml.preferences) {
+ if (currentPreferences != R.xml.preferences) {
showFragment(R.xml.preferences, R.string.action_view_preferences);
} else {
- /* Switching themes won't actually change the theme of activities on the back stack.
- * Either the back stack activities need to all be recreated, or do the easier thing, which
- * is hijack the back button press and use it to launch a new MainActivity and clear the
- * back stack. */
+ /* Switching themes won't actually change the theme of activities on the back stack.
+ * Either the back stack activities need to all be recreated, or do the easier thing, which
+ * is hijack the back button press and use it to launch a new MainActivity and clear the
+ * back stack. */
if (restartActivitiesOnExit) {
Intent intent = new Intent(this, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
index 4a920c07..a1e2bce0 100644
--- a/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
+++ b/app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
@@ -1,7 +1,9 @@
package com.keylesspalace.tusky.adapter;
import android.content.Context;
+import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
+import android.preference.PreferenceManager;
import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
@@ -30,8 +32,10 @@ import com.keylesspalace.tusky.viewdata.StatusViewData;
import com.mikepenz.iconics.utils.Utils;
import com.squareup.picasso.Picasso;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
+import java.util.Locale;
import at.connyduck.sparkbutton.SparkButton;
import at.connyduck.sparkbutton.SparkEventListener;
@@ -126,25 +130,40 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
}
protected void setCreatedAt(@Nullable Date createdAt) {
- // This is the visible timestampInfo.
- String readout;
- /* This one is for screen-readers. Frequently, they would mispronounce timestamps like "17m"
- * as 17 meters instead of minutes. */
- CharSequence readoutAloud;
- if (createdAt != null) {
- long then = createdAt.getTime();
- long now = new Date().getTime();
- readout = DateUtils.getRelativeTimeSpanString(timestampInfo.getContext(), then, now);
- readoutAloud = android.text.format.DateUtils.getRelativeTimeSpanString(then, now,
- android.text.format.DateUtils.SECOND_IN_MILLIS,
- android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE);
+ 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 {
- // unknown minutes~
- readout = "?m";
- readoutAloud = "? minutes";
+ // This is the visible timestampInfo.
+ String readout;
+ /* This one is for screen-readers. Frequently, they would mispronounce timestamps like "17m"
+ * as 17 meters instead of minutes. */
+ CharSequence readoutAloud;
+ if (createdAt != null) {
+ long then = createdAt.getTime();
+ long now = new Date().getTime();
+ readout = DateUtils.getRelativeTimeSpanString(timestampInfo.getContext(), then, now);
+ readoutAloud = android.text.format.DateUtils.getRelativeTimeSpanString(then, now,
+ android.text.format.DateUtils.SECOND_IN_MILLIS,
+ android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE);
+ } else {
+ // unknown minutes~
+ readout = "?m";
+ readoutAloud = "? minutes";
+ }
+ timestampInfo.setText(readout);
+ timestampInfo.setContentDescription(readoutAloud);
}
- timestampInfo.setText(readout);
- timestampInfo.setContentDescription(readoutAloud);
}
protected void showContent(boolean show) {
@@ -256,7 +275,7 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
final int urlIndex = i;
previews[i].setOnClickListener(v -> {
- if(getAdapterPosition() != RecyclerView.NO_POSITION) {
+ if (getAdapterPosition() != RecyclerView.NO_POSITION) {
listener.onViewMedia(getAdapterPosition(), urlIndex, v);
}
});
diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml
index 5032f052..f3e3a2f6 100644
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -277,4 +277,6 @@
説明を設定
消去
+ 絶対時間で表示
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1a1ff7d0..1cac71b2 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -347,4 +347,6 @@
Label
Content
+ Use absolute time
+
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 1dd472b8..c9b125d6 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -42,6 +42,11 @@
android:key="alwaysShowSensitiveMedia"
android:title="@string/pref_title_alway_show_sensitive_media" />
+
+