Improvements to contacts handling

Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
Mario Danic 2020-01-29 09:13:00 +01:00
parent 618bcf5790
commit 8a3bd19d3b
No known key found for this signature in database
GPG Key ID: CDE0BBD2738C4CC0
5 changed files with 18 additions and 9 deletions

View File

@ -182,7 +182,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
private fun openNewConversationScreen() { private fun openNewConversationScreen() {
router?.pushController( router?.pushController(
RouterTransaction.with(ContactsView<Any>()) RouterTransaction.with(ContactsView())
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler()) .popChangeHandler(HorizontalChangeHandler())
) )

View File

@ -66,6 +66,7 @@ import com.nextcloud.talk.models.json.converters.EnumNotificationLevelConverter
import com.nextcloud.talk.models.json.generic.GenericOverall import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.models.json.participants.Participant import com.nextcloud.talk.models.json.participants.Participant
import com.nextcloud.talk.models.json.participants.ParticipantsOverall import com.nextcloud.talk.models.json.participants.ParticipantsOverall
import com.nextcloud.talk.newarch.features.contactsflow.ContactsView
import com.nextcloud.talk.newarch.local.models.UserNgEntity import com.nextcloud.talk.newarch.local.models.UserNgEntity
import com.nextcloud.talk.newarch.local.models.getCredentials import com.nextcloud.talk.newarch.local.models.getCredentials
import com.nextcloud.talk.newarch.utils.Images import com.nextcloud.talk.newarch.utils.Images
@ -501,10 +502,10 @@ class ConversationInfoController(args: Bundle) : BaseController(),
adapter!!.addListener(this) adapter!!.addListener(this)
actionTextView.setOnClickListener { actionTextView.setOnClickListener {
val bundle = Bundle() val bundle = Bundle()
bundle.putString(BundleKeys.KEY_TOKEN, conversation!!.token) bundle.putString(BundleKeys.KEY_CONVERSATION_TOKEN, conversation!!.token)
router.pushController( router.pushController(
(RouterTransaction.with(ContactsController(bundle)) (RouterTransaction.with(ContactsView(bundle))
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())) .popChangeHandler(HorizontalChangeHandler()))
) )

View File

@ -55,7 +55,7 @@ import kotlinx.android.synthetic.main.search_layout.*
import kotlinx.android.synthetic.main.search_layout.view.* import kotlinx.android.synthetic.main.search_layout.view.*
import org.koin.android.ext.android.inject import org.koin.android.ext.android.inject
class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() { class ContactsView(private val bundle: Bundle? = null) : BaseView() {
override val scopeProvider: LifecycleScopeProvider<*> = ControllerScopeProvider.from(this) override val scopeProvider: LifecycleScopeProvider<*> = ControllerScopeProvider.from(this)
private lateinit var viewModel: ContactsViewModel private lateinit var viewModel: ContactsViewModel
@ -153,7 +153,6 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
operationState.observe(this@ContactsView) { operationState -> operationState.observe(this@ContactsView) { operationState ->
when (operationState.operationState) { when (operationState.operationState) {
ContactsViewOperationState.OK -> { ContactsViewOperationState.OK -> {
searchLayout?.searchProgressBar?.isVisible = true
val bundle = Bundle() val bundle = Bundle()
if (!hasToken || isNewGroupConversation) { if (!hasToken || isNewGroupConversation) {
bundle.putString(BundleKeys.KEY_CONVERSATION_TOKEN, operationState.conversationToken) bundle.putString(BundleKeys.KEY_CONVERSATION_TOKEN, operationState.conversationToken)
@ -167,6 +166,7 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
} }
ContactsViewOperationState.PROCESSING -> { ContactsViewOperationState.PROCESSING -> {
searchLayout?.searchProgressBar?.isVisible = true searchLayout?.searchProgressBar?.isVisible = true
floatingActionButton?.isVisible = false
} }
ContactsViewOperationState.CONVERSATION_CREATION_FAILED -> { ContactsViewOperationState.CONVERSATION_CREATION_FAILED -> {
// dunno what to do yet, an error message somewhere // dunno what to do yet, an error message somewhere
@ -187,6 +187,7 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
override fun onAttach(view: View) { override fun onAttach(view: View) {
super.onAttach(view) super.onAttach(view)
searchLayout?.settingsButton?.isVisible = false searchLayout?.settingsButton?.isVisible = false
floatingActionButton?.isVisible = selectedParticipantsAdapter.itemCount > 0
} }
private fun toggleSelectedParticipantsViewVisibility() { private fun toggleSelectedParticipantsViewVisibility() {
@ -194,7 +195,7 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
view?.divider?.isVisible = selectedParticipantsAdapter.itemCount > 0 view?.divider?.isVisible = selectedParticipantsAdapter.itemCount > 0
} }
private fun onElementClick(page: Page, holder: Presenter.Holder, element: Element<T>) { private fun onElementClick(page: Page, holder: Presenter.Holder, element: Element<Any>) {
if (element.data is Participant?) { if (element.data is Participant?) {
val participant = element.data as Participant? val participant = element.data as Participant?
@ -239,6 +240,12 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
} }
} }
override fun onDestroyView(view: View) {
super.onDestroyView(view)
activity?.inputEditText?.text = null
searchLayout?.searchProgressBar?.isVisible = false
}
override fun getAppBarLayoutType(): AppBarLayoutType { override fun getAppBarLayoutType(): AppBarLayoutType {
return AppBarLayoutType.SEARCH_BAR return AppBarLayoutType.SEARCH_BAR
} }

View File

@ -38,4 +38,6 @@ class FixedListSource(list: List<Any>, elementType: Int) : ListSource<Any>(list,
override fun dependsOn(source: Source<*>): Boolean { override fun dependsOn(source: Source<*>): Boolean {
return source is ContactsViewSource return source is ContactsViewSource
} }
} }

View File

@ -228,9 +228,8 @@ class ConversationsListView : BaseView() {
private fun openNewConversationScreen() { private fun openNewConversationScreen() {
val bundle = Bundle() val bundle = Bundle()
bundle.putBoolean(BundleKeys.KEY_NEW_CONVERSATION, true)
router.pushController( router.pushController(
RouterTransaction.with(ContactsController(bundle)) RouterTransaction.with(ContactsView())
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())) .popChangeHandler(HorizontalChangeHandler()))
} }
@ -287,7 +286,7 @@ class ConversationsListView : BaseView() {
override fun onFloatingActionButtonClick() { override fun onFloatingActionButtonClick() {
router?.pushController( router?.pushController(
RouterTransaction.with(ContactsView<Any>()) RouterTransaction.with(ContactsView())
.pushChangeHandler(HorizontalChangeHandler()) .pushChangeHandler(HorizontalChangeHandler())
.popChangeHandler(HorizontalChangeHandler())) .popChangeHandler(HorizontalChangeHandler()))
} }