Skip to content

Commit

Permalink
Merge branch 'hotfix/1.4.7' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
ganfra committed Mar 24, 2022
2 parents 7c27ce5 + 60ecfd4 commit 9ec684f
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 238 deletions.
9 changes: 9 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Changes in Element v1.4.7 (2022-03-24)
======================================

Bugfixes 🐛
----------
- Fix inconsistencies between the arrow visibility and the collapse action on the room sections ([#5616](https://github.com/vector-im/element-android/issues/5616))
- Fix room list header count flickering

Changes in Element v1.4.6 (2022-03-23)
======================================

Expand Down Expand Up @@ -37,6 +45,7 @@ SDK API changes ⚠️

Other changes
-------------
- Refactoring for safer olm and megolm session usage ([#5380](https://github.com/vector-im/element-android/issues/5380))
- Improve headers UI in Rooms/Messages lists ([#4533](https://github.com/vector-im/element-android/issues/4533))
- Number of unread messages on space badge now include number of unread DMs ([#5260](https://github.com/vector-im/element-android/issues/5260))
- Amend spaces menu to be consistent with iOS version ([#5270](https://github.com/vector-im/element-android/issues/5270))
Expand Down
2 changes: 2 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/40104070.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Main changes in this version: Various bug fixes and stability improvements.
Full changelog: https://github.com/vector-im/element-android/releases/tag/v1.4.7
2 changes: 1 addition & 1 deletion matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
// that the app's state is completely cleared between tests.
testInstrumentationRunnerArguments clearPackageData: 'true'

buildConfigField "String", "SDK_VERSION", "\"1.4.6\""
buildConfigField "String", "SDK_VERSION", "\"1.4.7\""

buildConfigField "String", "GIT_SDK_REVISION", "\"${gitRevision()}\""
buildConfigField "String", "GIT_SDK_REVISION_UNIX_DATE", "\"${gitRevisionUnixDate()}\""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package org.matrix.android.sdk.api.session.room

import androidx.lifecycle.LiveData
import androidx.paging.PagedList
import kotlinx.coroutines.flow.Flow
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.Membership
Expand Down Expand Up @@ -218,9 +217,10 @@ interface RoomService {
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY): UpdatableLivePageResult

/**
* Retrieve a flow on the number of rooms.
* Return a LiveData on the number of rooms
* @param queryParams parameters to query the room summaries. It can be use to keep only joined rooms, for instance.
*/
fun getRoomCountFlow(queryParams: RoomSummaryQueryParams): Flow<Int>
fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int>

/**
* TODO Doc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.Transformations
import androidx.paging.PagedList
import com.zhuinden.monarchy.Monarchy
import kotlinx.coroutines.flow.Flow
import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.api.session.room.Room
import org.matrix.android.sdk.api.session.room.RoomService
Expand Down Expand Up @@ -110,8 +109,8 @@ internal class DefaultRoomService @Inject constructor(
return roomSummaryDataSource.getUpdatablePagedRoomSummariesLive(queryParams, pagedListConfig, sortOrder)
}

override fun getRoomCountFlow(queryParams: RoomSummaryQueryParams): Flow<Int> {
return roomSummaryDataSource.getCountFlow(queryParams)
override fun getRoomCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
return roomSummaryDataSource.getCountLive(queryParams)
}

override fun getNotificationCountForRooms(queryParams: RoomSummaryQueryParams): RoomAggregateNotificationCount {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import androidx.paging.PagedList
import com.zhuinden.monarchy.Monarchy
import io.realm.Realm
import io.realm.RealmQuery
import io.realm.kotlin.toFlow
import io.realm.kotlin.where
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import org.matrix.android.sdk.api.MatrixCoroutineDispatchers
import org.matrix.android.sdk.api.query.ActiveSpaceFilter
import org.matrix.android.sdk.api.query.RoomCategoryFilter
Expand Down Expand Up @@ -241,15 +236,14 @@ internal class RoomSummaryDataSource @Inject constructor(
}
}

fun getCountFlow(queryParams: RoomSummaryQueryParams): Flow<Int> =
realmSessionProvider
.withRealm { realm -> roomSummariesQuery(realm, queryParams).findAllAsync() }
.toFlow()
// need to create the flow on a context dispatcher with a thread with attached Looper
.flowOn(coroutineDispatchers.main)
.map { it.size }
.flowOn(coroutineDispatchers.io)
.distinctUntilChanged()
fun getCountLive(queryParams: RoomSummaryQueryParams): LiveData<Int> {
val liveRooms = monarchy.findAllManagedWithChanges {
roomSummariesQuery(it, queryParams)
}
return Transformations.map(liveRooms) {
it.realmResults.where().count().toInt()
}
}

fun getNotificationCountForRooms(queryParams: RoomSummaryQueryParams): RoomAggregateNotificationCount {
var notificationCount: RoomAggregateNotificationCount? = null
Expand Down
2 changes: 1 addition & 1 deletion vector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ ext.versionMinor = 4
// Note: even values are reserved for regular release, odd values for hotfix release.
// When creating a hotfix, you should decrease the value, since the current value
// is the value for the next regular release.
ext.versionPatch = 6
ext.versionPatch = 7

static def getGitTimestamp() {
def cmd = 'git show -s --format=%ct'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
import im.vector.app.features.home.room.list.widget.NotifsFabMenuView
import im.vector.app.features.notifications.NotificationDrawerManager
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -148,8 +149,10 @@ class RoomListFragment @Inject constructor(
}

private fun refreshCollapseStates() {
val sectionsCount = adapterInfosList.count { !it.sectionHeaderAdapter.roomsSectionData.isHidden }
roomListViewModel.sections.forEachIndexed { index, roomsSection ->
val actualBlock = adapterInfosList[index]
val isRoomSectionCollapsable = sectionsCount > 1
val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue()
if (actualBlock.section.isExpanded && !isRoomSectionExpanded) {
// mark controller as collapsed
Expand All @@ -158,12 +161,18 @@ class RoomListFragment @Inject constructor(
// we must expand!
actualBlock.contentEpoxyController.setCollapsed(false)
}
actualBlock.section = actualBlock.section.copy(
isExpanded = isRoomSectionExpanded
)
actualBlock.sectionHeaderAdapter.updateSection(
actualBlock.sectionHeaderAdapter.roomsSectionData.copy(isExpanded = isRoomSectionExpanded)
)
actualBlock.section = actualBlock.section.copy(isExpanded = isRoomSectionExpanded)
actualBlock.sectionHeaderAdapter.updateSection {
it.copy(
isExpanded = isRoomSectionExpanded,
isCollapsable = isRoomSectionCollapsable
)
}

if (!isRoomSectionExpanded && !isRoomSectionCollapsable) {
// force expand if the section is not collapsable
roomListViewModel.handle(RoomListAction.ToggleSection(roomsSection))
}
}
}

Expand Down Expand Up @@ -271,32 +280,36 @@ class RoomListFragment @Inject constructor(

val concatAdapter = ConcatAdapter()

roomListViewModel.sections.forEach { section ->
val sectionAdapter = SectionHeaderAdapter {
roomListViewModel.handle(RoomListAction.ToggleSection(section))
}.also {
it.updateSection(SectionHeaderAdapter.RoomsSectionData(section.sectionName))
roomListViewModel.sections.forEachIndexed { index, section ->
val sectionAdapter = SectionHeaderAdapter(SectionHeaderAdapter.RoomsSectionData(section.sectionName)) {
if (adapterInfosList[index].sectionHeaderAdapter.roomsSectionData.isCollapsable) {
roomListViewModel.handle(RoomListAction.ToggleSection(section))
}
}

val contentAdapter =
when {
section.livePages != null -> {
pagedControllerFactory.createRoomSummaryPagedController()
.also { controller ->
section.livePages.observe(viewLifecycleOwner) { pl ->
controller.submitList(pl)
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
isHidden = pl.isEmpty(),
isLoading = false
))
sectionAdapter.updateSection {
it.copy(
isHidden = pl.isEmpty(),
isLoading = false
)
}
refreshCollapseStates()
checkEmptyState()
}
observeItemCount(section, sectionAdapter)
section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight
))
sectionAdapter.updateSection {
it.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight,
)
}
}
section.isExpanded.observe(viewLifecycleOwner) { _ ->
refreshCollapseStates()
Expand All @@ -309,10 +322,13 @@ class RoomListFragment @Inject constructor(
.also { controller ->
section.liveSuggested.observe(viewLifecycleOwner) { info ->
controller.setData(info)
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
isHidden = info.rooms.isEmpty(),
isLoading = false
))
sectionAdapter.updateSection {
it.copy(
isHidden = info.rooms.isEmpty(),
isLoading = false
)
}
refreshCollapseStates()
checkEmptyState()
}
observeItemCount(section, sectionAdapter)
Expand All @@ -327,17 +343,23 @@ class RoomListFragment @Inject constructor(
.also { controller ->
section.liveList?.observe(viewLifecycleOwner) { list ->
controller.setData(list)
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
isHidden = list.isEmpty(),
isLoading = false))
sectionAdapter.updateSection {
it.copy(
isHidden = list.isEmpty(),
isLoading = false,
)
}
refreshCollapseStates()
checkEmptyState()
}
observeItemCount(section, sectionAdapter)
section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight
))
sectionAdapter.updateSection {
it.copy(
notificationCount = counts.totalCount,
isHighlighted = counts.isHighlight
)
}
}
section.isExpanded.observe(viewLifecycleOwner) { _ ->
refreshCollapseStates()
Expand Down Expand Up @@ -384,10 +406,11 @@ class RoomListFragment @Inject constructor(
lifecycleScope.launch {
section.itemCount
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)
.filter { it > 0 }
.collect { count ->
sectionAdapter.updateSection(
sectionAdapter.roomsSectionData.copy(itemCount = count)
)
sectionAdapter.updateSection {
it.copy(itemCount = count)
}
}
}
}
Expand Down
Loading

0 comments on commit 9ec684f

Please sign in to comment.