Skip to content

Commit 3173350

Browse files
committed
add threads overview
Signed-off-by: Marcel Hibbe <[email protected]>
1 parent 3bba4e8 commit 3173350

File tree

14 files changed

+481
-27
lines changed

14 files changed

+481
-27
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@
258258
android:name=".lock.LockedActivity"
259259
android:theme="@style/AppTheme" />
260260

261+
<activity
262+
android:name=".threadsoverview.ThreadsOverviewActivity"
263+
android:theme="@style/AppTheme" />
264+
261265
<receiver
262266
android:name=".receivers.PackageReplacedReceiver"
263267
android:exported="false">

app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import com.nextcloud.talk.models.json.participants.TalkBanOverall
2020
import com.nextcloud.talk.models.json.profile.ProfileOverall
2121
import com.nextcloud.talk.models.json.testNotification.TestNotificationOverall
2222
import com.nextcloud.talk.models.json.threads.ThreadOverall
23+
import com.nextcloud.talk.models.json.threads.ThreadsOverall
2324
import com.nextcloud.talk.models.json.userAbsence.UserAbsenceOverall
2425
import okhttp3.MultipartBody
2526
import okhttp3.RequestBody
@@ -289,4 +290,7 @@ interface NcApiCoroutines {
289290

290291
@POST
291292
suspend fun createThread(@Header("Authorization") authorization: String, @Url url: String): ThreadOverall
293+
294+
@GET
295+
suspend fun getThreads(@Header("Authorization") authorization: String, @Url url: String): ThreadsOverall
292296
}

app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ import com.nextcloud.talk.remotefilebrowser.activities.RemoteFileBrowserActivity
153153
import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
154154
import com.nextcloud.talk.signaling.SignalingMessageReceiver
155155
import com.nextcloud.talk.signaling.SignalingMessageSender
156+
import com.nextcloud.talk.threadsoverview.ThreadsOverviewActivity
156157
import com.nextcloud.talk.translate.ui.TranslateActivity
157158
import com.nextcloud.talk.ui.PlaybackSpeed
158159
import com.nextcloud.talk.ui.PlaybackSpeedControl
@@ -1247,6 +1248,26 @@ class ChatActivity :
12471248
}
12481249
}
12491250
}
1251+
1252+
this.lifecycleScope.launch {
1253+
chatViewModel.threadCreationState.collect { uiState ->
1254+
when (uiState) {
1255+
ChatViewModel.ThreadCreationUiState.None -> {
1256+
}
1257+
1258+
is ChatViewModel.ThreadCreationUiState.Error -> {
1259+
Log.e(TAG, "Error when creating thread")
1260+
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
1261+
}
1262+
1263+
is ChatViewModel.ThreadCreationUiState.Success -> {
1264+
uiState.thread?.first?.threadId?.let {
1265+
openThread(it)
1266+
}
1267+
}
1268+
}
1269+
}
1270+
}
12501271
}
12511272

12521273
private fun removeUnreadMessagesMarker() {
@@ -3188,6 +3209,11 @@ class ChatActivity :
31883209
true
31893210
}
31903211

3212+
R.id.show_threads -> {
3213+
openThreadsOverview()
3214+
true
3215+
}
3216+
31913217
else -> super.onOptionsItemSelected(item)
31923218
}
31933219

@@ -4130,15 +4156,13 @@ class ChatActivity :
41304156

41314157
private fun isChatThread(): Boolean = threadId != null && threadId!! > 0
41324158

4133-
fun openThread(chatMessage: ChatMessage) {
4134-
chatMessage.threadId?.let {
4135-
val bundle = Bundle()
4136-
bundle.putString(KEY_ROOM_TOKEN, roomToken)
4137-
bundle.putLong(KEY_THREAD_ID, it)
4138-
val chatIntent = Intent(context, ChatActivity::class.java)
4139-
chatIntent.putExtras(bundle)
4140-
startActivity(chatIntent)
4141-
}
4159+
fun openThread(messageId: Long) {
4160+
val bundle = Bundle()
4161+
bundle.putString(KEY_ROOM_TOKEN, roomToken)
4162+
bundle.putLong(KEY_THREAD_ID, messageId)
4163+
val chatIntent = Intent(context, ChatActivity::class.java)
4164+
chatIntent.putExtras(bundle)
4165+
startActivity(chatIntent)
41424166
}
41434167

41444168
fun createThread(chatMessage: ChatMessage) {
@@ -4151,24 +4175,14 @@ class ChatActivity :
41514175
threadId = chatMessage.jsonMessageId
41524176
)
41534177
)
4178+
}
41544179

