mirror of
https://github.com/oxen-io/session-android.git
synced 2023-12-14 02:53:01 +01:00
c113a447cf
* refactor: Migrate home screen to data binding * Add view binding * Migrate ConversationView to view binding * Migrate ConversationActivityV2 to view binding * View model refactor * Move more functionality to the view model * Add ui state events flow * Update conversation item bindings * Update profile picture view bindings * Replace Kotlin synthetics with view bindings * Fix qr code fragment binding and optimize imports * View binding refactors * Make TextSecurePreferences an interface and add an implementation to improve testability * Add conversation repository * Migrate remaining TextSecurePreferences functions into the interface * Add unit conversation unit tests * Add unit test coverage for remaining view model functions
63 lines
2.1 KiB
Kotlin
63 lines
2.1 KiB
Kotlin
package org.thoughtcrime.securesms.conversation.v2.search
|
|
|
|
import android.content.Context
|
|
import android.util.AttributeSet
|
|
import android.view.LayoutInflater
|
|
import android.view.View
|
|
import android.widget.LinearLayout
|
|
import network.loki.messenger.R
|
|
import network.loki.messenger.databinding.ViewSearchBottomBarBinding
|
|
|
|
|
|
class SearchBottomBar : LinearLayout {
|
|
private lateinit var binding: ViewSearchBottomBarBinding
|
|
private var eventListener: EventListener? = null
|
|
|
|
// region Lifecycle
|
|
constructor(context: Context) : super(context) { initialize() }
|
|
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() }
|
|
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() }
|
|
|
|
fun initialize() {
|
|
binding = ViewSearchBottomBarBinding.inflate(LayoutInflater.from(context), this, true)
|
|
}
|
|
|
|
fun setData(position: Int, count: Int) = with(binding) {
|
|
searchProgressWheel.visibility = GONE
|
|
searchUp.setOnClickListener { v: View? ->
|
|
if (eventListener != null) {
|
|
eventListener!!.onSearchMoveUpPressed()
|
|
}
|
|
}
|
|
searchDown.setOnClickListener { v: View? ->
|
|
if (eventListener != null) {
|
|
eventListener!!.onSearchMoveDownPressed()
|
|
}
|
|
}
|
|
if (count > 0) {
|
|
searchPosition.text = resources.getString(R.string.ConversationActivity_search_position, position + 1, count)
|
|
} else {
|
|
searchPosition.text = ""
|
|
}
|
|
setViewEnabled(searchUp, position < count - 1)
|
|
setViewEnabled(searchDown, position > 0)
|
|
}
|
|
|
|
fun showLoading() {
|
|
binding.searchProgressWheel.visibility = VISIBLE
|
|
}
|
|
|
|
private fun setViewEnabled(view: View, enabled: Boolean) {
|
|
view.isEnabled = enabled
|
|
view.alpha = if (enabled) 1f else 0.25f
|
|
}
|
|
|
|
fun setEventListener(eventListener: EventListener?) {
|
|
this.eventListener = eventListener
|
|
}
|
|
|
|
interface EventListener {
|
|
fun onSearchMoveUpPressed()
|
|
fun onSearchMoveDownPressed()
|
|
}
|
|
} |