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 -> unreadMessagesSharedViewModel.subscribe { state ->
if (vectorPreferences.labSpaces()) { views.drawerUnreadCounterBadgeView.render(
views.drawerUnreadCounterBadgeView.render( UnreadCounterBadgeView.State(
UnreadCounterBadgeView.State( count = state.otherSpacesUnread.totalCount,
count = state.otherSpacesUnread.totalCount, highlighted = state.otherSpacesUnread.isHighlight
highlighted = state.otherSpacesUnread.isHighlight )
) )
)
} else {
views.drawerUnreadCounterBadgeView.isVisible = false
}
} }
sharedCallActionViewModel sharedCallActionViewModel

View file

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

View file

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

View file

@ -20,12 +20,10 @@ import android.media.RingtoneManager
import android.net.Uri import android.net.Uri
import android.provider.MediaStore import android.provider.MediaStore
import androidx.core.content.edit import androidx.core.content.edit
import androidx.lifecycle.LiveData
import com.squareup.seismic.ShakeDetector import com.squareup.seismic.ShakeDetector
import im.vector.app.BuildConfig import im.vector.app.BuildConfig
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.di.DefaultSharedPreferences 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.disclaimer.SHARED_PREF_KEY
import im.vector.app.features.homeserver.ServerUrlsRepository import im.vector.app.features.homeserver.ServerUrlsRepository
import im.vector.app.features.themes.ThemeUtils 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) 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 { fun failFast(): Boolean {
return BuildConfig.DEBUG || (developerMode() && defaultPrefs.getBoolean(SETTINGS_DEVELOPER_MODE_FAIL_FAST_PREFERENCE_KEY, false)) 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 package im.vector.app.features.settings
import im.vector.app.R 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 import javax.inject.Inject
class VectorSettingsLabsFragment @Inject constructor( class VectorSettingsLabsFragment @Inject constructor(
@ -30,11 +27,6 @@ class VectorSettingsLabsFragment @Inject constructor(
override val preferenceXmlRes = R.xml.vector_settings_labs override val preferenceXmlRes = R.xml.vector_settings_labs
override fun bindPref() { override fun bindPref() {
findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_USE_SPACES)!!.let { pref -> // Nothing to do
pref.setOnPreferenceChangeListener { _, _ ->
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false))
true
}
}
} }
} }

View file

@ -2198,9 +2198,6 @@
<string name="labs_swipe_to_reply_in_timeline">Enable swipe to reply in timeline</string> <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_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="link_copied_to_clipboard">Link copied to clipboard</string>
<string name="add_by_matrix_id">Add by matrix ID</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" /> android:title="@string/labs_show_unread_notifications_as_tab" />
<!--</im.vector.app.core.preference.VectorPreferenceCategory>--> <!--</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> </androidx.preference.PreferenceScreen>