4155-
this.lifecycleScope.launch {
4156-
chatViewModel.threadCreationState.collect { uiState ->
4157-
when (uiState) {
4158-
ChatViewModel.ThreadCreationUiState.None -> {
4159-
}
4160-
4161-
is ChatViewModel.ThreadCreationUiState.Error -> {
4162-
Log.e(TAG, "Error when creating thread")
4163-
Snackbar.make(binding.root, R.string.nc_common_error_sorry, Snackbar.LENGTH_LONG).show()
4164-
}
4165-
4166-
is ChatViewModel.ThreadCreationUiState.Success -> {
4167-
openThread(chatMessage)
4168-
}
4169-
}
4170-
}
4171-
}
4180+
fun openThreadsOverview() {
4181+
val bundle = Bundle()
4182+
bundle.putString(KEY_ROOM_TOKEN, roomToken)
4183+
val threadsOverviewIntent = Intent(context, ThreadsOverviewActivity::class.java)
4184+
threadsOverviewIntent.putExtras(bundle)
4185+
startActivity(threadsOverviewIntent)
41724186
}
41734187

41744188
override fun joinAudioCall() {

app/src/main/java/com/nextcloud/talk/dagger/modules/RepositoryModule.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepository
5454
import com.nextcloud.talk.repositories.unifiedsearch.UnifiedSearchRepositoryImpl
5555
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepository
5656
import com.nextcloud.talk.shareditems.repositories.SharedItemsRepositoryImpl
57+
import com.nextcloud.talk.threadsoverview.data.ThreadsRepository
58+
import com.nextcloud.talk.threadsoverview.data.ThreadsRepositoryImpl
5759
import com.nextcloud.talk.translate.repositories.TranslateRepository
5860
import com.nextcloud.talk.translate.repositories.TranslateRepositoryImpl
5961
import com.nextcloud.talk.utils.DateUtils
@@ -186,4 +188,10 @@ class RepositoryModule {
186188
ncApiCoroutines: NcApiCoroutines,
187189
currentUserProviderNew: CurrentUserProviderNew
188190
): ConversationCreationRepository = ConversationCreationRepositoryImpl(ncApiCoroutines, currentUserProviderNew)
191+
192+
@Provides
193+
fun provideThreadsRepository(
194+
ncApiCoroutines: NcApiCoroutines,
195+
currentUserProviderNew: CurrentUserProviderNew
196+
): ThreadsRepository = ThreadsRepositoryImpl(ncApiCoroutines, currentUserProviderNew)
189197
}

app/src/main/java/com/nextcloud/talk/dagger/modules/ViewModelModule.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.nextcloud.talk.polls.viewmodels.PollVoteViewModel
2727
import com.nextcloud.talk.raisehand.viewmodel.RaiseHandViewModel
2828
import com.nextcloud.talk.remotefilebrowser.viewmodels.RemoteFileBrowserItemsViewModel
2929
import com.nextcloud.talk.shareditems.viewmodels.SharedItemsViewModel
30+
import com.nextcloud.talk.threadsoverview.viewmodels.ThreadsOverviewViewModel
3031
import com.nextcloud.talk.translate.viewmodels.TranslateViewModel
3132
import com.nextcloud.talk.viewmodels.CallRecordingViewModel
3233
import dagger.Binds
@@ -154,4 +155,9 @@ abstract class ViewModelModule {
154155
@IntoMap
155156
@ViewModelKey(DiagnoseViewModel::class)
156157
abstract fun diagnoseViewModel(viewModel: DiagnoseViewModel): ViewModel
158+
159+
@Binds
160+
@IntoMap
161+
@ViewModelKey(ThreadsOverviewViewModel::class)
162+
abstract fun threadsOverviewViewModel(viewModel: ThreadsOverviewViewModel): ViewModel
157163
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Nextcloud Talk - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <[email protected]>
5+
* SPDX-License-Identifier: GPL-3.0-or-later
6+
*/
7+
package com.nextcloud.talk.models.json.threads
8+
9+
import android.os.Parcelable
10+
import com.bluelinelabs.logansquare.annotation.JsonField
11+
import com.bluelinelabs.logansquare.annotation.JsonObject
12+
import com.nextcloud.talk.models.json.generic.GenericMeta
13+
import kotlinx.parcelize.Parcelize
14+
15+
@Parcelize
16+
@JsonObject
17+
data class ThreadsOCS(
18+
@JsonField(name = ["meta"])
19+
var meta: GenericMeta?,
20+
@JsonField(name = ["data"])
21+
var data: List<ThreadInfo>? = null
22+
) : Parcelable {
23+
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
24+
constructor() : this(null, null)
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Nextcloud Talk - Android Client
3+
*
4+
* SPDX-FileCopyrightText: 2025 Marcel Hibbe <[email protected]>
5+
* SPDX-License-Identifier: GPL-3.0-or-later
6+
*/
7+
package com.nextcloud.talk.models.json.threads
8+
9+
import android.os.Parcelable
10+
import com.bluelinelabs.logansquare.annotation.JsonField
11+
import com.bluelinelabs.logansquare.annotation.JsonObject
12+
import kotlinx.parcelize.Parcelize
13+
14+
@Parcelize
15+
@JsonObject
16+
data class ThreadsOverall(
17+
@JsonField(name = ["ocs"])
18+
var ocs: ThreadsOCS? = null
19+
) : Parcelable {
20+
// This constructor is added to work with the 'com.bluelinelabs.logansquare.annotation.JsonObject'
21+
constructor() : this(null)
22+
}

0 commit comments

Comments
 (0)