Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ internal class RoomChildRelationInfo(private val realm: Realm,
*/
fun getDirectChildrenDescriptions(): List<SpaceChildInfo> {
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_CHILD)
.findAll().also {
Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId")
}
.findAll()
// .also {
// Timber.v("## Space: Found ${it.count()} m.space.child state events for $roomId")
// }
.mapNotNull {
ContentMapper.map(it.root?.content).toModel<SpaceChildContent>()?.let { scc ->
Timber.v("## Space child desc state event $scc")
Expand All @@ -81,12 +82,13 @@ internal class RoomChildRelationInfo(private val realm: Realm,

fun getParentDescriptions(): List<SpaceParentInfo> {
return CurrentStateEventEntity.whereType(realm, roomId, EventType.STATE_SPACE_PARENT)
.findAll().also {
Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId")
}
.findAll()
// .also {
// Timber.v("## Space: Found ${it.count()} m.space.parent state events for $roomId")
// }
.mapNotNull {
ContentMapper.map(it.root?.content).toModel<SpaceParentContent>()?.let { scc ->
Timber.v("## Space parent desc state event $scc")
// Timber.v("## Space parent desc state event $scc")
// Parent where via is not present are ignored.
scc.via?.let { via ->
SpaceParentInfo(
Expand Down
4 changes: 3 additions & 1 deletion vector/src/main/java/im/vector/app/AppStateHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ class AppStateHandler @Inject constructor(
}
}

val rooms = currentSession.getFlattenRoomSummaryChildOf(currentSpace?.roomId?.takeIf { it != ALL_COMMUNITIES_GROUP_ID })
val rooms = currentSession.getFlattenRoomSummaryChildOf(
currentSpace?.roomId?.takeIf { it != ALL_COMMUNITIES_GROUP_ID }
)
(filteredDm + rooms).sortedWith(chronologicalRoomComparator)
// .also {
// Timber.w("VAL: live summaries update filter done ${System.currentTimeMillis() - startime}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package im.vector.app.core.ui.list

import android.graphics.Typeface
import android.view.Gravity
import android.widget.TextView
import androidx.annotation.ColorInt
Expand All @@ -36,7 +37,7 @@ import im.vector.app.features.themes.ThemeUtils
abstract class GenericFooterItem : VectorEpoxyModel<GenericFooterItem.Holder>() {

@EpoxyAttribute
var text: String? = null
var text: CharSequence? = null

@EpoxyAttribute
var style: GenericItem.STYLE = GenericItem.STYLE.NORMAL_TEXT
Expand All @@ -53,10 +54,17 @@ abstract class GenericFooterItem : VectorEpoxyModel<GenericFooterItem.Holder>()

override fun bind(holder: Holder) {
super.bind(holder)

holder.text.setTextOrHide(text)
holder.text.typeface = Typeface.DEFAULT
when (style) {
GenericItem.STYLE.BIG_TEXT -> holder.text.textSize = 18f
GenericItem.STYLE.NORMAL_TEXT -> holder.text.textSize = 14f
GenericItem.STYLE.SUBHEADER -> holder.text.textSize = 16f
GenericItem.STYLE.TITLE -> {
holder.text.textSize = 20f
holder.text.typeface = Typeface.DEFAULT_BOLD
}
}
holder.text.gravity = if (centered) Gravity.CENTER_HORIZONTAL else Gravity.START

Expand Down
12 changes: 8 additions & 4 deletions vector/src/main/java/im/vector/app/core/ui/list/GenericItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {

enum class STYLE {
BIG_TEXT,
NORMAL_TEXT
NORMAL_TEXT,
TITLE,
SUBHEADER
}

class Action(var title: String) {
Expand Down Expand Up @@ -87,9 +89,11 @@ abstract class GenericItem : VectorEpoxyModel<GenericItem.Holder>() {
holder.titleIcon.isVisible = false
}

when (style) {
STYLE.BIG_TEXT -> holder.titleText.textSize = 18f
STYLE.NORMAL_TEXT -> holder.titleText.textSize = 14f
holder.titleText.textSize = when (style) {
STYLE.BIG_TEXT -> 18f
STYLE.NORMAL_TEXT -> 14f
STYLE.TITLE -> 20f
STYLE.SUBHEADER -> 16f
}

holder.descriptionText.setTextOrHide(description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abstract class FormMultiLineEditTextItem : VectorEpoxyModel<FormMultiLineEditTex
holder.textInputLayout.error = errorMessage

holder.textInputEditText.typeface = typeFace
holder.textInputEditText.textSize = textSizeSp?.toFloat() ?: 12f
holder.textInputEditText.textSize = textSizeSp?.toFloat() ?: 14f
holder.textInputEditText.minLines = minLines

// Update only if text is different and value is not null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import im.vector.app.features.popup.VerificationVectorAlert
import im.vector.app.features.rageshake.VectorUncaughtExceptionHandler
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.features.settings.VectorSettingsActivity
import im.vector.app.features.spaces.ShareSpaceBottomSheet
import im.vector.app.features.spaces.SpaceCreationActivity
import im.vector.app.features.spaces.SpacePreviewActivity
import im.vector.app.features.spaces.SpaceSettingsMenuBottomSheet
Expand Down Expand Up @@ -168,7 +169,11 @@ class HomeActivity :
is HomeActivitySharedAction.ShowSpaceSettings -> {
// open bottom sheet
SpaceSettingsMenuBottomSheet
.newInstance(sharedAction.spaceId)
.newInstance(sharedAction.spaceId, object : SpaceSettingsMenuBottomSheet.InteractionListener {
override fun onShareSpaceSelected(spaceId: String) {
ShareSpaceBottomSheet.show(supportFragmentManager, spaceId)
}
})
.show(supportFragmentManager, "SPACE_SETTINGS")
}
}.exhaustive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.airbnb.mvrx.ViewModelContext
import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.utils.DataSource
import im.vector.app.features.grouplist.SelectedSpaceDataSource
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -46,7 +47,8 @@ import javax.inject.Inject
class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
private val session: Session,
private val roomSummariesSource: DataSource<List<RoomSummary>>,
suggestedRoomListDataSource: DataSource<List<SpaceChildInfo>>)
suggestedRoomListDataSource: DataSource<List<SpaceChildInfo>>,
selectedSpaceDataSource: SelectedSpaceDataSource)
: VectorViewModel<RoomListViewState, RoomListAction, RoomListViewEvents>(initialState) {

interface Factory {
Expand All @@ -73,20 +75,38 @@ class RoomListViewModel @Inject constructor(initialState: RoomListViewState,
.execute { info ->
copy(asyncSuggestedRooms = info)
}.disposeOnClear()

selectedSpaceDataSource.observe()
.map { it.orNull() }
.distinctUntilChanged()
.execute {
copy(
currentSpace = it
)
}

session.rx().liveUser(session.myUserId)
.map { it.getOrNull()?.getBestName() }
.distinctUntilChanged()
.execute {
copy(
currentUserName = it.invoke() ?: session.myUserId
)
}
}

override fun handle(action: RoomListAction) {
when (action) {
is RoomListAction.SelectRoom -> handleSelectRoom(action)
is RoomListAction.ToggleCategory -> handleToggleCategory(action)
is RoomListAction.AcceptInvitation -> handleAcceptInvitation(action)
is RoomListAction.RejectInvitation -> handleRejectInvitation(action)
is RoomListAction.FilterWith -> handleFilter(action)
is RoomListAction.MarkAllRoomsRead -> handleMarkAllRoomsRead()
is RoomListAction.LeaveRoom -> handleLeaveRoom(action)
is RoomListAction.SelectRoom -> handleSelectRoom(action)
is RoomListAction.ToggleCategory -> handleToggleCategory(action)
is RoomListAction.AcceptInvitation -> handleAcceptInvitation(action)
is RoomListAction.RejectInvitation -> handleRejectInvitation(action)
is RoomListAction.FilterWith -> handleFilter(action)
is RoomListAction.MarkAllRoomsRead -> handleMarkAllRoomsRead()
is RoomListAction.LeaveRoom -> handleLeaveRoom(action)
is RoomListAction.ChangeRoomNotificationState -> handleChangeNotificationMode(action)
is RoomListAction.ToggleTag -> handleToggleTag(action)
is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action)
is RoomListAction.ToggleTag -> handleToggleTag(action)
is RoomListAction.JoinSuggestedRoom -> handleJoinSuggestedRoom(action)
}.exhaustive
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package im.vector.app.features.home.room.list

import im.vector.app.features.grouplist.SelectedSpaceDataSource
import im.vector.app.features.home.CurrentSpaceSuggestedRoomListDataSource
import im.vector.app.features.home.HomeRoomListDataSource
import org.matrix.android.sdk.api.session.Session
Expand All @@ -24,15 +25,17 @@ import javax.inject.Provider

class RoomListViewModelFactory @Inject constructor(private val session: Provider<Session>,
private val homeRoomListDataSource: Provider<HomeRoomListDataSource>,
private val suggestedRoomDataSource: Provider<CurrentSpaceSuggestedRoomListDataSource>)
private val suggestedRoomDataSource: Provider<CurrentSpaceSuggestedRoomListDataSource>,
private val selectedSpaceDataSource: Provider<SelectedSpaceDataSource>)
: RoomListViewModel.Factory {

override fun create(initialState: RoomListViewState): RoomListViewModel {
return RoomListViewModel(
initialState,
session.get(),
homeRoomListDataSource.get(),
suggestedRoomDataSource.get()
suggestedRoomDataSource.get(),
selectedSpaceDataSource.get()
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ data class RoomListViewState(
val roomFilter: String = "",
val asyncFilteredRooms: Async<RoomSummaries> = Uninitialized,
val roomMembershipChanges: Map<String, ChangeMembershipState> = emptyMap(),
val currentUserName: String = "",
val currentSpace: Async<RoomSummary?> = Uninitialized,
val isInviteExpanded: Boolean = true,
val isFavouriteRoomsExpanded: Boolean = true,
val isDirectRoomsExpanded: Boolean = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import com.airbnb.epoxy.EpoxyController
import com.airbnb.mvrx.Success
import im.vector.app.R
import im.vector.app.core.epoxy.helpFooterItem
import im.vector.app.core.resources.ColorProvider
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.resources.UserPreferencesProvider
import im.vector.app.core.ui.list.GenericItem
import im.vector.app.core.ui.list.genericFooterItem
import im.vector.app.features.home.RoomListDisplayMode
import im.vector.app.features.home.room.filtered.FilteredRoomFooterItem
Expand All @@ -36,7 +38,8 @@ import javax.inject.Inject
class RoomSummaryController @Inject constructor(private val stringProvider: StringProvider,
private val roomSummaryItemFactory: RoomSummaryItemFactory,
private val roomListNameFilter: RoomListNameFilter,
private val userPreferencesProvider: UserPreferencesProvider
private val userPreferencesProvider: UserPreferencesProvider,
private val colorProvider: ColorProvider
) : EpoxyController() {

var listener: Listener? = null
Expand Down Expand Up @@ -118,6 +121,17 @@ class RoomSummaryController @Inject constructor(private val stringProvider: Stri
}
if (suggested?.isNotEmpty() == true) {
if (roomSummaries.isNullOrEmpty()) {
genericFooterItem {
id("empty_suggested_header")
centered(false)
style(GenericItem.STYLE.TITLE)
text(stringProvider.getString(
R.string.suggested_rooms_pills_on_empty_header,
viewState.currentSpace.invoke()?.name,
viewState.currentUserName
))
textColor(colorProvider.getColorFromAttribute(R.attr.riot_primary_text_color))
}
genericFooterItem {
id("empty_suggested")
centered(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.os.Parcelable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentManager
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
Expand Down Expand Up @@ -64,6 +65,8 @@ class ShareSpaceBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpa
val spaceName = summary?.name
views.descriptionText.text = getString(R.string.invite_people_to_your_space_desc, spaceName)

// XXX enable back when supported
views.inviteByMailButton.isVisible = false
views.inviteByMailButton.debouncedClicks {
}

Expand All @@ -84,9 +87,9 @@ class ShareSpaceBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpa
}
}

views.skipButton.debouncedClicks {
dismiss()
}
// views.skipButton.debouncedClicks {
// dismiss()
// }
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class SpaceCreationActivity : SimpleFragmentActivity(), CreateSpaceViewModel.Fac

override fun initUiAndData() {
super.initUiAndData()

viewModel.subscribe(this) {
renderState(it)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomS

private val spaceArgs: SpaceBottomSheetSettingsArgs by args()

interface InteractionListener {
fun onShareSpaceSelected(spaceId: String)
}

var interactionListener : InteractionListener? = null

override fun injectWith(injector: ScreenComponent) {
injector.inject(this)
}
Expand Down Expand Up @@ -89,7 +95,8 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomS
}.disposeOnDestroyView()

views.invitePeople.views.bottomSheetActionClickableZone.debouncedClicks {
navigator.openInviteUsersToRoom(requireContext(), spaceArgs.spaceId)
dismiss()
interactionListener?.onShareSpaceSelected(spaceArgs.spaceId)
}

views.showMemberList.views.bottomSheetActionClickableZone.debouncedClicks {
Expand Down Expand Up @@ -126,8 +133,9 @@ class SpaceSettingsMenuBottomSheet : VectorBaseBottomSheetDialogFragment<BottomS
}

companion object {
fun newInstance(spaceId: String): SpaceSettingsMenuBottomSheet {
fun newInstance(spaceId: String, interactionListener: InteractionListener): SpaceSettingsMenuBottomSheet {
return SpaceSettingsMenuBottomSheet().apply {
this.interactionListener = interactionListener
setArguments(SpaceBottomSheetSettingsArgs(spaceId))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ class SpaceSummaryController @Inject constructor(
// it's expanded
subSpaces?.forEach { child ->
summaries.firstOrNull { it.roomId == child.childRoomId }?.let { childSum ->
val isSelected = childSum.roomId == selected?.roomId
val isChildSelected = childSum.roomId == selected?.roomId
spaceSummaryItem {
avatarRenderer(avatarRenderer)
id(child.childRoomId)
hasChildren(false)
selected(isSelected)
selected(isChildSelected)
matrixItem(MatrixItem.RoomItem(child.childRoomId, child.name, child.avatarUrl))
listener { callback?.onSpaceSelected(childSum) }
indent(1)
Expand Down
Loading