diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-01-06 07:03:15 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-01-06 07:03:15 +0000 |
commit | b3da83e3735e974d14cbc002c562e33f58b846b2 (patch) | |
tree | fec4873195028a94c39530b688ccd017b48ddda2 /app/src/main/java/ml | |
parent | d2ca131d2570efc555bf35be2f7df84e27106b1c (diff) | |
download | infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar.gz infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar.bz2 infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar.lz infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar.xz infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.tar.zst infinity-for-reddit-b3da83e3735e974d14cbc002c562e33f58b846b2.zip |
Quote and code block are added to MarkdownBottomBarRecyclerViewAdapter. Fix issues in header size selection.
Diffstat (limited to 'app/src/main/java/ml')
2 files changed, 45 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java index 60906ec5..1b8366a5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java @@ -166,7 +166,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME); getCurrentAccountAndFetchMessage(savedInstanceState); } - + viewPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener(){ @Override public void onPageSelected(int position) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java index 6dd2fff3..8145e8a0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java @@ -26,8 +26,10 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R public static final int ORDERED_LIST = 5; public static final int UNORDERED_LIST = 6; public static final int SPOILER = 7; + public static final int QUOTE = 8; + public static final int CODE_BLOCK = 9; - private static final int ITEM_COUNT = 8; + private static final int ITEM_COUNT = 10; private CustomThemeWrapper customThemeWrapper; private ItemClickListener itemClickListener; @@ -76,6 +78,12 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R case SPOILER: ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_spoiler_black_24dp); break; + case QUOTE: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_quote_24dp); + break; + case CODE_BLOCK: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_code_24dp); + break; } } } @@ -171,23 +179,23 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R int end = Math.max(commentEditText.getSelectionEnd(), 0); String hashTags; switch ((int) seekBar.getValue()) { - case 0: - hashTags = "###### "; - break; case 1: - hashTags = "##### "; + hashTags = "# "; break; case 2: - hashTags = "#### "; + hashTags = "## "; break; case 3: hashTags = "### "; break; case 4: - hashTags = "## "; + hashTags = "#### "; + break; + case 5: + hashTags = "##### "; break; default: - hashTags = "# "; + hashTags = "###### "; break; } if (end != start) { @@ -243,6 +251,34 @@ public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter<R } break; } + case QUOTE: { + int start = Math.max(commentEditText.getSelectionStart(), 0); + int end = Math.max(commentEditText.getSelectionEnd(), 0); + if (end != start) { + String currentSelection = commentEditText.getText().subSequence(start, end).toString(); + commentEditText.getText().replace(Math.min(start, end), Math.max(start, end), + "> " + currentSelection + "\n\n", 0, "> \n\n".length() + currentSelection.length()); + } else { + commentEditText.getText().replace(start, end, + "> \n\n", 0, "> \n\n".length()); + commentEditText.setSelection(start + "> ".length()); + } + break; + } + case CODE_BLOCK: { + int start = Math.max(commentEditText.getSelectionStart(), 0); + int end = Math.max(commentEditText.getSelectionEnd(), 0); + if (end != start) { + String currentSelection = commentEditText.getText().subSequence(start, end).toString(); + commentEditText.getText().replace(Math.min(start, end), Math.max(start, end), + "```\n" + currentSelection + "\n```\n", 0, "```\n\n```\n".length() + currentSelection.length()); + } else { + commentEditText.getText().replace(start, end, + "```\n\n```\n", 0, "```\n\n```\n".length()); + commentEditText.setSelection(start + "```\n".length()); + } + break; + } } } |