Skip to content
Snippets Groups Projects
Verified Commit a60f920a authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Replace old autocomplete code

parent 32784eb3
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -21,6 +21,7 @@ package de.kuschku.quasseldroid.ui.chat.topic ...@@ -21,6 +21,7 @@ package de.kuschku.quasseldroid.ui.chat.topic
import android.arch.lifecycle.Observer import android.arch.lifecycle.Observer
import android.os.Bundle import android.os.Bundle
import android.support.design.widget.BottomSheetBehavior
import android.support.v7.widget.DefaultItemAnimator import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
...@@ -102,11 +103,15 @@ class TopicFragment : SettingsFragment(), SettingsFragment.Savable { ...@@ -102,11 +103,15 @@ class TopicFragment : SettingsFragment(), SettingsFragment.Savable {
editorViewModel.lastWord.onNext(editorHelper.lastWord) editorViewModel.lastWord.onNext(editorHelper.lastWord)
if (autoCompleteSettings.prefix || autoCompleteSettings.auto) { if (autoCompleteSettings.prefix || autoCompleteSettings.auto) {
val autoCompleteBottomSheet = BottomSheetBehavior.from(autoCompleteList)
autoCompleteAdapter.setOnClickListener(chatline::autoComplete) autoCompleteAdapter.setOnClickListener(chatline::autoComplete)
autoCompleteList.layoutManager = LinearLayoutManager(activity) autoCompleteList.layoutManager = LinearLayoutManager(activity)
autoCompleteList.itemAnimator = DefaultItemAnimator() autoCompleteList.itemAnimator = DefaultItemAnimator()
autoCompleteList.adapter = autoCompleteAdapter autoCompleteList.adapter = autoCompleteAdapter
autoCompleteHelper.addDataListener { autoCompleteHelper.addDataListener {
autoCompleteBottomSheet.state =
if (it.isEmpty()) BottomSheetBehavior.STATE_HIDDEN
else BottomSheetBehavior.STATE_COLLAPSED
autoCompleteAdapter.submitList(it) autoCompleteAdapter.submitList(it)
} }
} }
......
...@@ -22,6 +22,7 @@ package de.kuschku.quasseldroid.ui.coresettings.aliasitem ...@@ -22,6 +22,7 @@ package de.kuschku.quasseldroid.ui.coresettings.aliasitem
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.os.Bundle import android.os.Bundle
import android.support.design.widget.BottomSheetBehavior
import android.support.v7.widget.DefaultItemAnimator import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.LinearLayoutManager import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView import android.support.v7.widget.RecyclerView
...@@ -115,11 +116,15 @@ class AliasItemFragment : SettingsFragment(), SettingsFragment.Savable, ...@@ -115,11 +116,15 @@ class AliasItemFragment : SettingsFragment(), SettingsFragment.Savable,
editorViewModel.lastWord.onNext(editorHelper.lastWord) editorViewModel.lastWord.onNext(editorHelper.lastWord)
if (autoCompleteSettings.prefix || autoCompleteSettings.auto) { if (autoCompleteSettings.prefix || autoCompleteSettings.auto) {
val autoCompleteBottomSheet = BottomSheetBehavior.from(autoCompleteList)
autoCompleteAdapter.setOnClickListener(expansion::autoComplete) autoCompleteAdapter.setOnClickListener(expansion::autoComplete)
autoCompleteList.layoutManager = LinearLayoutManager(activity) autoCompleteList.layoutManager = LinearLayoutManager(activity)
autoCompleteList.itemAnimator = DefaultItemAnimator() autoCompleteList.itemAnimator = DefaultItemAnimator()
autoCompleteList.adapter = autoCompleteAdapter autoCompleteList.adapter = autoCompleteAdapter
autoCompleteHelper.addDataListener { autoCompleteHelper.addDataListener {
autoCompleteBottomSheet.state =
if (it.isEmpty()) BottomSheetBehavior.STATE_HIDDEN
else BottomSheetBehavior.STATE_COLLAPSED
autoCompleteAdapter.submitList(it) autoCompleteAdapter.submitList(it)
} }
} }
......
/*
* Quasseldroid - Quassel client for Android
*
* Copyright (c) 2018 Janne Koschinski
* Copyright (c) 2018 The Quassel Project
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 as published
* by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.kuschku.quasseldroid.util.ui
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.util.AttributeSet
import de.kuschku.quasseldroid.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
)
)
}
}
...@@ -25,12 +25,16 @@ ...@@ -25,12 +25,16 @@
android:minHeight="240dp" android:minHeight="240dp"
android:orientation="vertical"> android:orientation="vertical">
<ScrollView <android.support.design.widget.CoordinatorLayout
android:id="@+id/chatline_scroller"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="0dip"
android:layout_weight="1"> android:layout_weight="1">
<ScrollView
android:id="@+id/chatline_scroller"
android:layout_width="match_parent"
android:layout_height="match_parent">
<de.kuschku.quasseldroid.ui.chat.input.RichEditText <de.kuschku.quasseldroid.ui.chat.input.RichEditText
android:id="@+id/chatline" android:id="@+id/chatline"
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -49,12 +53,18 @@ ...@@ -49,12 +53,18 @@
android:textSize="16sp" /> android:textSize="16sp" />
</ScrollView> </ScrollView>
<de.kuschku.quasseldroid.util.ui.AutoCompleteRecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/autocomplete_list" android:id="@+id/autocomplete_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?colorBackgroundCard"
app:behavior_hideable="true"
app:behavior_peekHeight="@dimen/autocomplete_max_height"
app:layout_behavior="@string/bottom_sheet_behavior"
tools:listitem="@layout/widget_nick" /> tools:listitem="@layout/widget_nick" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -30,6 +30,11 @@ ...@@ -30,6 +30,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<LinearLayout style="@style/Widget.CoreSettings.Wrapper"> <LinearLayout style="@style/Widget.CoreSettings.Wrapper">
<LinearLayout <LinearLayout
...@@ -51,8 +56,7 @@ ...@@ -51,8 +56,7 @@
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="0dip" android:layout_height="match_parent">
android:layout_weight="1">
<LinearLayout style="@style/Widget.CoreSettings.Wrapper"> <LinearLayout style="@style/Widget.CoreSettings.Wrapper">
...@@ -71,12 +75,18 @@ ...@@ -71,12 +75,18 @@
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
<de.kuschku.quasseldroid.util.ui.AutoCompleteRecyclerView <android.support.v7.widget.RecyclerView
android:id="@+id/autocomplete_list" android:id="@+id/autocomplete_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?colorBackgroundCard"
app:behavior_hideable="true"
app:behavior_peekHeight="@dimen/autocomplete_max_height"
app:layout_behavior="@string/bottom_sheet_behavior"
tools:listitem="@layout/widget_nick" /> tools:listitem="@layout/widget_nick" />
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment