Highlight the selected thread in the split layout

multisite
Floens 10 years ago
parent c67998cfba
commit d77d3d6ea6
  1. 6
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java
  2. 11
      Clover/app/src/main/java/org/floens/chan/ui/adapter/PostAdapter.java
  3. 2
      Clover/app/src/main/java/org/floens/chan/ui/cell/CardPostCell.java
  4. 8
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  5. 2
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java
  6. 2
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostStubCell.java
  7. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/PostRepliesController.java
  8. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java
  9. 4
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThreadController.java
  10. 22
      Clover/app/src/main/java/org/floens/chan/ui/controller/ViewThreadController.java
  11. 5
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadLayout.java
  12. 4
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java
  13. 1
      Clover/app/src/main/java/org/floens/chan/ui/text/FastTextView.java
  14. 9
      Clover/app/src/main/java/org/floens/chan/ui/theme/Theme.java
  15. 1
      Clover/app/src/main/res/values/attrs.xml
  16. 1
      Clover/app/src/main/res/values/styles.xml

@ -332,6 +332,10 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
threadPresenterCallback.highlightPost(post);
}
public void selectPost(int post) {
threadPresenterCallback.selectPost(post);
}
/*
* PostView callbacks
*/
@ -674,6 +678,8 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
void highlightPostTripcode(String tripcode);
void selectPost(int post);
void showSearch(boolean show);
void setSearchStatus(String query, boolean setEmptyText, boolean hideKeyboard);

@ -50,6 +50,7 @@ public class PostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private String highlightedPostId;
private int highlightedPostNo = -1;
private String highlightedPostTripcode;
private int selectedPost;
private int lastSeenIndicatorPosition = -1;
private boolean bound;
@ -102,8 +103,9 @@ public class PostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
case TYPE_POST_STUB:
PostViewHolder postViewHolder = (PostViewHolder) holder;
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, -1, true, postViewMode);
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);
break;
case TYPE_STATUS:
((StatusViewHolder) holder).threadStatusCell.update();
@ -259,6 +261,11 @@ public class PostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
notifyDataSetChanged();
}
public void selectPost(int no) {
selectedPost = no;
notifyDataSetChanged();
}
public void setPostViewMode(PostCellInterface.PostViewMode postViewMode) {
this.postViewMode = postViewMode;
}

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

@ -100,6 +100,7 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
private Post post;
private PostCellCallback callback;
private boolean highlighted;
private boolean selected;
private int markedNo;
private boolean showDivider;
@ -234,8 +235,8 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
}
public void setPost(Theme theme, final Post post, PostCellInterface.PostCellCallback callback,
boolean highlighted, int markedNo, boolean showDivider, PostCellInterface.PostViewMode postViewMode) {
if (this.post == post && this.highlighted == highlighted && this.markedNo == markedNo) {
boolean highlighted, boolean selected, int markedNo, boolean showDivider, PostCellInterface.PostViewMode postViewMode) {
if (this.post == post && this.highlighted == highlighted && this.selected == selected && this.markedNo == markedNo && this.showDivider == showDivider) {
return;
}
@ -252,6 +253,7 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
this.post = post;
this.callback = callback;
this.highlighted = highlighted;
this.selected = selected;
this.markedNo = markedNo;
this.showDivider = showDivider;
@ -289,6 +291,8 @@ public class PostCell extends LinearLayout implements PostCellInterface, PostLin
setBackgroundColor(theme.highlightedColor);
} else if (post.isSavedReply) {
setBackgroundColor(theme.savedReplyColor);
} else if (selected) {
setBackgroundColor(theme.selectedColor);
} else if (threadMode) {
setBackgroundResource(0);
} else {

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

@ -139,7 +139,7 @@ public class PostStubCell extends RelativeLayout implements PostCellInterface, V
}
public void setPost(Theme theme, final Post post, PostCellInterface.PostCellCallback callback,
boolean highlighted, int markedNo, boolean showDivider, PostCellInterface.PostViewMode postViewMode) {
boolean highlighted, boolean selected, int markedNo, boolean showDivider, PostCellInterface.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, data.forPost.no, showDivider, PostCellInterface.PostViewMode.LIST);
postCell.setPost(null, p, presenter, false, false, data.forPost.no, showDivider, PostCellInterface.PostViewMode.LIST);
return (View) postCell;
}

