diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index bacda5cf3..a5e8cf247 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -218,6 +218,10 @@
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
+
+
?)
}
- binding?.controllerGenericRv?.swipeRefreshLayout?.isEnabled = !adapter!!.hasFilter()
+ binding.controllerGenericRv?.swipeRefreshLayout?.isEnabled = !adapter!!.hasFilter()
return true
}
@@ -877,6 +884,11 @@ class ContactsActivity :
prepareAndShowBottomSheetWithBundle(bundle)
}
+ private fun listOpenConversations() {
+ val intent = Intent(this, ListOpenConversationsActivity::class.java)
+ startActivity(intent)
+ }
+
private fun toggleCallHeader() {
toggleConversationPrivacyLayout(isPublicCall)
isPublicCall = !isPublicCall
@@ -917,25 +929,25 @@ class ContactsActivity :
private fun toggleConversationPrivacyLayout(showInitialLayout: Boolean) {
if (showInitialLayout) {
- binding?.conversationPrivacyToggle?.initialRelativeLayout?.visibility = View.VISIBLE
- binding?.conversationPrivacyToggle?.secondaryRelativeLayout?.visibility = View.GONE
+ binding.initialRelativeLayout.visibility = View.VISIBLE
+ binding.secondaryRelativeLayout.visibility = View.GONE
} else {
- binding?.conversationPrivacyToggle?.initialRelativeLayout?.visibility = View.GONE
- binding?.conversationPrivacyToggle?.secondaryRelativeLayout?.visibility = View.VISIBLE
+ binding.initialRelativeLayout.visibility = View.GONE
+ binding.secondaryRelativeLayout.visibility = View.VISIBLE
}
}
private fun toggleConversationViaLinkVisibility(isPublicCall: Boolean) {
if (isPublicCall) {
- binding?.joinConversationViaLink?.joinConversationViaLinkRelativeLayout?.visibility = View.GONE
+ binding.joinConversationViaLink.visibility = View.GONE
updateGroupParticipantSelection()
} else {
- binding?.joinConversationViaLink?.joinConversationViaLinkRelativeLayout?.visibility = View.VISIBLE
+ binding.joinConversationViaLink.visibility = View.VISIBLE
}
}
companion object {
- const val TAG = "ContactsController"
+ private val TAG = ContactsActivity::class.simpleName
const val RETRIES: Long = 3
const val CONTACTS_BATCH_SIZE: Int = 50
const val HEADER_ELEVATION: Int = 5
diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt b/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt
index 8ac104d1c..b76ad0c0b 100644
--- a/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt
+++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt
@@ -31,6 +31,8 @@ import com.nextcloud.talk.data.storage.ArbitraryStoragesRepository
import com.nextcloud.talk.data.storage.ArbitraryStoragesRepositoryImpl
import com.nextcloud.talk.data.user.UsersRepository
import com.nextcloud.talk.data.user.UsersRepositoryImpl
+import com.nextcloud.talk.openconversations.data.OpenConversationsRepository
+import com.nextcloud.talk.openconversations.data.OpenConversationsRepositoryImpl
import com.nextcloud.talk.polls.repositories.PollRepository
import com.nextcloud.talk.polls.repositories.PollRepositoryImpl
import com.nextcloud.talk.raisehand.RequestAssistanceRepository
@@ -110,6 +112,12 @@ class RepositoryModule {
return RequestAssistanceRepositoryImpl(ncApi, userProvider)
}
+ @Provides
+ fun provideOpenConversationsRepository(ncApi: NcApi, userProvider: CurrentUserProviderNew):
+ OpenConversationsRepository {
+ return OpenConversationsRepositoryImpl(ncApi, userProvider)
+ }
+
@Provides
fun translateRepository(ncApi: NcApi):
TranslateRepository {
diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/ViewModelModule.kt b/app/src/main/java/com/nextcloud/talk/dagger/modules/ViewModelModule.kt
index 55bf44321..44a5a6f8a 100644
--- a/app/src/main/java/com/nextcloud/talk/dagger/modules/ViewModelModule.kt
+++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/ViewModelModule.kt
@@ -24,6 +24,7 @@ package com.nextcloud.talk.dagger.modules
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.nextcloud.talk.messagesearch.MessageSearchViewModel
+import com.nextcloud.talk.openconversations.viewmodels.OpenConversationsViewModel
import com.nextcloud.talk.polls.viewmodels.PollCreateViewModel
import com.nextcloud.talk.polls.viewmodels.PollMainViewModel
import com.nextcloud.talk.polls.viewmodels.PollResultsViewModel
@@ -107,4 +108,9 @@ abstract class ViewModelModule {
@IntoMap
@ViewModelKey(TranslateViewModel::class)
abstract fun translateViewModel(viewModel: TranslateViewModel): ViewModel
+
+ @Binds
+ @IntoMap
+ @ViewModelKey(OpenConversationsViewModel::class)
+ abstract fun openConversationsViewModelModel(viewModel: OpenConversationsViewModel): ViewModel
}
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/ListOpenConversationsActivity.kt b/app/src/main/java/com/nextcloud/talk/openconversations/ListOpenConversationsActivity.kt
new file mode 100644
index 000000000..5632831bf
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/ListOpenConversationsActivity.kt
@@ -0,0 +1,135 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations
+
+import android.content.Intent
+import android.graphics.drawable.ColorDrawable
+import android.os.Bundle
+import android.view.View
+import android.widget.Toast
+import androidx.lifecycle.ViewModelProvider
+import autodagger.AutoInjector
+import com.nextcloud.talk.R
+import com.nextcloud.talk.activities.BaseActivity
+import com.nextcloud.talk.api.NcApi
+import com.nextcloud.talk.application.NextcloudTalkApplication
+import com.nextcloud.talk.chat.ChatActivity
+import com.nextcloud.talk.databinding.ActivityOpenConversationsBinding
+import com.nextcloud.talk.openconversations.data.OpenConversation
+import com.nextcloud.talk.openconversations.viewmodels.OpenConversationsViewModel
+import com.nextcloud.talk.utils.bundle.BundleKeys
+import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
+import javax.inject.Inject
+
+@AutoInjector(NextcloudTalkApplication::class)
+class ListOpenConversationsActivity : BaseActivity() {
+
+ private lateinit var binding: ActivityOpenConversationsBinding
+
+ @Inject
+ lateinit var ncApi: NcApi
+
+ @Inject
+ lateinit var viewModelFactory: ViewModelProvider.Factory
+
+ @Inject
+ lateinit var userProvider: CurrentUserProviderNew
+
+ lateinit var openConversationsViewModel: OpenConversationsViewModel
+
+ lateinit var adapter: OpenConversationsAdapter
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
+
+ openConversationsViewModel = ViewModelProvider(this, viewModelFactory)[OpenConversationsViewModel::class.java]
+
+ openConversationsViewModel.fetchConversations()
+
+ binding = ActivityOpenConversationsBinding.inflate(layoutInflater)
+ setupActionBar()
+ setContentView(binding.root)
+ setupSystemColors()
+
+ val user = userProvider.currentUser.blockingGet()
+
+ adapter = OpenConversationsAdapter(user) { conversation -> adapterOnClick(conversation) }
+ binding.openConversationsRecyclerView.adapter = adapter
+
+ initObservers()
+ }
+
+ private fun adapterOnClick(conversation: OpenConversation) {
+ val user = userProvider.currentUser.blockingGet()
+
+ val bundle = Bundle()
+ bundle.putParcelable(BundleKeys.KEY_USER_ENTITY, user)
+ bundle.putString(BundleKeys.KEY_ROOM_TOKEN, conversation.roomToken)
+
+ val chatIntent = Intent(context, ChatActivity::class.java)
+ chatIntent.putExtras(bundle)
+ chatIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
+ startActivity(chatIntent)
+ }
+
+ private fun initObservers() {
+ openConversationsViewModel.viewState.observe(this) { state ->
+ when (state) {
+ is OpenConversationsViewModel.FetchConversationsStartState -> {
+ binding.openConversationsRecyclerView.visibility = View.GONE
+ binding.progressBarWrapper.visibility = View.VISIBLE
+ }
+ is OpenConversationsViewModel.FetchConversationsSuccessState -> {
+ binding.openConversationsRecyclerView.visibility = View.VISIBLE
+ binding.progressBarWrapper.visibility = View.GONE
+ adapter.submitList(state.conversations)
+ }
+ is OpenConversationsViewModel.FetchConversationsEmptyState -> {
+ binding.openConversationsRecyclerView.visibility = View.GONE
+ binding.progressBarWrapper.visibility = View.GONE
+
+ binding.emptyList.emptyListView.visibility = View.VISIBLE
+ binding.emptyList.emptyListViewHeadline.text = getString(R.string.nc_no_open_conversations_headline)
+ binding.emptyList.emptyListViewText.text = getString(R.string.nc_no_open_conversations_text)
+ binding.emptyList.emptyListIcon.setImageResource(R.drawable.baseline_info_24)
+ binding.emptyList.emptyListIcon.visibility = View.VISIBLE
+ binding.emptyList.emptyListViewText.visibility = View.VISIBLE
+ }
+ is OpenConversationsViewModel.FetchConversationsErrorState -> {
+ Toast.makeText(context, R.string.nc_common_error_sorry, Toast.LENGTH_LONG).show()
+ }
+ else -> {}
+ }
+ }
+ }
+
+ private fun setupActionBar() {
+ setSupportActionBar(binding.openConversationsToolbar)
+ binding.openConversationsToolbar.setNavigationOnClickListener {
+ onBackPressedDispatcher.onBackPressed()
+ }
+ supportActionBar?.setDisplayHomeAsUpEnabled(true)
+ supportActionBar?.setDisplayShowHomeEnabled(true)
+ supportActionBar?.setIcon(ColorDrawable(resources!!.getColor(R.color.transparent, null)))
+ viewThemeUtils.material.themeToolbar(binding.openConversationsToolbar)
+ }
+}
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/adapters/OpenConversationsAdapter.kt b/app/src/main/java/com/nextcloud/talk/openconversations/adapters/OpenConversationsAdapter.kt
new file mode 100644
index 000000000..79087c68b
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/adapters/OpenConversationsAdapter.kt
@@ -0,0 +1,84 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations
+
+import android.view.LayoutInflater
+import android.view.ViewGroup
+import androidx.recyclerview.widget.DiffUtil
+import androidx.recyclerview.widget.ListAdapter
+import androidx.recyclerview.widget.RecyclerView
+import com.nextcloud.talk.R
+import com.nextcloud.talk.data.user.model.User
+import com.nextcloud.talk.databinding.RvItemOpenConversationBinding
+import com.nextcloud.talk.extensions.loadUserAvatar
+import com.nextcloud.talk.openconversations.data.OpenConversation
+
+class OpenConversationsAdapter(val user: User, private val onClick: (OpenConversation) -> Unit) :
+ ListAdapter(ConversationsCallback) {
+
+ inner class OpenConversationsViewHolder(val itemBinding: RvItemOpenConversationBinding) :
+ RecyclerView.ViewHolder(itemBinding.root) {
+
+ var currentConversation: OpenConversation? = null
+
+ init {
+ itemBinding.root.setOnClickListener {
+ currentConversation?.let {
+ onClick(it)
+ }
+ }
+ }
+
+ fun bindItem(conversation: OpenConversation) {
+ currentConversation = conversation
+ itemBinding.nameText.text = conversation.displayName
+
+ // load avatar from server when https://github.com/nextcloud/spreed/issues/9600 is solved
+ // itemBinding.avatarView.loadUserAvatar(user, conversation.displayName, true, false)
+ itemBinding.avatarView.loadUserAvatar(R.drawable.ic_circular_group)
+ }
+ }
+
+ override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): OpenConversationsViewHolder {
+ return OpenConversationsViewHolder(
+ RvItemOpenConversationBinding.inflate(
+ LayoutInflater.from(parent.context),
+ parent,
+ false
+ )
+ )
+ }
+
+ override fun onBindViewHolder(holder: OpenConversationsViewHolder, position: Int) {
+ val conversation = getItem(position)
+ holder.bindItem(conversation)
+ }
+}
+
+object ConversationsCallback : DiffUtil.ItemCallback() {
+ override fun areItemsTheSame(oldItem: OpenConversation, newItem: OpenConversation): Boolean {
+ return oldItem == newItem
+ }
+
+ override fun areContentsTheSame(oldItem: OpenConversation, newItem: OpenConversation): Boolean {
+ return oldItem.roomId == newItem.roomId
+ }
+}
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/JoinConversationModel.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/JoinConversationModel.kt
new file mode 100644
index 000000000..1e0a885c5
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/JoinConversationModel.kt
@@ -0,0 +1,25 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.data
+
+data class JoinConversationModel(
+ var success: Boolean
+)
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversation.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversation.kt
new file mode 100644
index 000000000..3b277bed5
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversation.kt
@@ -0,0 +1,27 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.data
+
+data class OpenConversation(
+ var roomId: String,
+ var roomToken: String,
+ var displayName: String
+)
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsModel.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsModel.kt
new file mode 100644
index 000000000..e28c3c952
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsModel.kt
@@ -0,0 +1,25 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.data
+
+data class OpenConversationsModel(
+ var conversations: List
+)
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepository.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepository.kt
new file mode 100644
index 000000000..c6e5790af
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepository.kt
@@ -0,0 +1,28 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.data
+
+import io.reactivex.Observable
+
+interface OpenConversationsRepository {
+
+ fun fetchConversations(): Observable
+}
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt
new file mode 100644
index 000000000..1924b85c1
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/data/OpenConversationsRepositoryImpl.kt
@@ -0,0 +1,58 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.data
+
+import com.nextcloud.talk.api.NcApi
+import com.nextcloud.talk.data.user.model.User
+import com.nextcloud.talk.models.json.conversations.Conversation
+import com.nextcloud.talk.utils.ApiUtils
+import com.nextcloud.talk.utils.database.user.CurrentUserProviderNew
+import io.reactivex.Observable
+
+class OpenConversationsRepositoryImpl(private val ncApi: NcApi, currentUserProvider: CurrentUserProviderNew) :
+ OpenConversationsRepository {
+
+ val currentUser: User = currentUserProvider.currentUser.blockingGet()
+ val credentials: String = ApiUtils.getCredentials(currentUser.username, currentUser.token)
+
+ val apiVersion = ApiUtils.getConversationApiVersion(currentUser, intArrayOf(ApiUtils.APIv4, ApiUtils.APIv3, 1))
+
+ override fun fetchConversations(): Observable {
+ return ncApi.getOpenConversations(
+ credentials,
+ ApiUtils.getUrlForOpenConversations(apiVersion, currentUser.baseUrl)
+ ).map { mapToOpenConversationsModel(it.ocs?.data!!) }
+ }
+
+ private fun mapToOpenConversationsModel(
+ conversations: List
+ ): OpenConversationsModel {
+ return OpenConversationsModel(
+ conversations.map { conversation ->
+ OpenConversation(
+ conversation.roomId!!,
+ conversation.token!!,
+ conversation.name!!
+ )
+ }
+ )
+ }
+}
diff --git a/app/src/main/java/com/nextcloud/talk/openconversations/viewmodels/OpenConversationsViewModel.kt b/app/src/main/java/com/nextcloud/talk/openconversations/viewmodels/OpenConversationsViewModel.kt
new file mode 100644
index 000000000..f4542c7d3
--- /dev/null
+++ b/app/src/main/java/com/nextcloud/talk/openconversations/viewmodels/OpenConversationsViewModel.kt
@@ -0,0 +1,84 @@
+/*
+ * Nextcloud Talk application
+ *
+ * @author Marcel Hibbe
+ * Copyright (C) 2023 Marcel Hibbe
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * at your option) any later version.
+ *
+ * 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 .
+ */
+
+package com.nextcloud.talk.openconversations.viewmodels
+
+import android.util.Log
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.ViewModel
+import com.nextcloud.talk.openconversations.data.OpenConversation
+import com.nextcloud.talk.openconversations.data.OpenConversationsModel
+import com.nextcloud.talk.openconversations.data.OpenConversationsRepository
+import io.reactivex.Observer
+import io.reactivex.android.schedulers.AndroidSchedulers
+import io.reactivex.disposables.Disposable
+import io.reactivex.schedulers.Schedulers
+import javax.inject.Inject
+
+class OpenConversationsViewModel @Inject constructor(private val repository: OpenConversationsRepository) :
+ ViewModel() {
+
+ sealed interface ViewState
+
+ object FetchConversationsStartState : ViewState
+ object FetchConversationsEmptyState : ViewState
+ object FetchConversationsErrorState : ViewState
+ open class FetchConversationsSuccessState(val conversations: List) : ViewState
+
+ private val _viewState: MutableLiveData = MutableLiveData(FetchConversationsStartState)
+ val viewState: LiveData
+ get() = _viewState
+
+ fun fetchConversations() {
+ _viewState.value = FetchConversationsStartState
+ repository.fetchConversations()
+ .subscribeOn(Schedulers.io())
+ ?.observeOn(AndroidSchedulers.mainThread())
+ ?.subscribe(FetchConversationsObserver())
+ }
+
+ inner class FetchConversationsObserver : Observer {
+ override fun onSubscribe(d: Disposable) {
+ // unused atm
+ }
+
+ override fun onNext(model: OpenConversationsModel) {
+ if (model.conversations.isEmpty()) {
+ _viewState.value = FetchConversationsEmptyState
+ } else {
+ _viewState.value = FetchConversationsSuccessState(model.conversations)
+ }
+ }
+
+ override fun onError(e: Throwable) {
+ Log.e(TAG, "Error when fetching open conversations")
+ _viewState.value = FetchConversationsErrorState
+ }
+
+ override fun onComplete() {
+ // unused atm
+ }
+ }
+
+ companion object {
+ private val TAG = OpenConversationsViewModel::class.simpleName
+ }
+}
diff --git a/app/src/main/res/drawable/baseline_format_list_bulleted_24.xml b/app/src/main/res/drawable/baseline_format_list_bulleted_24.xml
new file mode 100644
index 000000000..be87d721d
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_format_list_bulleted_24.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
diff --git a/app/src/main/res/drawable/baseline_info_24.xml b/app/src/main/res/drawable/baseline_info_24.xml
new file mode 100644
index 000000000..fd7a3a327
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_info_24.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_contacts.xml b/app/src/main/res/layout/activity_contacts.xml
new file mode 100644
index 000000000..6d7d87207
--- /dev/null
+++ b/app/src/main/res/layout/activity_contacts.xml
@@ -0,0 +1,218 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_open_conversations.xml b/app/src/main/res/layout/activity_open_conversations.xml
new file mode 100644
index 000000000..2694e2c8e
--- /dev/null
+++ b/app/src/main/res/layout/activity_open_conversations.xml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/controller_contacts_rv.xml b/app/src/main/res/layout/controller_contacts_rv.xml
deleted file mode 100644
index 2c2514a4d..000000000
--- a/app/src/main/res/layout/controller_contacts_rv.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/conversation_privacy_toggle.xml b/app/src/main/res/layout/conversation_privacy_toggle.xml
deleted file mode 100644
index d912e9e73..000000000
--- a/app/src/main/res/layout/conversation_privacy_toggle.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/join_conversation_via_link.xml b/app/src/main/res/layout/rv_item_open_conversation.xml
similarity index 67%
rename from app/src/main/res/layout/join_conversation_via_link.xml
rename to app/src/main/res/layout/rv_item_open_conversation.xml
index cee4c485a..5cc9b9444 100644
--- a/app/src/main/res/layout/join_conversation_via_link.xml
+++ b/app/src/main/res/layout/rv_item_open_conversation.xml
@@ -3,8 +3,10 @@
~
~ @author Mario Danic
~ @author Andy Scherzinger
- ~ Copyright (C) 2021 Andy Scherzinger
- ~ Copyright (C) 2017-2018 Mario Danic
+ ~ @author Marcel Hibbe
+ ~ Copyright (C) 2023 Marcel Hibbe
+ ~ Copyright (C) 2021 Andy Scherzinger
+ ~ Copyright (C) 2017 Mario Danic
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
@@ -21,8 +23,7 @@
-->
+
+
-
-
+ android:contentDescription="@string/avatar" />
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index 5610cf297..4d64f32ef 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -76,4 +76,6 @@
#353535
+ #99FFFFFF
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index ce3dbf019..8d6cb255f 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -105,4 +105,6 @@
possible?! don't use this to set the background of dialogs -->
#FFFFFF
+ #99000000
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5ca7542fc..c678e2a93 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -197,6 +197,7 @@ How to translate with transifex:
New conversation
Join with a link
+ List open conversations
Join via web
Mark as read
Mark as unread
@@ -205,6 +206,10 @@ How to translate with transifex:
Forward to …
+
+ No open conversations
+ No open conversations that you can join.\nEither there are no open conversations or you already joined all of them.
+
Select participants
Add participants