mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 06:14:10 +01:00
WIP UI fixes for offline conversations - next up get queued messges to work and show up as temp messages ( I have some creative ideas for the UI )
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
aa76636f72
commit
db8d7b91d4
@ -657,9 +657,7 @@ class ChatActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
is ChatViewModel.JoinRoomErrorState -> {
|
is ChatViewModel.JoinRoomErrorState -> {}
|
||||||
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
@ -812,7 +810,6 @@ class ChatActivity :
|
|||||||
) {
|
) {
|
||||||
adapter?.clear()
|
adapter?.clear()
|
||||||
adapter?.notifyDataSetChanged()
|
adapter?.notifyDataSetChanged()
|
||||||
// TODO: remove messages from DB, Should be handled beforehand (in viewModel?)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lookIntoFuture) {
|
if (lookIntoFuture) {
|
||||||
|
@ -175,6 +175,8 @@ class MessageInputFragment : Fragment() {
|
|||||||
wasOnline = !binding.fragmentMessageInputView.isShown
|
wasOnline = !binding.fragmentMessageInputView.isShown
|
||||||
Log.d(TAG, "isOnline: $isOnline\nwasOnline: $wasOnline\nconnectionGained: $connectionGained")
|
Log.d(TAG, "isOnline: $isOnline\nwasOnline: $wasOnline\nconnectionGained: $connectionGained")
|
||||||
|
|
||||||
|
// FIXME I think this might be called when remote server is null, because I joined when no internet
|
||||||
|
// thus room not joined. I would need to make sure that the room is joined before I send messages
|
||||||
handleMessageQueue(isOnline)
|
handleMessageQueue(isOnline)
|
||||||
handleUI(isOnline, connectionGained)
|
handleUI(isOnline, connectionGained)
|
||||||
}.collect()
|
}.collect()
|
||||||
|
@ -322,6 +322,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
|||||||
val result = network.pullChatMessages(credentials, urlForChatting, fieldMap)
|
val result = network.pullChatMessages(credentials, urlForChatting, fieldMap)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
// .timeout(3, TimeUnit.SECONDS)
|
||||||
.map {
|
.map {
|
||||||
when (it.code()) {
|
when (it.code()) {
|
||||||
HTTP_CODE_OK -> {
|
HTTP_CODE_OK -> {
|
||||||
|
@ -81,6 +81,7 @@ import com.nextcloud.talk.arbitrarystorage.ArbitraryStorageManager
|
|||||||
import com.nextcloud.talk.chat.ChatActivity
|
import com.nextcloud.talk.chat.ChatActivity
|
||||||
import com.nextcloud.talk.contacts.ContactsActivityCompose
|
import com.nextcloud.talk.contacts.ContactsActivityCompose
|
||||||
import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel
|
import com.nextcloud.talk.conversationlist.viewmodels.ConversationsListViewModel
|
||||||
|
import com.nextcloud.talk.data.network.NetworkMonitor
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.databinding.ActivityConversationsBinding
|
import com.nextcloud.talk.databinding.ActivityConversationsBinding
|
||||||
import com.nextcloud.talk.events.ConversationsListFetchDataEvent
|
import com.nextcloud.talk.events.ConversationsListFetchDataEvent
|
||||||
@ -106,7 +107,6 @@ import com.nextcloud.talk.utils.BrandingUtils
|
|||||||
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
|
import com.nextcloud.talk.utils.CapabilitiesUtil.hasSpreedFeatureCapability
|
||||||
import com.nextcloud.talk.utils.CapabilitiesUtil.isServerEOL
|
import com.nextcloud.talk.utils.CapabilitiesUtil.isServerEOL
|
||||||
import com.nextcloud.talk.utils.CapabilitiesUtil.isUnifiedSearchAvailable
|
import com.nextcloud.talk.utils.CapabilitiesUtil.isUnifiedSearchAvailable
|
||||||
import com.nextcloud.talk.utils.CapabilitiesUtil.isUserStatusAvailable
|
|
||||||
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
import com.nextcloud.talk.utils.ClosedInterfaceImpl
|
||||||
import com.nextcloud.talk.utils.ConversationUtils
|
import com.nextcloud.talk.utils.ConversationUtils
|
||||||
import com.nextcloud.talk.utils.FileUtils
|
import com.nextcloud.talk.utils.FileUtils
|
||||||
@ -173,6 +173,9 @@ class ConversationsListActivity :
|
|||||||
@Inject
|
@Inject
|
||||||
lateinit var viewModelFactory: ViewModelProvider.Factory
|
lateinit var viewModelFactory: ViewModelProvider.Factory
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var networkMonitor: NetworkMonitor
|
||||||
|
|
||||||
lateinit var conversationsListViewModel: ConversationsListViewModel
|
lateinit var conversationsListViewModel: ConversationsListViewModel
|
||||||
|
|
||||||
override val appBarLayoutType: AppBarLayoutType
|
override val appBarLayoutType: AppBarLayoutType
|
||||||
@ -300,6 +303,12 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun initObservers() {
|
private fun initObservers() {
|
||||||
|
this.lifecycleScope.launch {
|
||||||
|
networkMonitor.isOnline.onEach { isOnline ->
|
||||||
|
showNetworkErrorDialog(!isOnline)
|
||||||
|
}.collect()
|
||||||
|
}
|
||||||
|
|
||||||
conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state ->
|
conversationsListViewModel.getFederationInvitationsViewState.observe(this) { state ->
|
||||||
when (state) {
|
when (state) {
|
||||||
is ConversationsListViewModel.GetFederationInvitationsStartState -> {
|
is ConversationsListViewModel.GetFederationInvitationsStartState -> {
|
||||||
@ -315,7 +324,9 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ConversationsListViewModel.GetFederationInvitationsErrorState -> {
|
is ConversationsListViewModel.GetFederationInvitationsErrorState -> {
|
||||||
Snackbar.make(binding.root, R.string.get_invitations_error, Snackbar.LENGTH_LONG).show()
|
if (isNetworkAvailable(context)) {
|
||||||
|
Snackbar.make(binding.root, R.string.get_invitations_error, Snackbar.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {}
|
else -> {}
|
||||||
@ -731,72 +742,7 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun fetchRooms() {
|
fun fetchRooms() {
|
||||||
val includeStatus = isUserStatusAvailable(currentUser!!)
|
|
||||||
conversationsListViewModel.getRooms()
|
conversationsListViewModel.getRooms()
|
||||||
|
|
||||||
// checks internet connection before fetching rooms
|
|
||||||
if (isNetworkAvailable(context)) {
|
|
||||||
// Log.d(TAG, "Internet connection available")
|
|
||||||
// dispose(null)
|
|
||||||
// isRefreshing = true
|
|
||||||
// conversationItems = ArrayList()
|
|
||||||
// conversationItemsWithHeader = ArrayList()
|
|
||||||
// val apiVersion = ApiUtils.getConversationApiVersion(
|
|
||||||
// currentUser!!,
|
|
||||||
// intArrayOf(ApiUtils.API_V4, ApiUtils.API_V3, 1)
|
|
||||||
// )
|
|
||||||
// val startNanoTime = System.nanoTime()
|
|
||||||
// Log.d(TAG, "fetchData - getRooms - calling: $startNanoTime")
|
|
||||||
// roomsQueryDisposable = ncApi.getRooms(
|
|
||||||
// credentials,
|
|
||||||
// ApiUtils.getUrlForRooms(
|
|
||||||
// apiVersion,
|
|
||||||
// currentUser!!.baseUrl
|
|
||||||
// ),
|
|
||||||
// includeStatus
|
|
||||||
// )
|
|
||||||
// .subscribeOn(Schedulers.io())
|
|
||||||
// .observeOn(AndroidSchedulers.mainThread())
|
|
||||||
// .subscribe({ (ocs): RoomsOverall ->
|
|
||||||
// Log.d(TAG, "fetchData - getRooms - got response: $startNanoTime")
|
|
||||||
//
|
|
||||||
// // This is invoked asynchronously, when server returns a response the view might have been
|
|
||||||
// // unbound in the meantime. Check if the view is still there.
|
|
||||||
// // FIXME - does it make sense to update internal data structures even when view has been unbound?
|
|
||||||
// // if (view == null) {
|
|
||||||
// // Log.d(TAG, "fetchData - getRooms - view is not bound: $startNanoTime")
|
|
||||||
// // return@subscribe
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// if (adapterWasNull) {
|
|
||||||
// adapterWasNull = false
|
|
||||||
// binding?.loadingContent?.visibility = View.GONE
|
|
||||||
// }
|
|
||||||
// initOverallLayout(ocs!!.data!!.isNotEmpty())
|
|
||||||
// for (conversation in ocs.data!!) {
|
|
||||||
// addToConversationItems(conversation)
|
|
||||||
// }
|
|
||||||
// sortConversations(conversationItems)
|
|
||||||
// sortConversations(conversationItemsWithHeader)
|
|
||||||
// if (!filterState.containsValue(true)) filterableConversationItems = conversationItems
|
|
||||||
// filterConversation()
|
|
||||||
// adapter!!.updateDataSet(filterableConversationItems, false)
|
|
||||||
// Handler().postDelayed({ checkToShowUnreadBubble() }, UNREAD_BUBBLE_DELAY.toLong())
|
|
||||||
// fetchOpenConversations(apiVersion)
|
|
||||||
// binding?.swipeRefreshLayoutView?.isRefreshing = false
|
|
||||||
// }, { throwable: Throwable ->
|
|
||||||
// handleHttpExceptions(throwable)
|
|
||||||
// binding?.swipeRefreshLayoutView?.isRefreshing = false
|
|
||||||
// dispose(roomsQueryDisposable)
|
|
||||||
// }) {
|
|
||||||
// dispose(roomsQueryDisposable)
|
|
||||||
// binding?.swipeRefreshLayoutView?.isRefreshing = false
|
|
||||||
// isRefreshing = false
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
Log.d(TAG, "No internet connection detected")
|
|
||||||
showNetworkErrorDialog()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchPendingInvitations() {
|
private fun fetchPendingInvitations() {
|
||||||
@ -902,31 +848,8 @@ class ConversationsListActivity :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showNetworkErrorDialog() {
|
private fun showNetworkErrorDialog(show: Boolean) {
|
||||||
binding.floatingActionButton.let {
|
binding.chatListConnectionLost.visibility = if (show) View.VISIBLE else View.GONE
|
||||||
val dialogBuilder = MaterialAlertDialogBuilder(it.context)
|
|
||||||
.setIcon(
|
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogIcon(
|
|
||||||
context,
|
|
||||||
R.drawable.ic_baseline_error_outline_24dp
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.setTitle(R.string.nc_check_your_internet)
|
|
||||||
.setCancelable(false)
|
|
||||||
.setNegativeButton(R.string.close, null)
|
|
||||||
.setNeutralButton(R.string.nc_refresh) { _, _ ->
|
|
||||||
fetchRooms()
|
|
||||||
fetchPendingInvitations()
|
|
||||||
}
|
|
||||||
|
|
||||||
viewThemeUtils.dialog.colorMaterialAlertDialogBackground(it.context, dialogBuilder)
|
|
||||||
val dialog = dialogBuilder.show()
|
|
||||||
viewThemeUtils.platform.colorTextButtons(
|
|
||||||
dialog.getButton(AlertDialog.BUTTON_POSITIVE),
|
|
||||||
dialog.getButton(AlertDialog.BUTTON_NEGATIVE),
|
|
||||||
dialog.getButton(AlertDialog.BUTTON_NEUTRAL)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("ReturnCount")
|
@Suppress("ReturnCount")
|
||||||
|
@ -26,6 +26,17 @@
|
|||||||
app:liftOnScrollTargetViewId="@id/recycler_view"
|
app:liftOnScrollTargetViewId="@id/recycler_view"
|
||||||
app:liftOnScrollColor="@color/bg_default">
|
app:liftOnScrollColor="@color/bg_default">
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/chat_list_connection_lost"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/connection_lost"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:background="@color/hwSecurityRed"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.card.MaterialCardView
|
||||||
android:id="@+id/search_toolbar"
|
android:id="@+id/search_toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -803,4 +803,5 @@ How to translate with transifex:
|
|||||||
<string name="ban">Ban</string>
|
<string name="ban">Ban</string>
|
||||||
<string name="show_ban_reason">Show ban reason</string>
|
<string name="show_ban_reason">Show ban reason</string>
|
||||||
<string name="error_unbanning">Error occurred when unbanning participant</string>
|
<string name="error_unbanning">Error occurred when unbanning participant</string>
|
||||||
|
<string name="connection_lost">Connection Lost</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user