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

Fix autocomplete, add topic editing, fix settings

parent a0b1eda7
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,9 @@ import android.os.Bundle
import android.os.PersistableBundle
import android.support.v4.widget.DrawerLayout
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.support.v7.widget.Toolbar
import android.text.Html
import android.view.*
......@@ -32,6 +35,7 @@ import de.kuschku.quasseldroid.persistence.AccountDatabase
import de.kuschku.quasseldroid.persistence.QuasselDatabase
import de.kuschku.quasseldroid.settings.MessageSettings
import de.kuschku.quasseldroid.settings.Settings
import de.kuschku.quasseldroid.ui.chat.input.AutoCompleteAdapter
import de.kuschku.quasseldroid.ui.chat.input.ChatlineFragment
import de.kuschku.quasseldroid.ui.clientsettings.app.AppSettingsActivity
import de.kuschku.quasseldroid.ui.coresettings.CoreSettingsActivity
......@@ -58,6 +62,9 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
@BindView(R.id.editor_panel)
lateinit var editorPanel: SlidingUpPanelLayout
@BindView(R.id.autocomplete_list)
lateinit var autoCompleteList: RecyclerView
@Inject
lateinit var database: QuasselDatabase
......@@ -127,6 +134,18 @@ class ChatActivity : ServiceBoundActivity(), SharedPreferences.OnSharedPreferenc
}
})
if (autoCompleteSettings.prefix || autoCompleteSettings.auto) {
chatlineFragment?.let {
val autocompleteAdapter = AutoCompleteAdapter(messageSettings, it.chatline::autoComplete)
autoCompleteList.layoutManager = LinearLayoutManager(it.activity)
autoCompleteList.itemAnimator = DefaultItemAnimator()
autoCompleteList.adapter = autocompleteAdapter
it.autoCompleteHelper.setDataListener {
autocompleteAdapter.submitList(it)
}
}
}
viewModel.errors.observe(this, Observer { error ->
error?.let {
when (it) {
......
......@@ -48,6 +48,9 @@ class ChatlineFragment : ServiceBoundFragment() {
@BindView(R.id.history_panel)
lateinit var historyPanel: SlidingUpPanelLayout
@BindView(R.id.autocomplete_list_expanded)
lateinit var autoCompleteList: RecyclerView
@Inject
lateinit var autoCompleteSettings: AutoCompleteSettings
......@@ -65,6 +68,8 @@ class ChatlineFragment : ServiceBoundFragment() {
lateinit var editorHelper: EditorHelper
lateinit var autoCompleteHelper: AutoCompleteHelper
val panelSlideListener = object : SlidingUpPanelLayout.PanelSlideListener {
override fun onPanelSlide(panel: View?, slideOffset: Float) = Unit
......@@ -84,7 +89,7 @@ class ChatlineFragment : ServiceBoundFragment() {
val editorViewModel = ViewModelProviders.of(this).get(EditorViewModel::class.java)
editorViewModel.quasselViewModel.onNext(viewModel)
val autoCompleteHelper = AutoCompleteHelper(
autoCompleteHelper = AutoCompleteHelper(
requireActivity(),
autoCompleteSettings,
messageSettings,
......@@ -104,15 +109,12 @@ class ChatlineFragment : ServiceBoundFragment() {
editorViewModel.lastWord.onNext(editorHelper.lastWord)
if (autoCompleteSettings.prefix || autoCompleteSettings.auto) {
val autoCompleteLists = listOfNotNull<RecyclerView>(
view.findViewById(R.id.autocomplete_list),
view.findViewById(R.id.autocomplete_list_expanded)
)
val autocompleteAdapter = AutoCompleteAdapter(messageSettings, chatline::autoComplete)
for (autoCompleteList in autoCompleteLists) {
autoCompleteList.layoutManager = LinearLayoutManager(activity)
autoCompleteList.itemAnimator = DefaultItemAnimator()
autoCompleteList.adapter = autocompleteAdapter
autoCompleteHelper.setDataListener {
autocompleteAdapter.submitList(it)
}
}
......
......@@ -31,6 +31,9 @@ class TopicFragment : SettingsFragment() {
@BindView(R.id.formatting_toolbar)
lateinit var toolbar: RichToolbar
@BindView(R.id.autocomplete_list_expanded)
lateinit var autoCompleteList: RecyclerView
@Inject
lateinit var autoCompleteSettings: AutoCompleteSettings
......@@ -76,18 +79,15 @@ class TopicFragment : SettingsFragment() {
editorViewModel.lastWord.onNext(editorHelper.lastWord)
if (autoCompleteSettings.prefix || autoCompleteSettings.auto) {
val autoCompleteLists = listOfNotNull<RecyclerView>(
view.findViewById(R.id.autocomplete_list)
)
val autocompleteAdapter = AutoCompleteAdapter(messageSettings, chatline::autoComplete)
for (autoCompleteList in autoCompleteLists) {
autoCompleteList.layoutManager = LinearLayoutManager(activity)
autoCompleteList.itemAnimator = DefaultItemAnimator()
autoCompleteList.adapter = autocompleteAdapter
autoCompleteHelper.setDataListener {
autocompleteAdapter.submitList(it)
}
}
val bufferId = arguments?.getInt("buffer", -1) ?: -1
viewModel.buffer.onNext(bufferId)
viewModel.bufferData.filter {
......
......@@ -43,7 +43,7 @@
<string name="preference_show_prefix_entry_highest">Höchsten Modus</string>
<string name="preference_show_prefix_entry_none">Keine</string>
<string name="preference_hostmask_actions_title">Hostmaske</string>
<string name="preference_hostmask_actions_title">Hostmaske in Aktionen</string>
<string name="preference_hostmask_actions_summary">Zeigt Ident und Host in Betreten/Verlassen-Nachrichten</string>
<string name="preference_hostmask_plain_title">Hostmaske</string>
......
......@@ -99,8 +99,8 @@
<item>NONE</item>
</string-array>
<string name="preference_hostmask_actions_key" translatable="false">hostmaskactions_</string>
<string name="preference_hostmask_actions_title">Show Hostmask</string>
<string name="preference_hostmask_actions_key" translatable="false">hostmask_actions</string>
<string name="preference_hostmask_actions_title">Show Hostmask in actions</string>
<string name="preference_hostmask_actions_summary">Display the full nick!ident@host in join/part/quit messages</string>
<string name="preference_hostmask_plain_key" translatable="false">hostmask_plain</string>
......
......@@ -84,11 +84,13 @@
android:defaultValue="false"
android:dependency="@string/preference_nicks_on_new_line_key"
android:key="@string/preference_hostmask_plain_key"
android:summary="@string/preference_hostmask_plain_summary"
android:title="@string/preference_hostmask_plain_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/preference_hostmask_actions_key"
android:summary="@string/preference_hostmask_actions_summary"
android:title="@string/preference_hostmask_actions_title" />
<SwitchPreference
......
......@@ -207,6 +207,32 @@ class BufferSyncer constructor(
live_highlightCounts.onNext(_highlightCounts)
}
fun all(
bufferName: String? = null,
bufferId: BufferId? = null,
networkId: NetworkId? = null,
type: Buffer_Types? = null,
groupId: Int? = null
) = _bufferInfos.values.filter {
bufferId == null || it.bufferId == bufferId
}.filter {
networkId == null || it.networkId == networkId
}.filter {
type == null || it.type == type
}.filter {
groupId == null || it.groupId == groupId
}.filter {
bufferName == null || it.bufferName == bufferName
}
fun find(
bufferName: String? = null,
bufferId: BufferId? = null,
networkId: NetworkId? = null,
type: Buffer_Types? = null,
groupId: Int? = null
) = all(bufferName, bufferId, networkId, type, groupId).firstOrNull()
private val _lastSeenMsg: MutableMap<BufferId, MsgId> = mutableMapOf()
private val live_lastSeenMsg = BehaviorSubject.createDefault(mapOf<BufferId, MsgId>())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment