diff options
Diffstat (limited to '')
16 files changed, 175 insertions, 12 deletions
diff --git a/app/src/main/java/Settings/AboutPreferenceFragment.java b/app/src/main/java/Settings/AboutPreferenceFragment.java index 8d93bd6c..f2ba0518 100644 --- a/app/src/main/java/Settings/AboutPreferenceFragment.java +++ b/app/src/main/java/Settings/AboutPreferenceFragment.java @@ -27,6 +27,7 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { Preference reviewPreference = findPreference(SharedPreferencesUtils.RATE_KEY); Preference emailPreference = findPreference(SharedPreferencesUtils.EMAIL_KEY); Preference redditAccountPreference = findPreference(SharedPreferencesUtils.REDDIT_ACCOUNT_KEY); + Preference subredditPreference = findPreference(SharedPreferencesUtils.SUBREDDIT_KEY); Activity activity = getActivity(); @@ -76,6 +77,15 @@ public class AboutPreferenceFragment extends PreferenceFragmentCompat { return true; }); } + + if(subredditPreference != null) { + subredditPreference.setOnPreferenceClickListener(preference -> { + Intent intent = new Intent(activity, LinkResolverActivity.class); + intent.setData(Uri.parse("https://www.reddit.com/r/Infinity_For_Reddit")); + startActivity(intent); + return true; + }); + } } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AccountPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AccountPostsActivity.java index d7ee9918..e2e0a5b8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/AccountPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AccountPostsActivity.java @@ -139,8 +139,6 @@ public class AccountPostsActivity extends AppCompatActivity implements UserThing toolbar.setTitle(R.string.upvoted); } else if(mUserWhere.equals(PostDataSource.USER_WHERE_DOWNVOTED)) { toolbar.setTitle(R.string.downvoted); - } else if(mUserWhere.equals(PostDataSource.USER_WHERE_SAVED)) { - toolbar.setTitle(R.string.saved); } else if(mUserWhere.equals(PostDataSource.USER_WHERE_HIDDEN)) { toolbar.setTitle(R.string.hidden); } else if(mUserWhere.equals(PostDataSource.USER_WHERE_GILDED)){ diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java index b68628fb..b3c501c0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentAndPostRecyclerViewAdapter.java @@ -747,6 +747,50 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie public void onVoteThingFail(int position1) { } }, mVisibleComments.get(commentPosition).getFullName(), newVoteType, holder.getAdapterPosition()); }); + + if(comment.isSaved()) { + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + } else { + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + } + + ((CommentViewHolder) holder).saveButton.setOnClickListener(view -> { + if (comment.isSaved()) { + comment.setSaved(false); + SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { + @Override + public void success() { + comment.setSaved(false); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show(); + } + + @Override + public void failed() { + comment.setSaved(true); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show(); + } + }); + } else { + comment.setSaved(true); + SaveThing.saveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { + @Override + public void success() { + comment.setSaved(true); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show(); + } + + @Override + public void failed() { + comment.setSaved(false); + ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show(); + } + }); + } + }); } else if(holder instanceof LoadMoreChildCommentsViewHolder) { CommentData placeholder; placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getAdapterPosition() - 2) @@ -1314,6 +1358,7 @@ class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerVie @BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView; @BindView(R.id.down_vote_button_item_post_comment) ImageView downVoteButton; @BindView(R.id.more_button_item_post_comment) ImageView moreButton; + @BindView(R.id.save_button_item_post_comment) ImageView saveButton; @BindView(R.id.expand_button_item_post_comment) ImageView expandButton; @BindView(R.id.share_button_item_post_comment) ImageView shareButton; @BindView(R.id.reply_button_item_post_comment) ImageView replyButton; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java index bce51afa..b06caa15 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentData.java @@ -27,6 +27,7 @@ class CommentData implements Parcelable { private boolean collapsed; private boolean hasReply; private boolean scoreHidden; + private boolean saved; private boolean isExpanded; private ArrayList<CommentData> children; private ArrayList<String> moreChildrenFullnames; @@ -38,7 +39,7 @@ class CommentData implements Parcelable { CommentData(String id, String fullName, String author, String linkAuthor, String commentTime, String commentContent, String linkId, String subredditName, String parentId, int score, int voteType, boolean isSubmitter, String permalink, - int depth, boolean collapsed, boolean hasReply, boolean scoreHidden) { + int depth, boolean collapsed, boolean hasReply, boolean scoreHidden, boolean saved) { this.id = id; this.fullName = fullName; this.author = author; @@ -56,6 +57,7 @@ class CommentData implements Parcelable { this.collapsed = collapsed; this.hasReply = hasReply; this.scoreHidden = scoreHidden; + this.saved = saved; this.isExpanded = false; moreChildrenStartingIndex = 0; isPlaceHolder = false; @@ -192,6 +194,14 @@ class CommentData implements Parcelable { return scoreHidden; } + public boolean isSaved() { + return saved; + } + + public void setSaved(boolean saved) { + this.saved = saved; + } + public boolean isExpanded() { return isExpanded; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java index d148f026..0a2ec243 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/CommentsListingRecyclerViewAdapter.java @@ -287,6 +287,50 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R public void onVoteThingFail(int position1) { } }, comment.getFullName(), newVoteType, holder.getAdapterPosition()); }); + + if(comment.isSaved()) { + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + } else { + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + } + + ((DataViewHolder) holder).saveButton.setOnClickListener(view -> { + if (comment.isSaved()) { + comment.setSaved(false); + SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { + @Override + public void success() { + comment.setSaved(false); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show(); + } + + @Override + public void failed() { + comment.setSaved(true); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show(); + } + }); + } else { + comment.setSaved(true); + SaveThing.saveThing(mOauthRetrofit, mAccessToken, comment.getFullName(), new SaveThing.SaveThingListener() { + @Override + public void success() { + comment.setSaved(true); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px); + Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show(); + } + + @Override + public void failed() { + comment.setSaved(false); + ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px); + Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show(); + } + }); + } + }); } } } @@ -352,6 +396,7 @@ class CommentsListingRecyclerViewAdapter extends PagedListAdapter<CommentData, R @BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView; @BindView(R.id.down_vote_button_item_post_comment) ImageView downvoteButton; @BindView(R.id.more_button_item_post_comment) ImageView moreButton; + @BindView(R.id.save_button_item_post_comment) ImageView saveButton; @BindView(R.id.share_button_item_post_comment) ImageView shareButton; @BindView(R.id.reply_button_item_post_comment) ImageView replyButton; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ModifyCommentBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ModifyCommentBottomSheetFragment.java index 5b19cfaf..7c39a8e4 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ModifyCommentBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ModifyCommentBottomSheetFragment.java @@ -55,7 +55,7 @@ public class ModifyCommentBottomSheetFragment extends RoundedBottomSheetDialogFr String accessToken = bundle.getString(EXTRA_ACCESS_TOKEN); editTextView.setOnClickListener(view -> { - Intent intent = new Intent(getActivity(), EditCommentActivity.class); + Intent intent = new Intent(activity, EditCommentActivity.class); intent.putExtra(EditCommentActivity.EXTRA_ACCESS_TOKEN, accessToken); intent.putExtra(EditCommentActivity.EXTRA_FULLNAME, fullName); intent.putExtra(EditCommentActivity.EXTRA_CONTENT, content); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java index 7f48d8ea..e84b8e24 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ParseComment.java @@ -232,6 +232,7 @@ class ParseComment { } long submitTime = singleCommentData.getLong(JSONUtils.CREATED_UTC_KEY) * 1000; boolean scoreHidden = singleCommentData.getBoolean(JSONUtils.SCORE_HIDDEN_KEY); + boolean saved = singleCommentData.getBoolean(JSONUtils.SAVED_KEY); Calendar submitTimeCalendar = Calendar.getInstance(); submitTimeCalendar.setTimeInMillis(submitTime); @@ -247,7 +248,7 @@ class ParseComment { return new CommentData(id, fullName, author, linkAuthor, formattedSubmitTime, commentContent, linkId, subredditName, parentId, score, voteType, isSubmitter, permalink, depth, collapsed, - hasReply, scoreHidden); + hasReply, scoreHidden, saved); } @Nullable diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java index e671bda5..15b5187b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PostRecyclerViewAdapter.java @@ -360,7 +360,7 @@ class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHo if(mPostType == PostDataSource.TYPE_SUBREDDIT && !mDisplaySubredditName && post.isStickied()) { ((DataViewHolder) holder).stickiedPostImageView.setVisibility(View.VISIBLE); - mGlide.load(R.drawable.thumbtack).into(((DataViewHolder) holder).stickiedPostImageView); + mGlide.load(R.drawable.ic_thumbtack_24dp).into(((DataViewHolder) holder).stickiedPostImageView); } if(isArchived) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java index e3103796..e0b6672a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java @@ -22,4 +22,5 @@ public class SharedPreferencesUtils { public static final String RATE_KEY = "rate"; public static final String EMAIL_KEY = "email"; public static final String REDDIT_ACCOUNT_KEY = "reddit_account"; + public static final String SUBREDDIT_KEY = "subreddit"; } diff --git a/app/src/main/res/drawable/ic_thumbtack_24dp.xml b/app/src/main/res/drawable/ic_thumbtack_24dp.xml new file mode 100644 index 00000000..4d784693 --- /dev/null +++ b/app/src/main/res/drawable/ic_thumbtack_24dp.xml @@ -0,0 +1,4 @@ +<vector android:height="24dp" android:viewportHeight="401.506" + android:viewportWidth="401.506" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> + <path android:fillColor="#FF000000" android:pathData="M397.373,135.487L267.742,5.867c-2.67,-2.671 -6.22,-4.142 -9.991,-4.142c-3.773,0 -7.322,1.471 -9.991,4.142l-38.254,38.252c-2.67,2.67 -4.141,6.219 -4.141,9.992c0,3.774 1.471,7.322 4.141,9.992l5.575,5.562l-95.653,95.653L15.314,191.032c-4.944,1.221 -8.863,5.025 -10.227,9.93c-1.367,4.909 0.021,10.187 3.622,13.777l78.173,78.177l-82.741,82.74c-2.67,2.67 -4.141,6.219 -4.141,9.99c0,3.773 1.471,7.322 4.141,9.992c2.671,2.67 6.219,4.143 9.992,4.143s7.321,-1.473 9.992,-4.143l82.74,-82.738l78.188,78.18c3.556,3.561 8.759,5 13.796,3.621c4.891,-1.361 8.694,-5.281 9.915,-10.227l25.704,-104.104l0.396,-0.396l95.257,-95.257l9.016,9.016c2.632,2.631 6.274,4.141 9.993,4.141c3.773,0 7.322,-1.471 9.991,-4.141l38.253,-38.262C402.883,149.962 402.883,140.999 397.373,135.487zM187.332,353.387L46.402,212.465l75.883,-18.742l83.781,83.789L187.332,353.387zM221.695,253.174l-75.072,-75.081l88.44,-88.442l75.071,75.08L221.695,253.174zM349.129,163.754L239.484,54.109l18.267,-18.266l109.646,109.636L349.129,163.754z"/> +</vector> diff --git a/app/src/main/res/drawable/thumbtack.png b/app/src/main/res/drawable/thumbtack.png Binary files differdeleted file mode 100644 index b537f614..00000000 --- a/app/src/main/res/drawable/thumbtack.png +++ /dev/null diff --git a/app/src/main/res/layout/fragment_modify_comment_bottom_sheet.xml b/app/src/main/res/layout/fragment_modify_comment_bottom_sheet.xml index a419912e..c637e910 100644 --- a/app/src/main/res/layout/fragment_modify_comment_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_modify_comment_bottom_sheet.xml @@ -8,6 +8,20 @@ tools:context=".ModifyCommentBottomSheetFragment"> <TextView + android:id="@+id/save_text_view_modify_comment_bottom_sheet_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:paddingTop="16dp" + android:paddingBottom="16dp" + android:paddingStart="32dp" + android:paddingEnd="32dp" + android:text="@string/edit" + android:textColor="@color/primaryTextColor" + android:clickable="true" + android:focusable="true" + android:background="?attr/selectableItemBackground" /> + + <TextView android:id="@+id/edit_text_view_modify_comment_bottom_sheet_fragment" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index 16c4dafa..0c103825 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -20,7 +20,7 @@ android:layout_marginBottom="12dp" android:orientation="vertical"> - <LinearLayout + <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginStart="16dp" @@ -28,19 +28,25 @@ <TextView android:id="@+id/author_text_view_item_post_comment" - android:layout_width="0dp" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" android:layout_marginEnd="16dp" - android:textColor="@color/colorPrimaryDarkDayNightTheme"/> + android:textColor="@color/colorPrimaryDarkDayNightTheme" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toStartOf="@id/comment_time_text_view_item_post_comment" + app:layout_constraintHorizontal_bias="0" /> <TextView android:id="@+id/comment_time_text_view_item_post_comment" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:gravity="end" /> + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" /> - </LinearLayout> + </androidx.constraintlayout.widget.ConstraintLayout> <TextView android:id="@+id/comment_markdown_view_item_post_comment" @@ -108,6 +114,19 @@ android:src="@drawable/ic_outline_more_vert_24px" android:tint="@android:color/tab_indicator_text" android:visibility="gone" + app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent"/> + + <ImageView + android:id="@+id/save_button_item_post_comment" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginEnd="16dp" + android:background="?actionBarItemBackground" + android:clickable="true" + android:focusable="true" + android:tint="@android:color/tab_indicator_text" app:layout_constraintEnd_toStartOf="@+id/expand_button_item_post_comment" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index f82fc670..196fc489 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -38,6 +38,8 @@ </string-array> <string-array name="settings_lazy_mode_interval"> + <item>1s</item> + <item>2s</item> <item>2.5s</item> <item>3s</item> <item>5s</item> @@ -46,6 +48,8 @@ </string-array> <string-array name="settings_lazy_mode_interval_values"> + <item>1</item> + <item>2</item> <item>2.5</item> <item>3</item> <item>5</item> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 51149699..094846ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -300,6 +300,8 @@ <string name="settings_email_summary">docilealligator.app@gmail.com</string> <string name="settings_reddit_account_title">Reddit Account</string> <string name="settings_reddit_account_summary">u/Hostilenemy</string> + <string name="settings_subreddit_title">Subreddit</string> + <string name="settings_subreddit_summary">r/Infinity_For_Reddit</string> <string name="no_link_available">Cannot get the link</string> @@ -318,4 +320,9 @@ <string name="share">Share</string> <string name="no_email_client">No Email client found</string> + + <string name="comment_saved_success">Comment saved</string> + <string name="comment_saved_failed">Unable to save comment</string> + <string name="comment_unsaved_success">Comment unsaved</string> + <string name="comment_unsaved_failed">Unable to unsave comment</string> </resources> diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml index e27844fc..942a0cd4 100644 --- a/app/src/main/res/xml/about_preferences.xml +++ b/app/src/main/res/xml/about_preferences.xml @@ -30,4 +30,9 @@ app:title="@string/settings_reddit_account_title" app:summary="@string/settings_reddit_account_summary" /> + <Preference + android:key="subreddit" + app:title="@string/settings_subreddit_title" + app:summary="@string/settings_subreddit_summary" /> + </PreferenceScreen>
\ No newline at end of file |