From ead041fea6ed39c867b2a4b1c6a857b726ebc559 Mon Sep 17 00:00:00 2001 From: Janne Koschinski <janne@kuschku.de> Date: Thu, 8 Mar 2018 16:37:42 +0100 Subject: [PATCH] Improved autocomplete --- .../util/ui/AutoCompleteRecyclerView.kt | 24 +++++++++++++++++++ app/src/main/res/layout-land/layout_main.xml | 8 ++++++- .../res/layout-sw600dp-land/layout_main.xml | 21 ++++++++++++---- app/src/main/res/layout/layout_editor.xml | 3 +-- app/src/main/res/layout/layout_main.xml | 6 ++--- app/src/main/res/values/dimens.xml | 2 ++ 6 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/de/kuschku/quasseldroid_ng/util/ui/AutoCompleteRecyclerView.kt diff --git a/app/src/main/java/de/kuschku/quasseldroid_ng/util/ui/AutoCompleteRecyclerView.kt b/app/src/main/java/de/kuschku/quasseldroid_ng/util/ui/AutoCompleteRecyclerView.kt new file mode 100644 index 000000000..b6aece069 --- /dev/null +++ b/app/src/main/java/de/kuschku/quasseldroid_ng/util/ui/AutoCompleteRecyclerView.kt @@ -0,0 +1,24 @@ +package de.kuschku.quasseldroid_ng.util.ui + +import android.content.Context +import android.support.v7.widget.RecyclerView +import android.util.AttributeSet +import de.kuschku.quasseldroid_ng.R + +class AutoCompleteRecyclerView : RecyclerView { + constructor(context: Context?) : super(context) + constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) + constructor(context: Context?, attrs: AttributeSet?, defStyle: Int) : super( + context, attrs, defStyle + ) + + override fun onMeasure(widthSpec: Int, heightSpec: Int) { + super.onMeasure( + widthSpec, + MeasureSpec.makeMeasureSpec( + resources.getDimensionPixelSize(R.dimen.autocomplete_max_height), + MeasureSpec.AT_MOST + ) + ) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout-land/layout_main.xml b/app/src/main/res/layout-land/layout_main.xml index d02f4ac54..63319cf23 100644 --- a/app/src/main/res/layout-land/layout_main.xml +++ b/app/src/main/res/layout-land/layout_main.xml @@ -23,8 +23,14 @@ android:id="@+id/fragment_messages" android:name="de.kuschku.quasseldroid_ng.ui.chat.messages.MessageListFragment" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="0dip" + android:layout_weight="1" tools:layout="@layout/fragment_messages" /> + + <de.kuschku.quasseldroid_ng.util.ui.AutoCompleteRecyclerView + android:id="@+id/autocomplete_list" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> </LinearLayout> <include layout="@layout/layout_slider" /> diff --git a/app/src/main/res/layout-sw600dp-land/layout_main.xml b/app/src/main/res/layout-sw600dp-land/layout_main.xml index 9ec10cd07..11679ffe1 100644 --- a/app/src/main/res/layout-sw600dp-land/layout_main.xml +++ b/app/src/main/res/layout-sw600dp-land/layout_main.xml @@ -19,12 +19,25 @@ app:umanoScrollableView="@id/chatline_scroller" app:umanoShadowHeight="4dp"> - <fragment - android:id="@+id/fragment_messages" - android:name="de.kuschku.quasseldroid_ng.ui.chat.messages.MessageListFragment" + <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" - tools:layout="@layout/fragment_messages" /> + android:orientation="vertical"> + + <fragment + android:id="@+id/fragment_messages" + android:name="de.kuschku.quasseldroid_ng.ui.chat.messages.MessageListFragment" + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_weight="1" + tools:layout="@layout/fragment_messages" /> + + <de.kuschku.quasseldroid_ng.util.ui.AutoCompleteRecyclerView + android:id="@+id/autocomplete_list" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + </LinearLayout> <include layout="@layout/layout_slider" /> diff --git a/app/src/main/res/layout/layout_editor.xml b/app/src/main/res/layout/layout_editor.xml index 401e59074..c98d34570 100644 --- a/app/src/main/res/layout/layout_editor.xml +++ b/app/src/main/res/layout/layout_editor.xml @@ -46,11 +46,10 @@ app:layout_constraintEnd_toEndOf="parent" app:srcCompat="@drawable/ic_send" /> - <android.support.v7.widget.RecyclerView + <de.kuschku.quasseldroid_ng.util.ui.AutoCompleteRecyclerView android:id="@+id/autocomplete_list2" android:layout_width="match_parent" android:layout_height="wrap_content" - android:maxHeight="144dp" app:layout_constraintBottom_toTopOf="@+id/formatting_toolbar_container" /> <android.support.design.widget.AppBarLayout diff --git a/app/src/main/res/layout/layout_main.xml b/app/src/main/res/layout/layout_main.xml index 9c856a9a8..be36a2487 100644 --- a/app/src/main/res/layout/layout_main.xml +++ b/app/src/main/res/layout/layout_main.xml @@ -32,12 +32,10 @@ android:layout_weight="1" tools:layout="@layout/fragment_messages" /> - <android.support.v7.widget.RecyclerView + <de.kuschku.quasseldroid_ng.util.ui.AutoCompleteRecyclerView android:id="@+id/autocomplete_list" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:maxHeight="144dp" /> - + android:layout_height="wrap_content" /> </LinearLayout> <include layout="@layout/layout_slider" /> diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 03012d411..21fb8ab65 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -3,4 +3,6 @@ <dimen name="message_horizontal">8dp</dimen> <dimen name="message_vertical">2dp</dimen> + + <dimen name="autocomplete_max_height">96dp</dimen> </resources> -- GitLab