organize board, thread and post option menu's

reorder items to be consistent and add a more... option to the post menu
for the lesser used items.
refactor-toolbar
Floens 8 years ago
parent 78651025a4
commit 162a0b2f68
  1. 28
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java
  2. 17
      Clover/app/src/main/java/org/floens/chan/ui/cell/CardPostCell.java
  3. 25
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCell.java
  4. 3
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostCellInterface.java
  5. 22
      Clover/app/src/main/java/org/floens/chan/ui/cell/PostStubCell.java
  6. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/BrowseController.java
  7. 3
      Clover/app/src/main/java/org/floens/chan/ui/controller/ThemeSettingsController.java
  8. 2
      Clover/app/src/main/java/org/floens/chan/ui/controller/ViewThreadController.java
  9. 1
      Clover/app/src/main/res/values/strings.xml

@ -75,6 +75,7 @@ public class ThreadPresenter implements ChanThreadLoader.ChanLoaderCallback, Pos
private static final int POST_OPTION_HIDE = 12; private static final int POST_OPTION_HIDE = 12;
private static final int POST_OPTION_OPEN_BROWSER = 13; private static final int POST_OPTION_OPEN_BROWSER = 13;
private static final int POST_OPTION_FILTER_TRIPCODE = 14; private static final int POST_OPTION_FILTER_TRIPCODE = 14;
private static final int POST_OPTION_EXTRA = 15;
private ThreadPresenterCallback threadPresenterCallback; private ThreadPresenterCallback threadPresenterCallback;
private WatchManager watchManager; private WatchManager watchManager;
@ -442,7 +443,8 @@ public class ThreadPresenter implements ChanThreadLoader.ChanLoaderCallback, Pos
} }
@Override @Override
public void onPopulatePostOptions(Post post, List<FloatingMenuItem> menu) { public Object onPopulatePostOptions(Post post, List<FloatingMenuItem> menu,
List<FloatingMenuItem> extraMenu) {
if (!loadable.isThreadMode()) { if (!loadable.isThreadMode()) {
menu.add(new FloatingMenuItem(POST_OPTION_PIN, R.string.action_pin)); menu.add(new FloatingMenuItem(POST_OPTION_PIN, R.string.action_pin));
} else { } else {
@ -450,20 +452,14 @@ public class ThreadPresenter implements ChanThreadLoader.ChanLoaderCallback, Pos
menu.add(new FloatingMenuItem(POST_OPTION_QUOTE_TEXT, R.string.post_quote_text)); menu.add(new FloatingMenuItem(POST_OPTION_QUOTE_TEXT, R.string.post_quote_text));
} }
menu.add(new FloatingMenuItem(POST_OPTION_INFO, R.string.post_info)); if (!loadable.isThreadMode()) {
menu.add(new FloatingMenuItem(POST_OPTION_LINKS, R.string.post_show_links)); menu.add(new FloatingMenuItem(POST_OPTION_HIDE, R.string.post_hide));
menu.add(new FloatingMenuItem(POST_OPTION_OPEN_BROWSER, R.string.action_open_browser)); }
menu.add(new FloatingMenuItem(POST_OPTION_SHARE, R.string.post_share));
menu.add(new FloatingMenuItem(POST_OPTION_COPY_TEXT, R.string.post_copy_text));
if (loadable.getSite().feature(Site.Feature.POST_REPORT)) { if (loadable.getSite().feature(Site.Feature.POST_REPORT)) {
menu.add(new FloatingMenuItem(POST_OPTION_REPORT, R.string.post_report)); menu.add(new FloatingMenuItem(POST_OPTION_REPORT, R.string.post_report));
} }
if (!loadable.isThreadMode()) {
menu.add(new FloatingMenuItem(POST_OPTION_HIDE, R.string.post_hide));
}
if (loadable.isThreadMode()) { if (loadable.isThreadMode()) {
if (!TextUtils.isEmpty(post.id)) { if (!TextUtils.isEmpty(post.id)) {
menu.add(new FloatingMenuItem(POST_OPTION_HIGHLIGHT_ID, R.string.post_highlight_id)); menu.add(new FloatingMenuItem(POST_OPTION_HIGHLIGHT_ID, R.string.post_highlight_id));
@ -480,9 +476,19 @@ public class ThreadPresenter implements ChanThreadLoader.ChanLoaderCallback, Pos
menu.add(new FloatingMenuItem(POST_OPTION_DELETE, R.string.delete)); menu.add(new FloatingMenuItem(POST_OPTION_DELETE, R.string.delete));
} }
menu.add(new FloatingMenuItem(POST_OPTION_EXTRA, R.string.post_more));
extraMenu.add(new FloatingMenuItem(POST_OPTION_INFO, R.string.post_info));
extraMenu.add(new FloatingMenuItem(POST_OPTION_LINKS, R.string.post_show_links));
extraMenu.add(new FloatingMenuItem(POST_OPTION_OPEN_BROWSER, R.string.action_open_browser));
extraMenu.add(new FloatingMenuItem(POST_OPTION_SHARE, R.string.post_share));
extraMenu.add(new FloatingMenuItem(POST_OPTION_COPY_TEXT, R.string.post_copy_text));
if (ChanSettings.developer.get()) { if (ChanSettings.developer.get()) {
menu.add(new FloatingMenuItem(POST_OPTION_SAVE, "Save")); extraMenu.add(new FloatingMenuItem(POST_OPTION_SAVE, "Save"));
} }
return POST_OPTION_EXTRA;
} }
public void onPostOptionClicked(Post post, Object id) { public void onPostOptionClicked(Post post, Object id) {

@ -97,13 +97,23 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
options.setOnClickListener(v -> { options.setOnClickListener(v -> {
List<FloatingMenuItem> items = new ArrayList<>(); List<FloatingMenuItem> items = new ArrayList<>();
List<FloatingMenuItem> extraItems = new ArrayList<>();
Object extraOption = callback.onPopulatePostOptions(post, items, extraItems);
showOptions(v, items, extraItems, extraOption);
});
}
callback.onPopulatePostOptions(post, items); private void showOptions(View anchor, List<FloatingMenuItem> items,
List<FloatingMenuItem> extraItems,
FloatingMenu menu = new FloatingMenu(getContext(), v, items); Object extraOption) {
FloatingMenu menu = new FloatingMenu(getContext(), anchor, items);
menu.setCallback(new FloatingMenu.FloatingMenuCallback() { menu.setCallback(new FloatingMenu.FloatingMenuCallback() {
@Override @Override
public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) { public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) {
if (item.getId() == extraOption) {
showOptions(anchor, extraItems, null, null);
}
callback.onPostOptionClicked(post, item.getId()); callback.onPostOptionClicked(post, item.getId());
} }
@ -112,7 +122,6 @@ public class CardPostCell extends CardView implements PostCellInterface, View.On
} }
}); });
menu.show(); menu.show();
});
} }
@Override @Override

@ -200,18 +200,30 @@ public class PostCell extends LinearLayout implements PostCellInterface {
}); });
options.setOnClickListener(v -> { options.setOnClickListener(v -> {
List<FloatingMenuItem> items = new ArrayList<>();
List<FloatingMenuItem> extraItems = new ArrayList<>();
Object extraOption = callback.onPopulatePostOptions(post, items, extraItems);
showOptions(v, items, extraItems, extraOption);
});
setOnClickListener(selfClicked);
}
private void showOptions(View anchor, List<FloatingMenuItem> items,
List<FloatingMenuItem> extraItems,
Object extraOption) {
if (ThemeHelper.getInstance().getTheme().isLightTheme) { if (ThemeHelper.getInstance().getTheme().isLightTheme) {
options.setImageResource(R.drawable.ic_overflow_black); options.setImageResource(R.drawable.ic_overflow_black);
} }
List<FloatingMenuItem> items = new ArrayList<>(); FloatingMenu menu = new FloatingMenu(getContext(), anchor, items);
callback.onPopulatePostOptions(post, items);
FloatingMenu menu = new FloatingMenu(getContext(), v, items);
menu.setCallback(new FloatingMenu.FloatingMenuCallback() { menu.setCallback(new FloatingMenu.FloatingMenuCallback() {
@Override @Override
public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) { public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) {
if (item.getId() == extraOption) {
showOptions(anchor, extraItems, null, null);
}
callback.onPostOptionClicked(post, item.getId()); callback.onPostOptionClicked(post, item.getId());
} }
@ -221,9 +233,6 @@ public class PostCell extends LinearLayout implements PostCellInterface {
} }
}); });
menu.show(); menu.show();
});
setOnClickListener(selfClicked);
} }
@Override @Override

@ -53,7 +53,8 @@ public interface PostCellInterface {
void onShowPostReplies(Post post); void onShowPostReplies(Post post);
void onPopulatePostOptions(Post post, List<FloatingMenuItem> menu); Object onPopulatePostOptions(Post post, List<FloatingMenuItem> menu,
List<FloatingMenuItem> extraMenu);
void onPostOptionClicked(Post post, Object id); void onPostOptionClicked(Post post, Object id);

@ -91,17 +91,25 @@ public class PostStubCell extends RelativeLayout implements PostCellInterface, V
setOnClickListener(this); setOnClickListener(this);
options.setOnClickListener(new OnClickListener() { options.setOnClickListener(v -> {
@Override
public void onClick(View v) {
List<FloatingMenuItem> items = new ArrayList<>(); List<FloatingMenuItem> items = new ArrayList<>();
List<FloatingMenuItem> extraItems = new ArrayList<>();
Object extraOption = callback.onPopulatePostOptions(post, items, extraItems);
showOptions(v, items, extraItems, extraOption);
});
}
callback.onPopulatePostOptions(post, items); private void showOptions(View anchor, List<FloatingMenuItem> items,
List<FloatingMenuItem> extraItems,
FloatingMenu menu = new FloatingMenu(getContext(), v, items); Object extraOption) {
FloatingMenu menu = new FloatingMenu(getContext(), anchor, items);
menu.setCallback(new FloatingMenu.FloatingMenuCallback() { menu.setCallback(new FloatingMenu.FloatingMenuCallback() {
@Override @Override
public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) { public void onFloatingMenuItemClicked(FloatingMenu menu, FloatingMenuItem item) {
if (item.getId() == extraOption) {
showOptions(anchor, extraItems, null, null);
}
callback.onPostOptionClicked(post, item.getId()); callback.onPostOptionClicked(post, item.getId());
} }
@ -111,8 +119,6 @@ public class PostStubCell extends RelativeLayout implements PostCellInterface, V
}); });
menu.show(); menu.show();
} }
});
}
@Override @Override
public void onClick(View v) { public void onClick(View v) {

@ -126,12 +126,12 @@ public class BrowseController extends ThreadController implements ToolbarMenuIte
if (!ChanSettings.enableReplyFab.get()) { if (!ChanSettings.enableReplyFab.get()) {
items.add(new FloatingMenuItem(REPLY_ID, R.string.action_reply)); items.add(new FloatingMenuItem(REPLY_ID, R.string.action_reply));
} }
items.add(new FloatingMenuItem(SHARE_ID, R.string.action_share));
viewModeMenuItem = new FloatingMenuItem(VIEW_MODE_ID, postViewMode == ChanSettings.PostViewMode.LIST ? viewModeMenuItem = new FloatingMenuItem(VIEW_MODE_ID, postViewMode == ChanSettings.PostViewMode.LIST ?
R.string.action_switch_catalog : R.string.action_switch_board); R.string.action_switch_catalog : R.string.action_switch_board);
items.add(viewModeMenuItem); items.add(viewModeMenuItem);
items.add(new FloatingMenuItem(ORDER_ID, R.string.action_order)); items.add(new FloatingMenuItem(ORDER_ID, R.string.action_order));
items.add(new FloatingMenuItem(OPEN_BROWSER_ID, R.string.action_open_browser)); items.add(new FloatingMenuItem(OPEN_BROWSER_ID, R.string.action_open_browser));
items.add(new FloatingMenuItem(SHARE_ID, R.string.action_share));
overflow.setSubMenu(new FloatingMenu(context, overflow.getView(), items)); overflow.setSubMenu(new FloatingMenu(context, overflow.getView(), items));

@ -102,8 +102,9 @@ public class ThemeSettingsController extends Controller implements View.OnClickL
} }
@Override @Override
public void onPopulatePostOptions(Post post, List<FloatingMenuItem> menu) { public Object onPopulatePostOptions(Post post, List<FloatingMenuItem> menu, List<FloatingMenuItem> extraMenu) {
menu.add(new FloatingMenuItem(1, "Option")); menu.add(new FloatingMenuItem(1, "Option"));
return 0;
} }
@Override @Override

@ -90,8 +90,8 @@ public class ViewThreadController extends ThreadController implements ThreadLayo
if (!ChanSettings.enableReplyFab.get()) { if (!ChanSettings.enableReplyFab.get()) {
items.add(new FloatingMenuItem(REPLY_ID, context.getString(R.string.action_reply))); items.add(new FloatingMenuItem(REPLY_ID, context.getString(R.string.action_reply)));
} }
items.add(new FloatingMenuItem(REFRESH_ID, R.string.action_reload));
items.add(new FloatingMenuItem(SEARCH_ID, R.string.action_search)); items.add(new FloatingMenuItem(SEARCH_ID, R.string.action_search));
items.add(new FloatingMenuItem(REFRESH_ID, R.string.action_reload));
items.add(new FloatingMenuItem(OPEN_BROWSER_ID, R.string.action_open_browser)); items.add(new FloatingMenuItem(OPEN_BROWSER_ID, R.string.action_open_browser));
items.add(new FloatingMenuItem(SHARE_ID, R.string.action_share)); items.add(new FloatingMenuItem(SHARE_ID, R.string.action_share));
items.add(new FloatingMenuItem(UP_ID, R.string.action_up)); items.add(new FloatingMenuItem(UP_ID, R.string.action_up));

@ -296,6 +296,7 @@ Re-enable this permission in the app settings if you permanently disabled it."</
<string name="post_hide">Hide</string> <string name="post_hide">Hide</string>
<string name="post_hidden">Thread hidden</string> <string name="post_hidden">Thread hidden</string>
<string name="post_delete">Delete</string> <string name="post_delete">Delete</string>
<string name="post_more">More…</string>
<string name="reply_name">Name</string> <string name="reply_name">Name</string>
<string name="reply_options">Options</string> <string name="reply_options">Options</string>

Loading…
Cancel
Save