mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 22:15:41 +03:00
WIP got archived working - still have some todos
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
This commit is contained in:
parent
8eeca17d86
commit
94f33c13bc
12 changed files with 121 additions and 34 deletions
|
@ -2,7 +2,7 @@
|
|||
"formatVersion": 1,
|
||||
"database": {
|
||||
"version": 11,
|
||||
"identityHash": "bc802cadfdef41d3eb94ffbb0729eb89",
|
||||
"identityHash": "7edb537b6987d0de6586a6760c970958",
|
||||
"entities": [
|
||||
{
|
||||
"tableName": "User",
|
||||
|
@ -138,7 +138,7 @@
|
|||
},
|
||||
{
|
||||
"tableName": "Conversations",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )",
|
||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`internalId` TEXT NOT NULL, `accountId` INTEGER NOT NULL, `token` TEXT NOT NULL, `displayName` TEXT NOT NULL, `actorId` TEXT NOT NULL, `actorType` TEXT NOT NULL, `avatarVersion` TEXT NOT NULL, `callFlag` INTEGER NOT NULL, `callRecording` INTEGER NOT NULL, `callStartTime` INTEGER NOT NULL, `canDeleteConversation` INTEGER NOT NULL, `canLeaveConversation` INTEGER NOT NULL, `canStartCall` INTEGER NOT NULL, `description` TEXT NOT NULL, `hasCall` INTEGER NOT NULL, `hasPassword` INTEGER NOT NULL, `isCustomAvatar` INTEGER NOT NULL, `isFavorite` INTEGER NOT NULL, `lastActivity` INTEGER NOT NULL, `lastCommonReadMessage` INTEGER NOT NULL, `lastMessage` TEXT, `lastPing` INTEGER NOT NULL, `lastReadMessage` INTEGER NOT NULL, `lobbyState` TEXT NOT NULL, `lobbyTimer` INTEGER NOT NULL, `messageExpiration` INTEGER NOT NULL, `name` TEXT NOT NULL, `notificationCalls` INTEGER NOT NULL, `notificationLevel` TEXT NOT NULL, `objectType` TEXT NOT NULL, `participantType` TEXT NOT NULL, `permissions` INTEGER NOT NULL, `readOnly` TEXT NOT NULL, `recordingConsent` INTEGER NOT NULL, `remoteServer` TEXT, `remoteToken` TEXT, `sessionId` TEXT NOT NULL, `status` TEXT, `statusClearAt` INTEGER, `statusIcon` TEXT, `statusMessage` TEXT, `type` TEXT NOT NULL, `unreadMention` INTEGER NOT NULL, `unreadMentionDirect` INTEGER NOT NULL, `unreadMessages` INTEGER NOT NULL, `hasArchived` INTEGER NOT NULL, PRIMARY KEY(`internalId`), FOREIGN KEY(`accountId`) REFERENCES `User`(`id`) ON UPDATE CASCADE ON DELETE CASCADE )",
|
||||
"fields": [
|
||||
{
|
||||
"fieldPath": "internalId",
|
||||
|
@ -409,6 +409,12 @@
|
|||
"columnName": "unreadMessages",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
},
|
||||
{
|
||||
"fieldPath": "hasArchived",
|
||||
"columnName": "hasArchived",
|
||||
"affinity": "INTEGER",
|
||||
"notNull": true
|
||||
}
|
||||
],
|
||||
"primaryKey": {
|
||||
|
@ -713,7 +719,7 @@
|
|||
"views": [],
|
||||
"setupQueries": [
|
||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'bc802cadfdef41d3eb94ffbb0729eb89')"
|
||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '7edb537b6987d0de6586a6760c970958')"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -179,36 +179,17 @@ class ConversationInfoActivity :
|
|||
databaseStorageModule = DatabaseStorageModule(conversationUser, conversationToken)
|
||||
}
|
||||
|
||||
if (!spreedCapabilities.features!!.contains(ARCHIVED_CONVERSATIONS)) {
|
||||
binding.archiveConversationBtn.visibility = GONE
|
||||
}
|
||||
|
||||
binding.deleteConversationAction.setOnClickListener { showDeleteConversationDialog() }
|
||||
binding.leaveConversationAction.setOnClickListener { leaveConversation() }
|
||||
binding.clearConversationHistory.setOnClickListener { showClearHistoryDialog() }
|
||||
binding.addParticipantsAction.setOnClickListener { addParticipants() }
|
||||
binding.listBansButton.setOnClickListener { listBans() }
|
||||
binding.archiveConversationBtn.setOnClickListener {
|
||||
if (conversation!!.isArchived) {
|
||||
viewModel.unarchiveConversation(conversationUser, conversationToken)
|
||||
} else {
|
||||
viewModel.archiveConversation(conversationUser, conversationToken)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getRoom(conversationUser, conversationToken)
|
||||
|
||||
themeTextViews()
|
||||
themeSwitchPreferences()
|
||||
|
||||
if (conversation!!.isArchived) {
|
||||
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.ic_eye))
|
||||
binding.archiveConversationText.text = resources.getString(R.string.unarchive_conversation)
|
||||
} else {
|
||||
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.outline_archive_24))
|
||||
binding.archiveConversationText.text = resources.getString(R.string.archive_conversation)
|
||||
}
|
||||
|
||||
binding.addParticipantsAction.visibility = GONE
|
||||
|
||||
binding.progressBar.let { viewThemeUtils.platform.colorCircularProgressBar(it, ColorRole.PRIMARY) }
|
||||
|
@ -760,6 +741,26 @@ class ConversationInfoActivity :
|
|||
}
|
||||
}
|
||||
|
||||
if (!spreedCapabilities.features!!.contains(ARCHIVED_CONVERSATIONS)) {
|
||||
binding.archiveConversationBtn.visibility = GONE
|
||||
}
|
||||
|
||||
binding.archiveConversationBtn.setOnClickListener {
|
||||
if (conversation!!.hasArchived) {
|
||||
viewModel.unarchiveConversation(conversationUser, conversationToken)
|
||||
} else {
|
||||
viewModel.archiveConversation(conversationUser, conversationToken)
|
||||
}
|
||||
}
|
||||
|
||||
if (conversation!!.hasArchived) {
|
||||
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.ic_eye))
|
||||
binding.archiveConversationText.text = resources.getString(R.string.unarchive_conversation)
|
||||
} else {
|
||||
binding.archiveConversationIcon.setImageDrawable(resources.getDrawable(R.drawable.outline_archive_24))
|
||||
binding.archiveConversationText.text = resources.getString(R.string.archive_conversation)
|
||||
}
|
||||
|
||||
if (!isDestroyed) {
|
||||
binding.dangerZoneOptions.visibility = VISIBLE
|
||||
|
||||
|
|
|
@ -203,11 +203,53 @@ class ConversationInfoViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
fun archiveConversation(user: User, token: String) {
|
||||
// TODO
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
||||
val url = ApiUtils.getUrlForArchive(apiVersion, user.baseUrl, token)
|
||||
conversationsRepository.archiveConversation(user.getCredentials(), url)
|
||||
.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(object : Observer<GenericOverall> {
|
||||
override fun onSubscribe(p0: Disposable) {
|
||||
// unused
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.d("Julius", "Error in archive $e")
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
|
||||
override fun onNext(n: GenericOverall) {
|
||||
Log.d("Julius", "Archived successful")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun unarchiveConversation(user: User, token: String) {
|
||||
// TODO
|
||||
val apiVersion = ApiUtils.getConversationApiVersion(user, intArrayOf(ApiUtils.API_V4, ApiUtils.API_V1))
|
||||
val url = ApiUtils.getUrlForArchive(apiVersion, user.baseUrl, token)
|
||||
conversationsRepository.unarchiveConversation(user.getCredentials(), url)
|
||||
.subscribeOn(Schedulers.io())
|
||||
?.observeOn(AndroidSchedulers.mainThread())
|
||||
?.subscribe(object : Observer<GenericOverall> {
|
||||
override fun onSubscribe(p0: Disposable) {
|
||||
// unused
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
Log.d("Julius", "Error in unarchive $e")
|
||||
}
|
||||
|
||||
override fun onComplete() {
|
||||
// unused atm
|
||||
}
|
||||
|
||||
override fun onNext(n: GenericOverall) {
|
||||
Log.d("Julius", "unArchived successful")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
inner class GetRoomObserver : Observer<ConversationModel> {
|
||||
|
|
|
@ -210,7 +210,8 @@ class ConversationsListActivity :
|
|||
private var filterState =
|
||||
mutableMapOf(
|
||||
FilterConversationFragment.MENTION to false,
|
||||
FilterConversationFragment.UNREAD to false
|
||||
FilterConversationFragment.UNREAD to false,
|
||||
FilterConversationFragment.ARCHIVE to false
|
||||
)
|
||||
val searchBehaviorSubject = BehaviorSubject.createDefault(false)
|
||||
private lateinit var accountIconBadge: BadgeDrawable
|
||||
|
@ -413,9 +414,18 @@ class ConversationsListActivity :
|
|||
).blockingGet()?.value ?: ""
|
||||
) == "true"
|
||||
|
||||
filterState[FilterConversationFragment.ARCHIVE] = (
|
||||
arbitraryStorageManager.getStorageSetting(
|
||||
accountId,
|
||||
FilterConversationFragment.ARCHIVE,
|
||||
""
|
||||
).blockingGet()?.value ?: ""
|
||||
) == "true"
|
||||
|
||||
val newItems: MutableList<AbstractFlexibleItem<*>> = ArrayList()
|
||||
if (filterState[FilterConversationFragment.UNREAD] == false &&
|
||||
filterState[FilterConversationFragment.MENTION] == false
|
||||
filterState[FilterConversationFragment.MENTION] == false &&
|
||||
filterState[FilterConversationFragment.ARCHIVE] == false
|
||||
) {
|
||||
adapter!!.updateDataSet(conversationItems, true)
|
||||
} else {
|
||||
|
@ -449,6 +459,8 @@ class ConversationsListActivity :
|
|||
)
|
||||
|
||||
FilterConversationFragment.UNREAD -> result = result && (conversation.unreadMessages > 0)
|
||||
|
||||
FilterConversationFragment.ARCHIVE -> result = result && conversation.hasArchived
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ fun ConversationModel.asEntity() =
|
|||
callStartTime = callStartTime,
|
||||
recordingConsentRequired = recordingConsentRequired,
|
||||
remoteServer = remoteServer,
|
||||
remoteToken = remoteToken
|
||||
remoteToken = remoteToken,
|
||||
hasArchived = hasArchived
|
||||
)
|
||||
|
||||
fun ConversationEntity.asModel() =
|
||||
|
@ -109,7 +110,8 @@ fun ConversationEntity.asModel() =
|
|||
callStartTime = callStartTime,
|
||||
recordingConsentRequired = recordingConsentRequired,
|
||||
remoteServer = remoteServer,
|
||||
remoteToken = remoteToken
|
||||
remoteToken = remoteToken,
|
||||
hasArchived = hasArchived
|
||||
)
|
||||
|
||||
fun Conversation.asEntity(accountId: Long) =
|
||||
|
@ -158,5 +160,6 @@ fun Conversation.asEntity(accountId: Long) =
|
|||
callStartTime = callStartTime,
|
||||
recordingConsentRequired = recordingConsentRequired,
|
||||
remoteServer = remoteServer,
|
||||
remoteToken = remoteToken
|
||||
remoteToken = remoteToken,
|
||||
hasArchived = hasArchived
|
||||
)
|
||||
|
|
|
@ -92,7 +92,8 @@ data class ConversationEntity(
|
|||
@ColumnInfo(name = "type") var type: ConversationEnums.ConversationType,
|
||||
@ColumnInfo(name = "unreadMention") var unreadMention: Boolean = false,
|
||||
@ColumnInfo(name = "unreadMentionDirect") var unreadMentionDirect: Boolean,
|
||||
@ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0
|
||||
@ColumnInfo(name = "unreadMessages") var unreadMessages: Int = 0,
|
||||
@ColumnInfo(name = "hasArchived") var hasArchived: Boolean = false
|
||||
// missing/not needed: attendeeId
|
||||
// missing/not needed: attendeePin
|
||||
// missing/not needed: attendeePermissions
|
||||
|
|
|
@ -59,7 +59,7 @@ class ConversationModel(
|
|||
var recordingConsentRequired: Int = 0,
|
||||
var remoteServer: String? = null,
|
||||
var remoteToken: String? = null,
|
||||
var isArchived: Boolean = false,
|
||||
var hasArchived: Boolean = false,
|
||||
|
||||
// attributes that don't come from API. This should be changed?!
|
||||
var password: String? = null
|
||||
|
@ -122,7 +122,7 @@ class ConversationModel(
|
|||
recordingConsentRequired = conversation.recordingConsentRequired,
|
||||
remoteServer = conversation.remoteServer,
|
||||
remoteToken = conversation.remoteToken,
|
||||
isArchived = conversation.isArchived
|
||||
hasArchived = conversation.hasArchived
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,5 +162,5 @@ data class Conversation(
|
|||
var remoteToken: String? = "",
|
||||
|
||||
@JsonField(name = ["isArchived"])
|
||||
var isArchived: Boolean
|
||||
var hasArchived: Boolean = false
|
||||
) : Parcelable
|
||||
|
|
|
@ -69,7 +69,8 @@ class FilterConversationFragment : DialogFragment() {
|
|||
binding.run {
|
||||
listOf(
|
||||
unreadFilterChip,
|
||||
mentionedFilterChip
|
||||
mentionedFilterChip,
|
||||
archivedFilterChip
|
||||
)
|
||||
}.forEach(viewThemeUtils.talk::themeChipFilter)
|
||||
|
||||
|
@ -89,6 +90,12 @@ class FilterConversationFragment : DialogFragment() {
|
|||
processSubmit()
|
||||
}
|
||||
|
||||
binding.archivedFilterChip.setOnCheckedChangeListener { _, isChecked ->
|
||||
filterState[ARCHIVE] = isChecked
|
||||
binding.archivedFilterChip.isChecked = isChecked
|
||||
processSubmit()
|
||||
}
|
||||
|
||||
binding.buttonClose.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
|
@ -104,9 +111,11 @@ class FilterConversationFragment : DialogFragment() {
|
|||
val accountId = UserIdUtils.getIdForUser(userManager.currentUser.blockingGet())
|
||||
val mentionValue = filterState[MENTION] == true
|
||||
val unreadValue = filterState[UNREAD] == true
|
||||
val archivedValue = filterState[ARCHIVE] == true
|
||||
|
||||
arbitraryStorageManager.storeStorageSetting(accountId, MENTION, mentionValue.toString(), "")
|
||||
arbitraryStorageManager.storeStorageSetting(accountId, UNREAD, unreadValue.toString(), "")
|
||||
arbitraryStorageManager.storeStorageSetting(accountId, ARCHIVE, archivedValue.toString(), "")
|
||||
|
||||
(requireActivity() as ConversationsListActivity).filterConversation()
|
||||
}
|
||||
|
@ -126,5 +135,6 @@ class FilterConversationFragment : DialogFragment() {
|
|||
val TAG: String = FilterConversationFragment::class.java.simpleName
|
||||
const val MENTION: String = "mention"
|
||||
const val UNREAD: String = "unread"
|
||||
const val ARCHIVE: String = "archive"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -588,4 +588,8 @@ object ApiUtils {
|
|||
fun getUrlForUnban(baseUrl: String, token: String, banId: Int): String {
|
||||
return "${getUrlForBans(baseUrl, token)}/$banId"
|
||||
}
|
||||
|
||||
fun getUrlForArchive(version: Int, baseUrl: String?, token: String?): String {
|
||||
return "${getUrlForRoom(version, baseUrl, token)}/archive"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,13 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:text="@string/mentioned" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/archived_filter_chip"
|
||||
style="@style/Widget.Material3.Chip.Filter"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/archived" />
|
||||
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
|
|
|
@ -817,4 +817,5 @@ How to translate with transifex:
|
|||
<string name="connection_lost">Connection lost</string>
|
||||
<string name="archive_conversation">Archive Conversation</string>
|
||||
<string name="unarchive_conversation">Unarchive Conversation</string>
|
||||
<string name="archived">Archived</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue