aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-11-12 11:31:28 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-11-12 11:31:28 +0000
commita0aae589d70038cfb1760d61c8e9edf2099833ae (patch)
tree4fc864e02d7d605f9200ce1d8ba021457f504f1a /app
parent0aaa63b6f67030d57ae2852e02680a4f0e061069 (diff)
downloadinfinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar.gz
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar.bz2
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar.lz
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar.xz
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.tar.zst
infinity-for-reddit-a0aae589d70038cfb1760d61c8e9edf2099833ae.zip
Showing elapsed time in posts and comments is available.
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle5
-rw-r--r--app/src/main/AndroidManifest.xml8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java20
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeShowElapsedTimeEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java19
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java17
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java74
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post.java25
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/xml/main_preferences.xml8
17 files changed, 186 insertions, 76 deletions
diff --git a/app/build.gradle b/app/build.gradle
index c4a04917..3d3cf668 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -6,8 +6,8 @@ android {
applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21
targetSdkVersion 29
- versionCode 20
- versionName "1.4.1"
+ versionCode 21
+ versionName "1.5.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
@@ -80,4 +80,5 @@ dependencies {
implementation 'androidx.work:work-runtime:2.2.0'
implementation 'androidx.preference:preference:1.1.0'
implementation 'com.nex3z:flow-layout:1.3.0'
+ implementation 'com.github.thunder413:DateTimeUtils:3.0'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b166996a..c7883829 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
package="ml.docilealligator.infinityforreddit">
<uses-permission android:name="android.permission.INTERNET" />
@@ -14,11 +15,12 @@
android:name=".Infinity"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
+ android:label="@string/application_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
- android:usesCleartextTraffic="true">
+ android:usesCleartextTraffic="true"
+ tools:replace="android:label">
<activity
android:name=".Activity.ViewGIFActivity"
android:parentActivityName=".Activity.MainActivity"
@@ -212,7 +214,7 @@
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".Activity.MainActivity"
- android:label="@string/app_name"
+ android:label="@string/application_name"
android:theme="@style/AppTheme.Launcher">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 6bafbebe..6264b0a1 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -160,6 +160,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
private boolean mNeedBlurNsfw;
private boolean mNeedBlurSpoiler;
private boolean mVoteButtonsOnTheRight;
+ private boolean mShowElapsedTime;
private boolean showToast = false;
private boolean isSortingComments = false;
private LinearLayoutManager mLinearLayoutManager;
@@ -234,6 +235,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mNeedBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
mNeedBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
mVoteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
+ mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
mGlide = Glide.with(this);
mLocale = getResources().getConfiguration().locale;
@@ -387,7 +389,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mRetrofit,
mOauthRetrofit, mRedditDataRoomDatabase, mGlide, mAccessToken, mAccountName, mPost,
mLocale, mSingleCommentId, isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
- mVoteButtonsOnTheRight,
+ mVoteButtonsOnTheRight, mShowElapsedTime,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -508,7 +510,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
- mVoteButtonsOnTheRight,
+ mVoteButtonsOnTheRight, mShowElapsedTime,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index 1e2861f7..2074999e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -35,10 +35,13 @@ import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
+import com.github.thunder413.datetimeutils.DateTimeStyle;
+import com.github.thunder413.datetimeutils.DateTimeUtils;
import com.libRG.CustomTextView;
import com.santalu.aspectratioimageview.AspectRatioImageView;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Locale;
import butterknife.BindView;
@@ -105,6 +108,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mNeedBlurNSFW;
private boolean mNeedBlurSpoiler;
private boolean mVoteButtonsOnTheRight;
+ private boolean mShowElapsedTime;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -117,6 +121,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
String accessToken, String accountName, Post post, Locale locale,
String singleCommentId, boolean isSingleCommentThreadMode,
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
+ boolean showElapsedTime,
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity;
mRetrofit = retrofit;
@@ -153,6 +158,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mNeedBlurNSFW = needBlurNSFW;
mNeedBlurSpoiler = needBlurSpoiler;
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
+ mShowElapsedTime = showElapsedTime;
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
@@ -359,7 +365,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailViewHolder) holder).mSubredditTextView.setText(mPost.getSubredditNamePrefixed());
((PostDetailViewHolder) holder).mUserTextView.setText(mPost.getAuthorNamePrefixed());
- ((PostDetailViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime());
+ if (mShowElapsedTime) {
+ ((PostDetailViewHolder) holder).mPostTimeTextView.setText(
+ DateTimeUtils.getTimeAgo(mActivity, new Date(mPost.getPostTimeMillis()), DateTimeStyle.AGO_SHORT_STRING));
+ } else {
+ ((PostDetailViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime());
+ }
if (mPost.getGilded() > 0) {
((PostDetailViewHolder) holder).mGildedNumberTextView.setVisibility(View.VISIBLE);
@@ -602,7 +613,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((CommentViewHolder) holder).authorTypeImageView.setImageResource(R.drawable.ic_verified_user_14dp);
}
- ((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
+ if (mShowElapsedTime) {
+ ((CommentViewHolder) holder).commentTimeTextView.setText(
+ DateTimeUtils.getTimeAgo(mActivity, new Date(comment.getCommentTimeMillis()), DateTimeStyle.AGO_SHORT_STRING));
+ } else {
+ ((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
+ }
mMarkwon.setMarkdown(((CommentViewHolder) holder).commentMarkdownView, comment.getCommentContent());
((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(comment.getScore() + comment.getVoteType()));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
index 0ac21d44..3002ee10 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
@@ -24,6 +24,11 @@ import androidx.paging.PagedListAdapter;
import androidx.recyclerview.widget.DiffUtil;
import androidx.recyclerview.widget.RecyclerView;
+import com.github.thunder413.datetimeutils.DateTimeStyle;
+import com.github.thunder413.datetimeutils.DateTimeUtils;
+
+import java.util.Date;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import io.noties.markwon.AbstractMarkwonPlugin;
@@ -67,13 +72,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private int mTextColorPrimaryDark;
private int mColorAccent;
private boolean mVoteButtonsOnTheRight;
+ private boolean mShowElapsedTime;
private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
String accessToken, String accountName,
boolean voteButtonsOnTheRight,
- RetryLoadingMoreCallback retryLoadingMoreCallback) {
+ boolean showElapsedTime, RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
mContext = context;
mOauthRetrofit = oauthRetrofit;
@@ -99,6 +105,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
mAccessToken = accessToken;
mAccountName = accountName;
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
+ mShowElapsedTime = showElapsedTime;
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
mTextColorPrimaryDark = mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme);
mColorAccent = mContext.getResources().getColor(R.color.colorAccent);
@@ -139,7 +146,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
});
}
- ((DataViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
+ if (mShowElapsedTime) {
+ ((DataViewHolder) holder).commentTimeTextView.setText(
+ DateTimeUtils.getTimeAgo(mContext, new Date(comment.getCommentTimeMillis()), DateTimeStyle.AGO_SHORT_STRING));
+ } else {
+ ((DataViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
+ }
mMarkwon.setMarkdown(((DataViewHolder) holder).commentMarkdownView, comment.getCommentContent());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 673d2a33..2c1c31ef 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -33,11 +33,15 @@ import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.Target;
+import com.github.thunder413.datetimeutils.DateTimeStyle;
+import com.github.thunder413.datetimeutils.DateTimeUtils;
import com.google.android.material.card.MaterialCardView;
import com.libRG.CustomTextView;
import org.greenrobot.eventbus.EventBus;
+import java.util.Date;
+
import butterknife.BindView;
import butterknife.ButterKnife;
import jp.wasabeef.glide.transformations.BlurTransformation;
@@ -99,6 +103,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mVoteButtonsOnTheRight;
private boolean mNeedBlurNSFW;
private boolean mNeedBlurSpoiler;
+ private boolean mShowElapsedTime;
private NetworkState networkState;
private Callback mCallback;
@@ -106,7 +111,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
int postType, int postLayout, boolean displaySubredditName,
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
- Callback callback) {
+ boolean showElapsedTime, Callback callback) {
super(DIFF_CALLBACK);
if (context != null) {
mContext = context;
@@ -118,6 +123,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mNeedBlurNSFW = needBlurNSFW;
mNeedBlurSpoiler = needBlurSpoiler;
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
+ mShowElapsedTime = showElapsedTime;
mPostLayout = postLayout;
mGlide = Glide.with(mContext.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
@@ -333,7 +339,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostViewHolder) holder).userTextView.performClick());
}
- ((PostViewHolder) holder).postTimeTextView.setText(postTime);
+ if (mShowElapsedTime) {
+ ((PostViewHolder) holder).postTimeTextView.setText(DateTimeUtils
+ .getTimeAgo(mContext, new Date(post.getPostTimeMillis()), DateTimeStyle.AGO_SHORT_STRING));
+ } else {
+ ((PostViewHolder) holder).postTimeTextView.setText(postTime);
+ }
+
((PostViewHolder) holder).titleTextView.setText(title);
((PostViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@@ -877,7 +889,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((PostCompactViewHolder) holder).nameTextView.performClick());
}
- ((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
+ if (mShowElapsedTime) {
+ ((PostCompactViewHolder) holder).postTimeTextView.setText(DateTimeUtils
+ .getTimeAgo(mContext, new Date(post.getPostTimeMillis()), DateTimeStyle.AGO_SHORT_STRING));
+ } else {
+ ((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
+ }
+
((PostCompactViewHolder) holder).titleTextView.setText(title);
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
@@ -1342,6 +1360,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mNeedBlurSpoiler = needBlurSpoiler;
}
+ public void setShowElapsedTime(boolean showElapsedTime) {
+ mShowElapsedTime = showElapsedTime;
+ }
+
private boolean hasExtraRow() {
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
index af24ae8e..a08fa920 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java
@@ -26,6 +26,7 @@ public class CommentData implements Parcelable {
private String authorFlair;
private String linkAuthor;
private String commentTime;
+ private long commentTimeMillis;
private String commentContent;
private String linkId;
private String subredditName;
@@ -49,7 +50,7 @@ public class CommentData implements Parcelable {
private boolean loadMoreChildrenFailed;
public CommentData(String id, String fullName, String author, String authorFlair, String linkAuthor, String commentTime,
- String commentContent, String linkId, String subredditName, String parentId, int score,
+ long commentTimeMillis, String commentContent, String linkId, String subredditName, String parentId, int score,
int voteType, boolean isSubmitter, String distinguished, String permalink,
int depth, boolean collapsed, boolean hasReply, boolean scoreHidden, boolean saved) {
this.id = id;
@@ -58,6 +59,7 @@ public class CommentData implements Parcelable {
this.authorFlair = authorFlair;
this.linkAuthor = linkAuthor;
this.commentTime = commentTime;
+ this.commentTimeMillis = commentTimeMillis;
this.commentContent = commentContent;
this.linkId = linkId;
this.subredditName = subredditName;
@@ -92,6 +94,7 @@ public class CommentData implements Parcelable {
authorFlair = in.readString();
linkAuthor = in.readString();
commentTime = in.readString();
+ commentTimeMillis = in.readLong();
commentContent = in.readString();
linkId = in.readString();
subredditName = in.readString();
@@ -142,6 +145,10 @@ public class CommentData implements Parcelable {
return commentTime;
}
+ public long getCommentTimeMillis() {
+ return commentTimeMillis;
+ }
+
public String getCommentContent() {
return commentContent;
}
@@ -318,6 +325,7 @@ public class CommentData implements Parcelable {
parcel.writeString(authorFlair);
parcel.writeString(linkAuthor);
parcel.writeString(commentTime);
+ parcel.writeLong(commentTimeMillis);
parcel.writeString(commentContent);
parcel.writeString(linkId);
parcel.writeString(subredditName);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeShowElapsedTimeEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeShowElapsedTimeEvent.java
new file mode 100644
index 00000000..2b715833
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeShowElapsedTimeEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeShowElapsedTimeEvent {
+ public boolean showElapsedTime;
+
+ public ChangeShowElapsedTimeEvent(boolean showElapsedTime) {
+ this.showElapsedTime = showElapsedTime;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
index 7b721869..be16db1d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
@@ -83,8 +83,9 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
private boolean mNullAccessToken = false;
private String mAccessToken;
private RequestManager mGlide;
- private Activity activity;
+ private Activity mActivity;
private CommentsListingRecyclerViewAdapter mAdapter;
+ private boolean mShowElapsedTime;
public CommentsListingFragment() {
// Required empty public constructor
@@ -96,11 +97,11 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_comments_listing, container, false);
- ((Infinity) activity.getApplication()).getAppComponent().inject(this);
+ ((Infinity) mActivity.getApplication()).getAppComponent().inject(this);
ButterKnife.bind(this, rootView);
- mGlide = Glide.with(activity);
+ mGlide = Glide.with(mActivity);
Resources resources = getResources();
@@ -113,6 +114,8 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
}
}
+ mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
+
if (savedInstanceState == null) {
getCurrentAccountAndBindView(resources);
} else {
@@ -141,12 +144,12 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
}
private void bindView(Resources resources) {
- mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
+ mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
- mAdapter = new CommentsListingRecyclerViewAdapter(activity, mOauthRetrofit,
+ mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit,
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
- voteButtonsOnTheRight, () -> mCommentViewModel.retryLoadingMore());
+ voteButtonsOnTheRight, mShowElapsedTime, () -> mCommentViewModel.retryLoadingMore());
String username = getArguments().getString(EXTRA_USERNAME);
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
@@ -209,7 +212,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
- this.activity = (Activity) context;
+ this.mActivity = (Activity) context;
}
@Override
@@ -227,7 +230,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
}
private void showErrorView(int stringResId) {
- if (activity != null && isAdded()) {
+ if (mActivity != null && isAdded()) {
mProgressBar.setVisibility(View.GONE);
mFetchCommentInfoLinearLayout.setVisibility(View.VISIBLE);
mFetchCommentInfoTextView.setText(stringResId);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index 1a3ea761..24b116fd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -28,7 +28,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.paging.PagedList;
-import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.LinearSmoothScroller;
import androidx.recyclerview.widget.RecyclerView;
@@ -51,6 +50,7 @@ import ml.docilealligator.infinityforreddit.Activity.MainActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
@@ -279,6 +279,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
boolean needBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
+ boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
PostViewModel.Factory factory;
@@ -293,7 +294,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -356,7 +357,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, postLayout, displaySubredditName, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -402,7 +403,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -441,7 +442,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
- voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -644,6 +645,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Subscribe
+ public void onChangeShowElapsedTime(ChangeShowElapsedTimeEvent event) {
+ mAdapter.setShowElapsedTime(event.showElapsedTime);
+ refreshAdapter();
+ }
+
+ @Subscribe
public void onChangeVoteButtonsPositionEvent(ChangeVoteButtonsPositionEvent event) {
mAdapter.setVoteButtonsPosition(event.voteButtonsOnTheRight);
refreshAdapter();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
index 84343132..815ef8e3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java
@@ -154,8 +154,8 @@ public class ParseComment {
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
return new CommentData(id, fullName, author, authorFlair, linkAuthor, formattedSubmitTime,
- commentContent, linkId, subredditName, parentId, score, voteType, isSubmitter,
- distinguished, permalink, depth, collapsed, hasReply, scoreHidden, saved);
+ submitTime, commentContent, linkId, subredditName, parentId, score, voteType,
+ isSubmitter, distinguished, permalink, depth, collapsed, hasReply, scoreHidden, saved);
}
@Nullable
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
index c4979fde..66133766 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParsePost.java
@@ -89,22 +89,22 @@ public class ParsePost {
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
Post crosspostParent = parseBasicData(data, locale);
Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
- author, formattedPostTime, title, previewUrl, thumbnailPreviewUrl, previewWidth,
- previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, true);
+ author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl,
+ previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, true);
post.setCrosspostParentId(crosspostParent.getId());
return post;
} else {
return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
- author, formattedPostTime, title, previewUrl, thumbnailPreviewUrl, previewWidth,
- previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, false);
+ author, formattedPostTime, postTime, title, previewUrl, thumbnailPreviewUrl,
+ previewWidth, previewHeight, score, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, false);
}
}
private static Post parseData(JSONObject data, String permalink, String id, String fullName,
String subredditName, String subredditNamePrefixed, String author,
- String formattedPostTime, String title, String previewUrl,
+ String formattedPostTime, long postTimeMillis, String title, String previewUrl,
String thumbnailPreviewUrl, int previewWidth, int previewHeight,
int score, int voteType, int gilded, int nComments, String flair,
boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
@@ -118,9 +118,9 @@ public class ParsePost {
if (url.contains(permalink)) {
//Text post
int postType = Post.TEXT_TYPE;
- post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime,
- title, permalink, score, postType, voteType, gilded, nComments, flair, hidden,
- spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
+ title, permalink, score, postType, voteType, gilded, nComments, flair,
+ hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@@ -139,9 +139,9 @@ public class ParsePost {
} else {
//No preview link post
int postType = Post.NO_PREVIEW_LINK_TYPE;
- post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime,
- title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType, gilded,
- nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
+ title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
+ gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@@ -160,9 +160,9 @@ public class ParsePost {
int postType = Post.VIDEO_TYPE;
String videoUrl = Html.fromHtml(redditVideoObject.getString(JSONUtils.HLS_URL_KEY)).toString();
- post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime,
- title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType, gilded,
- nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
+ post = new Post(id, fullName, subredditName, subredditNamePrefixed, author, formattedPostTime, postTimeMillis,
+ title, previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
+ gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
@@ -175,9 +175,9 @@ public class ParsePost {
.getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.HLS_URL_KEY)).toString();
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, previewUrl, thumbnailPreviewUrl, permalink, score, postType,
- voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied,
- archived, locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, permalink, score,
+ postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
+ stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
post.setVideoUrl(videoUrl);
@@ -187,9 +187,9 @@ public class ParsePost {
int postType = Post.IMAGE_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, url, thumbnailPreviewUrl, url, permalink, score,
- postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink,
+ score, postType, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
@@ -197,9 +197,9 @@ public class ParsePost {
//Gif post
int postType = Post.GIF_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
- postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
+ score, postType, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
@@ -210,9 +210,9 @@ public class ParsePost {
int postType = Post.TEXT_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, permalink, score, postType, voteType,
- gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived,
- locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, permalink, score, postType,
+ voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied,
+ archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
@@ -237,9 +237,9 @@ public class ParsePost {
int postType = Post.LINK_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
- postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
+ score, postType, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, isCrosspost);
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
post.setSelfText("");
} else {
@@ -257,9 +257,9 @@ public class ParsePost {
int postType = Post.IMAGE_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
- postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw,
- stickied, archived, locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, previewUrl, thumbnailPreviewUrl, url, permalink,
+ score, postType, voteType, gilded, nComments, flair, hidden, spoiler,
+ nsfw, stickied, archived, locked, saved, isCrosspost);
post.setPreviewWidth(previewWidth);
post.setPreviewHeight(previewHeight);
} else {
@@ -267,9 +267,9 @@ public class ParsePost {
int postType = Post.NO_PREVIEW_LINK_TYPE;
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
- formattedPostTime, title, url, thumbnailPreviewUrl, url, permalink, score, postType,
- voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied, archived,
- locked, saved, isCrosspost);
+ formattedPostTime, postTimeMillis, title, url, thumbnailPreviewUrl, url, permalink, score,
+ postType, voteType, gilded, nComments, flair, hidden, spoiler, nsfw, stickied,
+ archived, locked, saved, isCrosspost);
}
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
index 90cf631d..fba35a7e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
@@ -44,6 +44,7 @@ public class Post implements Parcelable {
private String videoUrl;
private String permalink;
private String flair;
+ private long postTimeMillis;
private int score;
private int postType;
private int voteType;
@@ -61,10 +62,12 @@ public class Post implements Parcelable {
private boolean isCrosspost;
private String crosspostParentId;
- public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
- String postTime, String title, String previewUrl, String thumbnailPreviewUrl, String permalink, int score, int postType,
+ public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
+ String author, String postTime, long postTimeMillis, String title, String previewUrl,
+ String thumbnailPreviewUrl, String permalink, int score, int postType,
int voteType, int gilded, int nComments, String flair, boolean hidden, boolean spoiler,
- boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved, boolean isCrosspost) {
+ boolean nsfw, boolean stickied, boolean archived, boolean locked, boolean saved,
+ boolean isCrosspost) {
this.id = id;
this.fullName = fullName;
this.subredditName = subredditName;
@@ -72,6 +75,7 @@ public class Post implements Parcelable {
this.author = author;
this.authorNamePrefixed = "u/" + author;
this.postTime = postTime;
+ this.postTimeMillis = postTimeMillis;
this.title = title;
this.previewUrl = previewUrl;
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
@@ -92,8 +96,9 @@ public class Post implements Parcelable {
this.isCrosspost = isCrosspost;
}
- public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
- String postTime, String title, String previewUrl, String thumbnailPreviewUrl, String url, String permalink, int score,
+ public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
+ String author, String postTime, long postTimeMillis, String title, String previewUrl,
+ String thumbnailPreviewUrl, String url, String permalink, int score,
int postType, int voteType, int gilded, int nComments, String flair, boolean hidden,
boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked,
boolean saved, boolean isCrosspost) {
@@ -104,6 +109,7 @@ public class Post implements Parcelable {
this.author = author;
this.authorNamePrefixed = "u/" + author;
this.postTime = postTime;
+ this.postTimeMillis = postTimeMillis;
this.title = title;
this.previewUrl = previewUrl;
this.thumbnailPreviewUrl = thumbnailPreviewUrl;
@@ -126,7 +132,7 @@ public class Post implements Parcelable {
}
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed, String author,
- String postTime, String title, String permalink, int score, int postType, int voteType, int gilded,
+ String postTime, long postTimeMillis, String title, String permalink, int score, int postType, int voteType, int gilded,
int nComments, String flair, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
boolean archived, boolean locked, boolean saved, boolean isCrosspost) {
this.id = id;
@@ -136,6 +142,7 @@ public class Post implements Parcelable {
this.author = author;
this.authorNamePrefixed = "u/" + author;
this.postTime = postTime;
+ this.postTimeMillis = postTimeMillis;
this.title = title;
this.permalink = RedditUtils.API_BASE_URI + permalink;
this.score = score;
@@ -164,6 +171,7 @@ public class Post implements Parcelable {
authorNamePrefixed = in.readString();
authorIconUrl = in.readString();
postTime = in.readString();
+ postTimeMillis = in.readLong();
title = in.readString();
selfText = in.readString();
selfTextPlainTrimmed = in.readString();
@@ -235,6 +243,10 @@ public class Post implements Parcelable {
return postTime;
}
+ public long getPostTimeMillis() {
+ return postTimeMillis;
+ }
+
public String getTitle() {
return title;
}
@@ -411,6 +423,7 @@ public class Post implements Parcelable {
parcel.writeString(authorNamePrefixed);
parcel.writeString(authorIconUrl);
parcel.writeString(postTime);
+ parcel.writeLong(postTimeMillis);
parcel.writeString(title);
parcel.writeString(selfText);
parcel.writeString(selfTextPlainTrimmed);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
index dcc1c201..c6f936f4 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
@@ -18,6 +18,7 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
@@ -49,6 +50,7 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
+ SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
@@ -83,6 +85,13 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
});
}
+ if (showElapsedTimeSwitch != null) {
+ showElapsedTimeSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeShowElapsedTimeEvent((Boolean) newValue));
+ return true;
+ });
+ }
+
if (nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
index 309db29a..510cb357 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
@@ -56,4 +56,5 @@ public class SharedPreferencesUtils {
public static final int POST_LAYOUT_CARD = 0;
public static final int POST_LAYOUT_COMPACT = 1;
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
+ public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dd113044..db0ed690 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,5 +1,5 @@
<resources>
- <string name="app_name">Infinity</string>
+ <string name="application_name">Infinity</string>
<string name="login_activity_label">Login</string>
<string name="search_activity_label">Search</string>
<string name="comment_activity_label">Send Comment</string>
@@ -289,6 +289,7 @@
<string name="settings_amoled_dark_title">Amoled Dark</string>
<string name="settings_immersive_interface_title">Immersive Interface</string>
<string name="settings_vote_buttons_on_the_right_title">Vote Buttons on the Right</string>
+ <string name="settings_show_elapsed_time">Show Elpased Time in Posts and Comments</string>
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
<string name="settings_font_size_title">Font Size</string>
<string name="settings_title_font_size_title">Title Font Size</string>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index 575dfd38..548bf949 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -29,8 +29,12 @@
<SwitchPreference
app:defaultValue="false"
app:key="vote_buttons_on_the_right"
- app:title="@string/settings_vote_buttons_on_the_right_title"
- app:isPreferenceVisible="true" />
+ app:title="@string/settings_vote_buttons_on_the_right_title"/>
+
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="show_elapsed_time"
+ app:title="@string/settings_show_elapsed_time"/>
<Preference
app:title="@string/settings_font_size_title"