mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-12 19:27:12 +01:00
Saving and unsaving comments are now available. Use xml thumbtack to avoid crashes on low resolution devices. Add a subreddit link in Settings -> About.
This commit is contained in:
parent
c1adf51537
commit
50da29ad8c
4
.idea/assetWizardSettings.xml
generated
4
.idea/assetWizardSettings.xml
generated
@ -159,8 +159,8 @@
|
||||
<map>
|
||||
<entry key="assetSourceType" value="FILE" />
|
||||
<entry key="color" value="ffffff" />
|
||||
<entry key="outputName" value="ic_ufo" />
|
||||
<entry key="sourceFile" value="$USER_HOME$/Downloads/ic_notification.svg" />
|
||||
<entry key="outputName" value="ic_tack_save_button" />
|
||||
<entry key="sourceFile" value="$USER_HOME$/Downloads/tack-save-button.svg" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)){
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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";
|
||||
}
|
||||
|
4
app/src/main/res/drawable/ic_thumbtack_24dp.xml
Normal file
4
app/src/main/res/drawable/ic_thumbtack_24dp.xml
Normal file
@ -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>
|
Binary file not shown.
Before Width: | Height: | Size: 6.6 KiB |
@ -7,6 +7,20 @@
|
||||
android:orientation="vertical"
|
||||
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"
|
||||
|
@ -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"/>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
Loading…
Reference in New Issue
Block a user