aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/MarkdownBottomBarRecyclerViewAdapter.java52
-rw-r--r--app/src/main/res/drawable/ic_code_24dp.xml9
-rw-r--r--app/src/main/res/drawable/ic_quote_24dp.xml9
4 files changed, 63 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;
+ }
}
}
diff --git a/app/src/main/res/drawable/ic_code_24dp.xml b/app/src/main/res/drawable/ic_code_24dp.xml
new file mode 100644
index 00000000..ecd966bb
--- /dev/null
+++ b/app/src/main/res/drawable/ic_code_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:pathData="M9.4,16.6L4.8,12l4.6,-4.6L8,6l-6,6 6,6 1.4,-1.4zM14.6,16.6l4.6,-4.6 -4.6,-4.6L16,6l6,6 -6,6 -1.4,-1.4z"
+ android:fillColor="#000000"/>
+</vector>
diff --git a/app/src/main/res/drawable/ic_quote_24dp.xml b/app/src/main/res/drawable/ic_quote_24dp.xml
new file mode 100644
index 00000000..7e699680
--- /dev/null
+++ b/app/src/main/res/drawable/ic_quote_24dp.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M6,17h3l2,-4L11,7L5,7v6h3zM14,17h3l2,-4L19,7h-6v6h3z"/>
+</vector>