From b6bd67b7cfedffb401053ba209d74b0cc58092d3 Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Thu, 6 Sep 2018 16:09:52 +0300 Subject: [PATCH 1/2] colored letters and dot in color picker --- .../thmmy/mthmmy/editorview/EditorView.java | 7 +++- .../res/layout/editor_view_color_picker.xml | 42 ++++++++++++------- app/src/main/res/values/colors.xml | 21 ++++++++++ 3 files changed, 55 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java index a4ccc119..4e01856d 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java @@ -1,5 +1,6 @@ package gr.thmmy.mthmmy.editorview; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.AlertDialog; import android.content.Context; @@ -20,6 +21,7 @@ import android.view.inputmethod.InputMethodManager; import android.widget.LinearLayout; import android.widget.PopupWindow; import android.widget.ScrollView; +import android.widget.TextView; import java.util.Objects; @@ -50,6 +52,7 @@ public class EditorView extends LinearLayout { init(context, attrs); } + @SuppressLint("SetTextI18n") private void init(Context context, AttributeSet attrs) { LayoutInflater.from(context).inflate(R.layout.editor_view, this, true); setOrientation(VERTICAL); @@ -142,7 +145,9 @@ public class EditorView extends LinearLayout { LinearLayout colorPicker = (LinearLayout) colorPickerScrollview.getChildAt(0); popupWindow.setContentView(colorPickerScrollview); for (int i = 0; i < colorPicker.getChildCount(); i++) { - colorPicker.getChildAt(i).setOnClickListener(v -> { + TextView child = (TextView) colorPicker.getChildAt(i); + child.setText("\u2B24 " + child.getText()); + child.setOnClickListener(v -> { boolean hadTextSelection = editText.hasSelection(); getText().insert(editText.getSelectionStart(), "[color=" + colors.get(v.getId()) + "]"); getText().insert(editText.getSelectionEnd(), "[/color]"); diff --git a/app/src/main/res/layout/editor_view_color_picker.xml b/app/src/main/res/layout/editor_view_color_picker.xml index 0ac2d71b..b71214e1 100644 --- a/app/src/main/res/layout/editor_view_color_picker.xml +++ b/app/src/main/res/layout/editor_view_color_picker.xml @@ -13,71 +13,85 @@ + android:text="@string/black" + android:textColor="@color/black"/> + android:text="@string/red" + android:textColor="@color/red"/> + android:text="@string/yellow" + android:textColor="@color/yellow"/> + android:text="@string/pink" + android:textColor="@color/pink"/> + android:text="@string/green" + android:textColor="@color/green"/> + android:text="@string/orange" + android:textColor="@color/orange"/> + android:text="@string/purple" + android:textColor="@color/purple"/> + android:text="@string/blue" + android:textColor="@color/blue"/> + android:text="@string/beige" + android:textColor="@color/beige"/> + android:text="@string/brown" + android:textColor="@color/brown"/> + android:text="@string/teal" + android:textColor="@color/teal"/> + android:text="@string/navy" + android:textColor="@color/navy"/> + android:text="@string/maroon" + android:textColor="@color/maroon"/> + android:text="@string/lime_green" + android:textColor="@color/lime_green"/> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c3bdac7a..f2209027 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -26,4 +26,25 @@ #D92B2B2B #E91E63 @color/primary_text + + #FF0000 + #800000 + #A52A2A + #FFA500 + #FFFF00 + #808000 + #008000 + #800080 + #FF00FF + #FFC0CB + #F5F5DC + #00FF00 + #32CD32 + #008080 + #00FFFF + #0000FF + #000080 + #000000 + #808080 + #C0C0C0 From 9333b5d2b9bf306a458ff3251bd5c17afee4713d Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Thu, 6 Sep 2018 18:44:34 +0300 Subject: [PATCH 2/2] no dots --- app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java index 4e01856d..44b649a9 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java +++ b/app/src/main/java/gr/thmmy/mthmmy/editorview/EditorView.java @@ -146,7 +146,6 @@ public class EditorView extends LinearLayout { popupWindow.setContentView(colorPickerScrollview); for (int i = 0; i < colorPicker.getChildCount(); i++) { TextView child = (TextView) colorPicker.getChildAt(i); - child.setText("\u2B24 " + child.getText()); child.setOnClickListener(v -> { boolean hadTextSelection = editText.hasSelection(); getText().insert(editText.getSelectionStart(), "[color=" + colors.get(v.getId()) + "]");