Browse Source

make hint an EditorView attribute

pull/45/head
Thodoris1999 6 years ago
parent
commit
2dd28cb947
  1. 14
      app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java
  2. 4
      app/src/main/res/layout/activity_test_edit_view.xml
  3. 4
      app/src/main/res/layout/editor_view.xml
  4. 4
      app/src/main/res/values/attrs.xml

14
app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java

@ -3,6 +3,8 @@ package gr.thmmy.mthmmy.utils;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.res.TypedArray;
import android.support.design.widget.TextInputEditText;
import android.support.design.widget.TextInputLayout; import android.support.design.widget.TextInputLayout;
import android.support.v7.widget.AppCompatImageButton; import android.support.v7.widget.AppCompatImageButton;
import android.text.Editable; import android.text.Editable;
@ -13,7 +15,6 @@ import android.view.LayoutInflater;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
@ -24,9 +25,8 @@ import gr.thmmy.mthmmy.R;
public class EditorView extends LinearLayout { public class EditorView extends LinearLayout {
private SparseArray<String> colors = new SparseArray<>(); private SparseArray<String> colors = new SparseArray<>();
private SparseArray<String> fonts = new SparseArray<>();
private EditText editText; private TextInputEditText editText;
private AppCompatImageButton emojiButton; private AppCompatImageButton emojiButton;
private AppCompatImageButton submitButton; private AppCompatImageButton submitButton;
private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner; private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner;
@ -52,6 +52,14 @@ public class EditorView extends LinearLayout {
setOrientation(VERTICAL); setOrientation(VERTICAL);
editText = findViewById(R.id.editor_edittext); editText = findViewById(R.id.editor_edittext);
TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.EditorView, 0, 0);
try {
((TextInputLayout) findViewById(R.id.editor_edittext_wrapper)).setHint(a.getString(R.styleable.EditorView_hint));
} finally {
a.recycle();
}
emojiButton = findViewById(R.id.emoji_keyboard_button); emojiButton = findViewById(R.id.emoji_keyboard_button);
editText.setOnTouchListener((v, event) -> { editText.setOnTouchListener((v, event) -> {

4
app/src/main/res/layout/activity_test_edit_view.xml

@ -3,13 +3,15 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".activities.TestEditView"> tools:context=".activities.TestEditView">
<gr.thmmy.mthmmy.utils.EditorView <gr.thmmy.mthmmy.utils.EditorView
android:id="@+id/editor_view" android:id="@+id/editor_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true" /> android:layout_alignParentTop="true"
app:hint="Post message"/>
<gr.thmmy.mthmmy.utils.EmojiKeyboard <gr.thmmy.mthmmy.utils.EmojiKeyboard
android:id="@+id/emoji_keyboard" android:id="@+id/emoji_keyboard"

4
app/src/main/res/layout/editor_view.xml

@ -109,16 +109,16 @@
android:paddingRight="16dp"> android:paddingRight="16dp">
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:id="@+id/editor_edittext_wrapper"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<EditText <android.support.design.widget.TextInputEditText
android:id="@+id/editor_edittext" android:id="@+id/editor_edittext"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/quick_reply"
android:inputType="textMultiLine" /> android:inputType="textMultiLine" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>

4
app/src/main/res/values/attrs.xml

@ -3,4 +3,8 @@
<declare-styleable name="AutoFitGridLayout" > <declare-styleable name="AutoFitGridLayout" >
<attr name="columnWidth" format="dimension" /> <attr name="columnWidth" format="dimension" />
</declare-styleable> </declare-styleable>
<declare-styleable name="EditorView" >
<attr name="hint" format="string" />
</declare-styleable>
</resources> </resources>
Loading…
Cancel
Save