mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-02-02 12:54:45 +01:00
Placing vote buttons on the right for comments is now available.
This commit is contained in:
parent
11a69ad333
commit
b9733e69e9
@ -510,7 +510,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
mActivity.startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE);
|
||||
});
|
||||
|
||||
((PostDetailViewHolder) holder).commentsCountTextView.setText(Integer.toString(mPost.getnComments()));
|
||||
((PostDetailViewHolder) holder).commentsCountTextView.setText(Integer.toString(mPost.getNComments()));
|
||||
|
||||
if (mPost.isSaved()) {
|
||||
((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
@ -1697,6 +1697,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
TextView commentTimeTextView;
|
||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
||||
TextView commentMarkdownView;
|
||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
||||
ConstraintLayout bottomConstraintLayout;
|
||||
@BindView(R.id.up_vote_button_item_post_comment)
|
||||
ImageView upVoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_comment)
|
||||
@ -1768,6 +1770,29 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
expandButton.performClick();
|
||||
return true;
|
||||
});
|
||||
|
||||
if (mVoteButtonsOnTheRight) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
constraintSet.clone(bottomConstraintLayout);
|
||||
constraintSet.clear(upVoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(downVoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(expandButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(saveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(replyButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(shareButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(upVoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downVoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(downVoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(moreButton.getId(), ConstraintSet.END, upVoteButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(replyButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
|
||||
constraintSet.setHorizontalBias(moreButton.getId(), 0);
|
||||
constraintSet.applyTo(bottomConstraintLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.paging.PagedListAdapter;
|
||||
import androidx.recyclerview.widget.DiffUtil;
|
||||
@ -64,11 +66,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
private String mAccountName;
|
||||
private int mTextColorPrimaryDark;
|
||||
private int mColorAccent;
|
||||
private boolean mVoteButtonsOnTheRight;
|
||||
private NetworkState networkState;
|
||||
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
|
||||
|
||||
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
|
||||
String accessToken, String accountName,
|
||||
boolean voteButtonsOnTheRight,
|
||||
RetryLoadingMoreCallback retryLoadingMoreCallback) {
|
||||
super(DIFF_CALLBACK);
|
||||
mContext = context;
|
||||
@ -94,6 +98,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
.build();
|
||||
mAccessToken = accessToken;
|
||||
mAccountName = accountName;
|
||||
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
|
||||
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
|
||||
mTextColorPrimaryDark = mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme);
|
||||
mColorAccent = mContext.getResources().getColor(R.color.colorAccent);
|
||||
@ -407,6 +412,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
TextView commentTimeTextView;
|
||||
@BindView(R.id.comment_markdown_view_item_post_comment)
|
||||
TextView commentMarkdownView;
|
||||
@BindView(R.id.bottom_constraint_layout_item_post_comment)
|
||||
ConstraintLayout bottomConstraintLayout;
|
||||
@BindView(R.id.up_vote_button_item_post_comment)
|
||||
ImageView upvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_comment)
|
||||
@ -417,6 +424,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<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)
|
||||
@ -425,6 +434,29 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
||||
DataViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
|
||||
if (mVoteButtonsOnTheRight) {
|
||||
ConstraintSet constraintSet = new ConstraintSet();
|
||||
constraintSet.clone(bottomConstraintLayout);
|
||||
constraintSet.clear(upvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.clear(expandButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(saveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(replyButton.getId(), ConstraintSet.END);
|
||||
constraintSet.clear(shareButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
|
||||
constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
|
||||
constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(moreButton.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(replyButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END);
|
||||
constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
|
||||
constraintSet.setHorizontalBias(moreButton.getId(), 0);
|
||||
constraintSet.applyTo(bottomConstraintLayout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -616,7 +616,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}, fullName, newVoteType, holder.getAdapterPosition());
|
||||
});
|
||||
|
||||
((DataViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getnComments()));
|
||||
((DataViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
|
||||
|
||||
if (post.isSaved()) {
|
||||
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
|
||||
|
@ -143,9 +143,10 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
|
||||
private void bindView(Resources resources) {
|
||||
mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
|
||||
|
||||
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||
mAdapter = new CommentsListingRecyclerViewAdapter(activity, mOauthRetrofit,
|
||||
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
|
||||
() -> mCommentViewModel.retryLoadingMore());
|
||||
voteButtonsOnTheRight, () -> mCommentViewModel.retryLoadingMore());
|
||||
|
||||
String username = getArguments().getString(EXTRA_USERNAME);
|
||||
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
|
||||
|
@ -323,11 +323,11 @@ public class Post implements Parcelable {
|
||||
this.previewHeight = previewHeight;
|
||||
}
|
||||
|
||||
public int getnComments() {
|
||||
public int getNComments() {
|
||||
return nComments;
|
||||
}
|
||||
|
||||
public void setnComments(int nComments) {
|
||||
public void setNComments(int nComments) {
|
||||
this.nComments = nComments;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<vector android:height="20dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<vector android:height="24dp" android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#FF808080" android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
|
||||
</vector>
|
||||
|
@ -71,20 +71,144 @@
|
||||
android:textColor="@color/primaryTextColor"
|
||||
android:textSize="?attr/content_font_default" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
<!--<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/bottom_constraint_layout_item_post_comment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/up_vote_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_arrow_upward_grey_24dp"
|
||||
app:layout_constraintEnd_toStartOf="@id/score_text_view_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/score_text_view_item_post_comment"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintEnd_toStartOf="@+id/down_vote_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/down_vote_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_arrow_downward_grey_24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/more_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_more_vert_grey_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@+id/expand_button_item_post_comment"
|
||||
app:layout_constraintEnd_toStartOf="@id/up_vote_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/expand_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_expand_less_grey_24dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toEndOf="@+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:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintStart_toEndOf="@+id/reply_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reply_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_reply_grey_24dp"
|
||||
app:layout_constraintStart_toEndOf="@id/share_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_share_grey_24dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>-->
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/bottom_constraint_layout_item_post_comment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="4dp"
|
||||
android:paddingEnd="4dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/up_vote_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_arrow_upward_grey_24dp"
|
||||
android:tint="@android:color/tab_indicator_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent" />
|
||||
@ -93,7 +217,6 @@
|
||||
android:id="@+id/score_text_view_item_post_comment"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:gravity="center"
|
||||
android:textSize="?attr/font_12"
|
||||
android:textStyle="bold"
|
||||
@ -105,8 +228,8 @@
|
||||
android:id="@+id/down_vote_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
@ -122,7 +245,8 @@
|
||||
android:id="@+id/more_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
@ -136,7 +260,8 @@
|
||||
android:id="@+id/expand_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
@ -151,23 +276,11 @@
|
||||
android:id="@+id/save_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:layout_constraintEnd_toStartOf="@+id/share_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_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:src="@drawable/ic_share_grey_24dp"
|
||||
app:layout_constraintEnd_toStartOf="@+id/reply_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
@ -176,11 +289,26 @@
|
||||
android:id="@+id/reply_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_reply_grey_24dp"
|
||||
app:layout_constraintEnd_toStartOf="@id/share_button_item_post_comment"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_button_item_post_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:background="?actionBarItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:src="@drawable/ic_share_grey_24dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user