mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Quote and code block are added to MarkdownBottomBarRecyclerViewAdapter. Fix issues in header size selection.
This commit is contained in:
parent
d2ca131d25
commit
b3da83e373
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
9
app/src/main/res/drawable/ic_code_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_code_24dp.xml
Normal file
@ -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>
|
9
app/src/main/res/drawable/ic_quote_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_quote_24dp.xml
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user