Browse Source

fixes: color picker scrollbar, correct viewholder update on backpress with emoji keyboard visible

pull/45/head
Thodoris1999 6 years ago
parent
commit
3aced6ac9c
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 6
      app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java
  3. 98
      app/src/main/res/layout/editor_view_color_picker.xml

2
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -264,7 +264,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
if (viewModel.isEditingPost())
topicAdapter.notifyItemChanged(viewModel.getPostBeingEditedPosition());
if (viewModel.isWritingReply())
topicAdapter.notifyItemChanged(viewModel.postCount() - 1);
topicAdapter.notifyItemChanged(viewModel.postCount());
return;
} else if (viewModel.isWritingReply()) {
postsList.remove(postsList.size() - 1);

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

@ -19,6 +19,7 @@ import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.ScrollView;
import java.util.Objects;
@ -133,8 +134,9 @@ public class EditorView extends LinearLayout {
popupWindow.setHeight(LayoutParams.WRAP_CONTENT);
popupWindow.setWidth(LayoutParams.WRAP_CONTENT);
popupWindow.setFocusable(true);
LinearLayout colorPicker = (LinearLayout) LayoutInflater.from(context).inflate(R.layout.editor_view_color_picker, null);
popupWindow.setContentView(colorPicker);
ScrollView colorPickerScrollview = (ScrollView) LayoutInflater.from(context).inflate(R.layout.editor_view_color_picker, null);
LinearLayout colorPicker = (LinearLayout) colorPickerScrollview.getChildAt(0);
popupWindow.setContentView(colorPickerScrollview);
for (int i = 0; i < colorPicker.getChildCount(); i++) {
colorPicker.getChildAt(i).setOnClickListener(v -> {
if (editText.hasSelection())

98
app/src/main/res/layout/editor_view_color_picker.xml

@ -1,21 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView android:id="@+id/black" android:text="@string/black" style="@style/PopupMenuItem.TopItem"/>
<TextView android:id="@+id/red" android:text="@string/red" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/yellow" android:text="@string/yellow" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/pink" android:text="@string/pink" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/green" android:text="@string/green" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/orange" android:text="@string/orange" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/purple" android:text="@string/purple" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/blue" android:text="@string/blue" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/beige" android:text="@string/beige" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/brown" android:text="@string/brown" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/teal" android:text="@string/teal" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/navy" android:text="@string/navy" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/maroon" android:text="@string/maroon" style="@style/PopupMenuItem"/>
<TextView android:id="@+id/lime_green" android:text="@string/lime_green" style="@style/PopupMenuItem.BottomItem"/>
</LinearLayout>
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/black"
style="@style/PopupMenuItem.TopItem"
android:text="@string/black" />
<TextView
android:id="@+id/red"
style="@style/PopupMenuItem"
android:text="@string/red" />
<TextView
android:id="@+id/yellow"
style="@style/PopupMenuItem"
android:text="@string/yellow" />
<TextView
android:id="@+id/pink"
style="@style/PopupMenuItem"
android:text="@string/pink" />
<TextView
android:id="@+id/green"
style="@style/PopupMenuItem"
android:text="@string/green" />
<TextView
android:id="@+id/orange"
style="@style/PopupMenuItem"
android:text="@string/orange" />
<TextView
android:id="@+id/purple"
style="@style/PopupMenuItem"
android:text="@string/purple" />
<TextView
android:id="@+id/blue"
style="@style/PopupMenuItem"
android:text="@string/blue" />
<TextView
android:id="@+id/beige"
style="@style/PopupMenuItem"
android:text="@string/beige" />
<TextView
android:id="@+id/brown"
style="@style/PopupMenuItem"
android:text="@string/brown" />
<TextView
android:id="@+id/teal"
style="@style/PopupMenuItem"
android:text="@string/teal" />
<TextView
android:id="@+id/navy"
style="@style/PopupMenuItem"
android:text="@string/navy" />
<TextView
android:id="@+id/maroon"
style="@style/PopupMenuItem"
android:text="@string/maroon" />
<TextView
android:id="@+id/lime_green"
style="@style/PopupMenuItem.BottomItem"
android:text="@string/lime_green" />
</LinearLayout>
</ScrollView>
Loading…
Cancel
Save