diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java index 1c171f16..2138e6b5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/CommentActivity.java @@ -9,6 +9,7 @@ import android.os.Bundle; import android.text.Spanned; import android.text.style.SuperscriptSpan; import android.text.util.Linkify; +import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -47,6 +48,7 @@ import io.noties.markwon.recycler.MarkwonAdapter; import io.noties.markwon.recycler.table.TableEntry; import io.noties.markwon.recycler.table.TableEntryPlugin; import io.noties.markwon.simple.ext.SimpleExtPlugin; +import ml.docilealligator.infinityforreddit.Adapter.MarkdownBottomBarRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask; import ml.docilealligator.infinityforreddit.BottomSheetFragment.CopyTextBottomSheetFragment; import ml.docilealligator.infinityforreddit.Comment.Comment; @@ -89,6 +91,8 @@ public class CommentActivity extends BaseActivity { RecyclerView contentMarkdownRecyclerView; @BindView(R.id.comment_edit_text_comment_activity) EditText commentEditText; + @BindView(R.id.markdown_bottom_bar_recycler_view_comment_activity) + RecyclerView markdownBottomBarRecyclerView; @Inject @Named("oauth") Retrofit mOauthRetrofit; @@ -259,6 +263,17 @@ public class CommentActivity extends BaseActivity { setSupportActionBar(toolbar); + MarkdownBottomBarRecyclerViewAdapter adapter = new MarkdownBottomBarRecyclerViewAdapter(mCustomThemeWrapper, new MarkdownBottomBarRecyclerViewAdapter.ItemClickListener() { + @Override + public void onClick(int item) { + Log.i("asasdf", "s " + item); + } + }); + + markdownBottomBarRecyclerView.setLayoutManager(new LinearLayoutManager(this, + LinearLayoutManager.HORIZONTAL, false)); + markdownBottomBarRecyclerView.setAdapter(adapter); + commentEditText.requestFocus(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MarkdownBottomBarRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MarkdownBottomBarRecyclerViewAdapter.java new file mode 100644 index 00000000..11d06b14 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/MarkdownBottomBarRecyclerViewAdapter.java @@ -0,0 +1,94 @@ +package ml.docilealligator.infinityforreddit.Adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper; +import ml.docilealligator.infinityforreddit.R; + +public class MarkdownBottomBarRecyclerViewAdapter extends RecyclerView.Adapter { + + public static final int BOLD = 0; + public static final int ITALIC = 1; + public static final int LINK = 2; + public static final int STRIKE_THROUGH = 3; + public static final int HEADER = 4; + public static final int ORDERED_LIST = 5; + public static final int UNORDERED_LIST = 6; + public static final int SPOILER = 7; + + private static final int ITEM_COUNT = 8; + + private CustomThemeWrapper customThemeWrapper; + private ItemClickListener itemClickListener; + + public interface ItemClickListener { + void onClick(int item); + } + + public MarkdownBottomBarRecyclerViewAdapter(CustomThemeWrapper customThemeWrapper, + ItemClickListener itemClickListener) { + this.customThemeWrapper = customThemeWrapper; + this.itemClickListener = itemClickListener; + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new MarkdownBottomBarItemViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_markdown_bottom_bar, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + if (holder instanceof MarkdownBottomBarItemViewHolder) { + switch (position) { + case BOLD: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_bold_black_24dp); + break; + case ITALIC: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_italic_black_24dp); + break; + case LINK: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_link_round_black_24dp); + break; + case STRIKE_THROUGH: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_strikethrough_black_24dp); + break; + case HEADER: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_header_hashtag_black_24dp); + break; + case ORDERED_LIST: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_ordered_list_black_24dp); + break; + case UNORDERED_LIST: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_unordered_list_black_24dp); + break; + case SPOILER: + ((MarkdownBottomBarItemViewHolder) holder).imageView.setImageResource(R.drawable.ic_spoiler_black_24dp); + break; + } + } + } + + @Override + public int getItemCount() { + return ITEM_COUNT; + } + + class MarkdownBottomBarItemViewHolder extends RecyclerView.ViewHolder { + ImageView imageView; + + public MarkdownBottomBarItemViewHolder(@NonNull View itemView) { + super(itemView); + imageView = (ImageView) itemView; + itemView.setOnClickListener(view -> itemClickListener.onClick(getAdapterPosition())); + + imageView.setColorFilter(customThemeWrapper.getPrimaryIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); + } + } +} diff --git a/app/src/main/res/drawable/ic_bold_black_24dp.xml b/app/src/main/res/drawable/ic_bold_black_24dp.xml new file mode 100644 index 00000000..b0a3248a --- /dev/null +++ b/app/src/main/res/drawable/ic_bold_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_header_hashtag_black_24dp.xml b/app/src/main/res/drawable/ic_header_hashtag_black_24dp.xml new file mode 100644 index 00000000..1cef8584 --- /dev/null +++ b/app/src/main/res/drawable/ic_header_hashtag_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_italic_black_24dp.xml b/app/src/main/res/drawable/ic_italic_black_24dp.xml new file mode 100644 index 00000000..0a695061 --- /dev/null +++ b/app/src/main/res/drawable/ic_italic_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_link_round_black_24dp.xml b/app/src/main/res/drawable/ic_link_round_black_24dp.xml new file mode 100644 index 00000000..b4a7855f --- /dev/null +++ b/app/src/main/res/drawable/ic_link_round_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_ordered_list_black_24dp.xml b/app/src/main/res/drawable/ic_ordered_list_black_24dp.xml new file mode 100644 index 00000000..1c7fc65c --- /dev/null +++ b/app/src/main/res/drawable/ic_ordered_list_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_spoiler_black_24dp.xml b/app/src/main/res/drawable/ic_spoiler_black_24dp.xml new file mode 100644 index 00000000..e8d7b1e3 --- /dev/null +++ b/app/src/main/res/drawable/ic_spoiler_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_strikethrough_black_24dp.xml b/app/src/main/res/drawable/ic_strikethrough_black_24dp.xml new file mode 100644 index 00000000..62edd25f --- /dev/null +++ b/app/src/main/res/drawable/ic_strikethrough_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_unordered_list_black_24dp.xml b/app/src/main/res/drawable/ic_unordered_list_black_24dp.xml new file mode 100644 index 00000000..2a2bb753 --- /dev/null +++ b/app/src/main/res/drawable/ic_unordered_list_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/activity_comment.xml b/app/src/main/res/layout/activity_comment.xml index 1fe93f50..69e0a4d7 100644 --- a/app/src/main/res/layout/activity_comment.xml +++ b/app/src/main/res/layout/activity_comment.xml @@ -23,56 +23,71 @@ - - + android:layout_height="0dp" + android:layout_weight="1"> - - - - - - - + android:orientation="vertical"> - + - + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_markdown_bottom_bar.xml b/app/src/main/res/layout/item_markdown_bottom_bar.xml new file mode 100644 index 00000000..53ef5b84 --- /dev/null +++ b/app/src/main/res/layout/item_markdown_bottom_bar.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file