make post text selectable

we'll see how this goes, haven't found any bugs yet.
refactor-toolbar
Floens 8 years ago
parent c7087209ef
commit bfa5fcaca7
  1. 2
      Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java
  2. 3
      Clover/app/src/main/java/org/floens/chan/ui/cell/CardPostCell.java
  3. 79
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  4. 10
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java
  5. 3
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostStubCell.java
  6. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/PostRepliesController.java
  7. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java

@ -106,7 +106,7 @@ public class PostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
Post post = displayList.get(getPostPosition(position));
boolean highlight = post == highlightedPost || post.id.equals(highlightedPostId) || post.no == highlightedPostNo ||
post.tripcode.equals(highlightedPostTripcode);
postViewHolder.postView.setPost(null, post, postCellCallback, highlight, post.no == selectedPost, -1, true, postViewMode);
postViewHolder.postView.setPost(null, post, postCellCallback, true, highlight, post.no == selectedPost, -1, true, postViewMode);
break;
case TYPE_STATUS:
((StatusViewHolder) holder).threadStatusCell.update();

@ -146,7 +146,8 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
}
public void setPost(Theme theme, final Post post, PostCellInterface.PostCellCallback callback,
boolean highlighted, boolean selected, int markedNo, boolean showDivider, ChanSettings.PostViewMode postViewMode) {
boolean selectable, boolean highlighted, boolean selected, int markedNo,
boolean showDivider, ChanSettings.PostViewMode postViewMode) {
if (this.post == post) {
return;
}

@ -98,7 +98,6 @@ public class PostCell extends LinearLayout implements PostCellInterface {
private View divider;
private View filterMatchColor;
private boolean commentClickable = false;
private int detailsSizePx;
private int iconSizePx;
private int paddingPx;
@ -109,6 +108,7 @@ public class PostCell extends LinearLayout implements PostCellInterface {
private Theme theme;
private Post post;
private PostCellCallback callback;
private boolean selectable;
private boolean highlighted;
private boolean selected;
private int markedNo;
@ -143,12 +143,12 @@ public class PostCell extends LinearLayout implements PostCellInterface {
protected void onFinishInflate() {
super.onFinishInflate();
thumbnailView = (PostImageThumbnailView) findViewById(R.id.thumbnail_view);
title = (FastTextView) findViewById(R.id.title);
icons = (PostIcons) findViewById(R.id.icons);
comment = (TextView) findViewById(R.id.comment);
replies = (FastTextView) findViewById(R.id.replies);
options = (ImageView) findViewById(R.id.options);
thumbnailView = findViewById(R.id.thumbnail_view);
title = findViewById(R.id.title);
icons = findViewById(R.id.icons);
comment = findViewById(R.id.comment);
replies = findViewById(R.id.replies);
options = findViewById(R.id.options);
divider = findViewById(R.id.divider);
filterMatchColor = findViewById(R.id.filter_match_color);
@ -182,17 +182,10 @@ public class PostCell extends LinearLayout implements PostCellInterface {
divider.setLayoutParams(dividerParams);
thumbnailView.setClickable(true);
thumbnailView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
callback.onThumbnailClicked(post, thumbnailView);
}
});
thumbnailView.setOnClickListener(v -> callback.onThumbnailClicked(post, thumbnailView));
thumbnailView.setRounding(dp(2));
replies.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
replies.setOnClickListener(v -> {
if (threadMode) {
int repliesFromSize;
synchronized (post.repliesFrom) {
@ -203,12 +196,9 @@ public class PostCell extends LinearLayout implements PostCellInterface {
callback.onShowPostReplies(post);
}
}
}
});
options.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
options.setOnClickListener(v -> {
if (ThemeHelper.getInstance().getTheme().isLightTheme) {
options.setImageResource(R.drawable.ic_overflow_black);
}
@ -230,7 +220,6 @@ public class PostCell extends LinearLayout implements PostCellInterface {
}
});
menu.show();
}
});
setOnClickListener(selfClicked);
@ -254,9 +243,21 @@ public class PostCell extends LinearLayout implements PostCellInterface {
}
}
public void setPost(Theme theme, final Post post, PostCellInterface.PostCellCallback callback,
boolean highlighted, boolean selected, int markedNo, boolean showDivider, ChanSettings.PostViewMode postViewMode) {
if (this.post == post && this.highlighted == highlighted && this.selected == selected && this.markedNo == markedNo && this.showDivider == showDivider) {
public void setPost(Theme theme,
final Post post,
PostCellInterface.PostCellCallback callback,
boolean selectable,
boolean highlighted,
boolean selected,
int markedNo,
boolean showDivider,
ChanSettings.PostViewMode postViewMode) {
if (this.post == post &&
this.selectable == selectable &&
this.highlighted == highlighted &&
this.selected == selected &&
this.markedNo == markedNo &&
this.showDivider == showDivider) {
return;
}
@ -272,6 +273,7 @@ public class PostCell extends LinearLayout implements PostCellInterface {
this.theme = theme;
this.post = post;
this.callback = callback;
this.selectable = selectable;
this.highlighted = highlighted;
this.selected = selected;
this.markedNo = markedNo;
@ -416,25 +418,44 @@ public class PostCell extends LinearLayout implements PostCellInterface {
commentText = post.comment;
}
comment.setText(commentText);
comment.setVisibility(isEmpty(commentText) && post.image == null ? GONE : VISIBLE);
if (commentClickable != threadMode) {
commentClickable = threadMode;
if (commentClickable) {
if (threadMode) {
if (selectable) {
// Setting the text to selectable creates an editor, sets up a bunch of click
// handlers and sets a movementmethod.
// Required for the isTextSelectable check.
// We override the test and movementmethod settings.
comment.setTextIsSelectable(true);
comment.setText(commentText, TextView.BufferType.SPANNABLE);
} else {
comment.setText(commentText);
}
// Sets focusable to auto, clickable and longclickable to true.
comment.setMovementMethod(commentMovementMethod);
// And this sets clickable to appropriate values again.
comment.setOnClickListener(selfClicked);
if (noClickable) {
title.setMovementMethod(titleMovementMethod);
}
} else {
// comment.setTextIsSelectable(false);
comment.setText(commentText);
comment.setOnClickListener(null);
comment.setClickable(false);
// Sets focusable to auto, clickable and longclickable to false.
comment.setMovementMethod(null);
title.setMovementMethod(null);
}
}
int repliesFromSize;
synchronized (post.repliesFrom) {

@ -28,7 +28,15 @@ import org.floens.chan.ui.view.ThumbnailView;
import java.util.List;
public interface PostCellInterface {
void setPost(Theme theme, Post post, PostCellCallback callback, boolean highlighted, boolean selected, int markedNo, boolean showDivider, ChanSettings.PostViewMode postViewMode);
void setPost(Theme theme,
Post post,
PostCellCallback callback,
boolean selectable,
boolean highlighted,
boolean selected,
int markedNo,
boolean showDivider,
ChanSettings.PostViewMode postViewMode);
Post getPost();

@ -139,7 +139,8 @@ public class PostStubCell extends RelativeLayout implements PostCellInterface, V
}
public void setPost(Theme theme, final Post post, PostCellInterface.PostCellCallback callback,
boolean highlighted, boolean selected, int markedNo, boolean showDivider, ChanSettings.PostViewMode postViewMode) {
boolean selectable, boolean highlighted, boolean selected, int markedNo,
boolean showDivider, ChanSettings.PostViewMode postViewMode) {
if (this.post == post) {
return;
}

@ -191,7 +191,7 @@ public class PostRepliesController extends Controller {
final Post p = getItem(position);
boolean showDivider = position < getCount() - 1;
postCell.setPost(null, p, presenter, false, false, data.forPost.no, showDivider, ChanSettings.PostViewMode.LIST);
postCell.setPost(null, p, presenter, false, false, false, data.forPost.no, showDivider, ChanSettings.PostViewMode.LIST);
return (View) postCell;
}

@ -325,7 +325,7 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
themeContext.getResources().getDimensionPixelSize(R.dimen.toolbar_height)));
PostCell postCell = (PostCell) LayoutInflater.from(themeContext).inflate(R.layout.cell_post, null);
postCell.setPost(theme, post, DUMMY_POST_CALLBACK, false, false, -1, true, ChanSettings.PostViewMode.LIST);
postCell.setPost(theme, post, DUMMY_POST_CALLBACK, false, false, false, -1, true, ChanSettings.PostViewMode.LIST);
linearLayout.addView(postCell, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
return linearLayout;

Loading…
Cancel
Save