mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Add an option to change time format. Properly show message time in ViewPrivateMessagesActivity.
This commit is contained in:
parent
3a72c5a1f8
commit
9a4edde8fb
@ -158,7 +158,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void bindView() {
|
private void bindView() {
|
||||||
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, privateMessage, mAccountName, mCustomThemeWrapper);
|
mAdapter = new PrivateMessagesDetailRecyclerViewAdapter(this, mSharedPreferences,
|
||||||
|
getResources().getConfiguration().locale, privateMessage, mAccountName, mCustomThemeWrapper);
|
||||||
mLinearLayoutManager = new LinearLayoutManager(this);
|
mLinearLayoutManager = new LinearLayoutManager(this);
|
||||||
mLinearLayoutManager.setStackFromEnd(true);
|
mLinearLayoutManager.setStackFromEnd(true);
|
||||||
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
|
@ -36,7 +36,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
import com.bumptech.glide.RequestBuilder;
|
import com.bumptech.glide.RequestBuilder;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.load.DataSource;
|
import com.bumptech.glide.load.DataSource;
|
||||||
import com.bumptech.glide.load.DecodeFormat;
|
|
||||||
import com.bumptech.glide.load.engine.GlideException;
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
@ -147,6 +146,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private boolean mNeedBlurSpoiler;
|
private boolean mNeedBlurSpoiler;
|
||||||
private boolean mVoteButtonsOnTheRight;
|
private boolean mVoteButtonsOnTheRight;
|
||||||
private boolean mShowElapsedTime;
|
private boolean mShowElapsedTime;
|
||||||
|
private String mTimeFormatPattern;
|
||||||
private boolean mExpandChildren;
|
private boolean mExpandChildren;
|
||||||
private boolean mCommentToolbarHidden;
|
private boolean mCommentToolbarHidden;
|
||||||
private boolean mCommentToolbarHideOnClick;
|
private boolean mCommentToolbarHideOnClick;
|
||||||
@ -215,7 +215,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
|
||||||
String accessToken, String accountName, Post post, Locale locale,
|
String accessToken, String accountName, Post post, Locale locale,
|
||||||
String singleCommentId, boolean isSingleCommentThreadMode,
|
String singleCommentId, boolean isSingleCommentThreadMode,
|
||||||
SharedPreferences mSharedPreferences, ExoCreator exoCreator,
|
SharedPreferences sharedPreferences, ExoCreator exoCreator,
|
||||||
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
|
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
mRetrofit = retrofit;
|
mRetrofit = retrofit;
|
||||||
@ -302,25 +302,26 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mSingleCommentId = singleCommentId;
|
mSingleCommentId = singleCommentId;
|
||||||
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
|
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
|
||||||
|
|
||||||
mNeedBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
|
mNeedBlurNsfw = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
|
||||||
mNeedBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
||||||
mVoteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||||
mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
|
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
||||||
mCommentToolbarHidden = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDDEN, false);
|
mExpandChildren = !sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false);
|
||||||
mCommentToolbarHideOnClick = mSharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true);
|
mCommentToolbarHidden = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDDEN, false);
|
||||||
mSwapTapAndLong = mSharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false);
|
mCommentToolbarHideOnClick = sharedPreferences.getBoolean(SharedPreferencesUtils.COMMENT_TOOLBAR_HIDE_ON_CLICK, true);
|
||||||
mShowCommentDivider = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
mSwapTapAndLong = sharedPreferences.getBoolean(SharedPreferencesUtils.SWAP_TAP_AND_LONG_COMMENTS, false);
|
||||||
mShowAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
mShowCommentDivider = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
||||||
|
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
||||||
|
|
||||||
String autoplayString = mSharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
|
String autoplayString = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
|
||||||
if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
|
if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
|
||||||
mAutoplay = true;
|
mAutoplay = true;
|
||||||
} else if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
|
} else if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
|
||||||
mAutoplay = Utils.isConnectedToWifi(activity);
|
mAutoplay = Utils.isConnectedToWifi(activity);
|
||||||
}
|
}
|
||||||
mAutoplayNsfwVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
||||||
mMuteAutoplayingVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||||
|
|
||||||
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||||
isInitiallyLoading = true;
|
isInitiallyLoading = true;
|
||||||
@ -610,7 +611,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(
|
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, mPost.getPostTimeMillis()));
|
Utils.getElapsedTime(mActivity, mPost.getPostTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(mPost.getPostTime());
|
((PostDetailBaseViewHolder) holder).mPostTimeTextView.setText(Utils.getFormattedTime(mLocale, mPost.getPostTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mPost.isArchived()) {
|
if (mPost.isArchived()) {
|
||||||
@ -771,7 +772,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
((CommentViewHolder) holder).commentTimeTextView.setText(
|
((CommentViewHolder) holder).commentTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
Utils.getElapsedTime(mActivity, comment.getCommentTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
|
((CommentViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCommentToolbarHidden) {
|
if (mCommentToolbarHidden) {
|
||||||
|
@ -2,6 +2,7 @@ package ml.docilealligator.infinityforreddit.Adapter;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -25,6 +26,8 @@ import androidx.paging.PagedListAdapter;
|
|||||||
import androidx.recyclerview.widget.DiffUtil;
|
import androidx.recyclerview.widget.DiffUtil;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
@ -37,13 +40,14 @@ import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
||||||
import ml.docilealligator.infinityforreddit.CommentData;
|
import ml.docilealligator.infinityforreddit.CommentData;
|
||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.BottomSheetFragment.CommentMoreBottomSheetFragment;
|
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.SaveThing;
|
import ml.docilealligator.infinityforreddit.SaveThing;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
import ml.docilealligator.infinityforreddit.VoteThing;
|
import ml.docilealligator.infinityforreddit.VoteThing;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
@ -65,6 +69,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
};
|
};
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Retrofit mOauthRetrofit;
|
private Retrofit mOauthRetrofit;
|
||||||
|
private Locale mLocale;
|
||||||
private Markwon mMarkwon;
|
private Markwon mMarkwon;
|
||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
@ -83,17 +88,16 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
private int mCommentIconAndInfoColor;
|
private int mCommentIconAndInfoColor;
|
||||||
private boolean mVoteButtonsOnTheRight;
|
private boolean mVoteButtonsOnTheRight;
|
||||||
private boolean mShowElapsedTime;
|
private boolean mShowElapsedTime;
|
||||||
|
private String mTimeFormatPattern;
|
||||||
private boolean mShowCommentDivider;
|
private boolean mShowCommentDivider;
|
||||||
private boolean mShowAbsoluteNumberOfVotes;
|
private boolean mShowAbsoluteNumberOfVotes;
|
||||||
private NetworkState networkState;
|
private NetworkState networkState;
|
||||||
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
|
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
|
||||||
|
|
||||||
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
|
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
|
||||||
CustomThemeWrapper customThemeWrapper, String accessToken,
|
CustomThemeWrapper customThemeWrapper, Locale locale,
|
||||||
String accountName, boolean voteButtonsOnTheRight,
|
SharedPreferences sharedPreferences, String accessToken,
|
||||||
boolean showElapsedTime, boolean showCommentDivider,
|
String accountName, RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||||
boolean showAbsoluteNumberOfVotes,
|
|
||||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mOauthRetrofit = oauthRetrofit;
|
mOauthRetrofit = oauthRetrofit;
|
||||||
@ -122,12 +126,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
mLocale = locale;
|
||||||
mAccessToken = accessToken;
|
mAccessToken = accessToken;
|
||||||
mAccountName = accountName;
|
mAccountName = accountName;
|
||||||
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
|
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
mShowElapsedTime = showElapsedTime;
|
mShowCommentDivider = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
||||||
mShowCommentDivider = showCommentDivider;
|
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
||||||
mShowAbsoluteNumberOfVotes = showAbsoluteNumberOfVotes;
|
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||||
|
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
||||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||||
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
@ -191,7 +197,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
((CommentViewHolder) holder).commentTimeTextView.setText(
|
((CommentViewHolder) holder).commentTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mContext, comment.getCommentTimeMillis()));
|
Utils.getElapsedTime(mContext, comment.getCommentTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((CommentViewHolder) holder).commentTimeTextView.setText(comment.getCommentTime());
|
((CommentViewHolder) holder).commentTimeTextView.setText(Utils.getFormattedTime(mLocale, comment.getCommentTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comment.getAwards() != null && !comment.getAwards().equals("")) {
|
if (comment.getAwards() != null && !comment.getAwards().equals("")) {
|
||||||
|
@ -34,7 +34,6 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.RequestBuilder;
|
import com.bumptech.glide.RequestBuilder;
|
||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.load.DataSource;
|
import com.bumptech.glide.load.DataSource;
|
||||||
import com.bumptech.glide.load.DecodeFormat;
|
|
||||||
import com.bumptech.glide.load.engine.GlideException;
|
import com.bumptech.glide.load.engine.GlideException;
|
||||||
import com.bumptech.glide.request.RequestListener;
|
import com.bumptech.glide.request.RequestListener;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
@ -51,6 +50,7 @@ import com.libRG.CustomTextView;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
@ -121,6 +121,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
private RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
|
private Locale mLocale;
|
||||||
private UserDao mUserDao;
|
private UserDao mUserDao;
|
||||||
private boolean canStartActivity = true;
|
private boolean canStartActivity = true;
|
||||||
private int mPostType;
|
private int mPostType;
|
||||||
@ -161,6 +162,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
private boolean mNeedBlurNSFW;
|
private boolean mNeedBlurNSFW;
|
||||||
private boolean mNeedBlurSpoiler;
|
private boolean mNeedBlurSpoiler;
|
||||||
private boolean mShowElapsedTime;
|
private boolean mShowElapsedTime;
|
||||||
|
private String mTimeFormatPattern;
|
||||||
private boolean mShowDividerInCompactLayout;
|
private boolean mShowDividerInCompactLayout;
|
||||||
private boolean mShowAbsoluteNumberOfVotes;
|
private boolean mShowAbsoluteNumberOfVotes;
|
||||||
private boolean mAutoplay = false;
|
private boolean mAutoplay = false;
|
||||||
@ -175,7 +177,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
public PostRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, Retrofit retrofit,
|
public PostRecyclerViewAdapter(AppCompatActivity activity, Retrofit oauthRetrofit, Retrofit retrofit,
|
||||||
RedditDataRoomDatabase redditDataRoomDatabase,
|
RedditDataRoomDatabase redditDataRoomDatabase,
|
||||||
CustomThemeWrapper customThemeWrapper, String accessToken,
|
CustomThemeWrapper customThemeWrapper, Locale locale, String accessToken,
|
||||||
int postType, int postLayout, boolean displaySubredditName,
|
int postType, int postLayout, boolean displaySubredditName,
|
||||||
SharedPreferences sharedPreferences, ExoCreator exoCreator,
|
SharedPreferences sharedPreferences, ExoCreator exoCreator,
|
||||||
Callback callback) {
|
Callback callback) {
|
||||||
@ -191,6 +193,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
mNeedBlurSpoiler = sharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
||||||
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
mVoteButtonsOnTheRight = sharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||||
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
|
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
||||||
mShowDividerInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
|
mShowDividerInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
|
||||||
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
||||||
String autoplayString = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
|
String autoplayString = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
|
||||||
@ -243,6 +246,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mScale = activity.getResources().getDisplayMetrics().density;
|
mScale = activity.getResources().getDisplayMetrics().density;
|
||||||
mGlide = Glide.with(mActivity);
|
mGlide = Glide.with(mActivity);
|
||||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
|
mLocale = locale;
|
||||||
mUserDao = redditDataRoomDatabase.userDao();
|
mUserDao = redditDataRoomDatabase.userDao();
|
||||||
mExoCreator = exoCreator;
|
mExoCreator = exoCreator;
|
||||||
mCallback = callback;
|
mCallback = callback;
|
||||||
@ -445,7 +449,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
((PostBaseViewHolder) holder).postTimeTextView.setText(
|
((PostBaseViewHolder) holder).postTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
|
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((PostBaseViewHolder) holder).postTimeTextView.setText(post.getPostTime());
|
((PostBaseViewHolder) holder).postTimeTextView.setText(Utils.getFormattedTime(mLocale, post.getPostTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle());
|
((PostBaseViewHolder) holder).titleTextView.setText(post.getTitle());
|
||||||
@ -577,7 +581,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
final String subredditNamePrefixed = post.getSubredditNamePrefixed();
|
final String subredditNamePrefixed = post.getSubredditNamePrefixed();
|
||||||
String subredditName = subredditNamePrefixed.substring(2);
|
String subredditName = subredditNamePrefixed.substring(2);
|
||||||
String authorPrefixed = "u/" + post.getAuthor();
|
String authorPrefixed = "u/" + post.getAuthor();
|
||||||
final String postTime = post.getPostTime();
|
|
||||||
final String title = post.getTitle();
|
final String title = post.getTitle();
|
||||||
int voteType = post.getVoteType();
|
int voteType = post.getVoteType();
|
||||||
boolean nsfw = post.isNSFW();
|
boolean nsfw = post.isNSFW();
|
||||||
@ -741,7 +744,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
((PostCompactViewHolder) holder).postTimeTextView.setText(
|
((PostCompactViewHolder) holder).postTimeTextView.setText(
|
||||||
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
|
Utils.getElapsedTime(mActivity, post.getPostTimeMillis()));
|
||||||
} else {
|
} else {
|
||||||
((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
|
((PostCompactViewHolder) holder).postTimeTextView.setText(Utils.getFormattedTime(mLocale, post.getPostTimeMillis(), mTimeFormatPattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowDividerInCompactLayout) {
|
if (mShowDividerInCompactLayout) {
|
||||||
@ -1281,6 +1284,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mShowElapsedTime = showElapsedTime;
|
mShowElapsedTime = showElapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTimeFormat(String timeFormat) {
|
||||||
|
mTimeFormatPattern = timeFormat;
|
||||||
|
}
|
||||||
|
|
||||||
public void setShowDividerInCompactLayout(boolean showDividerInCompactLayout) {
|
public void setShowDividerInCompactLayout(boolean showDividerInCompactLayout) {
|
||||||
mShowDividerInCompactLayout = showDividerInCompactLayout;
|
mShowDividerInCompactLayout = showDividerInCompactLayout;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Adapter;
|
package ml.docilealligator.infinityforreddit.Adapter;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.style.SuperscriptSpan;
|
import android.text.style.SuperscriptSpan;
|
||||||
@ -18,6 +19,8 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.bumptech.glide.RequestManager;
|
import com.bumptech.glide.RequestManager;
|
||||||
import com.bumptech.glide.request.RequestOptions;
|
import com.bumptech.glide.request.RequestOptions;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||||
@ -33,6 +36,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.Message;
|
import ml.docilealligator.infinityforreddit.Message;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||||
|
|
||||||
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||||
@ -41,17 +45,23 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
private Message mMessage;
|
private Message mMessage;
|
||||||
private ViewPrivateMessagesActivity mViewPrivateMessagesActivity;
|
private ViewPrivateMessagesActivity mViewPrivateMessagesActivity;
|
||||||
private RequestManager mGlide;
|
private RequestManager mGlide;
|
||||||
|
private Locale mLocale;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private Markwon mMarkwon;
|
private Markwon mMarkwon;
|
||||||
|
private boolean mShowElapsedTime;
|
||||||
|
private String mTimeFormatPattern;
|
||||||
private int mMessageBackgroundColor;
|
private int mMessageBackgroundColor;
|
||||||
private int mSecondaryTextColor;
|
private int mSecondaryTextColor;
|
||||||
private int mUnreadMessageBackgroundColor;
|
private int mUnreadMessageBackgroundColor;
|
||||||
|
|
||||||
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity, Message message, String accountName,
|
public PrivateMessagesDetailRecyclerViewAdapter(ViewPrivateMessagesActivity viewPrivateMessagesActivity,
|
||||||
|
SharedPreferences sharedPreferences, Locale locale,
|
||||||
|
Message message, String accountName,
|
||||||
CustomThemeWrapper customThemeWrapper) {
|
CustomThemeWrapper customThemeWrapper) {
|
||||||
mMessage = message;
|
mMessage = message;
|
||||||
mViewPrivateMessagesActivity = viewPrivateMessagesActivity;
|
mViewPrivateMessagesActivity = viewPrivateMessagesActivity;
|
||||||
mGlide = Glide.with(viewPrivateMessagesActivity);
|
mGlide = Glide.with(viewPrivateMessagesActivity);
|
||||||
|
mLocale = locale;
|
||||||
mAccountName = accountName;
|
mAccountName = accountName;
|
||||||
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
mMarkwon = Markwon.builder(viewPrivateMessagesActivity)
|
||||||
.usePlugin(new AbstractMarkwonPlugin() {
|
.usePlugin(new AbstractMarkwonPlugin() {
|
||||||
@ -78,6 +88,8 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
|
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
|
mTimeFormatPattern = sharedPreferences.getString(SharedPreferencesUtils.TIME_FORMAT_KEY, SharedPreferencesUtils.TIME_FORMAT_DEFAULT_VALUE);
|
||||||
mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor();
|
mMessageBackgroundColor = customThemeWrapper.getCardViewBackgroundColor();
|
||||||
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
mSecondaryTextColor = customThemeWrapper.getSecondaryTextColor();
|
||||||
mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor();
|
mUnreadMessageBackgroundColor = customThemeWrapper.getUnreadMessageBackgroundColor();
|
||||||
@ -115,6 +127,11 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getBody());
|
mMarkwon.setMarkdown(((MessageViewHolder) holder).messageTextView, message.getBody());
|
||||||
|
|
||||||
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> ((MessageViewHolder) holder).itemView.performClick());
|
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> ((MessageViewHolder) holder).itemView.performClick());
|
||||||
|
if (mShowElapsedTime) {
|
||||||
|
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
|
||||||
|
} else {
|
||||||
|
((MessageViewHolder) holder).timeTextView.setText(Utils.getFormattedTime(mLocale, message.getTimeUTC(), mTimeFormatPattern));
|
||||||
|
}
|
||||||
|
|
||||||
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
|
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
|
||||||
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
|
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
|
||||||
@ -125,8 +142,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
mViewPrivateMessagesActivity.delayTransition();
|
mViewPrivateMessagesActivity.delayTransition();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (holder instanceof SentMessageViewHolder) {
|
if (holder instanceof SentMessageViewHolder) {
|
||||||
|
@ -28,7 +28,6 @@ public class CommentData implements Parcelable {
|
|||||||
private String authorFlair;
|
private String authorFlair;
|
||||||
private String authorFlairHTML;
|
private String authorFlairHTML;
|
||||||
private String linkAuthor;
|
private String linkAuthor;
|
||||||
private String commentTime;
|
|
||||||
private long commentTimeMillis;
|
private long commentTimeMillis;
|
||||||
private String commentMarkdown;
|
private String commentMarkdown;
|
||||||
private String commentRawText;
|
private String commentRawText;
|
||||||
@ -55,7 +54,7 @@ public class CommentData implements Parcelable {
|
|||||||
private boolean loadMoreChildrenFailed;
|
private boolean loadMoreChildrenFailed;
|
||||||
|
|
||||||
public CommentData(String id, String fullName, String author, String authorFlair,
|
public CommentData(String id, String fullName, String author, String authorFlair,
|
||||||
String authorFlairHTML, String linkAuthor, String commentTime,
|
String authorFlairHTML, String linkAuthor,
|
||||||
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
long commentTimeMillis, String commentMarkdown, String commentRawText,
|
||||||
String linkId, String subredditName, String parentId, int score,
|
String linkId, String subredditName, String parentId, int score,
|
||||||
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
int voteType, boolean isSubmitter, String distinguished, String permalink,
|
||||||
@ -67,7 +66,6 @@ public class CommentData implements Parcelable {
|
|||||||
this.authorFlair = authorFlair;
|
this.authorFlair = authorFlair;
|
||||||
this.authorFlairHTML = authorFlairHTML;
|
this.authorFlairHTML = authorFlairHTML;
|
||||||
this.linkAuthor = linkAuthor;
|
this.linkAuthor = linkAuthor;
|
||||||
this.commentTime = commentTime;
|
|
||||||
this.commentTimeMillis = commentTimeMillis;
|
this.commentTimeMillis = commentTimeMillis;
|
||||||
this.commentMarkdown = commentMarkdown;
|
this.commentMarkdown = commentMarkdown;
|
||||||
this.commentRawText = commentRawText;
|
this.commentRawText = commentRawText;
|
||||||
@ -105,7 +103,6 @@ public class CommentData implements Parcelable {
|
|||||||
authorFlair = in.readString();
|
authorFlair = in.readString();
|
||||||
authorFlairHTML = in.readString();
|
authorFlairHTML = in.readString();
|
||||||
linkAuthor = in.readString();
|
linkAuthor = in.readString();
|
||||||
commentTime = in.readString();
|
|
||||||
commentTimeMillis = in.readLong();
|
commentTimeMillis = in.readLong();
|
||||||
commentMarkdown = in.readString();
|
commentMarkdown = in.readString();
|
||||||
commentRawText = in.readString();
|
commentRawText = in.readString();
|
||||||
@ -159,10 +156,6 @@ public class CommentData implements Parcelable {
|
|||||||
return linkAuthor;
|
return linkAuthor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommentTime() {
|
|
||||||
return commentTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCommentTimeMillis() {
|
public long getCommentTimeMillis() {
|
||||||
return commentTimeMillis;
|
return commentTimeMillis;
|
||||||
}
|
}
|
||||||
@ -355,7 +348,6 @@ public class CommentData implements Parcelable {
|
|||||||
parcel.writeString(authorFlair);
|
parcel.writeString(authorFlair);
|
||||||
parcel.writeString(authorFlairHTML);
|
parcel.writeString(authorFlairHTML);
|
||||||
parcel.writeString(linkAuthor);
|
parcel.writeString(linkAuthor);
|
||||||
parcel.writeString(commentTime);
|
|
||||||
parcel.writeLong(commentTimeMillis);
|
parcel.writeLong(commentTimeMillis);
|
||||||
parcel.writeString(commentMarkdown);
|
parcel.writeString(commentMarkdown);
|
||||||
parcel.writeString(commentRawText);
|
parcel.writeString(commentRawText);
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ChangeTimeFormatEvent {
|
||||||
|
public String timeFormat;
|
||||||
|
|
||||||
|
public ChangeTimeFormatEvent(String timeFormat) {
|
||||||
|
this.timeFormat = timeFormat;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@ import android.content.SharedPreferences;
|
|||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -98,9 +97,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
private LinearLayoutManager mLinearLayoutManager;
|
private LinearLayoutManager mLinearLayoutManager;
|
||||||
private CommentsListingRecyclerViewAdapter mAdapter;
|
private CommentsListingRecyclerViewAdapter mAdapter;
|
||||||
private SortType sortType;
|
private SortType sortType;
|
||||||
private boolean mShowElapsedTime;
|
|
||||||
private boolean mShowCommentDivider;
|
|
||||||
private boolean mShowAbsoluteNumberOfVotes;
|
|
||||||
|
|
||||||
public CommentsListingFragment() {
|
public CommentsListingFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -132,10 +128,6 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mShowElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
|
||||||
mShowCommentDivider = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_COMMENT_DIVIDER, false);
|
|
||||||
mShowAbsoluteNumberOfVotes = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
getCurrentAccountAndBindView(resources);
|
getCurrentAccountAndBindView(resources);
|
||||||
} else {
|
} else {
|
||||||
@ -167,10 +159,9 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
mLinearLayoutManager = new LinearLayoutManager(mActivity);
|
||||||
mCommentRecyclerView.setLayoutManager(mLinearLayoutManager);
|
mCommentRecyclerView.setLayoutManager(mLinearLayoutManager);
|
||||||
|
|
||||||
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
|
||||||
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
|
mAdapter = new CommentsListingRecyclerViewAdapter(mActivity, mOauthRetrofit, customThemeWrapper,
|
||||||
|
getResources().getConfiguration().locale, mSharedPreferences,
|
||||||
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
|
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
|
||||||
voteButtonsOnTheRight, mShowElapsedTime, mShowCommentDivider, mShowAbsoluteNumberOfVotes,
|
|
||||||
() -> mCommentViewModel.retryLoadingMore());
|
() -> mCommentViewModel.retryLoadingMore());
|
||||||
|
|
||||||
String username = getArguments().getString(EXTRA_USERNAME);
|
String username = getArguments().getString(EXTRA_USERNAME);
|
||||||
@ -197,9 +188,9 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
}
|
}
|
||||||
|
|
||||||
mCommentViewModel = new ViewModelProvider(this, factory).get(CommentViewModel.class);
|
mCommentViewModel = new ViewModelProvider(this, factory).get(CommentViewModel.class);
|
||||||
mCommentViewModel.getComments().observe(this, comments -> mAdapter.submitList(comments));
|
mCommentViewModel.getComments().observe(getViewLifecycleOwner(), comments -> mAdapter.submitList(comments));
|
||||||
|
|
||||||
mCommentViewModel.hasComment().observe(this, hasComment -> {
|
mCommentViewModel.hasComment().observe(getViewLifecycleOwner(), hasComment -> {
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasComment) {
|
if (hasComment) {
|
||||||
mFetchCommentInfoLinearLayout.setVisibility(View.GONE);
|
mFetchCommentInfoLinearLayout.setVisibility(View.GONE);
|
||||||
@ -211,7 +202,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mCommentViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mCommentViewModel.getInitialLoadingState().observe(getViewLifecycleOwner(), networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
@ -223,7 +214,7 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mCommentViewModel.getPaginationNetworkState().observe(this, networkState -> mAdapter.setNetworkState(networkState));
|
mCommentViewModel.getPaginationNetworkState().observe(getViewLifecycleOwner(), networkState -> mAdapter.setNetworkState(networkState));
|
||||||
|
|
||||||
mSwipeRefreshLayout.setOnRefreshListener(() -> mCommentViewModel.refresh());
|
mSwipeRefreshLayout.setOnRefreshListener(() -> mCommentViewModel.refresh());
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ import com.bumptech.glide.RequestManager;
|
|||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeWifiStatusEvent;
|
||||||
@ -344,6 +347,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
String accessToken = getArguments().getString(EXTRA_ACCESS_TOKEN);
|
||||||
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
|
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
|
||||||
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
||||||
|
Locale locale = getResources().getConfiguration().locale;
|
||||||
|
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
@ -355,7 +359,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, locale, accessToken, postType, postLayout, true,
|
||||||
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
@ -417,7 +421,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, displaySubredditName,
|
customThemeWrapper, locale, accessToken, postType, postLayout, displaySubredditName,
|
||||||
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
@ -464,7 +468,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, locale, accessToken, postType, postLayout, true,
|
||||||
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
@ -509,7 +513,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, locale, accessToken, postType, postLayout, true,
|
||||||
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
@ -547,7 +551,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
customThemeWrapper, accessToken, postType, postLayout, true,
|
customThemeWrapper, locale, accessToken, postType, postLayout, true,
|
||||||
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
mSharedPreferences, exoCreator, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
@ -579,9 +583,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
return new PlaybackInfo(INDEX_UNSET, TIME_UNSET, volumeInfo);
|
return new PlaybackInfo(INDEX_UNSET, TIME_UNSET, volumeInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
mPostViewModel.getPosts().observe(this, posts -> mAdapter.submitList(posts));
|
mPostViewModel.getPosts().observe(getViewLifecycleOwner(), posts -> mAdapter.submitList(posts));
|
||||||
|
|
||||||
mPostViewModel.hasPost().observe(this, hasPost -> {
|
mPostViewModel.hasPost().observe(getViewLifecycleOwner(), hasPost -> {
|
||||||
this.hasPost = hasPost;
|
this.hasPost = hasPost;
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
if (hasPost) {
|
if (hasPost) {
|
||||||
@ -597,7 +601,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mPostViewModel.getInitialLoadingState().observe(this, networkState -> {
|
mPostViewModel.getInitialLoadingState().observe(getViewLifecycleOwner(), networkState -> {
|
||||||
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
if (networkState.getStatus().equals(NetworkState.Status.SUCCESS)) {
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
} else if (networkState.getStatus().equals(NetworkState.Status.FAILED)) {
|
||||||
@ -609,7 +613,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mPostViewModel.getPaginationNetworkState().observe(this, networkState -> mAdapter.setNetworkState(networkState));
|
mPostViewModel.getPaginationNetworkState().observe(getViewLifecycleOwner(), networkState -> mAdapter.setNetworkState(networkState));
|
||||||
|
|
||||||
return rootView;
|
return rootView;
|
||||||
}
|
}
|
||||||
@ -788,13 +792,21 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChangeShowElapsedTime(ChangeShowElapsedTimeEvent event) {
|
public void onChangeShowElapsedTimeEvent(ChangeShowElapsedTimeEvent event) {
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
mAdapter.setShowElapsedTime(event.showElapsedTime);
|
mAdapter.setShowElapsedTime(event.showElapsedTime);
|
||||||
refreshAdapter();
|
refreshAdapter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChangeTimeFormatEvent(ChangeTimeFormatEvent changeTimeFormatEvent) {
|
||||||
|
if (mAdapter != null) {
|
||||||
|
mAdapter.setTimeFormat(changeTimeFormatEvent.timeFormat);
|
||||||
|
refreshAdapter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChangeVoteButtonsPositionEvent(ChangeVoteButtonsPositionEvent event) {
|
public void onChangeVoteButtonsPositionEvent(ChangeVoteButtonsPositionEvent event) {
|
||||||
if (mAdapter != null) {
|
if (mAdapter != null) {
|
||||||
|
@ -9,9 +9,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
|
||||||
@ -171,11 +169,6 @@ public class ParseComment {
|
|||||||
boolean scoreHidden = singleCommentData.getBoolean(JSONUtils.SCORE_HIDDEN_KEY);
|
boolean scoreHidden = singleCommentData.getBoolean(JSONUtils.SCORE_HIDDEN_KEY);
|
||||||
boolean saved = singleCommentData.getBoolean(JSONUtils.SAVED_KEY);
|
boolean saved = singleCommentData.getBoolean(JSONUtils.SAVED_KEY);
|
||||||
|
|
||||||
Calendar submitTimeCalendar = Calendar.getInstance();
|
|
||||||
submitTimeCalendar.setTimeInMillis(submitTime);
|
|
||||||
String formattedSubmitTime = new SimpleDateFormat("MMM d, yyyy, HH:mm",
|
|
||||||
locale).format(submitTimeCalendar.getTime());
|
|
||||||
|
|
||||||
if (singleCommentData.has(JSONUtils.DEPTH_KEY)) {
|
if (singleCommentData.has(JSONUtils.DEPTH_KEY)) {
|
||||||
depth = singleCommentData.getInt(JSONUtils.DEPTH_KEY);
|
depth = singleCommentData.getInt(JSONUtils.DEPTH_KEY);
|
||||||
}
|
}
|
||||||
@ -184,7 +177,7 @@ public class ParseComment {
|
|||||||
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
|
boolean hasReply = !(singleCommentData.get(JSONUtils.REPLIES_KEY) instanceof String);
|
||||||
|
|
||||||
return new CommentData(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(),
|
return new CommentData(id, fullName, author, authorFlair, authorFlairHTMLBuilder.toString(),
|
||||||
linkAuthor, formattedSubmitTime, submitTime, commentMarkdown, commentRawText,
|
linkAuthor, submitTime, commentMarkdown, commentRawText,
|
||||||
linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
|
linkId, subredditName, parentId, score, voteType, isSubmitter, distinguished,
|
||||||
permalink, awardingsBuilder.toString(),depth, collapsed, hasReply, scoreHidden, saved);
|
permalink, awardingsBuilder.toString(),depth, collapsed, hasReply, scoreHidden, saved);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -107,10 +105,6 @@ public class ParsePost {
|
|||||||
score -= voteType;
|
score -= voteType;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar postTimeCalendar = Calendar.getInstance();
|
|
||||||
postTimeCalendar.setTimeInMillis(postTime);
|
|
||||||
String formattedPostTime = new SimpleDateFormat("MMM d, yyyy, HH:mm",
|
|
||||||
locale).format(postTimeCalendar.getTime());
|
|
||||||
String permalink = Html.fromHtml(data.getString(JSONUtils.PERMALINK_KEY)).toString();
|
String permalink = Html.fromHtml(data.getString(JSONUtils.PERMALINK_KEY)).toString();
|
||||||
|
|
||||||
String previewUrl = "";
|
String previewUrl = "";
|
||||||
@ -137,7 +131,7 @@ public class ParsePost {
|
|||||||
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
|
data = data.getJSONArray(JSONUtils.CROSSPOST_PARENT_LIST).getJSONObject(0);
|
||||||
Post crosspostParent = parseBasicData(data, locale);
|
Post crosspostParent = parseBasicData(data, locale);
|
||||||
Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
|
Post post = parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
|
||||||
author, authorFlair, authorFlairHTMLBuilder.toString(), formattedPostTime,
|
author, authorFlair, authorFlairHTMLBuilder.toString(),
|
||||||
postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight,
|
postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight,
|
||||||
score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden,
|
score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden,
|
||||||
spoiler, nsfw, stickied, archived, locked, saved, true);
|
spoiler, nsfw, stickied, archived, locked, saved, true);
|
||||||
@ -145,7 +139,7 @@ public class ParsePost {
|
|||||||
return post;
|
return post;
|
||||||
} else {
|
} else {
|
||||||
return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
|
return parseData(data, permalink, id, fullName, subredditName, subredditNamePrefixed,
|
||||||
author, authorFlair, authorFlairHTMLBuilder.toString(), formattedPostTime,
|
author, authorFlair, authorFlairHTMLBuilder.toString(),
|
||||||
postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight,
|
postTime, title, previewUrl, thumbnailPreviewUrl, previewWidth, previewHeight,
|
||||||
score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden,
|
score, voteType, nComments, flair, awardingsBuilder.toString(), nAwards, hidden,
|
||||||
spoiler, nsfw, stickied, archived, locked, saved, false);
|
spoiler, nsfw, stickied, archived, locked, saved, false);
|
||||||
@ -154,7 +148,7 @@ public class ParsePost {
|
|||||||
|
|
||||||
private static Post parseData(JSONObject data, String permalink, String id, String fullName,
|
private static Post parseData(JSONObject data, String permalink, String id, String fullName,
|
||||||
String subredditName, String subredditNamePrefixed, String author,
|
String subredditName, String subredditNamePrefixed, String author,
|
||||||
String authorFlair, String authorFlairHTML, String formattedPostTime,
|
String authorFlair, String authorFlairHTML,
|
||||||
long postTimeMillis, String title, String previewUrl,
|
long postTimeMillis, String title, String previewUrl,
|
||||||
String thumbnailPreviewUrl, int previewWidth, int previewHeight,
|
String thumbnailPreviewUrl, int previewWidth, int previewHeight,
|
||||||
int score, int voteType, int nComments, String flair,
|
int score, int voteType, int nComments, String flair,
|
||||||
@ -171,7 +165,7 @@ public class ParsePost {
|
|||||||
//Text post
|
//Text post
|
||||||
int postType = Post.TEXT_TYPE;
|
int postType = Post.TEXT_TYPE;
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, permalink, score, postType, voteType, nComments, flair, awards, nAwards,
|
title, permalink, score, postType, voteType, nComments, flair, awards, nAwards,
|
||||||
hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
|
hidden, spoiler, nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||||
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
if (data.isNull(JSONUtils.SELFTEXT_KEY)) {
|
||||||
@ -196,7 +190,7 @@ public class ParsePost {
|
|||||||
int postType = Post.IMAGE_TYPE;
|
int postType = Post.IMAGE_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
url, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
|
url, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
|
||||||
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
||||||
locked, saved, isCrosspost);
|
locked, saved, isCrosspost);
|
||||||
@ -207,7 +201,7 @@ public class ParsePost {
|
|||||||
//No preview link post
|
//No preview link post
|
||||||
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
title, previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
||||||
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
||||||
archived, locked, saved, isCrosspost);
|
archived, locked, saved, isCrosspost);
|
||||||
@ -232,7 +226,7 @@ public class ParsePost {
|
|||||||
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
String videoDownloadUrl = redditVideoObject.getString(JSONUtils.FALLBACK_URL_KEY);
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
|
previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
|
||||||
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked,
|
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked,
|
||||||
saved, isCrosspost);
|
saved, isCrosspost);
|
||||||
@ -251,7 +245,7 @@ public class ParsePost {
|
|||||||
.getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.FALLBACK_URL_KEY);
|
.getJSONObject(JSONUtils.REDDIT_VIDEO_PREVIEW_KEY).getString(JSONUtils.FALLBACK_URL_KEY);
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
|
previewUrl, thumbnailPreviewUrl, permalink, score, postType, voteType,
|
||||||
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
||||||
locked, saved, isCrosspost);
|
locked, saved, isCrosspost);
|
||||||
@ -265,7 +259,7 @@ public class ParsePost {
|
|||||||
int postType = Post.IMAGE_TYPE;
|
int postType = Post.IMAGE_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, url, thumbnailPreviewUrl, url, permalink, score, postType,
|
title, url, thumbnailPreviewUrl, url, permalink, score, postType,
|
||||||
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw,
|
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw,
|
||||||
stickied, archived, locked, saved, isCrosspost);
|
stickied, archived, locked, saved, isCrosspost);
|
||||||
@ -276,7 +270,7 @@ public class ParsePost {
|
|||||||
//Gif post
|
//Gif post
|
||||||
int postType = Post.GIF_TYPE;
|
int postType = Post.GIF_TYPE;
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
|
title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
|
||||||
postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler,
|
postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler,
|
||||||
nsfw, stickied, archived, locked, saved, isCrosspost);
|
nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||||
@ -289,7 +283,7 @@ public class ParsePost {
|
|||||||
int postType = Post.VIDEO_TYPE;
|
int postType = Post.VIDEO_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
||||||
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
||||||
archived, locked, saved, isCrosspost);
|
archived, locked, saved, isCrosspost);
|
||||||
@ -303,7 +297,7 @@ public class ParsePost {
|
|||||||
int postType = Post.TEXT_TYPE;
|
int postType = Post.TEXT_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, permalink, score, postType, voteType, nComments, flair,
|
title, permalink, score, postType, voteType, nComments, flair,
|
||||||
awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked,
|
awards, nAwards, hidden, spoiler, nsfw, stickied, archived, locked,
|
||||||
saved, isCrosspost);
|
saved, isCrosspost);
|
||||||
@ -332,7 +326,7 @@ public class ParsePost {
|
|||||||
int postType = Post.LINK_TYPE;
|
int postType = Post.LINK_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis,
|
authorFlair, authorFlairHTML, postTimeMillis,
|
||||||
title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
|
title, previewUrl, thumbnailPreviewUrl, url, permalink, score,
|
||||||
postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler,
|
postType, voteType, nComments, flair, awards, nAwards, hidden, spoiler,
|
||||||
nsfw, stickied, archived, locked, saved, isCrosspost);
|
nsfw, stickied, archived, locked, saved, isCrosspost);
|
||||||
@ -353,7 +347,7 @@ public class ParsePost {
|
|||||||
int postType = Post.IMAGE_TYPE;
|
int postType = Post.IMAGE_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
||||||
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
||||||
archived, locked, saved, isCrosspost);
|
archived, locked, saved, isCrosspost);
|
||||||
@ -364,7 +358,7 @@ public class ParsePost {
|
|||||||
int postType = Post.VIDEO_TYPE;
|
int postType = Post.VIDEO_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
previewUrl, thumbnailPreviewUrl, url, permalink, score, postType,
|
||||||
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
voteType, nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied,
|
||||||
archived, locked, saved, isCrosspost);
|
archived, locked, saved, isCrosspost);
|
||||||
@ -377,7 +371,7 @@ public class ParsePost {
|
|||||||
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
int postType = Post.NO_PREVIEW_LINK_TYPE;
|
||||||
|
|
||||||
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
post = new Post(id, fullName, subredditName, subredditNamePrefixed, author,
|
||||||
authorFlair, authorFlairHTML, formattedPostTime, postTimeMillis, title,
|
authorFlair, authorFlairHTML, postTimeMillis, title,
|
||||||
url, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
|
url, thumbnailPreviewUrl, url, permalink, score, postType, voteType,
|
||||||
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
nComments, flair, awards, nAwards, hidden, spoiler, nsfw, stickied, archived,
|
||||||
locked, saved, isCrosspost);
|
locked, saved, isCrosspost);
|
||||||
|
@ -40,7 +40,6 @@ public class Post implements Parcelable {
|
|||||||
private String authorIconUrl;
|
private String authorIconUrl;
|
||||||
private String authorFlair;
|
private String authorFlair;
|
||||||
private String authorFlairHTML;
|
private String authorFlairHTML;
|
||||||
private String postTime;
|
|
||||||
private String title;
|
private String title;
|
||||||
private String selfText;
|
private String selfText;
|
||||||
private String selfTextPlain;
|
private String selfTextPlain;
|
||||||
@ -72,7 +71,7 @@ public class Post implements Parcelable {
|
|||||||
private String crosspostParentId;
|
private String crosspostParentId;
|
||||||
|
|
||||||
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
||||||
String author, String authorFlair, String authorFlairHTML, String postTime,
|
String author, String authorFlair, String authorFlairHTML,
|
||||||
long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl,
|
long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl,
|
||||||
String permalink, int score, int postType, int voteType, int nComments, String flair,
|
String permalink, int score, int postType, int voteType, int nComments, String flair,
|
||||||
String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
|
String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw, boolean stickied,
|
||||||
@ -85,7 +84,6 @@ public class Post implements Parcelable {
|
|||||||
this.authorNamePrefixed = "u/" + author;
|
this.authorNamePrefixed = "u/" + author;
|
||||||
this.authorFlair = authorFlair;
|
this.authorFlair = authorFlair;
|
||||||
this.authorFlairHTML = authorFlairHTML;
|
this.authorFlairHTML = authorFlairHTML;
|
||||||
this.postTime = postTime;
|
|
||||||
this.postTimeMillis = postTimeMillis;
|
this.postTimeMillis = postTimeMillis;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.previewUrl = previewUrl;
|
this.previewUrl = previewUrl;
|
||||||
@ -109,7 +107,7 @@ public class Post implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
||||||
String author, String authorFlair, String authorFlairHTML, String postTime,
|
String author, String authorFlair, String authorFlairHTML,
|
||||||
long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl,
|
long postTimeMillis, String title, String previewUrl, String thumbnailPreviewUrl,
|
||||||
String url, String permalink, int score, int postType, int voteType, int nComments,
|
String url, String permalink, int score, int postType, int voteType, int nComments,
|
||||||
String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw,
|
String flair, String awards, int nAwards, boolean hidden, boolean spoiler, boolean nsfw,
|
||||||
@ -122,7 +120,6 @@ public class Post implements Parcelable {
|
|||||||
this.authorNamePrefixed = "u/" + author;
|
this.authorNamePrefixed = "u/" + author;
|
||||||
this.authorFlair = authorFlair;
|
this.authorFlair = authorFlair;
|
||||||
this.authorFlairHTML = authorFlairHTML;
|
this.authorFlairHTML = authorFlairHTML;
|
||||||
this.postTime = postTime;
|
|
||||||
this.postTimeMillis = postTimeMillis;
|
this.postTimeMillis = postTimeMillis;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.previewUrl = previewUrl;
|
this.previewUrl = previewUrl;
|
||||||
@ -147,7 +144,7 @@ public class Post implements Parcelable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
public Post(String id, String fullName, String subredditName, String subredditNamePrefixed,
|
||||||
String author, String authorFlair, String authorFlairHTML, String postTime,
|
String author, String authorFlair, String authorFlairHTML,
|
||||||
long postTimeMillis, String title, String permalink, int score, int postType,
|
long postTimeMillis, String title, String permalink, int score, int postType,
|
||||||
int voteType, int nComments, String flair, String awards, int nAwards, boolean hidden,
|
int voteType, int nComments, String flair, String awards, int nAwards, boolean hidden,
|
||||||
boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked,
|
boolean spoiler, boolean nsfw, boolean stickied, boolean archived, boolean locked,
|
||||||
@ -160,7 +157,6 @@ public class Post implements Parcelable {
|
|||||||
this.authorNamePrefixed = "u/" + author;
|
this.authorNamePrefixed = "u/" + author;
|
||||||
this.authorFlair = authorFlair;
|
this.authorFlair = authorFlair;
|
||||||
this.authorFlairHTML = authorFlairHTML;
|
this.authorFlairHTML = authorFlairHTML;
|
||||||
this.postTime = postTime;
|
|
||||||
this.postTimeMillis = postTimeMillis;
|
this.postTimeMillis = postTimeMillis;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.permalink = APIUtils.API_BASE_URI + permalink;
|
this.permalink = APIUtils.API_BASE_URI + permalink;
|
||||||
@ -192,7 +188,6 @@ public class Post implements Parcelable {
|
|||||||
authorFlair = in.readString();
|
authorFlair = in.readString();
|
||||||
authorFlairHTML = in.readString();
|
authorFlairHTML = in.readString();
|
||||||
authorIconUrl = in.readString();
|
authorIconUrl = in.readString();
|
||||||
postTime = in.readString();
|
|
||||||
postTimeMillis = in.readLong();
|
postTimeMillis = in.readLong();
|
||||||
title = in.readString();
|
title = in.readString();
|
||||||
selfText = in.readString();
|
selfText = in.readString();
|
||||||
@ -277,10 +272,6 @@ public class Post implements Parcelable {
|
|||||||
this.authorIconUrl = authorIconUrl;
|
this.authorIconUrl = authorIconUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPostTime() {
|
|
||||||
return postTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getPostTimeMillis() {
|
public long getPostTimeMillis() {
|
||||||
return postTimeMillis;
|
return postTimeMillis;
|
||||||
}
|
}
|
||||||
@ -494,7 +485,6 @@ public class Post implements Parcelable {
|
|||||||
parcel.writeString(authorFlair);
|
parcel.writeString(authorFlair);
|
||||||
parcel.writeString(authorFlairHTML);
|
parcel.writeString(authorFlairHTML);
|
||||||
parcel.writeString(authorIconUrl);
|
parcel.writeString(authorIconUrl);
|
||||||
parcel.writeString(postTime);
|
|
||||||
parcel.writeLong(postTimeMillis);
|
parcel.writeLong(postTimeMillis);
|
||||||
parcel.writeString(title);
|
parcel.writeString(title);
|
||||||
parcel.writeString(selfText);
|
parcel.writeString(selfText);
|
||||||
|
@ -11,7 +11,6 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
|
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
|
||||||
@ -27,7 +26,6 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
|
|
||||||
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
|
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
|
||||||
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
|
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
|
||||||
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
|
|
||||||
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
|
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
|
||||||
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
|
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
|
||||||
SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT);
|
SwitchPreference showThumbnailOnTheRightInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT);
|
||||||
@ -47,13 +45,6 @@ public class InterfacePreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showElapsedTimeSwitch != null) {
|
|
||||||
showElapsedTimeSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
|
||||||
EventBus.getDefault().post(new ChangeShowElapsedTimeEvent((Boolean) newValue));
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defaultPostLayoutSwitch != null) {
|
if (defaultPostLayoutSwitch != null) {
|
||||||
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
EventBus.getDefault().post(new ChangeDefaultPostLayoutEvent(Integer.parseInt((String) newValue)));
|
EventBus.getDefault().post(new ChangeDefaultPostLayoutEvent(Integer.parseInt((String) newValue)));
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Settings;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
|
public class TimeFormatPreferenceFragment extends PreferenceFragmentCompat {
|
||||||
|
@Override
|
||||||
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
|
setPreferencesFromResource(R.xml.time_format_preferences, rootKey);
|
||||||
|
|
||||||
|
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
|
||||||
|
ListPreference timeFormatList = findPreference(SharedPreferencesUtils.TIME_FORMAT_KEY);
|
||||||
|
|
||||||
|
if (showElapsedTimeSwitch != null) {
|
||||||
|
showElapsedTimeSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ChangeShowElapsedTimeEvent((Boolean) newValue));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeFormatList != null) {
|
||||||
|
timeFormatList.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ChangeTimeFormatEvent((String) newValue));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,6 +74,8 @@ public class SharedPreferencesUtils {
|
|||||||
|
|
||||||
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
||||||
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
||||||
|
public static final String TIME_FORMAT_KEY = "time_format";
|
||||||
|
public static final String TIME_FORMAT_DEFAULT_VALUE = "MMM d, yyyy, HH:mm";
|
||||||
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
|
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
|
||||||
public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout";
|
public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout";
|
||||||
public static final String SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT = "show_thumbnail_on_the_right_in_compact_layout";
|
public static final String SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT = "show_thumbnail_on_the_right_in_compact_layout";
|
||||||
|
@ -13,6 +13,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
@ -46,6 +48,12 @@ public class Utils {
|
|||||||
return source.subSequence(0, i+1);
|
return source.subSequence(0, i+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getFormattedTime(Locale locale, long time, String pattern) {
|
||||||
|
Calendar postTimeCalendar = Calendar.getInstance();
|
||||||
|
postTimeCalendar.setTimeInMillis(time);
|
||||||
|
return new SimpleDateFormat(pattern, locale).format(postTimeCalendar.getTime());
|
||||||
|
}
|
||||||
|
|
||||||
public static String getElapsedTime(Context context, long time) {
|
public static String getElapsedTime(Context context, long time) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
long diff = now - time;
|
long diff = now - time;
|
||||||
|
@ -168,4 +168,54 @@
|
|||||||
<item>4</item>
|
<item>4</item>
|
||||||
<item>5</item>
|
<item>5</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="settings_time_format">
|
||||||
|
<item>Jan 2, 2020, 01:00</item>
|
||||||
|
<item>Jan 2, 2020, 01:00 PM</item>
|
||||||
|
<item>2 Jan, 2020, 01:00</item>
|
||||||
|
<item>2 Jan, 2020, 01:00 PM</item>
|
||||||
|
<item>1/2/2020 01:00 (Month first)</item>
|
||||||
|
<item>1/2/2020 01:00 PM (Month first)</item>
|
||||||
|
<item>2/1/2020 01:00 (Day first)</item>
|
||||||
|
<item>2/1/2020 01:00 PM (Day first)</item>
|
||||||
|
<item>2020/1/2 01:00 (Month first)</item>
|
||||||
|
<item>2020/1/2 01:00 PM (Month first)</item>
|
||||||
|
<item>1-2-2020 01:00 (Month first)</item>
|
||||||
|
<item>1-2-2020 01:00 PM (Month first)</item>
|
||||||
|
<item>2-1-2020 01:00 (Day first)</item>
|
||||||
|
<item>2-1-2020 01:00 PM (Day first)</item>
|
||||||
|
<item>2020-1-2 01:00 (Month first)</item>
|
||||||
|
<item>2020-1-2 01:00 PM (Month first)</item>
|
||||||
|
<item>1.2.2020 01:00 (Month first)</item>
|
||||||
|
<item>1.2.2020 01:00 PM (Month first)</item>
|
||||||
|
<item>2.1.2020 01:00 (Day first)</item>
|
||||||
|
<item>2.1.2020 01:00 PM (Day first)</item>
|
||||||
|
<item>2020.1.2 01:00 (Month first)</item>
|
||||||
|
<item>2020.1.2 01:00 PM (Month first)</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="settings_time_format_values">
|
||||||
|
<item>MMM d, yyyy, HH:mm</item>
|
||||||
|
<item>MMM d, yyyy, hh:mm a</item>
|
||||||
|
<item>d MMM yyyy, HH:mm</item>
|
||||||
|
<item>d MMM yyyy, hh:mm a</item>
|
||||||
|
<item>M/d/yyyy HH:mm</item>
|
||||||
|
<item>M/d/yyyy hh:mm a</item>
|
||||||
|
<item>d/M/yyyy HH:mm</item>
|
||||||
|
<item>d/M/yyyy hh:mm a</item>
|
||||||
|
<item>yyyy/M/d HH:mm</item>
|
||||||
|
<item>yyyy/M/d hh:mm a</item>
|
||||||
|
<item>M-d-yyyy HH:mm</item>
|
||||||
|
<item>M-d-yyyy hh:mm a</item>
|
||||||
|
<item>d-M-yyyy HH:mm</item>
|
||||||
|
<item>d-M-yyyy hh:mm a</item>
|
||||||
|
<item>yyyy-M-d HH:mm</item>
|
||||||
|
<item>yyyy-M-d hh:mm a</item>
|
||||||
|
<item>M.d.yyyy HH:mm</item>
|
||||||
|
<item>M.d.yyyy hh:mm a</item>
|
||||||
|
<item>d.M.yyyy HH:mm</item>
|
||||||
|
<item>d.M.yyyy hh:mm a</item>
|
||||||
|
<item>yyyy.M.d HH:mm</item>
|
||||||
|
<item>yyyy.M.d hh:mm a</item>
|
||||||
|
</string-array>
|
||||||
</resources>
|
</resources>
|
@ -355,6 +355,7 @@
|
|||||||
<string name="settings_comment_toolbar_hidden">Comment Toolbar Hidden by Default</string>
|
<string name="settings_comment_toolbar_hidden">Comment Toolbar Hidden by Default</string>
|
||||||
<string name="settings_show_absolute_number_of_votes_title">Show Absolute Number of Votes</string>
|
<string name="settings_show_absolute_number_of_votes_title">Show Absolute Number of Votes</string>
|
||||||
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
||||||
|
<string name="settings_time_format_title">Time Format</string>
|
||||||
<string name="settings_default_post_layout">Default Post Layout</string>
|
<string name="settings_default_post_layout">Default Post Layout</string>
|
||||||
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
||||||
<string name="settings_show_thumbnail_on_the_right_in_compact_layout">Show Thumbnail on the Right in Compact Layout</string>
|
<string name="settings_show_thumbnail_on_the_right_in_compact_layout">Show Thumbnail on the Right in Compact Layout</string>
|
||||||
|
@ -27,10 +27,9 @@
|
|||||||
app:key="vote_buttons_on_the_right"
|
app:key="vote_buttons_on_the_right"
|
||||||
app:title="@string/settings_vote_buttons_on_the_right_title" />
|
app:title="@string/settings_vote_buttons_on_the_right_title" />
|
||||||
|
|
||||||
<SwitchPreference
|
<Preference
|
||||||
app:defaultValue="false"
|
app:title="@string/settings_time_format_title"
|
||||||
app:key="show_elapsed_time"
|
app:fragment="ml.docilealligator.infinityforreddit.Settings.TimeFormatPreferenceFragment" />
|
||||||
app:title="@string/settings_show_elapsed_time" />
|
|
||||||
|
|
||||||
<ListPreference
|
<ListPreference
|
||||||
app:defaultValue="0"
|
app:defaultValue="0"
|
||||||
|
16
app/src/main/res/xml/time_format_preferences.xml
Normal file
16
app/src/main/res/xml/time_format_preferences.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:key="show_elapsed_time"
|
||||||
|
app:title="@string/settings_show_elapsed_time" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
app:defaultValue="MMM d, yyyy, HH:mm"
|
||||||
|
app:entries="@array/settings_time_format"
|
||||||
|
app:entryValues="@array/settings_time_format_values"
|
||||||
|
app:key="time_format"
|
||||||
|
app:title="@string/settings_time_format_title"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user