Merge remote-tracking branch 'origin/develop' into feature/eric/new-layout-labs

This commit is contained in:
ericdecanini 2022-09-07 10:35:44 +02:00
commit 64c8789ef2
18 changed files with 230 additions and 7 deletions

1
changelog.d/7040.wip Normal file
View file

@ -0,0 +1 @@
[New Layout] Adds header to spaces bottom sheet

View file

@ -139,6 +139,7 @@
<string name="all_chats">All Chats</string>
<string name="start_chat">Start Chat</string>
<string name="create_room">Create Room</string>
<string name="change_space">Change Space</string>
<string name="explore_rooms">Explore Rooms</string>
<!-- Note to translators: %s refers to the space whose children is being expanded -->
<string name="a11y_expand_space_children">Expand %s children</string>

View file

@ -20,6 +20,8 @@ import android.os.Build
import androidx.test.platform.app.InstrumentationRegistry
import im.vector.app.AndroidVersionTestOverrider
import im.vector.app.features.DefaultVectorFeatures
import io.mockk.every
import io.mockk.spyk
import org.amshove.kluent.shouldBeInstanceOf
import org.junit.After
import org.junit.Test
@ -27,7 +29,7 @@ import org.junit.Test
class VoiceRecorderProviderTests {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val provider = VoiceRecorderProvider(context, DefaultVectorFeatures())
private val provider = spyk(VoiceRecorderProvider(context, DefaultVectorFeatures()))
@After
fun tearDown() {
@ -35,11 +37,19 @@ class VoiceRecorderProviderTests {
}
@Test
fun provideVoiceRecorderOnAndroidQReturnsQRecorder() {
fun provideVoiceRecorderOnAndroidQAndCodecReturnsQRecorder() {
AndroidVersionTestOverrider.override(Build.VERSION_CODES.Q)
every { provider.hasOpusEncoder() } returns true
provider.provideVoiceRecorder().shouldBeInstanceOf(VoiceRecorderQ::class)
}
@Test
fun provideVoiceRecorderOnAndroidQButNoCodecReturnsLRecorder() {
AndroidVersionTestOverrider.override(Build.VERSION_CODES.Q)
every { provider.hasOpusEncoder() } returns false
provider.provideVoiceRecorder().shouldBeInstanceOf(VoiceRecorderL::class)
}
@Test
fun provideVoiceRecorderOnOlderAndroidVersionReturnsLRecorder() {
AndroidVersionTestOverrider.override(Build.VERSION_CODES.LOLLIPOP)

View file

@ -16,6 +16,8 @@
package im.vector.app.features.debug.settings
import android.annotation.SuppressLint
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -24,6 +26,7 @@ import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentDebugPrivateSettingsBinding
import im.vector.app.features.home.room.list.home.release.ReleaseNotesActivity
class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSettingsBinding>() {
@ -35,7 +38,6 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setViewListeners()
}
@ -46,6 +48,12 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
views.forceLoginFallback.setOnCheckedChangeListener { _, isChecked ->
viewModel.handle(DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled(isChecked))
}
views.releaseNotesActivityHasBeenDisplayedReset.setOnClickListener {
viewModel.handle(DebugPrivateSettingsViewActions.ResetReleaseNotesActivityHasBeenDisplayed)
}
views.showReleaseNotesActivity.setOnClickListener {
startActivity(Intent(requireActivity(), ReleaseNotesActivity::class.java))
}
}
override fun invalidate() = withState(viewModel) {
@ -57,5 +65,7 @@ class DebugPrivateSettingsFragment : VectorBaseFragment<FragmentDebugPrivateSett
viewModel.handle(DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride(option))
}
views.forceLoginFallback.isChecked = it.forceLoginFallback
@SuppressLint("SetTextI18n")
views.releaseNotesActivityHasBeenDisplayed.text = "ReleaseNotesActivity has been displayed: ${it.releaseNotesActivityHasBeenDisplayed}"
}
}

View file

@ -23,4 +23,5 @@ sealed interface DebugPrivateSettingsViewActions : VectorViewModelAction {
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions
data class SetDisplayNameCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
data class SetAvatarCapabilityOverride(val option: BooleanHomeserverCapabilitiesOverride?) : DebugPrivateSettingsViewActions
object ResetReleaseNotesActivityHasBeenDisplayed : DebugPrivateSettingsViewActions
}

View file

@ -27,11 +27,13 @@ import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.debug.features.DebugVectorOverrides
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewActions.SetAvatarCapabilityOverride
import im.vector.app.features.debug.settings.DebugPrivateSettingsViewActions.SetDisplayNameCapabilityOverride
import im.vector.app.features.home.room.list.home.release.ReleaseNotesPreferencesStore
import kotlinx.coroutines.launch
class DebugPrivateSettingsViewModel @AssistedInject constructor(
@Assisted initialState: DebugPrivateSettingsViewState,
private val debugVectorOverrides: DebugVectorOverrides
private val debugVectorOverrides: DebugVectorOverrides,
private val releaseNotesPreferencesStore: ReleaseNotesPreferencesStore,
) : VectorViewModel<DebugPrivateSettingsViewState, DebugPrivateSettingsViewActions, EmptyViewEvents>(initialState) {
@AssistedFactory
@ -43,6 +45,15 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
init {
observeVectorOverrides()
observeReleaseNotesPreferencesStore()
}
private fun observeReleaseNotesPreferencesStore() {
releaseNotesPreferencesStore.appLayoutOnboardingShown.setOnEach {
copy(
releaseNotesActivityHasBeenDisplayed = it
)
}
}
private fun observeVectorOverrides() {
@ -72,6 +83,13 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action)
is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action)
DebugPrivateSettingsViewActions.ResetReleaseNotesActivityHasBeenDisplayed -> handleResetReleaseNotesActivityHasBeenDisplayed()
}
}
private fun handleResetReleaseNotesActivityHasBeenDisplayed() {
viewModelScope.launch {
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(false)
}
}

View file

@ -22,7 +22,8 @@ import im.vector.app.features.debug.settings.OverrideDropdownView.OverrideDropdo
data class DebugPrivateSettingsViewState(
val dialPadVisible: Boolean = false,
val forceLoginFallback: Boolean = false,
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides()
val homeserverCapabilityOverrides: HomeserverCapabilityOverrides = HomeserverCapabilityOverrides(),
val releaseNotesActivityHasBeenDisplayed: Boolean = false,
) : MavericksState
data class HomeserverCapabilityOverrides(

View file

@ -49,6 +49,27 @@
android:layout_marginEnd="16dp"
android:layout_marginBottom="4dp" />
<TextView
android:id="@+id/releaseNotesActivityHasBeenDisplayed"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
tools:text="ReleaseNotesActivity has been displayed: " />
<Button
android:id="@+id/releaseNotesActivityHasBeenDisplayedReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="Reset" />
<Button
android:id="@+id/showReleaseNotesActivity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="SHOW ReleaseNotesActivity"
android:textAllCaps="false" />
</LinearLayout>
</ScrollView>

View file

@ -40,6 +40,46 @@ data class Interaction(
) : VectorAnalyticsEvent {
enum class Name {
/**
* User tapped the All filter in the All Chats filter tab.
*/
MobileAllChatsFilterAll,
/**
* User tapped the Favourites filter in the All Chats filter tab.
*/
MobileAllChatsFilterFavourites,
/**
* User tapped the People filter in the All Chats filter tab.
*/
MobileAllChatsFilterPeople,
/**
* User tapped the Unreads filter in the All Chats filter tab.
*/
MobileAllChatsFilterUnreads,
/**
* User disabled filters from the all chats layout settings.
*/
MobileAllChatsFiltersDisabled,
/**
* User enabled filters from the all chats layout settings.
*/
MobileAllChatsFiltersEnabled,
/**
* User disabled recents from the all chats layout settings.
*/
MobileAllChatsRecentsDisabled,
/**
* User enabled recents from the all chats layout settings.
*/
MobileAllChatsRecentsEnabled,
/**
* User tapped on Add to Home button on Room Details screen.
*/
@ -60,6 +100,11 @@ data class Interaction(
*/
MobileRoomThreadSummaryItem,
/**
* User validated the creation of a new space.
*/
MobileSpaceCreationValidated,
/**
* User tapped on the filter button on ThreadList screen.
*/
@ -81,6 +126,12 @@ data class Interaction(
*/
SpacePanelSwitchSpace,
/**
* User tapped an unselected sub space from the space list -> space
* switching should occur.
*/
SpacePanelSwitchSubSpace,
/**
* User clicked the create room button in the add existing room to space
* dialog in Element Web/Desktop.

View file

@ -43,6 +43,11 @@ data class MobileScreen(
*/
CreateRoom,
/**
* The screen shown to create a new space.
*/
CreateSpace,
/**
* The confirmation screen shown before deactivating an account.
*/
@ -78,6 +83,11 @@ data class MobileScreen(
*/
InviteFriends,
/**
* Room accessed via space bottom sheet list.
*/
Invites,
/**
* The screen that displays the login flow (when the user already has an
* account).
@ -261,6 +271,11 @@ data class MobileScreen(
*/
Sidebar,
/**
* Room accessed via space bottom sheet list.
*/
SpaceBottomSheet,
/**
* Screen that displays the list of rooms and spaces of a space.
*/

View file

@ -44,6 +44,10 @@ data class UserProperties(
* Whether the user has the people space enabled.
*/
val webMetaSpacePeopleEnabled: Boolean? = null,
/**
* The active filter in the All Chats screen.
*/
val allChatsActiveFilter: AllChatsActiveFilter? = null,
/**
* The selected messaging use case during the onboarding flow.
*/
@ -80,6 +84,29 @@ data class UserProperties(
WorkMessaging,
}
enum class AllChatsActiveFilter {
/**
* Filters are activated and All is selected.
*/
All,
/**
* Filters are activated and Favourites is selected.
*/
Favourites,
/**
* Filters are activated and People is selected.
*/
People,
/**
* Filters are activated and Unreads is selected.
*/
Unreads,
}
fun getProperties(): Map<String, Any>? {
return mutableMapOf<String, Any>().apply {
webMetaSpaceFavouritesEnabled?.let { put("WebMetaSpaceFavouritesEnabled", it) }
@ -87,6 +114,7 @@ data class UserProperties(
webMetaSpaceHomeEnabled?.let { put("WebMetaSpaceHomeEnabled", it) }
webMetaSpaceOrphansEnabled?.let { put("WebMetaSpaceOrphansEnabled", it) }
webMetaSpacePeopleEnabled?.let { put("WebMetaSpacePeopleEnabled", it) }
allChatsActiveFilter?.let { put("allChatsActiveFilter", it.name) }
ftueUseCaseSelection?.let { put("ftueUseCaseSelection", it.name) }
numFavouriteRooms?.let { put("numFavouriteRooms", it) }
numSpaces?.let { put("numSpaces", it) }

View file

@ -110,6 +110,11 @@ data class ViewRoom(
*/
MobileSearchContactDetail,
/**
* Room accessed via space bottom sheet list.
*/
MobileSpaceBottomSheet,
/**
* Room accessed via interacting with direct chat item in the space
* contact detail screen.

View file

@ -123,7 +123,6 @@ class HomeActivityViewModel @AssistedInject constructor(
if (state.authenticationDescription == null && vectorPreferences.isNewAppLayoutEnabled()) {
releaseNotesPreferencesStore.appLayoutOnboardingShown.onEach { isAppLayoutOnboardingShown ->
if (!isAppLayoutOnboardingShown) {
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true)
_viewEvents.post(HomeActivityViewEvents.ShowReleaseNotes)
}
}.launchIn(viewModelScope)

View file

@ -16,17 +16,20 @@
package im.vector.app.features.home.room.list.home.release
import androidx.lifecycle.lifecycleScope
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.ScreenOrientationLocker
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding
import kotlinx.coroutines.launch
import javax.inject.Inject
@AndroidEntryPoint
class ReleaseNotesActivity : VectorBaseActivity<ActivitySimpleBinding>() {
@Inject lateinit var orientationLocker: ScreenOrientationLocker
@Inject lateinit var releaseNotesPreferencesStore: ReleaseNotesPreferencesStore
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
@ -38,4 +41,11 @@ class ReleaseNotesActivity : VectorBaseActivity<ActivitySimpleBinding>() {
addFragment(views.simpleFragmentContainer, ReleaseNotesFragment::class.java)
}
}
override fun onResume() {
super.onResume()
lifecycleScope.launch {
releaseNotesPreferencesStore.setAppLayoutOnboardingShown(true)
}
}
}

View file

@ -0,0 +1,27 @@
/*
* Copyright (c) 2022 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 com.airbnb.epoxy.EpoxyModelClass
import im.vector.app.R
import im.vector.app.core.epoxy.VectorEpoxyHolder
import im.vector.app.core.epoxy.VectorEpoxyModel
@EpoxyModelClass
abstract class NewSpaceListHeaderItem : VectorEpoxyModel<NewSpaceListHeaderItem.Holder>(R.layout.item_new_space_list_header) {
class Holder : VectorEpoxyHolder()
}

View file

@ -52,12 +52,19 @@ class NewSpaceSummaryController @Inject constructor(
}
private fun buildGroupModels(viewState: SpaceListViewState) = with(viewState) {
addHeaderItem()
addHomeItem(selectedSpace == null, homeAggregateCount)
addSpaces(spaces, selectedSpace, rootSpacesOrdered, expandedStates)
addInvites(selectedSpace, rootSpacesOrdered, inviters)
addCreateItem()
}
private fun addHeaderItem() {
newSpaceListHeaderItem {
id("space_list_header")
}
}
private fun addHomeItem(selected: Boolean, homeCount: RoomAggregateNotificationCount) {
val host = this
newHomeSpaceSummaryItem {

View file

@ -20,6 +20,7 @@ import android.content.Context
import android.media.MediaCodecList
import android.media.MediaFormat
import android.os.Build
import androidx.annotation.VisibleForTesting
import im.vector.app.features.VectorFeatures
import kotlinx.coroutines.Dispatchers
import javax.inject.Inject
@ -40,7 +41,8 @@ class VoiceRecorderProvider @Inject constructor(
return Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || !hasOpusEncoder() || vectorFeatures.forceUsageOfOpusEncoder()
}
private fun hasOpusEncoder(): Boolean {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun hasOpusEncoder(): Boolean {
val codecList = MediaCodecList(MediaCodecList.ALL_CODECS)
val format = MediaFormat.createAudioFormat(MediaFormat.MIMETYPE_AUDIO_OPUS, 48000, 1)
return codecList.findEncoderForFormat(format) != null

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
style="@style/TextAppearance.Vector.Body.Medium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_space_item"
android:ellipsize="middle"
android:orientation="vertical"
android:padding="16dp"
android:singleLine="true"
android:text="@string/change_space"
android:textAllCaps="true"
android:textColor="?vctr_content_tertiary"
android:textSize="14sp"
tools:viewBindingIgnore="true" />