Remove space lab flags

This commit is contained in:
Valere 2021-04-26 10:13:33 +02:00
parent d186b73c90
commit dba6784487
7 changed files with 50 additions and 74 deletions

View file

@ -159,16 +159,12 @@ class HomeDetailFragment @Inject constructor(
}
unreadMessagesSharedViewModel.subscribe { state ->
if (vectorPreferences.labSpaces()) {
views.drawerUnreadCounterBadgeView.render(
UnreadCounterBadgeView.State(
count = state.otherSpacesUnread.totalCount,
highlighted = state.otherSpacesUnread.isHighlight
)
)
} else {
views.drawerUnreadCounterBadgeView.isVisible = false
}
views.drawerUnreadCounterBadgeView.render(
UnreadCounterBadgeView.State(
count = state.otherSpacesUnread.totalCount,
highlighted = state.otherSpacesUnread.isHighlight
)
)
}
sharedCallActionViewModel

View file

@ -59,11 +59,7 @@ class HomeDrawerFragment @Inject constructor(
sharedActionViewModel = activityViewModelProvider.get(HomeSharedActionViewModel::class.java)
if (savedInstanceState == null) {
// if (vectorPreferences.labSpaces()) {
replaceChildFragment(R.id.homeDrawerGroupListContainer, SpaceListFragment::class.java)
// } else {
// replaceChildFragment(R.id.homeDrawerGroupListContainer, GroupListFragment::class.java)
// }
replaceChildFragment(R.id.homeDrawerGroupListContainer, SpaceListFragment::class.java)
}
session.getUserLive(session.myUserId).observeK(viewLifecycleOwner) { optionalUser ->
val user = optionalUser?.getOrNull()

View file

@ -25,10 +25,10 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import im.vector.app.AppStateHandler
import im.vector.app.RoomGroupingMethod
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.settings.VectorPreferences
import io.reactivex.Observable
import io.reactivex.functions.BiFunction
import io.reactivex.schedulers.Schedulers
@ -53,8 +53,7 @@ data class CountInfo(
class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initialState: UnreadMessagesState,
session: Session,
appStateHandler: AppStateHandler,
private val vectorPreferences: VectorPreferences)
appStateHandler: AppStateHandler)
: VectorViewModel<UnreadMessagesState, EmptyAction, EmptyViewEvents>(initialState) {
@AssistedFactory
@ -119,30 +118,47 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
.throttleFirst(300, TimeUnit.MILLISECONDS)
.observeOn(Schedulers.computation())
},
BiFunction { _, _ ->
val selectedSpace = appStateHandler.safeActiveSpaceId()
val counts = session.getNotificationCountForRooms(
roomSummaryQueryParams {
this.memberships = listOf(Membership.JOIN)
this.activeSpaceId = ActiveSpaceFilter.ActiveSpace(null)
}
)
val rootCounts = session.spaceService().getRootSpaceSummaries()
.filter {
// filter out current selection
it.roomId != selectedSpace
}
CountInfo(
homeCount = counts,
otherCount = RoomAggregateNotificationCount(
rootCounts.fold(0, { acc, rs ->
acc + rs.notificationCount
}) + (counts.notificationCount.takeIf { selectedSpace != null } ?: 0),
rootCounts.fold(0, { acc, rs ->
acc + rs.highlightCount
}) + (counts.highlightCount.takeIf { selectedSpace != null } ?: 0)
BiFunction { groupingMethod, _ ->
when (groupingMethod.orNull()) {
is RoomGroupingMethod.ByLegacyGroup -> {
// currently not supported
CountInfo(
RoomAggregateNotificationCount(0, 0),
RoomAggregateNotificationCount(0, 0)
)
)
}
is RoomGroupingMethod.BySpace -> {
val selectedSpace = appStateHandler.safeActiveSpaceId()
val counts = session.getNotificationCountForRooms(
roomSummaryQueryParams {
this.memberships = listOf(Membership.JOIN)
this.activeSpaceId = ActiveSpaceFilter.ActiveSpace(null)
}
)
val rootCounts = session.spaceService().getRootSpaceSummaries()
.filter {
// filter out current selection
it.roomId != selectedSpace
}
CountInfo(
homeCount = counts,
otherCount = RoomAggregateNotificationCount(
rootCounts.fold(0, { acc, rs ->
acc + rs.notificationCount
}) + (counts.notificationCount.takeIf { selectedSpace != null } ?: 0),
rootCounts.fold(0, { acc, rs ->
acc + rs.highlightCount
}) + (counts.highlightCount.takeIf { selectedSpace != null } ?: 0)
)
)
}
null -> {
CountInfo(
RoomAggregateNotificationCount(0, 0),
RoomAggregateNotificationCount(0, 0)
)
}
}
}
).execute {
copy(

View file

@ -20,12 +20,10 @@ import android.media.RingtoneManager
import android.net.Uri
import android.provider.MediaStore
import androidx.core.content.edit
import androidx.lifecycle.LiveData
import com.squareup.seismic.ShakeDetector
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.core.platform.livedata.SharedPreferenceLiveData
import im.vector.app.features.disclaimer.SHARED_PREF_KEY
import im.vector.app.features.homeserver.ServerUrlsRepository
import im.vector.app.features.themes.ThemeUtils
@ -310,18 +308,6 @@ class VectorPreferences @Inject constructor(private val context: Context) {
return defaultPrefs.getBoolean(SETTINGS_LABS_UNREAD_NOTIFICATIONS_AS_TAB, false)
}
fun labSpaces(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_USE_SPACES, false)
}
fun labSpacesLive(): LiveData<Boolean> {
return SharedPreferenceLiveData.booleanLiveData(
defaultPrefs,
SETTINGS_LABS_USE_SPACES,
false
)
}
fun failFast(): Boolean {
return BuildConfig.DEBUG || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false))
}

View file

@ -17,9 +17,6 @@
package im.vector.app.features.settings
import im.vector.app.R
import im.vector.app.core.preference.VectorSwitchPreference
import im.vector.app.features.MainActivity
import im.vector.app.features.MainActivityArgs
import javax.inject.Inject
class VectorSettingsLabsFragment @Inject constructor(
@ -30,11 +27,6 @@ class VectorSettingsLabsFragment @Inject constructor(
override val preferenceXmlRes = R.xml.vector_settings_labs
override fun bindPref() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_USE_SPACES)!!.let { pref ->
pref.setOnPreferenceChangeListener { _, _ ->
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false))
true
}
}
// Nothing to do
}
}

View file

@ -2198,9 +2198,6 @@
<string name="labs_swipe_to_reply_in_timeline">Enable swipe to reply in timeline</string>
<string name="labs_show_unread_notifications_as_tab">Add a dedicated tab for unread notifications on main screen.</string>
<string name="labs_experimental_spaces">Spaces prototype</string>
<string name="labs_experimental_spaces_desc">Spaces are the new way to group people and rooms for work, fun or just yourself. You can try them out now on Android, or from your computer.</string>
<string name="link_copied_to_clipboard">Link copied to clipboard</string>
<string name="add_by_matrix_id">Add by matrix ID</string>

View file

@ -45,11 +45,4 @@
android:title="@string/labs_show_unread_notifications_as_tab" />
<!--</im.vector.app.core.preference.VectorPreferenceCategory>-->
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_LABS_USE_SPACES"
android:title="@string/labs_experimental_spaces"
android:summary="@string/labs_experimental_spaces_desc"/>
</androidx.preference.PreferenceScreen>