@ -255,7 +255,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, -1, true, PostCellInterface.PostViewMode.LIST);
postCell.setPost(theme, post, DUMMY_POST_CALLBACK, false, false, -1, true, PostCellInterface.PostViewMode.LIST);
linearLayout.addView(postCell, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
return linearLayout;

@ -102,6 +102,10 @@ public abstract class ThreadController extends Controller implements ThreadLayou
return threadLayout.getPresenter().getLoadable();
}
public void selectPost(int post) {
threadLayout.getPresenter().selectPost(post);
}
@Override
public boolean onBack() {
return threadLayout.onBack();

@ -24,6 +24,8 @@ import android.support.v7.app.AlertDialog;
import org.floens.chan.Chan;
import org.floens.chan.R;
import org.floens.chan.chan.ChanUrls;
import org.floens.chan.controller.Controller;
import org.floens.chan.controller.NavigationController;
import org.floens.chan.core.manager.WatchManager;
import org.floens.chan.core.model.Loadable;
import org.floens.chan.core.model.Pin;
@ -93,6 +95,7 @@ public class ViewThreadController extends ThreadController implements ThreadLayo
public void onDestroy() {
super.onDestroy();
updateDrawerHighlighting(null);
updateLeftPaneHighlighting(null);
}
@Override
@ -140,6 +143,7 @@ public class ViewThreadController extends ThreadController implements ThreadLayo
navigationItem.updateTitle();
setPinIconState(presenter.isPinned());
updateDrawerHighlighting(loadable);
updateLeftPaneHighlighting(loadable);
presenter.requestInitialData();
}
}
@ -209,6 +213,24 @@ public class ViewThreadController extends ThreadController implements ThreadLayo
}
}
private void updateLeftPaneHighlighting(Loadable loadable) {
if (splitNavigationController != null) {
if (splitNavigationController.leftController instanceof NavigationController) {
NavigationController leftNavigationController = (NavigationController) splitNavigationController.leftController;
ThreadController threadController = null;
for (Controller controller : leftNavigationController.childControllers) {
if (controller instanceof ThreadController) {
threadController = (ThreadController) controller;
break;
}
}
if (threadController != null) {
threadController.selectPost(loadable != null ? loadable.no : -1);
}
}
}
}
private void setPinIconState() {
WatchManager wm = Chan.getWatchManager();
setPinIconState(wm.findPinByLoadable(loadable) != null);

@ -346,6 +346,11 @@ public class ThreadLayout extends CoordinatorLayout implements ThreadPresenter.T
threadListLayout.highlightPostTripcode(tripcode);
}
@Override
public void selectPost(int post) {
threadListLayout.selectPost(post);
}
@Override
public void showSearch(boolean show) {
threadListLayout.openSearch(show);

@ -400,6 +400,10 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
postAdapter.highlightPostTripcode(tripcode);
}
public void selectPost(int post) {
postAdapter.selectPost(post);
}
@Override
public void highlightPostNo(int no) {
postAdapter.highlightPostNo(no);

@ -22,7 +22,6 @@ import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.Layout;
import android.text.Spannable;
import android.text.Spanned;
import android.text.StaticLayout;
import android.text.TextPaint;

@ -54,6 +54,7 @@ public class Theme {
public int detailsColor;
public int highlightedColor;
public int savedReplyColor;
public int selectedColor;
public ThemeDrawable settingsDrawable;
public ThemeDrawable imageDrawable;
@ -106,6 +107,7 @@ public class Theme {
R.attr.post_details_color,
R.attr.post_highlighted_color,
R.attr.post_saved_reply_color,
R.attr.post_selected_color,
R.attr.text_color_primary,
R.attr.text_color_secondary,
R.attr.text_color_hint
@ -124,9 +126,10 @@ public class Theme {
detailsColor = ta.getColor(10, 0);
highlightedColor = ta.getColor(11, 0);
savedReplyColor = ta.getColor(12, 0);
textPrimary = ta.getColor(13, 0);
textSecondary = ta.getColor(14, 0);
textHint = ta.getColor(15, 0);
selectedColor = ta.getColor(13, 0);
textPrimary = ta.getColor(14, 0);
textSecondary = ta.getColor(15, 0);
textHint = ta.getColor(16, 0);
ta.recycle();
}

@ -38,6 +38,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<attr name="post_inline_quote_color" format="color" />
<attr name="post_options_drawable" format="integer" />
<attr name="post_last_seen_color" format="color" />
<attr name="post_selected_color" format="color" />
<attr name="divider_color" format="color" />
<attr name="divider_split_color" format="color" />

@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<item name="post_options_drawable">@drawable/ic_overflow</item>
<item name="post_saved_reply_color">#FFBCBCBC</item>
<item name="post_highlighted_color">#FFD6BAD0</item>
<item name="post_selected_color">#20000000</item>
<item name="divider_color">#1e000000</item>
<item name="divider_split_color">#ffe1e1e1</item>

Loading…
Cancel
Save