Merge pull request #5131 from vector-im/feature/nfe/spaces_promo_removal

spaces restricted promo removed
This commit is contained in:
Benoit Marty 2022-02-03 00:44:07 +01:00 committed by GitHub
commit 6ebba4e3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 6 additions and 277 deletions

1
changelog.d/4315.misc Normal file
View File

@ -0,0 +1 @@
Removed spaces restricted search hint dialogs

View File

@ -39,7 +39,6 @@ import im.vector.app.features.discovery.DiscoverySettingsViewModel
import im.vector.app.features.discovery.change.SetIdentityServerViewModel
import im.vector.app.features.home.HomeActivityViewModel
import im.vector.app.features.home.HomeDetailViewModel
import im.vector.app.features.home.PromoteRestrictedViewModel
import im.vector.app.features.home.UnknownDeviceDetectorSharedViewModel
import im.vector.app.features.home.UnreadMessagesSharedViewModel
import im.vector.app.features.home.UserColorAccountDataViewModel
@ -241,11 +240,6 @@ interface MavericksViewModelModule {
@MavericksViewModelKey(SharedSecureStorageViewModel::class)
fun sharedSecureStorageViewModelFactory(factory: SharedSecureStorageViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(PromoteRestrictedViewModel::class)
fun promoteRestrictedViewModelFactory(factory: PromoteRestrictedViewModel.Factory): MavericksAssistedViewModelFactory<*, *>
@Binds
@IntoMap
@MavericksViewModelKey(UserListViewModel::class)

View File

@ -66,7 +66,6 @@ import im.vector.app.features.rageshake.ReportType
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.RestrictedPromoBottomSheet
import im.vector.app.features.spaces.SpaceCreationActivity
import im.vector.app.features.spaces.SpacePreviewActivity
import im.vector.app.features.spaces.SpaceSettingsMenuBottomSheet
@ -111,7 +110,6 @@ class HomeActivity :
private val userColorAccountDataViewModel: UserColorAccountDataViewModel by viewModel()
private val serverBackupStatusViewModel: ServerBackupStatusViewModel by viewModel()
private val promoteRestrictedViewModel: PromoteRestrictedViewModel by viewModel()
@Inject lateinit var activeSessionHolder: ActiveSessionHolder
@Inject lateinit var vectorUncaughtExceptionHandler: VectorUncaughtExceptionHandler
@ -267,21 +265,6 @@ class HomeActivity :
shortcutsHandler.observeRoomsAndBuildShortcuts(lifecycleScope)
if (!vectorPreferences.didPromoteNewRestrictedFeature()) {
promoteRestrictedViewModel.onEach {
if (it.activeSpaceSummary != null && !it.activeSpaceSummary.isPublic &&
it.activeSpaceSummary.otherMemberIds.isNotEmpty()) {
// It's a private space with some members show this once
if (it.canUserManageSpace && !popupAlertManager.hasAlertsToShow()) {
if (!vectorPreferences.didPromoteNewRestrictedFeature()) {
vectorPreferences.setDidPromoteNewRestrictedFeature()
RestrictedPromoBottomSheet().show(supportFragmentManager, "RestrictedPromoBottomSheet")
}
}
}
}
}
if (isFirstCreation()) {
handleIntent(intent)
}

View File

@ -1,82 +0,0 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.home
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MavericksViewModelFactory
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.di.ActiveSessionHolder
import im.vector.app.core.di.MavericksAssistedViewModelFactory
import im.vector.app.core.di.hiltMavericksViewModelFactory
import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel
import kotlinx.coroutines.flow.distinctUntilChanged
import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.events.model.EventType
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.api.session.room.model.PowerLevelsContent
import org.matrix.android.sdk.api.session.room.model.RoomSummary
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
data class ActiveSpaceViewState(
val isInSpaceMode: Boolean = false,
val activeSpaceSummary: RoomSummary? = null,
val canUserManageSpace: Boolean = false
) : MavericksState
class PromoteRestrictedViewModel @AssistedInject constructor(
@Assisted initialState: ActiveSpaceViewState,
private val activeSessionHolder: ActiveSessionHolder,
appStateHandler: AppStateHandler
) : VectorViewModel<ActiveSpaceViewState, EmptyAction, EmptyViewEvents>(initialState) {
init {
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().execute { state ->
val groupingMethod = state.invoke()?.orNull()
val isSpaceMode = groupingMethod is RoomGroupingMethod.BySpace
val currentSpace = (groupingMethod as? RoomGroupingMethod.BySpace)?.spaceSummary
val canManage = currentSpace?.roomId?.let { roomId ->
activeSessionHolder.getSafeActiveSession()
?.getRoom(roomId)
?.getStateEvent(EventType.STATE_ROOM_POWER_LEVELS, QueryStringValue.NoCondition)
?.content?.toModel<PowerLevelsContent>()?.let {
PowerLevelsHelper(it).isUserAllowedToSend(activeSessionHolder.getActiveSession().myUserId, true, EventType.STATE_SPACE_CHILD)
} ?: false
} ?: false
copy(
isInSpaceMode = isSpaceMode,
activeSpaceSummary = currentSpace,
canUserManageSpace = canManage
)
}
}
@AssistedFactory
interface Factory : MavericksAssistedViewModelFactory<PromoteRestrictedViewModel, ActiveSpaceViewState> {
override fun create(initialState: ActiveSpaceViewState): PromoteRestrictedViewModel
}
companion object : MavericksViewModelFactory<PromoteRestrictedViewModel, ActiveSpaceViewState> by hiltMavericksViewModelFactory()
override fun handle(action: EmptyAction) {}
}

View File

@ -185,7 +185,6 @@ class VectorPreferences @Inject constructor(private val context: Context) {
private const val SETTINGS_DISPLAY_ALL_EVENTS_KEY = "SETTINGS_DISPLAY_ALL_EVENTS_KEY"
private const val DID_ASK_TO_ENABLE_SESSION_PUSH = "DID_ASK_TO_ENABLE_SESSION_PUSH"
private const val DID_PROMOTE_NEW_RESTRICTED_JOIN_RULE = "DID_PROMOTE_NEW_RESTRICTED_JOIN_RULE"
// Location Sharing
const val SETTINGS_PREF_ENABLE_LOCATION_SHARING = "SETTINGS_PREF_ENABLE_LOCATION_SHARING"
@ -356,16 +355,6 @@ class VectorPreferences @Inject constructor(private val context: Context) {
}
}
fun didPromoteNewRestrictedFeature(): Boolean {
return defaultPrefs.getBoolean(DID_PROMOTE_NEW_RESTRICTED_JOIN_RULE, false)
}
fun setDidPromoteNewRestrictedFeature() {
defaultPrefs.edit {
putBoolean(DID_PROMOTE_NEW_RESTRICTED_JOIN_RULE, true)
}
}
/**
* Tells if we have already asked the user to disable battery optimisations on android >= M devices.
*

View File

@ -1,72 +0,0 @@
/*
* Copyright (c) 2021 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.app.features.spaces
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.view.isVisible
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
import im.vector.app.databinding.BottomSheetSpaceAdvertiseRestrictedBinding
class RestrictedPromoBottomSheet : VectorBaseBottomSheetDialogFragment<BottomSheetSpaceAdvertiseRestrictedBinding>() {
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?) =
BottomSheetSpaceAdvertiseRestrictedBinding.inflate(inflater, container, false)
override val showExpanded = true
var learnMoreMode: Boolean = false
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
render()
views.skipButton.debouncedClicks {
dismiss()
}
views.learnMore.debouncedClicks {
if (learnMoreMode) {
dismiss()
} else {
learnMoreMode = true
render()
}
}
}
private fun render() {
if (learnMoreMode) {
views.title.text = getString(R.string.new_let_people_in_spaces_find_and_join)
views.topDescription.text = getString(R.string.to_help_space_members_find_and_join)
views.imageHint.isVisible = true
views.bottomDescription.isVisible = true
views.bottomDescription.text = getString(R.string.this_makes_it_easy_for_rooms_to_stay_private_to_a_space)
views.skipButton.isVisible = false
views.learnMore.text = getString(R.string.ok)
} else {
views.title.text = getString(R.string.help_space_members)
views.topDescription.text = getString(R.string.help_people_in_spaces_find_and_join)
views.imageHint.isVisible = false
views.bottomDescription.isVisible = false
views.skipButton.isVisible = true
views.learnMore.text = getString(R.string.learn_more)
}
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,89 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://www.figma.com/file/HOGxCoUWoedha639SjD90n/%5BBeta%5D-Restricted-room-access?node-id=107%3A61157 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurface"
android:orientation="vertical"
android:padding="16dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:layout_marginTop="16dp"
android:layout_marginBottom="12dp"
android:importantForAccessibility="no"
android:src="@drawable/ic_beta_pill" />
<TextView
style="@style/Widget.Vector.TextView.Title"
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="12dp"
android:gravity="start"
tools:text="@string/new_let_people_in_spaces_find_and_join"
android:textColor="?vctr_content_primary"
android:textStyle="bold" />
<TextView
style="@style/Widget.Vector.TextView.Body"
android:id="@+id/topDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="start"
android:textColor="?vctr_content_secondary"
tools:text="@string/help_people_in_spaces_find_and_join" />
<ImageView
android:id="@+id/imageHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAccessibility="no"
android:maxWidth="300dp"
android:src="@drawable/room_settings"
android:visibility="gone"
tools:visibility="visible" />
<TextView
style="@style/Widget.Vector.TextView.Body"
android:id="@+id/bottomDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="start"
android:text="@string/this_makes_it_easy_for_rooms_to_stay_private_to_a_space"
android:textColor="?vctr_content_secondary"
android:visibility="gone"
tools:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_vertical_margin"
android:gravity="end"
android:orientation="horizontal">
<Button
android:id="@+id/skipButton"
style="@style/Widget.Vector.Button.Text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:text="@string/action_skip"
android:textAllCaps="true" />
<Button
android:id="@+id/learnMore"
style="@style/Widget.Vector.Button.Positive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/learn_more"
android:textAllCaps="true" />
</LinearLayout>
</LinearLayout>

View File

@ -3672,10 +3672,15 @@
<string name="upgrade_room_for_restricted_note">Please note upgrading will make a new version of the room. All current messages will stay in this archived room.</string>
<!-- TODO TO BE REMOVED -->
<string name="new_let_people_in_spaces_find_and_join">New: Let people in spaces find and join private rooms</string>
<!-- TODO TO BE REMOVED -->
<string name="help_people_in_spaces_find_and_join">Help people in spaces to find and join private rooms themselves, no need to manually invite everyone.</string>
<!-- TODO TO BE REMOVED -->
<string name="this_makes_it_easy_for_rooms_to_stay_private_to_a_space">This makes it easy for rooms to stay private to a space, while letting people in the space find and join them. All new rooms in a space will have this option available.</string>
<!-- TODO TO BE REMOVED -->
<string name="help_space_members">Help space members find private rooms</string>
<!-- TODO TO BE REMOVED -->
<string name="to_help_space_members_find_and_join">To help space members find and join a private room, go to that rooms settings by tapping on the avatar.</string>
<!-- %s will be replaced by an email at runtime -->