Browse Source

implement editorview

pull/61/merge
Thodoris1999 6 years ago
parent
commit
5987fed0ed
  1. 29
      app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java
  2. 20
      app/src/main/res/layout/fragment_shoutbox.xml

29
app/src/main/java/gr/thmmy/mthmmy/activities/main/shoutbox/ShoutboxFragment.java

@ -4,6 +4,8 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import java.util.ArrayList;
@ -13,12 +15,14 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseFragment;
import gr.thmmy.mthmmy.editorview.EditorView;
import gr.thmmy.mthmmy.editorview.EmojiKeyboard;
import gr.thmmy.mthmmy.model.Shout;
import gr.thmmy.mthmmy.utils.CustomRecyclerView;
import gr.thmmy.mthmmy.utils.NetworkResultCodes;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
public class ShoutboxFragment extends BaseFragment {
public class ShoutboxFragment extends BaseFragment implements EmojiKeyboard.EmojiKeyboardOwner {
private static final String TAG = "ShoutboxFragment";
@ -27,6 +31,8 @@ public class ShoutboxFragment extends BaseFragment {
private ShoutAdapter shoutAdapter;
private SwipeRefreshLayout swipeRefreshLayout;
private ArrayList<Shout> shouts;
private EmojiKeyboard emojiKeyboard;
private EditorView editorView;
public static ShoutboxFragment newInstance(int sectionNumber) {
ShoutboxFragment fragment = new ShoutboxFragment();
@ -74,6 +80,27 @@ public class ShoutboxFragment extends BaseFragment {
shoutboxTask.execute("https://www.thmmy.gr/smf/index.php?");
});
emojiKeyboard = rootView.findViewById(R.id.emoji_keyboard);
editorView = rootView.findViewById(R.id.edior_view);
editorView.setEmojiKeyboardOwner(this);
InputConnection ic = editorView.onCreateInputConnection(new EditorInfo());
setEmojiKeyboardInputConnection(ic);
return rootView;
}
@Override
public void setEmojiKeyboardVisible(boolean visible) {
emojiKeyboard.setVisibility(visible ? View.VISIBLE : View.GONE);
}
@Override
public boolean isEmojiKeyboardVisible() {
return emojiKeyboard.getVisibility() == View.VISIBLE;
}
@Override
public void setEmojiKeyboardInputConnection(InputConnection ic) {
emojiKeyboard.setInputConnection(ic);
}
}

20
app/src/main/res/layout/fragment_shoutbox.xml

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:orientation="vertical">
<me.zhanghai.android.materialprogressbar.MaterialProgressBar
android:id="@+id/progressBar"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal.NoPadding"
android:layout_width="match_parent"
android:layout_height="@dimen/progress_bar_height"
android:layout_alignParentTop="true"
android:indeterminate="true"
android:visibility="invisible"
app:mpb_indeterminateTint="@color/accent"
@ -20,7 +20,8 @@
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="0dp"
android:layout_weight="1">
<gr.thmmy.mthmmy.utils.CustomRecyclerView
android:id="@+id/shoutbox_recyclerview"
@ -34,6 +35,13 @@
android:id="@+id/edior_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/swiperefresh"/>
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"/>
</RelativeLayout>
<gr.thmmy.mthmmy.editorview.EmojiKeyboard
android:id="@+id/emoji_keyboard"
android:layout_width="match_parent"
android:layout_height="180dp"
android:visibility="gone"/>
</LinearLayout>
Loading…
Cancel
Save