From 8177d9777ccd9df18d6e222aa48a19e8e8a3cb54 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 12 Sep 2022 12:26:57 -0400 Subject: [PATCH 01/51] Fixes crash on double click of space fabs --- .../im/vector/app/features/home/NewHomeDetailFragment.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt index 3681ba4c15..f31f8a7d92 100644 --- a/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/NewHomeDetailFragment.kt @@ -201,13 +201,12 @@ class NewHomeDetailFragment : private fun setupFabs() { showFABs() - views.newLayoutCreateChatButton.setOnClickListener { - newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG) + views.newLayoutCreateChatButton.debouncedClicks { + newChatBottomSheet.takeIf { !it.isAdded }?.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG) } - views.newLayoutOpenSpacesButton.setOnClickListener { - // Click action for open spaces modal goes here - spaceListBottomSheet.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG) + views.newLayoutOpenSpacesButton.debouncedClicks { + spaceListBottomSheet.takeIf { !it.isAdded }?.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG) } } From db83099dc353242e5619f57b809d074f4467aad3 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 12 Sep 2022 12:29:33 -0400 Subject: [PATCH 02/51] Adds changelog file --- changelog.d/7102.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7102.bugfix diff --git a/changelog.d/7102.bugfix b/changelog.d/7102.bugfix new file mode 100644 index 0000000000..73d1bbc7d6 --- /dev/null +++ b/changelog.d/7102.bugfix @@ -0,0 +1 @@ +Fixes crash when quickly double clicking FABs in the new app layout From 662d77cb7ec4e489b4e04e283ce5e0860391e33d Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 12 Sep 2022 17:40:22 -0400 Subject: [PATCH 03/51] Adds min height to space sheet --- .../features/spaces/SpaceListBottomSheet.kt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt index 910f8c5379..866d2d81a7 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt @@ -16,10 +16,14 @@ package im.vector.app.features.spaces +import android.app.Dialog import android.os.Bundle +import android.util.DisplayMetrics import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.annotation.FloatRange +import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import im.vector.app.R import im.vector.app.core.extensions.replaceChildFragment @@ -37,6 +41,21 @@ class SpaceListBottomSheet : BottomSheetDialogFragment() { return binding.root } + + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + return super.onCreateDialog(savedInstanceState).apply { + (this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.75f) + } + } + + @Suppress("DEPRECATION") + private fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { + val displayMetrics = DisplayMetrics() + window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics) + val height = displayMetrics.heightPixels + behavior.setPeekHeight((height * percentage).toInt(), true) + } + companion object { const val TAG = "SpacesBottomSheet" } From 8fc201121ddace119aab8113dc240b7bfc449db6 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 12 Sep 2022 17:44:59 -0400 Subject: [PATCH 04/51] Adds min height to new chat --- .../app/core/extensions/BottomSheetDialog.kt | 29 +++++++++++++++++++ .../home/room/list/home/NewChatBottomSheet.kt | 9 ++++++ .../features/spaces/SpaceListBottomSheet.kt | 9 +----- 3 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt diff --git a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt new file mode 100644 index 0000000000..ab55d95573 --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt @@ -0,0 +1,29 @@ +/* + * 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.core.extensions + +import android.util.DisplayMetrics +import androidx.annotation.FloatRange +import com.google.android.material.bottomsheet.BottomSheetDialog + +@Suppress("DEPRECATION") +fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { + val displayMetrics = DisplayMetrics() + window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics) + val height = displayMetrics.heightPixels + behavior.setPeekHeight((height * percentage).toInt(), true) +} diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt index 05b86f7393..4db47e53b8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt @@ -16,12 +16,15 @@ package im.vector.app.features.home.room.list.home +import android.app.Dialog import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage import im.vector.app.databinding.FragmentNewChatBottomSheetBinding import im.vector.app.features.navigation.Navigator import javax.inject.Inject @@ -53,6 +56,12 @@ class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() { } } + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { + return super.onCreateDialog(savedInstanceState).apply { + (this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.5f) + } + } + companion object { const val TAG = "NewChatBottomSheet" } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt index 866d2d81a7..5bb450c5b4 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt @@ -27,6 +27,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import im.vector.app.R import im.vector.app.core.extensions.replaceChildFragment +import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage import im.vector.app.databinding.FragmentSpacesBottomSheetBinding class SpaceListBottomSheet : BottomSheetDialogFragment() { @@ -48,14 +49,6 @@ class SpaceListBottomSheet : BottomSheetDialogFragment() { } } - @Suppress("DEPRECATION") - private fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { - val displayMetrics = DisplayMetrics() - window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics) - val height = displayMetrics.heightPixels - behavior.setPeekHeight((height * percentage).toInt(), true) - } - companion object { const val TAG = "SpacesBottomSheet" } From 55c60c9a40dfecd0929353da6477c7b4cb2bab1b Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Mon, 12 Sep 2022 17:49:06 -0400 Subject: [PATCH 05/51] Adds changelog file --- changelog.d/7103.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7103.bugfix diff --git a/changelog.d/7103.bugfix b/changelog.d/7103.bugfix new file mode 100644 index 0000000000..12a07b79e5 --- /dev/null +++ b/changelog.d/7103.bugfix @@ -0,0 +1 @@ +Fixes space list and new chat bottom sheets showing too small in New App Layout (especially evident in landscape) From 85f16e8dfa3748a6eae89bcc1dab8faa0bd0d132 Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 13 Sep 2022 16:21:36 -0400 Subject: [PATCH 06/51] Adds API 30 compatible method --- .../app/core/extensions/BottomSheetDialog.kt | 20 ++++++++++++++++++- .../features/spaces/SpaceListBottomSheet.kt | 3 --- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt index ab55d95573..3b5cab7a80 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt @@ -16,13 +16,31 @@ package im.vector.app.core.extensions +import android.os.Build import android.util.DisplayMetrics import androidx.annotation.FloatRange +import androidx.annotation.RequiresApi import com.google.android.material.bottomsheet.BottomSheetDialog -@Suppress("DEPRECATION") fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + setPeekHeightPostApi30(percentage) + } else { + setPeekHeightPreApi30(percentage) + } +} + +@RequiresApi(Build.VERSION_CODES.R) +private fun BottomSheetDialog.setPeekHeightPostApi30(percentage: Float) { + window?.windowManager?.currentWindowMetrics?.let { windowMetrics -> + val height = windowMetrics.bounds.height() + behavior.setPeekHeight((height * percentage).toInt(), true) + } +} + +private fun BottomSheetDialog.setPeekHeightPreApi30(percentage: Float) { val displayMetrics = DisplayMetrics() + @Suppress("DEPRECATION") window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics) val height = displayMetrics.heightPixels behavior.setPeekHeight((height * percentage).toInt(), true) diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt index 5bb450c5b4..c28d877f30 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt @@ -18,11 +18,9 @@ package im.vector.app.features.spaces import android.app.Dialog import android.os.Bundle -import android.util.DisplayMetrics import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.annotation.FloatRange import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialogFragment import im.vector.app.R @@ -42,7 +40,6 @@ class SpaceListBottomSheet : BottomSheetDialogFragment() { return binding.root } - override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return super.onCreateDialog(savedInstanceState).apply { (this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.75f) From 34303c4a62703d9354fa4821c1c875ac5c89d38b Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Tue, 13 Sep 2022 16:27:29 -0400 Subject: [PATCH 07/51] Removes inject constructor in NewChatBottomSheet --- .../app/features/home/room/list/home/NewChatBottomSheet.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt index 05b86f7393..1d8a70c3bb 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt @@ -27,7 +27,7 @@ import im.vector.app.features.navigation.Navigator import javax.inject.Inject @AndroidEntryPoint -class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() { +class NewChatBottomSheet : BottomSheetDialogFragment() { @Inject lateinit var navigator: Navigator From 583cc294720c1f6f354c0c6de9b284f21617d0ad Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 10:03:39 +0200 Subject: [PATCH 08/51] Adding changelog entry --- changelog.d/7077.wip | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7077.wip diff --git a/changelog.d/7077.wip b/changelog.d/7077.wip new file mode 100644 index 0000000000..907993c76f --- /dev/null +++ b/changelog.d/7077.wip @@ -0,0 +1 @@ +[Device management] Session details screen From 4a89fcea14739a5a34dd405127b64163db24e09c Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 10:30:33 +0200 Subject: [PATCH 09/51] Adding basic structure for the new screen --- .../src/main/res/values/strings.xml | 1 + vector/src/main/AndroidManifest.xml | 1 + .../app/core/di/MavericksViewModelModule.kt | 6 ++ .../v2/details/SessionDetailsAction.kt | 21 ++++++ .../v2/details/SessionDetailsActivity.kt | 52 +++++++++++++++ .../devices/v2/details/SessionDetailsArgs.kt | 25 ++++++++ .../v2/details/SessionDetailsFragment.kt | 64 +++++++++++++++++++ .../v2/details/SessionDetailsViewModel.kt | 60 +++++++++++++++++ .../v2/details/SessionDetailsViewState.kt | 31 +++++++++ .../res/layout/fragment_session_details.xml | 6 ++ 10 files changed, 267 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsActivity.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsArgs.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewState.kt create mode 100644 vector/src/main/res/layout/fragment_session_details.xml diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 6a87ce82f4..8ccfd2bf38 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3265,6 +3265,7 @@ Session Last activity %1$s + Session details %s\nis looking a little empty. diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index c55852d7d8..94f2abe78b 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -340,6 +340,7 @@ + diff --git a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt index 8bcfd4e422..9d2b6c8196 100644 --- a/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/MavericksViewModelModule.kt @@ -88,6 +88,7 @@ import im.vector.app.features.settings.account.deactivation.DeactivateAccountVie import im.vector.app.features.settings.crosssigning.CrossSigningSettingsViewModel import im.vector.app.features.settings.devices.DeviceVerificationInfoBottomSheetViewModel import im.vector.app.features.settings.devices.DevicesViewModel +import im.vector.app.features.settings.devices.v2.details.SessionDetailsViewModel import im.vector.app.features.settings.devices.v2.overview.SessionOverviewViewModel import im.vector.app.features.settings.devtools.AccountDataViewModel import im.vector.app.features.settings.devtools.GossipingEventsPaperTrailViewModel @@ -641,4 +642,9 @@ interface MavericksViewModelModule { @IntoMap @MavericksViewModelKey(SessionOverviewViewModel::class) fun sessionOverviewViewModelFactory(factory: SessionOverviewViewModel.Factory): MavericksAssistedViewModelFactory<*, *> + + @Binds + @IntoMap + @MavericksViewModelKey(SessionDetailsViewModel::class) + fun sessionDetailsViewModelFactory(factory: SessionDetailsViewModel.Factory): MavericksAssistedViewModelFactory<*, *> } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt new file mode 100644 index 0000000000..5c3743add4 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 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.settings.devices.v2.details + +import im.vector.app.core.platform.VectorViewModelAction + +sealed class SessionDetailsAction : VectorViewModelAction diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsActivity.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsActivity.kt new file mode 100644 index 0000000000..101bf1da2e --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsActivity.kt @@ -0,0 +1,52 @@ +/* + * Copyright 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.settings.devices.v2.details + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import com.airbnb.mvrx.Mavericks +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.core.extensions.addFragment +import im.vector.app.core.platform.SimpleFragmentActivity + +/** + * Display the details info about a Session. + */ +@AndroidEntryPoint +class SessionDetailsActivity : SimpleFragmentActivity() { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + if (isFirstCreation()) { + addFragment( + container = views.container, + fragmentClass = SessionDetailsFragment::class.java, + params = intent.getParcelableExtra(Mavericks.KEY_ARG) + ) + } + } + + companion object { + fun newIntent(context: Context, deviceId: String): Intent { + return Intent(context, SessionDetailsActivity::class.java).apply { + putExtra(Mavericks.KEY_ARG, SessionDetailsArgs(deviceId)) + } + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsArgs.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsArgs.kt new file mode 100644 index 0000000000..97716d7c47 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsArgs.kt @@ -0,0 +1,25 @@ +/* + * 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.settings.devices.v2.details + +import android.os.Parcelable +import kotlinx.parcelize.Parcelize + +@Parcelize +data class SessionDetailsArgs( + val deviceId: String +) : Parcelable diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt new file mode 100644 index 0000000000..278f9eec7a --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt @@ -0,0 +1,64 @@ +/* + * 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.settings.devices.v2.details + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity +import com.airbnb.mvrx.fragmentViewModel +import dagger.hilt.android.AndroidEntryPoint +import im.vector.app.R +import im.vector.app.core.platform.VectorBaseFragment +import im.vector.app.databinding.FragmentSessionDetailsBinding + +/** + * Display the details info about a Session. + */ +@AndroidEntryPoint +class SessionDetailsFragment : + VectorBaseFragment() { + + private val viewModel: SessionDetailsViewModel by fragmentViewModel() + + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSessionDetailsBinding { + return FragmentSessionDetailsBinding.inflate(inflater, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + initToolbar() + } + + private fun initToolbar() { + (activity as? AppCompatActivity) + ?.supportActionBar + ?.setTitle(R.string.device_manager_session_details_title) + } + + /*override fun invalidate() = withState(viewModel) { state -> + if (state.deviceInfo is Success) { + renderSessionDetails(state.deviceInfo.invoke()) + } else { + hideSessionInfo() + } + } + + private fun renderSessionDetails(deviceInfo: DeviceInfo) { + }*/ +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt new file mode 100644 index 0000000000..c2beec2c89 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt @@ -0,0 +1,60 @@ +/* + * 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.settings.devices.v2.details + +import com.airbnb.mvrx.MavericksViewModelFactory +import com.airbnb.mvrx.Success +import dagger.assisted.Assisted +import dagger.assisted.AssistedFactory +import dagger.assisted.AssistedInject +import im.vector.app.core.di.MavericksAssistedViewModelFactory +import im.vector.app.core.di.hiltMavericksViewModelFactory +import im.vector.app.core.platform.EmptyViewEvents +import im.vector.app.core.platform.VectorViewModel +import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseCase +import kotlinx.coroutines.flow.launchIn +import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.flow.onEach + +// TODO add unit tests +class SessionDetailsViewModel @AssistedInject constructor( + @Assisted val initialState: SessionDetailsViewState, + private val getDeviceFullInfoUseCase: GetDeviceFullInfoUseCase, +) : VectorViewModel(initialState) { + + companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() + + @AssistedFactory + interface Factory : MavericksAssistedViewModelFactory { + override fun create(initialState: SessionDetailsViewState): SessionDetailsViewModel + } + + init { + observeSessionInfo(initialState.deviceId) + } + + private fun observeSessionInfo(deviceId: String) { + getDeviceFullInfoUseCase.execute(deviceId) + .mapNotNull { it.getOrNull() } + .onEach { setState { copy(deviceInfo = Success(it.deviceInfo)) } } + .launchIn(viewModelScope) + } + + override fun handle(action: SessionDetailsAction) { + TODO("Implement when adding the first action") + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewState.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewState.kt new file mode 100644 index 0000000000..15868d3110 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewState.kt @@ -0,0 +1,31 @@ +/* + * 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.settings.devices.v2.details + +import com.airbnb.mvrx.Async +import com.airbnb.mvrx.MavericksState +import com.airbnb.mvrx.Uninitialized +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo + +data class SessionDetailsViewState( + val deviceId: String, + val deviceInfo: Async = Uninitialized, +) : MavericksState { + constructor(args: SessionDetailsArgs) : this( + deviceId = args.deviceId + ) +} diff --git a/vector/src/main/res/layout/fragment_session_details.xml b/vector/src/main/res/layout/fragment_session_details.xml new file mode 100644 index 0000000000..1354408486 --- /dev/null +++ b/vector/src/main/res/layout/fragment_session_details.xml @@ -0,0 +1,6 @@ + + + + From a661f9c3fbab9742de8a38da94c566f4f6910898 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 11:33:21 +0200 Subject: [PATCH 10/51] Navigation from session overview to session details --- .../src/main/res/values/strings.xml | 1 + .../stylable_session_overview_entry_view.xml | 9 +++ ...=> stylable_sessions_list_header_view.xml} | 4 +- .../res/values/styles_devices_management.xml | 4 ++ .../devices/v2/list/SessionsListHeaderView.kt | 4 +- .../v2/overview/SessionOverviewEntryView.kt | 66 +++++++++++++++++++ .../v2/overview/SessionOverviewFragment.kt | 9 +++ .../overview/SessionOverviewViewNavigator.kt | 29 ++++++++ .../res/layout/fragment_session_overview.xml | 10 +++ .../res/layout/fragment_settings_devices.xml | 12 ++-- .../layout/view_session_overview_entry.xml | 42 ++++++++++++ 11 files changed, 180 insertions(+), 10 deletions(-) create mode 100644 library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml rename library/ui-styles/src/main/res/values/{stylable_devices_list_header_view.xml => stylable_sessions_list_header_view.xml} (51%) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt create mode 100644 vector/src/main/res/layout/view_session_overview_entry.xml diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 8ccfd2bf38..5eaec2c84b 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3266,6 +3266,7 @@ Last activity %1$s Session details + Application, device, and activity information. %s\nis looking a little empty. diff --git a/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml b/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml new file mode 100644 index 0000000000..d3884f247d --- /dev/null +++ b/library/ui-styles/src/main/res/values/stylable_session_overview_entry_view.xml @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml similarity index 51% rename from library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml rename to library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml index 97e0290815..d3b931e44a 100644 --- a/library/ui-styles/src/main/res/values/stylable_devices_list_header_view.xml +++ b/library/ui-styles/src/main/res/values/stylable_sessions_list_header_view.xml @@ -2,8 +2,8 @@ - - + + diff --git a/library/ui-styles/src/main/res/values/styles_devices_management.xml b/library/ui-styles/src/main/res/values/styles_devices_management.xml index 6fb236d3e6..6b42b85ffd 100644 --- a/library/ui-styles/src/main/res/values/styles_devices_management.xml +++ b/library/ui-styles/src/main/res/values/styles_devices_management.xml @@ -1,6 +1,10 @@ + + diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt index 547ed93f24..bea8b74b01 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt @@ -53,12 +53,12 @@ class SessionsListHeaderView @JvmOverloads constructor( } private fun setTitle(typedArray: TypedArray) { - val title = typedArray.getString(R.styleable.SessionsListHeaderView_devicesListHeaderTitle) + val title = typedArray.getString(R.styleable.SessionsListHeaderView_sessionsListHeaderTitle) binding.sessionsListHeaderTitle.text = title } private fun setDescription(typedArray: TypedArray) { - val description = typedArray.getString(R.styleable.SessionsListHeaderView_devicesListHeaderDescription) + val description = typedArray.getString(R.styleable.SessionsListHeaderView_sessionsListHeaderDescription) if (description.isNullOrEmpty()) { binding.sessionsListHeaderDescription.isVisible = false return diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt new file mode 100644 index 0000000000..5c4f0047ce --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewEntryView.kt @@ -0,0 +1,66 @@ +/* + * 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.settings.devices.v2.overview + +import android.content.Context +import android.content.res.TypedArray +import android.util.AttributeSet +import android.view.LayoutInflater +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.res.use +import im.vector.app.R +import im.vector.app.core.extensions.setAttributeBackground +import im.vector.app.databinding.ViewSessionOverviewEntryBinding + +class SessionOverviewEntryView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : ConstraintLayout(context, attrs, defStyleAttr) { + + private val binding = ViewSessionOverviewEntryBinding.inflate( + LayoutInflater.from(context), + this + ) + + init { + initBackground() + context.obtainStyledAttributes( + attrs, + R.styleable.SessionOverviewEntryView, + 0, + 0 + ).use { + setTitle(it) + setDescription(it) + } + } + + private fun initBackground() { + binding.root.setAttributeBackground(android.R.attr.selectableItemBackground) + } + + private fun setTitle(typedArray: TypedArray) { + val title = typedArray.getString(R.styleable.SessionOverviewEntryView_sessionOverviewEntryTitle) + binding.sessionsOverviewEntryTitle.text = title + } + + private fun setDescription(typedArray: TypedArray) { + val description = typedArray.getString(R.styleable.SessionOverviewEntryView_sessionOverviewEntryDescription) + binding.sessionsOverviewEntryDescription.text = description + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt index c5cd80bd3c..3fea7a9316 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewFragment.kt @@ -45,6 +45,8 @@ import javax.inject.Inject class SessionOverviewFragment : VectorBaseFragment() { + @Inject lateinit var viewNavigator: SessionOverviewViewNavigator + @Inject lateinit var dateFormatter: VectorDateFormatter @Inject lateinit var drawableProvider: DrawableProvider @@ -79,6 +81,7 @@ class SessionOverviewFragment : override fun invalidate() = withState(viewModel) { state -> updateToolbar(state.isCurrentSession) + updateEntryDetails(state.deviceId) if (state.deviceInfo is Success) { renderSessionInfo(state.isCurrentSession, state.deviceInfo.invoke()) } else { @@ -93,6 +96,12 @@ class SessionOverviewFragment : ?.setTitle(titleResId) } + private fun updateEntryDetails(deviceId: String) { + views.sessionOverviewEntryDetails.setOnClickListener { + viewNavigator.navigateToSessionDetails(requireContext(), deviceId) + } + } + private fun renderSessionInfo(isCurrentSession: Boolean, deviceFullInfo: DeviceFullInfo) { views.sessionOverviewInfo.isVisible = true val viewState = SessionInfoViewState( diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt new file mode 100644 index 0000000000..d6e94238ed --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt @@ -0,0 +1,29 @@ +/* + * 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.settings.devices.v2.overview + +import android.content.Context +import im.vector.app.features.settings.devices.v2.details.SessionDetailsActivity +import javax.inject.Inject + +// TODO add unit tests +class SessionOverviewViewNavigator @Inject constructor() { + + fun navigateToSessionDetails(context: Context, deviceId: String) { + context.startActivity(SessionDetailsActivity.newIntent(context, deviceId)) + } +} diff --git a/vector/src/main/res/layout/fragment_session_overview.xml b/vector/src/main/res/layout/fragment_session_overview.xml index 156e61673b..3e4a88bd75 100644 --- a/vector/src/main/res/layout/fragment_session_overview.xml +++ b/vector/src/main/res/layout/fragment_session_overview.xml @@ -17,4 +17,14 @@ app:layout_constraintTop_toTopOf="parent" tools:visibility="visible" /> + + diff --git a/vector/src/main/res/layout/fragment_settings_devices.xml b/vector/src/main/res/layout/fragment_settings_devices.xml index 9cefd6aa24..b53aef33d7 100644 --- a/vector/src/main/res/layout/fragment_settings_devices.xml +++ b/vector/src/main/res/layout/fragment_settings_devices.xml @@ -12,8 +12,8 @@ android:id="@+id/deviceListHeaderSectionSecurityRecommendations" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="@string/device_manager_header_section_security_recommendations_description" - app:devicesListHeaderTitle="@string/device_manager_header_section_security_recommendations_title" + app:sessionsListHeaderDescription="@string/device_manager_header_section_security_recommendations_description" + app:sessionsListHeaderTitle="@string/device_manager_header_section_security_recommendations_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> @@ -60,8 +60,8 @@ android:id="@+id/deviceListHeaderCurrentSession" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="" - app:devicesListHeaderTitle="@string/device_manager_current_session_title" + app:sessionsListHeaderDescription="" + app:sessionsListHeaderTitle="@string/device_manager_current_session_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListSecurityRecommendationsDivider" /> @@ -90,8 +90,8 @@ android:id="@+id/deviceListHeaderOtherSessions" android:layout_width="0dp" android:layout_height="wrap_content" - app:devicesListHeaderDescription="@string/settings_sessions_other_description" - app:devicesListHeaderTitle="@string/settings_sessions_other_title" + app:sessionsListHeaderDescription="@string/settings_sessions_other_description" + app:sessionsListHeaderTitle="@string/settings_sessions_other_title" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/deviceListDividerCurrentSession" /> diff --git a/vector/src/main/res/layout/view_session_overview_entry.xml b/vector/src/main/res/layout/view_session_overview_entry.xml new file mode 100644 index 0000000000..4a0071d72d --- /dev/null +++ b/vector/src/main/res/layout/view_session_overview_entry.xml @@ -0,0 +1,42 @@ + + + + + + + + + + From 9553fe06481055bedf1d7c668eacfd9bcf938ea8 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 13:31:26 +0200 Subject: [PATCH 11/51] Using a ScrollView for the Session overview screen --- .../res/layout/fragment_session_overview.xml | 50 +++++++++++-------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/vector/src/main/res/layout/fragment_session_overview.xml b/vector/src/main/res/layout/fragment_session_overview.xml index 3e4a88bd75..f4573ef85e 100644 --- a/vector/src/main/res/layout/fragment_session_overview.xml +++ b/vector/src/main/res/layout/fragment_session_overview.xml @@ -1,30 +1,36 @@ - - + - + - + + + + + From 15cf8b63a0bb9a0a85b91c0f62933bc294869911 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 13:46:26 +0200 Subject: [PATCH 12/51] Using unwrap() extension method --- .../v2/details/SessionDetailsViewModel.kt | 2 -- .../v2/overview/GetDeviceFullInfoUseCase.kt | 6 ++--- .../v2/overview/SessionOverviewViewModel.kt | 1 - .../overview/GetDeviceFullInfoUseCaseTest.kt | 25 ++++++++++++------- .../overview/SessionOverviewViewModelTest.kt | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt index c2beec2c89..629f9bb839 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt @@ -27,7 +27,6 @@ import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.VectorViewModel import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseCase import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.onEach // TODO add unit tests @@ -49,7 +48,6 @@ class SessionDetailsViewModel @AssistedInject constructor( private fun observeSessionInfo(deviceId: String) { getDeviceFullInfoUseCase.execute(deviceId) - .mapNotNull { it.getOrNull() } .onEach { setState { copy(deviceInfo = Success(it.deviceInfo)) } } .launchIn(viewModelScope) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt index fff81b6dc5..5a8106f2fd 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCase.kt @@ -25,8 +25,8 @@ import im.vector.app.features.settings.devices.v2.list.CheckIfSessionIsInactiveU import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.emptyFlow -import org.matrix.android.sdk.api.util.Optional import org.matrix.android.sdk.api.util.toOptional +import org.matrix.android.sdk.flow.unwrap import javax.inject.Inject class GetDeviceFullInfoUseCase @Inject constructor( @@ -36,7 +36,7 @@ class GetDeviceFullInfoUseCase @Inject constructor( private val checkIfSessionIsInactiveUseCase: CheckIfSessionIsInactiveUseCase, ) { - fun execute(deviceId: String): Flow> { + fun execute(deviceId: String): Flow { return activeSessionHolder.getSafeActiveSession()?.let { session -> combine( getCurrentSessionCrossSigningInfoUseCase.execute(), @@ -58,7 +58,7 @@ class GetDeviceFullInfoUseCase @Inject constructor( null } fullInfo.toOptional() - } + }.unwrap() } ?: emptyFlow() } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt index 1a1d3640a2..a236814a40 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt @@ -54,7 +54,6 @@ class SessionOverviewViewModel @AssistedInject constructor( private fun observeSessionInfo(deviceId: String) { getDeviceFullInfoUseCase.execute(deviceId) - .mapNotNull { it.getOrNull() } .onEach { setState { copy(deviceInfo = Success(it)) } } .launchIn(viewModelScope) } diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt index 7dc8e08a4e..2001d2ba37 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt @@ -72,6 +72,7 @@ class GetDeviceFullInfoUseCaseTest { @Test fun `given current session and info for device when getting device info then the result is correct`() = runTest { + // Given val currentSessionCrossSigningInfo = givenCurrentSessionCrossSigningInfo() val deviceInfo = DeviceInfo( lastSeenTs = A_TIMESTAMP @@ -85,15 +86,15 @@ class GetDeviceFullInfoUseCaseTest { val isInactive = false every { checkIfSessionIsInactiveUseCase.execute(any()) } returns isInactive + // When val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() - deviceFullInfo shouldBeEqualTo Optional( - DeviceFullInfo( - deviceInfo = deviceInfo, - cryptoDeviceInfo = cryptoDeviceInfo, - roomEncryptionTrustLevel = trustLevel, - isInactive = isInactive, - ) + // Then + deviceFullInfo shouldBeEqualTo DeviceFullInfo( + deviceInfo = deviceInfo, + cryptoDeviceInfo = cryptoDeviceInfo, + roomEncryptionTrustLevel = trustLevel, + isInactive = isInactive, ) verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } verify { getCurrentSessionCrossSigningInfoUseCase.execute() } @@ -104,16 +105,19 @@ class GetDeviceFullInfoUseCaseTest { } @Test - fun `given current session and no info for device when getting device info then the result is null`() = runTest { + fun `given current session and no info for device when getting device info then the result is empty`() = runTest { + // Given givenCurrentSessionCrossSigningInfo() fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData = MutableLiveData(Optional(null)) fakeActiveSessionHolder.fakeSession.fakeCryptoService.myDevicesInfoWithIdLiveData.givenAsFlow() fakeActiveSessionHolder.fakeSession.fakeCryptoService.cryptoDeviceInfoWithIdLiveData = MutableLiveData(Optional(null)) fakeActiveSessionHolder.fakeSession.fakeCryptoService.cryptoDeviceInfoWithIdLiveData.givenAsFlow() + // When val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() - deviceFullInfo shouldBeEqualTo Optional(null) + // Then + deviceFullInfo shouldBeEqualTo null verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } verify { fakeActiveSessionHolder.fakeSession.fakeCryptoService.getMyDevicesInfoLive(A_DEVICE_ID).asFlow() } verify { fakeActiveSessionHolder.fakeSession.fakeCryptoService.getLiveCryptoDeviceInfoWithId(A_DEVICE_ID).asFlow() } @@ -121,10 +125,13 @@ class GetDeviceFullInfoUseCaseTest { @Test fun `given no current session when getting device info then the result is empty`() = runTest { + // Given fakeActiveSessionHolder.givenGetSafeActiveSessionReturns(null) + // When val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() + // Then deviceFullInfo shouldBeEqualTo null verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } } diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt index 4a26fc4adc..fe33bd8b0b 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt @@ -54,7 +54,7 @@ class SessionOverviewViewModelTest { fun `given the viewModel has been initialized then viewState is updated with session info`() { val sessionParams = givenIdForSession(A_SESSION_ID) val deviceFullInfo = mockk() - every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(Optional(deviceFullInfo)) + every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo) val expectedState = SessionOverviewViewState( deviceId = A_SESSION_ID, isCurrentSession = true, From 3970c2ec31f3c459636d8ddc96ec22908f237dc8 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 13:50:34 +0200 Subject: [PATCH 13/51] Using setTextOrHide() extension method inside SessionInfoView --- .../settings/devices/v2/list/SessionInfoView.kt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt index 0cb621a502..ad1c01870a 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt @@ -24,6 +24,7 @@ import androidx.core.view.isVisible import im.vector.app.R import im.vector.app.core.date.DateFormatKind import im.vector.app.core.date.VectorDateFormatter +import im.vector.app.core.extensions.setTextOrHide import im.vector.app.core.extensions.setTextWithColoredPart import im.vector.app.core.resources.ColorProvider import im.vector.app.core.resources.DrawableProvider @@ -172,15 +173,7 @@ class SessionInfoView @JvmOverloads constructor( views.sessionInfoLastActivityTextView.isGone = true } - deviceInfo.lastSeenIp - ?.takeIf { isLastSeenDetailsVisible } - ?.let { ipAddress -> - views.sessionInfoLastIPAddressTextView.isVisible = true - views.sessionInfoLastIPAddressTextView.text = ipAddress - } - ?: run { - views.sessionInfoLastIPAddressTextView.isGone = true - } + views.sessionInfoLastIPAddressTextView.setTextOrHide(deviceInfo.lastSeenIp?.takeIf { isLastSeenDetailsVisible }) } private fun renderDetailsButton(isDetailsButtonVisible: Boolean) { From 51fba85a3a938f83ac4fc1fe2610a4cdeff9dd9c Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 13:57:23 +0200 Subject: [PATCH 14/51] Using buildString{} inline method to improve readability --- .../settings/devices/v2/list/SessionInfoView.kt | 11 ++++++----- .../devices/v2/list/SessionsListHeaderView.kt | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt index ad1c01870a..555d216dfc 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionInfoView.kt @@ -92,13 +92,14 @@ class SessionInfoView @JvmOverloads constructor( private fun appendLearnMoreToVerificationStatus() { val status = views.sessionInfoVerificationStatusDetailTextView.text val learnMore = context.getString(R.string.action_learn_more) - val stringBuilder = StringBuilder() - stringBuilder.append(status) - stringBuilder.append(" ") - stringBuilder.append(learnMore) + val statusText = buildString { + append(status) + append(" ") + append(learnMore) + } views.sessionInfoVerificationStatusDetailTextView.setTextWithColoredPart( - fullText = stringBuilder.toString(), + fullText = statusText, coloredPart = learnMore, underline = false ) { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt index bea8b74b01..ebcf801695 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/list/SessionsListHeaderView.kt @@ -65,14 +65,15 @@ class SessionsListHeaderView @JvmOverloads constructor( } val learnMore = context.getString(R.string.action_learn_more) - val stringBuilder = StringBuilder() - stringBuilder.append(description) - stringBuilder.append(" ") - stringBuilder.append(learnMore) + val fullDescription = buildString { + append(description) + append(" ") + append(learnMore) + } binding.sessionsListHeaderDescription.isVisible = true binding.sessionsListHeaderDescription.setTextWithColoredPart( - fullText = stringBuilder.toString(), + fullText = fullDescription, coloredPart = learnMore, underline = false ) { From c7099f53c167cbf914de3dac92c40464e076ab2a Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 14:24:53 +0200 Subject: [PATCH 15/51] Using camelCase syntax for view ids --- .../res/layout/view_session_overview_entry.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/vector/src/main/res/layout/view_session_overview_entry.xml b/vector/src/main/res/layout/view_session_overview_entry.xml index 4a0071d72d..464f775192 100644 --- a/vector/src/main/res/layout/view_session_overview_entry.xml +++ b/vector/src/main/res/layout/view_session_overview_entry.xml @@ -7,7 +7,7 @@ tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> + app:layout_constraintEnd_toEndOf="@id/sessionsOverviewEntryTitle" + app:layout_constraintStart_toStartOf="@id/sessionsOverviewEntryTitle" + app:layout_constraintTop_toBottomOf="@id/sessionsOverviewEntryDescription" /> From 94d1649ec9a600060a91310747d5f70c667bff4c Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 15:10:48 +0200 Subject: [PATCH 16/51] Creation of header and content items --- .../v2/details/SessionDetailsContentItem.kt | 51 +++++++++++++++++++ .../v2/details/SessionDetailsHeaderItem.kt | 40 +++++++++++++++ .../layout/item_session_details_content.xml | 45 ++++++++++++++++ .../layout/item_session_details_header.xml | 22 ++++++++ 4 files changed, 158 insertions(+) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt create mode 100644 vector/src/main/res/layout/item_session_details_content.xml create mode 100644 vector/src/main/res/layout/item_session_details_header.xml diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt new file mode 100644 index 0000000000..5c3a46475d --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -0,0 +1,51 @@ +/* + * 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.settings.devices.v2.details + +import android.view.View +import android.widget.TextView +import com.airbnb.epoxy.EpoxyAttribute +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 SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_header) { + + @EpoxyAttribute + var title: String? = null + + @EpoxyAttribute + var description: String? = null + + @EpoxyAttribute(EpoxyAttribute.Option.DoNotHash) + var onLongClickListener: View.OnLongClickListener? = null + + override fun bind(holder: Holder) { + super.bind(holder) + holder.sessionDetailsContentTitle.text = title + holder.sessionDetailsContentDescription.text = description + holder.view.isClickable = onLongClickListener != null + holder.view.setOnLongClickListener(onLongClickListener) + } + + class Holder : VectorEpoxyHolder() { + val sessionDetailsContentTitle by bind(R.id.sessionDetailsContentTitle) + val sessionDetailsContentDescription by bind(R.id.sessionDetailsContentDescription) + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt new file mode 100644 index 0000000000..5c21460bd6 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt @@ -0,0 +1,40 @@ +/* + * 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.settings.devices.v2.details + +import android.widget.TextView +import com.airbnb.epoxy.EpoxyAttribute +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 SessionDetailsHeaderItem : VectorEpoxyModel(R.layout.item_session_details_header) { + + @EpoxyAttribute + var title: String? = null + + override fun bind(holder: Holder) { + super.bind(holder) + holder.sessionDetailsHeaderTitle.text = title + } + + class Holder : VectorEpoxyHolder() { + val sessionDetailsHeaderTitle by bind(R.id.sessionDetailsHeaderTitle) + } +} diff --git a/vector/src/main/res/layout/item_session_details_content.xml b/vector/src/main/res/layout/item_session_details_content.xml new file mode 100644 index 0000000000..a3b2e42c72 --- /dev/null +++ b/vector/src/main/res/layout/item_session_details_content.xml @@ -0,0 +1,45 @@ + + + + + + + + + + diff --git a/vector/src/main/res/layout/item_session_details_header.xml b/vector/src/main/res/layout/item_session_details_header.xml new file mode 100644 index 0000000000..4cead8acff --- /dev/null +++ b/vector/src/main/res/layout/item_session_details_header.xml @@ -0,0 +1,22 @@ + + + + + + From bf88c16c9d117274a957a189dc1dfee1d2e4d9fc Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 16:46:40 +0200 Subject: [PATCH 17/51] Show basic details info --- .../src/main/res/values/strings.xml | 6 + .../CheckIfSectionDeviceIsVisibleUseCase.kt | 29 +++++ .../CheckIfSectionSessionIsVisibleUseCase.kt | 31 +++++ .../v2/details/SessionDetailsContentItem.kt | 2 +- .../v2/details/SessionDetailsController.kt | 109 ++++++++++++++++++ .../v2/details/SessionDetailsFragment.kt | 36 +++++- .../res/layout/fragment_session_details.xml | 15 +++ 7 files changed, 224 insertions(+), 4 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index 5eaec2c84b..c33185ba26 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -3267,6 +3267,12 @@ Last activity %1$s Session details Application, device, and activity information. + Session + Session name + Session ID + Last activity + Device + IP address %s\nis looking a little empty. diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt new file mode 100644 index 0000000000..0bfcc371c5 --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt @@ -0,0 +1,29 @@ +/* + * 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.settings.devices.v2.details + +import org.matrix.android.sdk.api.extensions.orFalse +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo +import javax.inject.Inject + +// TODO add unit tests +class CheckIfSectionDeviceIsVisibleUseCase @Inject constructor() { + + fun execute(deviceInfo: DeviceInfo): Boolean { + return deviceInfo.lastSeenIp?.isNotEmpty().orFalse() + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt new file mode 100644 index 0000000000..b07d3b7ebf --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt @@ -0,0 +1,31 @@ +/* + * 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.settings.devices.v2.details + +import org.matrix.android.sdk.api.extensions.orFalse +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo +import javax.inject.Inject + +// TODO add unit tests +class CheckIfSectionSessionIsVisibleUseCase @Inject constructor() { + + fun execute(deviceInfo: DeviceInfo): Boolean { + return deviceInfo.displayName?.isNotEmpty().orFalse() || + deviceInfo.deviceId?.isNotEmpty().orFalse() || + (deviceInfo.lastSeenTs ?: 0) > 0 + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt index 5c3a46475d..e0f433af35 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -25,7 +25,7 @@ import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel @EpoxyModelClass -abstract class SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_header) { +abstract class SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_content) { @EpoxyAttribute var title: String? = null diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt new file mode 100644 index 0000000000..5a55ef55ef --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt @@ -0,0 +1,109 @@ +/* + * 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.settings.devices.v2.details + +import androidx.annotation.StringRes +import com.airbnb.epoxy.TypedEpoxyController +import im.vector.app.R +import im.vector.app.core.date.DateFormatKind +import im.vector.app.core.date.VectorDateFormatter +import im.vector.app.core.resources.StringProvider +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo +import javax.inject.Inject + +class SessionDetailsController @Inject constructor( + private val checkIfSectionSessionIsVisibleUseCase: CheckIfSectionSessionIsVisibleUseCase, + private val checkIfSectionDeviceIsVisibleUseCase: CheckIfSectionDeviceIsVisibleUseCase, + private val stringProvider: StringProvider, + private val dateFormatter: VectorDateFormatter, +) : TypedEpoxyController() { + + var callback: Callback? = null + + interface Callback { + fun onItemLongClicked(content: String) + } + + override fun buildModels(data: DeviceInfo?) { + data?.let { info -> + if (hasSectionSession(data)) { + buildSectionSession(info) + } + + if (hasSectionDevice(data)) { + // TODO add a marginTop of 48dp if the session section is visible + buildSectionDevice(info) + } + } + } + + private fun buildHeaderItem(@StringRes titleResId: Int) { + val host = this + sessionDetailsHeaderItem { + id(titleResId) + title(host.stringProvider.getString(titleResId)) + } + } + + private fun buildContentItem(@StringRes titleResId: Int, value: String) { + val host = this + sessionDetailsContentItem { + id(titleResId) + title(host.stringProvider.getString(titleResId)) + description(value) + } + } + + private fun hasSectionSession(data: DeviceInfo): Boolean { + return checkIfSectionSessionIsVisibleUseCase.execute(data) + } + + private fun buildSectionSession(data: DeviceInfo) { + val sessionName = data.displayName + val sessionId = data.deviceId + val sessionLastSeenTs = data.lastSeenTs + + buildHeaderItem(R.string.device_manager_session_details_section_session_title) + + // TODO hide divider on the last visible item + sessionName?.let { + buildContentItem(R.string.device_manager_session_details_session_name, it) + } + sessionId?.let { + buildContentItem(R.string.device_manager_session_details_session_id, it) + } + sessionLastSeenTs?.let { + val formattedDate = dateFormatter.format(it, DateFormatKind.MESSAGE_DETAIL) + buildContentItem(R.string.device_manager_session_details_session_last_activity, formattedDate) + } + } + + private fun hasSectionDevice(data: DeviceInfo): Boolean { + return checkIfSectionDeviceIsVisibleUseCase.execute(data) + } + + private fun buildSectionDevice(data: DeviceInfo) { + val lastSeenIp = data.lastSeenIp + + buildHeaderItem(R.string.device_manager_session_details_section_device_title) + + // TODO hide divider on the last visible item + lastSeenIp?.let { + buildContentItem(R.string.device_manager_session_details_device_ip_address, it) + } + } +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt index 278f9eec7a..bf0037b0e8 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt @@ -21,11 +21,19 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.isGone +import androidx.core.view.isVisible +import com.airbnb.mvrx.Success import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R +import im.vector.app.core.extensions.cleanup +import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentSessionDetailsBinding +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo +import javax.inject.Inject /** * Display the details info about a Session. @@ -34,6 +42,8 @@ import im.vector.app.databinding.FragmentSessionDetailsBinding class SessionDetailsFragment : VectorBaseFragment() { + @Inject lateinit var sessionDetailsController: SessionDetailsController + private val viewModel: SessionDetailsViewModel by fragmentViewModel() override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSessionDetailsBinding { @@ -43,6 +53,7 @@ class SessionDetailsFragment : override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) initToolbar() + initSessionDetails() } private fun initToolbar() { @@ -51,14 +62,33 @@ class SessionDetailsFragment : ?.setTitle(R.string.device_manager_session_details_title) } - /*override fun invalidate() = withState(viewModel) { state -> + private fun initSessionDetails() { + views.sessionDetails.configureWith(sessionDetailsController) + } + + override fun onDestroyView() { + cleanUpSessionDetails() + super.onDestroyView() + } + + private fun cleanUpSessionDetails() { + views.sessionDetails.cleanup() + } + + override fun invalidate() = withState(viewModel) { state -> if (state.deviceInfo is Success) { renderSessionDetails(state.deviceInfo.invoke()) } else { - hideSessionInfo() + hideSessionDetails() } } private fun renderSessionDetails(deviceInfo: DeviceInfo) { - }*/ + views.sessionDetails.isVisible = true + sessionDetailsController.setData(deviceInfo) + } + + private fun hideSessionDetails() { + views.sessionDetails.isGone = true + } } diff --git a/vector/src/main/res/layout/fragment_session_details.xml b/vector/src/main/res/layout/fragment_session_details.xml index 1354408486..de0ce27798 100644 --- a/vector/src/main/res/layout/fragment_session_details.xml +++ b/vector/src/main/res/layout/fragment_session_details.xml @@ -1,6 +1,21 @@ + + From 92888b666cd6096efd01526a733e7e09f7826fac Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 17:41:18 +0200 Subject: [PATCH 18/51] Adding extra top margin between sections --- .../v2/details/SessionDetailsController.kt | 17 ++++++++++------ .../v2/details/SessionDetailsHeaderItem.kt | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt index 5a55ef55ef..72e558bddb 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt @@ -22,6 +22,7 @@ import im.vector.app.R import im.vector.app.core.date.DateFormatKind import im.vector.app.core.date.VectorDateFormatter import im.vector.app.core.resources.StringProvider +import im.vector.app.core.utils.DimensionConverter import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo import javax.inject.Inject @@ -30,6 +31,7 @@ class SessionDetailsController @Inject constructor( private val checkIfSectionDeviceIsVisibleUseCase: CheckIfSectionDeviceIsVisibleUseCase, private val stringProvider: StringProvider, private val dateFormatter: VectorDateFormatter, + private val dimensionConverter: DimensionConverter, ) : TypedEpoxyController() { var callback: Callback? = null @@ -40,27 +42,30 @@ class SessionDetailsController @Inject constructor( override fun buildModels(data: DeviceInfo?) { data?.let { info -> - if (hasSectionSession(data)) { + val hasSectionSession = hasSectionSession(data) + if (hasSectionSession) { buildSectionSession(info) } if (hasSectionDevice(data)) { - // TODO add a marginTop of 48dp if the session section is visible - buildSectionDevice(info) + buildSectionDevice(info, addExtraTopMargin = hasSectionSession) } } } - private fun buildHeaderItem(@StringRes titleResId: Int) { + private fun buildHeaderItem(@StringRes titleResId: Int, addExtraTopMargin: Boolean = false) { val host = this sessionDetailsHeaderItem { id(titleResId) title(host.stringProvider.getString(titleResId)) + addExtraTopMargin(addExtraTopMargin) + dimensionConverter(host.dimensionConverter) } } private fun buildContentItem(@StringRes titleResId: Int, value: String) { val host = this + // TODO bind the longClickListener to copy the description to the clipboard sessionDetailsContentItem { id(titleResId) title(host.stringProvider.getString(titleResId)) @@ -96,10 +101,10 @@ class SessionDetailsController @Inject constructor( return checkIfSectionDeviceIsVisibleUseCase.execute(data) } - private fun buildSectionDevice(data: DeviceInfo) { + private fun buildSectionDevice(data: DeviceInfo, addExtraTopMargin: Boolean) { val lastSeenIp = data.lastSeenIp - buildHeaderItem(R.string.device_manager_session_details_section_device_title) + buildHeaderItem(R.string.device_manager_session_details_section_device_title, addExtraTopMargin) // TODO hide divider on the last visible item lastSeenIp?.let { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt index 5c21460bd6..ff6ce3faad 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsHeaderItem.kt @@ -16,12 +16,18 @@ package im.vector.app.features.settings.devices.v2.details +import android.view.ViewGroup import android.widget.TextView +import androidx.core.view.updateLayoutParams +import androidx.core.view.updateMargins import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.utils.DimensionConverter + +private const val EXTRA_TOP_MARGIN_DP = 48 @EpoxyModelClass abstract class SessionDetailsHeaderItem : VectorEpoxyModel(R.layout.item_session_details_header) { @@ -29,9 +35,23 @@ abstract class SessionDetailsHeaderItem : VectorEpoxyModel { + updateMargins(top = topMargin) + } } class Holder : VectorEpoxyHolder() { From 30effb781bdc1e584c09a69be7f8f96ed13549ab Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Thu, 8 Sep 2022 17:53:00 +0200 Subject: [PATCH 19/51] Fixing margins in list items --- .../res/layout/item_session_details_content.xml | 13 +++++++++---- .../main/res/layout/item_session_details_header.xml | 3 +-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/vector/src/main/res/layout/item_session_details_content.xml b/vector/src/main/res/layout/item_session_details_content.xml index a3b2e42c72..fefae65b3d 100644 --- a/vector/src/main/res/layout/item_session_details_content.xml +++ b/vector/src/main/res/layout/item_session_details_content.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - android:paddingTop="16dp"> + android:paddingTop="14dp"> + app:layout_constraintTop_toBottomOf="@id/sessionDetailsContentBarrier" /> + + diff --git a/vector/src/main/res/layout/item_session_details_header.xml b/vector/src/main/res/layout/item_session_details_header.xml index 4cead8acff..571a541b2b 100644 --- a/vector/src/main/res/layout/item_session_details_header.xml +++ b/vector/src/main/res/layout/item_session_details_header.xml @@ -3,8 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" - android:layout_height="wrap_content" - android:paddingTop="16dp"> + android:layout_height="wrap_content"> Date: Fri, 9 Sep 2022 09:46:48 +0200 Subject: [PATCH 20/51] Hiding the last content item divider --- .../v2/details/SessionDetailsContentItem.kt | 6 ++++++ .../v2/details/SessionDetailsController.kt | 17 ++++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt index e0f433af35..665ba5126c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -18,6 +18,7 @@ package im.vector.app.features.settings.devices.v2.details import android.view.View import android.widget.TextView +import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R @@ -33,6 +34,9 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel(R.id.sessionDetailsContentTitle) val sessionDetailsContentDescription by bind(R.id.sessionDetailsContentDescription) + val sessionDetailsContentDivider by bind(R.id.sessionDetailsContentDivider) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt index 72e558bddb..8c53b07ce7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt @@ -63,13 +63,14 @@ class SessionDetailsController @Inject constructor( } } - private fun buildContentItem(@StringRes titleResId: Int, value: String) { + private fun buildContentItem(@StringRes titleResId: Int, value: String, hasDivider: Boolean) { val host = this // TODO bind the longClickListener to copy the description to the clipboard sessionDetailsContentItem { id(titleResId) title(host.stringProvider.getString(titleResId)) description(value) + hasDivider(hasDivider) } } @@ -84,16 +85,18 @@ class SessionDetailsController @Inject constructor( buildHeaderItem(R.string.device_manager_session_details_section_session_title) - // TODO hide divider on the last visible item sessionName?.let { - buildContentItem(R.string.device_manager_session_details_session_name, it) + val hasDivider = sessionId != null || sessionLastSeenTs != null + buildContentItem(R.string.device_manager_session_details_session_name, it, hasDivider) } sessionId?.let { - buildContentItem(R.string.device_manager_session_details_session_id, it) + val hasDivider = sessionLastSeenTs != null + buildContentItem(R.string.device_manager_session_details_session_id, it, hasDivider) } sessionLastSeenTs?.let { val formattedDate = dateFormatter.format(it, DateFormatKind.MESSAGE_DETAIL) - buildContentItem(R.string.device_manager_session_details_session_last_activity, formattedDate) + val hasDivider = false + buildContentItem(R.string.device_manager_session_details_session_last_activity, formattedDate, hasDivider) } } @@ -106,9 +109,9 @@ class SessionDetailsController @Inject constructor( buildHeaderItem(R.string.device_manager_session_details_section_device_title, addExtraTopMargin) - // TODO hide divider on the last visible item lastSeenIp?.let { - buildContentItem(R.string.device_manager_session_details_device_ip_address, it) + val hasDivider = false + buildContentItem(R.string.device_manager_session_details_device_ip_address, it, hasDivider) } } } From 4cd81f194cba196319d6971c2e9a389d59117b35 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 9 Sep 2022 10:01:50 +0200 Subject: [PATCH 21/51] Copy content to clipboard on long click on an item --- .../devices/v2/details/SessionDetailsContentItem.kt | 7 ++----- .../devices/v2/details/SessionDetailsController.kt | 7 ------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt index 665ba5126c..0363e320cd 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -24,6 +24,7 @@ import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.app.core.extensions.copyOnLongClick @EpoxyModelClass abstract class SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_content) { @@ -37,15 +38,11 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel() { - var callback: Callback? = null - - interface Callback { - fun onItemLongClicked(content: String) - } - override fun buildModels(data: DeviceInfo?) { data?.let { info -> val hasSectionSession = hasSectionSession(data) @@ -65,7 +59,6 @@ class SessionDetailsController @Inject constructor( private fun buildContentItem(@StringRes titleResId: Int, value: String, hasDivider: Boolean) { val host = this - // TODO bind the longClickListener to copy the description to the clipboard sessionDetailsContentItem { id(titleResId) title(host.stringProvider.getString(titleResId)) From 4205b4a777f6fb31dda34fcf996da28d1927901e Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 9 Sep 2022 10:10:21 +0200 Subject: [PATCH 22/51] Unit tests for session overview navigator --- .../overview/SessionOverviewViewNavigator.kt | 1 - .../SessionOverviewViewNavigatorTest.kt | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigatorTest.kt diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt index d6e94238ed..ef61856255 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigator.kt @@ -20,7 +20,6 @@ import android.content.Context import im.vector.app.features.settings.devices.v2.details.SessionDetailsActivity import javax.inject.Inject -// TODO add unit tests class SessionOverviewViewNavigator @Inject constructor() { fun navigateToSessionDetails(context: Context, deviceId: String) { diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigatorTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigatorTest.kt new file mode 100644 index 0000000000..56f1e5920d --- /dev/null +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewNavigatorTest.kt @@ -0,0 +1,68 @@ +/* + * 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.settings.devices.v2.overview + +import android.content.Intent +import im.vector.app.features.settings.devices.v2.details.SessionDetailsActivity +import im.vector.app.test.fakes.FakeContext +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkObject +import io.mockk.unmockkAll +import io.mockk.verify +import org.junit.After +import org.junit.Before +import org.junit.Test + +private const val A_SESSION_ID = "session_id" + +class SessionOverviewViewNavigatorTest { + + private val context = FakeContext() + private val sessionOverviewViewNavigator = SessionOverviewViewNavigator() + + @Before + fun setUp() { + mockkObject(SessionDetailsActivity) + } + + @After + fun tearDown() { + unmockkAll() + } + + @Test + fun `given a session id when navigating to details then it starts the correct activity`() { + // Given + val intent = givenIntentForSessionDetails(A_SESSION_ID) + context.givenStartActivity(intent) + + // When + sessionOverviewViewNavigator.navigateToSessionDetails(context.instance, A_SESSION_ID) + + // Then + verify { + context.instance.startActivity(intent) + } + } + + private fun givenIntentForSessionDetails(sessionId: String): Intent { + val intent = mockk() + every { SessionDetailsActivity.newIntent(context.instance, sessionId) } returns intent + return intent + } +} From c1dfa925c04eb6962f6a79afe1558c10b2f1ffbe Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 9 Sep 2022 12:02:10 +0200 Subject: [PATCH 23/51] Unit tests for use cases to check visibility of sections --- .../CheckIfSectionDeviceIsVisibleUseCase.kt | 1 - .../CheckIfSectionSessionIsVisibleUseCase.kt | 1 - ...heckIfSectionDeviceIsVisibleUseCaseTest.kt | 64 +++++++++ ...eckIfSectionSessionIsVisibleUseCaseTest.kt | 125 ++++++++++++++++++ 4 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCaseTest.kt create mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCaseTest.kt diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt index 0bfcc371c5..25b5ddb0e8 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCase.kt @@ -20,7 +20,6 @@ import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo import javax.inject.Inject -// TODO add unit tests class CheckIfSectionDeviceIsVisibleUseCase @Inject constructor() { fun execute(deviceInfo: DeviceInfo): Boolean { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt index b07d3b7ebf..4998b4b5d3 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCase.kt @@ -20,7 +20,6 @@ import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo import javax.inject.Inject -// TODO add unit tests class CheckIfSectionSessionIsVisibleUseCase @Inject constructor() { fun execute(deviceInfo: DeviceInfo): Boolean { diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCaseTest.kt new file mode 100644 index 0000000000..b618c58b7e --- /dev/null +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionDeviceIsVisibleUseCaseTest.kt @@ -0,0 +1,64 @@ +/* + * 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.settings.devices.v2.details + +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import org.amshove.kluent.shouldBeEqualTo +import org.junit.Test +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo + +private const val AN_IP_ADDRESS = "ip-address" + +class CheckIfSectionDeviceIsVisibleUseCaseTest { + + private val checkIfSectionDeviceIsVisibleUseCase = CheckIfSectionDeviceIsVisibleUseCase() + + @Test + fun `given device info with Ip address when checking is device section is visible then it returns true`() = runTest { + // Given + val deviceInfo = givenADeviceInfo(AN_IP_ADDRESS) + + // When + val result = checkIfSectionDeviceIsVisibleUseCase.execute(deviceInfo) + + // Then + result shouldBeEqualTo true + } + + @Test + fun `given device info with empty or null Ip address when checking is device section is visible then it returns false`() = runTest { + // Given + val deviceInfo1 = givenADeviceInfo("") + val deviceInfo2 = givenADeviceInfo(null) + + // When + val result1 = checkIfSectionDeviceIsVisibleUseCase.execute(deviceInfo1) + val result2 = checkIfSectionDeviceIsVisibleUseCase.execute(deviceInfo2) + + // Then + result1 shouldBeEqualTo false + result2 shouldBeEqualTo false + } + + private fun givenADeviceInfo(ipAddress: String?): DeviceInfo { + val info = mockk() + every { info.lastSeenIp } returns ipAddress + return info + } +} diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCaseTest.kt new file mode 100644 index 0000000000..806c86d175 --- /dev/null +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/CheckIfSectionSessionIsVisibleUseCaseTest.kt @@ -0,0 +1,125 @@ +/* + * 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.settings.devices.v2.details + +import io.mockk.every +import io.mockk.mockk +import kotlinx.coroutines.test.runTest +import org.amshove.kluent.shouldBeEqualTo +import org.junit.Test +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo + +private const val A_SESSION_NAME = "session-name" +private const val A_SESSION_ID = "session-id" +private const val A_LAST_SEEN_TS = 123L + +class CheckIfSectionSessionIsVisibleUseCaseTest { + + private val checkIfSectionSessionIsVisibleUseCase = CheckIfSectionSessionIsVisibleUseCase() + + @Test + fun `given device info with name, id or lastSeenTs when checking is session section is visible then it returns true`() = runTest { + // Given + val deviceInfoList = listOf( + givenADeviceInfo( + sessionName = A_SESSION_NAME, + sessionId = null, + lastSeenTs = null, + ), + givenADeviceInfo( + sessionName = null, + sessionId = A_SESSION_ID, + lastSeenTs = null, + ), + givenADeviceInfo( + sessionName = null, + sessionId = null, + lastSeenTs = A_LAST_SEEN_TS, + ), + givenADeviceInfo( + sessionName = A_SESSION_NAME, + sessionId = A_SESSION_ID, + lastSeenTs = null, + ), + givenADeviceInfo( + sessionName = A_SESSION_NAME, + sessionId = null, + lastSeenTs = A_LAST_SEEN_TS, + ), + givenADeviceInfo( + sessionName = null, + sessionId = A_SESSION_ID, + lastSeenTs = A_LAST_SEEN_TS, + ), + givenADeviceInfo( + sessionName = A_SESSION_NAME, + sessionId = A_SESSION_ID, + lastSeenTs = A_LAST_SEEN_TS, + ), + ) + + deviceInfoList.forEach { deviceInfo -> + // When + val result = checkIfSectionSessionIsVisibleUseCase.execute(deviceInfo) + + // Then + result shouldBeEqualTo true + } + } + + @Test + fun `given device info with missing session info when checking is session section is visible then it returns true`() = runTest { + // Given + val deviceInfoList = listOf( + givenADeviceInfo( + sessionName = null, + sessionId = null, + lastSeenTs = null, + ), + givenADeviceInfo( + sessionName = "", + sessionId = "", + lastSeenTs = null, + ), + givenADeviceInfo( + sessionName = "", + sessionId = "", + lastSeenTs = -1, + ), + ) + + deviceInfoList.forEach { deviceInfo -> + // When + val result = checkIfSectionSessionIsVisibleUseCase.execute(deviceInfo) + + // Then + result shouldBeEqualTo false + } + } + + private fun givenADeviceInfo( + sessionName: String?, + sessionId: String?, + lastSeenTs: Long?, + ): DeviceInfo { + val info = mockk() + every { info.displayName } returns sessionName + every { info.deviceId } returns sessionId + every { info.lastSeenTs } returns lastSeenTs + return info + } +} From 6cd0fbb614f4778a3f2b6446d44e560d4ae997d5 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 9 Sep 2022 14:32:35 +0200 Subject: [PATCH 24/51] Unit tests for the ViewModel --- .../v2/details/SessionDetailsViewModel.kt | 1 - .../v2/overview/SessionOverviewViewModel.kt | 1 - .../v2/details/SessionDetailsViewModelTest.kt | 71 +++++++++++++++++++ .../overview/SessionOverviewViewModelTest.kt | 8 ++- 4 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt index 629f9bb839..2064f8ffdd 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt @@ -29,7 +29,6 @@ import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseC import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach -// TODO add unit tests class SessionDetailsViewModel @AssistedInject constructor( @Assisted val initialState: SessionDetailsViewState, private val getDeviceFullInfoUseCase: GetDeviceFullInfoUseCase, diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt index a236814a40..bdcdc40c56 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt @@ -26,7 +26,6 @@ import im.vector.app.core.di.hiltMavericksViewModelFactory import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.VectorViewModel import kotlinx.coroutines.flow.launchIn -import kotlinx.coroutines.flow.mapNotNull import kotlinx.coroutines.flow.onEach import org.matrix.android.sdk.api.session.Session diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt new file mode 100644 index 0000000000..8444378193 --- /dev/null +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt @@ -0,0 +1,71 @@ +/* + * 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.settings.devices.v2.details + +import com.airbnb.mvrx.Success +import com.airbnb.mvrx.test.MvRxTestRule +import im.vector.app.features.settings.devices.v2.DeviceFullInfo +import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseCase +import im.vector.app.test.test +import im.vector.app.test.testDispatcher +import io.mockk.every +import io.mockk.mockk +import io.mockk.verify +import kotlinx.coroutines.flow.flowOf +import org.junit.Rule +import org.junit.Test +import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo + +private const val A_SESSION_ID = "session-id" + +class SessionDetailsViewModelTest { + + @get:Rule + val mvRxTestRule = MvRxTestRule(testDispatcher = testDispatcher) + + private val args = SessionDetailsArgs( + deviceId = A_SESSION_ID + ) + private val getDeviceFullInfoUseCase = mockk() + + private fun createViewModel() = SessionDetailsViewModel( + initialState = SessionDetailsViewState(args), + getDeviceFullInfoUseCase = getDeviceFullInfoUseCase + ) + + @Test + fun `given the viewModel has been initialized then viewState is updated with session info`() { + // Given + val deviceFullInfo = mockk() + val deviceInfo = mockk() + every { deviceFullInfo.deviceInfo } returns deviceInfo + every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo) + val expectedState = SessionDetailsViewState( + deviceId = A_SESSION_ID, + deviceInfo = Success(deviceInfo) + ) + + // When + val viewModel = createViewModel() + + // Then + viewModel.test() + .assertLatestState { state -> state == expectedState } + .finish() + verify { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } + } +} diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt index fe33bd8b0b..8d4e49ef85 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModelTest.kt @@ -21,22 +21,21 @@ import com.airbnb.mvrx.test.MvRxTestRule import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.test.fakes.FakeSession import im.vector.app.test.test +import im.vector.app.test.testDispatcher import io.mockk.every import io.mockk.mockk import io.mockk.verify import kotlinx.coroutines.flow.flowOf -import kotlinx.coroutines.test.UnconfinedTestDispatcher import org.junit.Rule import org.junit.Test import org.matrix.android.sdk.api.auth.data.SessionParams -import org.matrix.android.sdk.api.util.Optional private const val A_SESSION_ID = "session-id" class SessionOverviewViewModelTest { @get:Rule - val mvRxTestRule = MvRxTestRule(testDispatcher = UnconfinedTestDispatcher()) + val mvRxTestRule = MvRxTestRule(testDispatcher = testDispatcher) private val args = SessionOverviewArgs( deviceId = A_SESSION_ID @@ -52,6 +51,7 @@ class SessionOverviewViewModelTest { @Test fun `given the viewModel has been initialized then viewState is updated with session info`() { + // Given val sessionParams = givenIdForSession(A_SESSION_ID) val deviceFullInfo = mockk() every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo) @@ -61,8 +61,10 @@ class SessionOverviewViewModelTest { deviceInfo = Success(deviceFullInfo) ) + // When val viewModel = createViewModel() + // Then viewModel.test() .assertLatestState { state -> state == expectedState } .finish() From 279820224c2bf2eeaf35139f8d3a311949a1aec7 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Fri, 9 Sep 2022 17:06:32 +0200 Subject: [PATCH 25/51] Long press on the whole content item --- .../app/core/utils/CopyToClipboardUseCase.kt | 34 ++++++++++ .../im/vector/app/core/utils/SystemUtils.kt | 5 +- .../v2/details/SessionDetailsAction.kt | 4 +- .../v2/details/SessionDetailsContentItem.kt | 7 +- .../v2/details/SessionDetailsController.kt | 11 ++++ .../v2/details/SessionDetailsFragment.kt | 16 +++++ .../v2/details/SessionDetailsViewEvent.kt | 23 +++++++ .../v2/details/SessionDetailsViewModel.kt | 14 +++- .../core/utils/CopyToClipboardUseCaseTest.kt | 65 +++++++++++++++++++ .../v2/details/SessionDetailsViewModelTest.kt | 30 ++++++++- .../app/test/fakes/FakeClipboardManager.kt | 37 +++++++++++ .../im/vector/app/test/fakes/FakeContext.kt | 7 ++ 12 files changed, 242 insertions(+), 11 deletions(-) create mode 100644 vector/src/main/java/im/vector/app/core/utils/CopyToClipboardUseCase.kt create mode 100644 vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewEvent.kt create mode 100644 vector/src/test/java/im/vector/app/core/utils/CopyToClipboardUseCaseTest.kt create mode 100644 vector/src/test/java/im/vector/app/test/fakes/FakeClipboardManager.kt diff --git a/vector/src/main/java/im/vector/app/core/utils/CopyToClipboardUseCase.kt b/vector/src/main/java/im/vector/app/core/utils/CopyToClipboardUseCase.kt new file mode 100644 index 0000000000..19ad9e2bba --- /dev/null +++ b/vector/src/main/java/im/vector/app/core/utils/CopyToClipboardUseCase.kt @@ -0,0 +1,34 @@ +/* + * 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.core.utils + +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context +import androidx.core.content.getSystemService +import dagger.hilt.android.qualifiers.ApplicationContext +import javax.inject.Inject + +class CopyToClipboardUseCase @Inject constructor( + @ApplicationContext private val context: Context, +) { + + fun execute(text: CharSequence) { + context.getSystemService() + ?.setPrimaryClip(ClipData.newPlainText("", text)) + } +} diff --git a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt index 6cfe8acc16..cde4fe2a35 100644 --- a/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt +++ b/vector/src/main/java/im/vector/app/core/utils/SystemUtils.kt @@ -19,8 +19,6 @@ package im.vector.app.core.utils import android.annotation.TargetApi import android.app.Activity import android.content.ActivityNotFoundException -import android.content.ClipData -import android.content.ClipboardManager import android.content.Context import android.content.Intent import android.content.pm.PackageManager @@ -100,8 +98,7 @@ fun requestDisablingBatteryOptimization(activity: Activity, activityResultLaunch * @param toastMessage content of the toast message as a String resource */ fun copyToClipboard(context: Context, text: CharSequence, showToast: Boolean = true, @StringRes toastMessage: Int = R.string.copied_to_clipboard) { - val clipboard = context.getSystemService()!! - clipboard.setPrimaryClip(ClipData.newPlainText("", text)) + CopyToClipboardUseCase(context).execute(text) if (showToast) { context.toast(toastMessage) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt index 5c3743add4..0fa524dab4 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsAction.kt @@ -18,4 +18,6 @@ package im.vector.app.features.settings.devices.v2.details import im.vector.app.core.platform.VectorViewModelAction -sealed class SessionDetailsAction : VectorViewModelAction +sealed class SessionDetailsAction : VectorViewModelAction { + data class CopyToClipboard(val content: String) : SessionDetailsAction() +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt index 0363e320cd..665ba5126c 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsContentItem.kt @@ -24,7 +24,6 @@ import com.airbnb.epoxy.EpoxyModelClass import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel -import im.vector.app.core.extensions.copyOnLongClick @EpoxyModelClass abstract class SessionDetailsContentItem : VectorEpoxyModel(R.layout.item_session_details_content) { @@ -38,11 +37,15 @@ abstract class SessionDetailsContentItem : VectorEpoxyModel() { + var callback: Callback? = null + + interface Callback { + fun onItemLongClicked(content: String) + } + override fun buildModels(data: DeviceInfo?) { data?.let { info -> val hasSectionSession = hasSectionSession(data) @@ -64,6 +71,10 @@ class SessionDetailsController @Inject constructor( title(host.stringProvider.getString(titleResId)) description(value) hasDivider(hasDivider) + onLongClickListener(View.OnLongClickListener { + host.callback?.onItemLongClicked(value) + true + }) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt index bf0037b0e8..5d7717e5f7 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsFragment.kt @@ -31,6 +31,7 @@ import im.vector.app.R import im.vector.app.core.extensions.cleanup import im.vector.app.core.extensions.configureWith import im.vector.app.core.platform.VectorBaseFragment +import im.vector.app.core.platform.showOptimizedSnackbar import im.vector.app.databinding.FragmentSessionDetailsBinding import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo import javax.inject.Inject @@ -54,6 +55,7 @@ class SessionDetailsFragment : super.onViewCreated(view, savedInstanceState) initToolbar() initSessionDetails() + observeViewEvents() } private fun initToolbar() { @@ -63,15 +65,29 @@ class SessionDetailsFragment : } private fun initSessionDetails() { + sessionDetailsController.callback = object : SessionDetailsController.Callback { + override fun onItemLongClicked(content: String) { + viewModel.handle(SessionDetailsAction.CopyToClipboard(content)) + } + } views.sessionDetails.configureWith(sessionDetailsController) } + private fun observeViewEvents() { + viewModel.observeViewEvents { viewEvent -> + when (viewEvent) { + SessionDetailsViewEvent.ContentCopiedToClipboard -> view?.showOptimizedSnackbar(getString(R.string.copied_to_clipboard)) + } + } + } + override fun onDestroyView() { cleanUpSessionDetails() super.onDestroyView() } private fun cleanUpSessionDetails() { + sessionDetailsController.callback = null views.sessionDetails.cleanup() } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewEvent.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewEvent.kt new file mode 100644 index 0000000000..02b313319e --- /dev/null +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewEvent.kt @@ -0,0 +1,23 @@ +/* + * 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.settings.devices.v2.details + +import im.vector.app.core.platform.VectorViewEvents + +sealed class SessionDetailsViewEvent : VectorViewEvents { + object ContentCopiedToClipboard : SessionDetailsViewEvent() +} diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt index 2064f8ffdd..c37858cc54 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModel.kt @@ -23,8 +23,8 @@ import dagger.assisted.AssistedFactory import dagger.assisted.AssistedInject import im.vector.app.core.di.MavericksAssistedViewModelFactory import im.vector.app.core.di.hiltMavericksViewModelFactory -import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.VectorViewModel +import im.vector.app.core.utils.CopyToClipboardUseCase import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseCase import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach @@ -32,7 +32,8 @@ import kotlinx.coroutines.flow.onEach class SessionDetailsViewModel @AssistedInject constructor( @Assisted val initialState: SessionDetailsViewState, private val getDeviceFullInfoUseCase: GetDeviceFullInfoUseCase, -) : VectorViewModel(initialState) { + private val copyToClipboardUseCase: CopyToClipboardUseCase, +) : VectorViewModel(initialState) { companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() @@ -52,6 +53,13 @@ class SessionDetailsViewModel @AssistedInject constructor( } override fun handle(action: SessionDetailsAction) { - TODO("Implement when adding the first action") + return when (action) { + is SessionDetailsAction.CopyToClipboard -> handleCopyToClipboard(action) + } + } + + private fun handleCopyToClipboard(copyToClipboard: SessionDetailsAction.CopyToClipboard) { + copyToClipboardUseCase.execute(copyToClipboard.content) + _viewEvents.post(SessionDetailsViewEvent.ContentCopiedToClipboard) } } diff --git a/vector/src/test/java/im/vector/app/core/utils/CopyToClipboardUseCaseTest.kt b/vector/src/test/java/im/vector/app/core/utils/CopyToClipboardUseCaseTest.kt new file mode 100644 index 0000000000..8de6991a2e --- /dev/null +++ b/vector/src/test/java/im/vector/app/core/utils/CopyToClipboardUseCaseTest.kt @@ -0,0 +1,65 @@ +/* + * 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.core.utils + +import android.content.ClipData +import im.vector.app.test.fakes.FakeContext +import io.mockk.every +import io.mockk.mockk +import io.mockk.mockkStatic +import io.mockk.unmockkAll +import io.mockk.verify +import org.junit.After +import org.junit.Before +import org.junit.Test + +private const val A_TEXT = "text" + +class CopyToClipboardUseCaseTest { + + private val fakeContext = FakeContext() + + private val copyToClipboardUseCase = CopyToClipboardUseCase( + context = fakeContext.instance + ) + + @Before + fun setup() { + mockkStatic(ClipData::class) + } + + @After + fun tearDown() { + unmockkAll() + } + + @Test + fun `given a text when executing the use case then the text is copied into the clipboard`() { + // Given + val clipboardManager = fakeContext.givenClipboardManager() + clipboardManager.givenSetPrimaryClip() + val clipData = mockk() + every { ClipData.newPlainText(any(), any()) } returns clipData + + // When + copyToClipboardUseCase.execute(A_TEXT) + + // Then + clipboardManager.verifySetPrimaryClip(clipData) + verify { ClipData.newPlainText("", A_TEXT) } + } +} diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt index 8444378193..df0613e06b 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsViewModelTest.kt @@ -18,12 +18,15 @@ package im.vector.app.features.settings.devices.v2.details import com.airbnb.mvrx.Success import com.airbnb.mvrx.test.MvRxTestRule +import im.vector.app.core.utils.CopyToClipboardUseCase import im.vector.app.features.settings.devices.v2.DeviceFullInfo import im.vector.app.features.settings.devices.v2.overview.GetDeviceFullInfoUseCase import im.vector.app.test.test import im.vector.app.test.testDispatcher import io.mockk.every +import io.mockk.just import io.mockk.mockk +import io.mockk.runs import io.mockk.verify import kotlinx.coroutines.flow.flowOf import org.junit.Rule @@ -31,6 +34,7 @@ import org.junit.Test import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo private const val A_SESSION_ID = "session-id" +private const val A_TEXT = "text" class SessionDetailsViewModelTest { @@ -41,10 +45,12 @@ class SessionDetailsViewModelTest { deviceId = A_SESSION_ID ) private val getDeviceFullInfoUseCase = mockk() + private val copyToClipboardUseCase = mockk() private fun createViewModel() = SessionDetailsViewModel( initialState = SessionDetailsViewState(args), - getDeviceFullInfoUseCase = getDeviceFullInfoUseCase + getDeviceFullInfoUseCase = getDeviceFullInfoUseCase, + copyToClipboardUseCase = copyToClipboardUseCase, ) @Test @@ -68,4 +74,26 @@ class SessionDetailsViewModelTest { .finish() verify { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } } + + @Test + fun `given copyToClipboard action when viewModel handle it then related use case is executed and viewEvent is updated`() { + // Given + val deviceFullInfo = mockk() + val deviceInfo = mockk() + every { deviceFullInfo.deviceInfo } returns deviceInfo + every { getDeviceFullInfoUseCase.execute(A_SESSION_ID) } returns flowOf(deviceFullInfo) + val action = SessionDetailsAction.CopyToClipboard(A_TEXT) + every { copyToClipboardUseCase.execute(any()) } just runs + + // When + val viewModel = createViewModel() + val viewModelTest = viewModel.test() + viewModel.handle(action) + + // Then + viewModelTest + .assertEvent { it is SessionDetailsViewEvent.ContentCopiedToClipboard } + .finish() + verify { copyToClipboardUseCase.execute(A_TEXT) } + } } diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeClipboardManager.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeClipboardManager.kt new file mode 100644 index 0000000000..983902b496 --- /dev/null +++ b/vector/src/test/java/im/vector/app/test/fakes/FakeClipboardManager.kt @@ -0,0 +1,37 @@ +/* + * 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.test.fakes + +import android.content.ClipData +import android.content.ClipboardManager +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.runs +import io.mockk.verify + +class FakeClipboardManager { + val instance = mockk() + + fun givenSetPrimaryClip() { + every { instance.setPrimaryClip(any()) } just runs + } + + fun verifySetPrimaryClip(clipData: ClipData) { + verify { instance.setPrimaryClip(clipData) } + } +} diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeContext.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeContext.kt index d74ebcb678..9a94313fec 100644 --- a/vector/src/test/java/im/vector/app/test/fakes/FakeContext.kt +++ b/vector/src/test/java/im/vector/app/test/fakes/FakeContext.kt @@ -16,6 +16,7 @@ package im.vector.app.test.fakes +import android.content.ClipboardManager import android.content.ContentResolver import android.content.Context import android.content.Intent @@ -74,4 +75,10 @@ class FakeContext( fun givenStartActivity(intent: Intent) { every { instance.startActivity(intent) } just runs } + + fun givenClipboardManager(): FakeClipboardManager { + val fakeClipboardManager = FakeClipboardManager() + givenService(Context.CLIPBOARD_SERVICE, ClipboardManager::class.java, fakeClipboardManager.instance) + return fakeClipboardManager + } } From a1bdfd1a5c00493ff4f0d9c0b8ff7748ffd3381b Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 13 Sep 2022 14:43:23 +0200 Subject: [PATCH 26/51] Using shouldBeNull() method in unit tests --- .../devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt index 2001d2ba37..9c7515f2da 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/overview/GetDeviceFullInfoUseCaseTest.kt @@ -34,6 +34,7 @@ import kotlinx.coroutines.flow.firstOrNull import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.amshove.kluent.shouldBeEqualTo +import org.amshove.kluent.shouldBeNull import org.junit.After import org.junit.Before import org.junit.Test @@ -117,7 +118,7 @@ class GetDeviceFullInfoUseCaseTest { val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() // Then - deviceFullInfo shouldBeEqualTo null + deviceFullInfo.shouldBeNull() verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } verify { fakeActiveSessionHolder.fakeSession.fakeCryptoService.getMyDevicesInfoLive(A_DEVICE_ID).asFlow() } verify { fakeActiveSessionHolder.fakeSession.fakeCryptoService.getLiveCryptoDeviceInfoWithId(A_DEVICE_ID).asFlow() } @@ -132,7 +133,7 @@ class GetDeviceFullInfoUseCaseTest { val deviceFullInfo = getDeviceFullInfoUseCase.execute(A_DEVICE_ID).firstOrNull() // Then - deviceFullInfo shouldBeEqualTo null + deviceFullInfo.shouldBeNull() verify { fakeActiveSessionHolder.instance.getSafeActiveSession() } } From fb3fdf097cdecf58ccd76a3d0f8a2dc4a966fd44 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 13 Sep 2022 14:45:48 +0200 Subject: [PATCH 27/51] Reusing some existing strings --- library/ui-strings/src/main/res/values-ar/strings.xml | 2 +- library/ui-strings/src/main/res/values-bg/strings.xml | 2 +- library/ui-strings/src/main/res/values-bn-rBD/strings.xml | 2 +- library/ui-strings/src/main/res/values-bn-rIN/strings.xml | 2 +- library/ui-strings/src/main/res/values-ca/strings.xml | 2 +- library/ui-strings/src/main/res/values-cs/strings.xml | 2 +- library/ui-strings/src/main/res/values-de/strings.xml | 4 ++-- library/ui-strings/src/main/res/values-el/strings.xml | 2 +- library/ui-strings/src/main/res/values-eo/strings.xml | 2 +- library/ui-strings/src/main/res/values-es-rMX/strings.xml | 2 +- library/ui-strings/src/main/res/values-es/strings.xml | 2 +- library/ui-strings/src/main/res/values-et/strings.xml | 2 +- library/ui-strings/src/main/res/values-eu/strings.xml | 2 +- library/ui-strings/src/main/res/values-fa/strings.xml | 2 +- library/ui-strings/src/main/res/values-fi/strings.xml | 2 +- library/ui-strings/src/main/res/values-fr-rCA/strings.xml | 2 +- library/ui-strings/src/main/res/values-fr/strings.xml | 2 +- library/ui-strings/src/main/res/values-gl/strings.xml | 2 +- library/ui-strings/src/main/res/values-hr/strings.xml | 2 +- library/ui-strings/src/main/res/values-hu/strings.xml | 2 +- library/ui-strings/src/main/res/values-in/strings.xml | 2 +- library/ui-strings/src/main/res/values-is/strings.xml | 2 +- library/ui-strings/src/main/res/values-it/strings.xml | 2 +- library/ui-strings/src/main/res/values-iw/strings.xml | 2 +- library/ui-strings/src/main/res/values-ja/strings.xml | 2 +- library/ui-strings/src/main/res/values-kab/strings.xml | 2 +- library/ui-strings/src/main/res/values-ko/strings.xml | 2 +- library/ui-strings/src/main/res/values-lo/strings.xml | 2 +- library/ui-strings/src/main/res/values-lv/strings.xml | 2 +- library/ui-strings/src/main/res/values-nb-rNO/strings.xml | 2 +- library/ui-strings/src/main/res/values-nl/strings.xml | 2 +- library/ui-strings/src/main/res/values-nn/strings.xml | 2 +- library/ui-strings/src/main/res/values-pl/strings.xml | 4 ++-- library/ui-strings/src/main/res/values-pt-rBR/strings.xml | 2 +- library/ui-strings/src/main/res/values-pt/strings.xml | 2 +- library/ui-strings/src/main/res/values-ru/strings.xml | 4 ++-- library/ui-strings/src/main/res/values-sk/strings.xml | 2 +- library/ui-strings/src/main/res/values-sq/strings.xml | 2 +- library/ui-strings/src/main/res/values-sv/strings.xml | 2 +- library/ui-strings/src/main/res/values-te/strings.xml | 2 +- library/ui-strings/src/main/res/values-tr/strings.xml | 2 +- library/ui-strings/src/main/res/values-uk/strings.xml | 2 +- library/ui-strings/src/main/res/values-vi/strings.xml | 2 +- library/ui-strings/src/main/res/values-zh-rCN/strings.xml | 4 ++-- library/ui-strings/src/main/res/values-zh-rTW/strings.xml | 2 +- library/ui-strings/src/main/res/values/strings.xml | 4 +--- .../settings/devices/v2/details/SessionDetailsController.kt | 4 ++-- vector/src/main/res/layout/dialog_device_verify.xml | 4 ++-- vector/src/main/res/xml/vector_settings_security_privacy.xml | 2 +- 49 files changed, 55 insertions(+), 57 deletions(-) diff --git a/library/ui-strings/src/main/res/values-ar/strings.xml b/library/ui-strings/src/main/res/values-ar/strings.xml index 073f961cb6..70b9a33ab5 100644 --- a/library/ui-strings/src/main/res/values-ar/strings.xml +++ b/library/ui-strings/src/main/res/values-ar/strings.xml @@ -320,7 +320,7 @@ السمة خطأ في فكّ التعمية اسم الجهاز - معرّف الجهاز + معرّف الجهاز مفتاح الجهاز صدّر مفاتيح الغرفة صدّر المفاتيح إلى ملف محلي diff --git a/library/ui-strings/src/main/res/values-bg/strings.xml b/library/ui-strings/src/main/res/values-bg/strings.xml index b29823040f..d3e9e599bc 100644 --- a/library/ui-strings/src/main/res/values-bg/strings.xml +++ b/library/ui-strings/src/main/res/values-bg/strings.xml @@ -396,7 +396,7 @@ Тема Грешка при разшифроване Публично име - Сесийно ID + Сесийно ID Ключ на устройство Експортирай E2E ключове за стая Експортиране на ключове за стая diff --git a/library/ui-strings/src/main/res/values-bn-rBD/strings.xml b/library/ui-strings/src/main/res/values-bn-rBD/strings.xml index 2f068f1bf8..7897da934e 100644 --- a/library/ui-strings/src/main/res/values-bn-rBD/strings.xml +++ b/library/ui-strings/src/main/res/values-bn-rBD/strings.xml @@ -789,7 +789,7 @@ রুমের কুঞ্জিগুলি এক্সপোর্ট করুন শেষ থেকে শেষ রুমের কুঞ্জিগুলি এক্সপোর্ট করুন সেশানের কুঞ্জি - আইডি + আইডি সর্বজনীন নাম ডিক্রিপশন সমস্যা থিম diff --git a/library/ui-strings/src/main/res/values-bn-rIN/strings.xml b/library/ui-strings/src/main/res/values-bn-rIN/strings.xml index 828bc3bd34..56bde36977 100644 --- a/library/ui-strings/src/main/res/values-bn-rIN/strings.xml +++ b/library/ui-strings/src/main/res/values-bn-rIN/strings.xml @@ -693,7 +693,7 @@ ডিক্রিপশন সমস্যা সর্বজনীন নাম - আইডি + আইডি সেশানের কুঞ্জি শেষ থেকে শেষ রুমের কুঞ্জিগুলি এক্সপোর্ট করুন diff --git a/library/ui-strings/src/main/res/values-ca/strings.xml b/library/ui-strings/src/main/res/values-ca/strings.xml index 13a5b6c119..77d9fc10d5 100644 --- a/library/ui-strings/src/main/res/values-ca/strings.xml +++ b/library/ui-strings/src/main/res/values-ca/strings.xml @@ -448,7 +448,7 @@ Tema Error al desxifrar Nom públic - ID de sessió + ID de sessió Clau de sessió Exporta les claus de la sala E2E Exporta les claus de la sala diff --git a/library/ui-strings/src/main/res/values-cs/strings.xml b/library/ui-strings/src/main/res/values-cs/strings.xml index b7bfeac444..ed5a05f38a 100644 --- a/library/ui-strings/src/main/res/values-cs/strings.xml +++ b/library/ui-strings/src/main/res/values-cs/strings.xml @@ -635,7 +635,7 @@ Motiv vzhledu Chyba dešifrování Veřejné jméno - ID relace + ID relace Klíč relace Export E2E klíčů místností Export klíčů místností diff --git a/library/ui-strings/src/main/res/values-de/strings.xml b/library/ui-strings/src/main/res/values-de/strings.xml index 8e502a6392..05ae25c5f7 100644 --- a/library/ui-strings/src/main/res/values-de/strings.xml +++ b/library/ui-strings/src/main/res/values-de/strings.xml @@ -418,7 +418,7 @@ Als Hauptadresse aufheben Entschlüsselungsfehler Öffentlicher Name - Sitzungs-ID + Sitzungs-ID Sitzungsschlüssel Ende-zu-Ende-Raumschlüssel exportieren Raumschlüssel exportieren @@ -2622,4 +2622,4 @@ Nicht verifiziert · Letzte Aktivität %1$s Verifiziere deine aktuelle Sitzung für besonders sichere Nachrichtenübertragung. Nicht verifizierte Sitzung - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-el/strings.xml b/library/ui-strings/src/main/res/values-el/strings.xml index 092a01bff4..f4973f4b95 100644 --- a/library/ui-strings/src/main/res/values-el/strings.xml +++ b/library/ui-strings/src/main/res/values-el/strings.xml @@ -172,7 +172,7 @@ Θέμα Σφάλμα αποκρυπτογράφησης Όνομα συσκευής - Αναγνωριστικό συσκευής + Αναγνωριστικό συσκευής Εξαγωγή Εισαγωγή Επιλέξτε ένα ευρετήριο δωματίων diff --git a/library/ui-strings/src/main/res/values-eo/strings.xml b/library/ui-strings/src/main/res/values-eo/strings.xml index 7e1925f708..f536ca00f9 100644 --- a/library/ui-strings/src/main/res/values-eo/strings.xml +++ b/library/ui-strings/src/main/res/values-eo/strings.xml @@ -1084,7 +1084,7 @@ Elporti ŝlosilojn de ĉambroj Elporti tutvoje ĉifrajn ŝlosilojn de ĉambroj Ŝlosilo de salutaĵo - Identigilo de salutaĵo + Identigilo de salutaĵo Publika nomo Eraris malĉifrado Haŭto diff --git a/library/ui-strings/src/main/res/values-es-rMX/strings.xml b/library/ui-strings/src/main/res/values-es-rMX/strings.xml index 0b38fa6a19..c82f9aff61 100644 --- a/library/ui-strings/src/main/res/values-es-rMX/strings.xml +++ b/library/ui-strings/src/main/res/values-es-rMX/strings.xml @@ -249,7 +249,7 @@ Desescojer como Dirección Principal Error en descifrar Nombre del dispositivo - Identificación del dispositivo + Identificación del dispositivo Clave del dispositivo Exportar claves de cifrado de extremo-a-extremo de salas Exportar claves de salas diff --git a/library/ui-strings/src/main/res/values-es/strings.xml b/library/ui-strings/src/main/res/values-es/strings.xml index 4eec90fbd6..fcdd3f90a0 100644 --- a/library/ui-strings/src/main/res/values-es/strings.xml +++ b/library/ui-strings/src/main/res/values-es/strings.xml @@ -415,7 +415,7 @@ Dejar de Establecer como dirección principal Error de descifrado Nombre público - ID de sesión + ID de sesión Clave de sesión Exportar claves de salas con cifrado Extremo-a-Extremo Exportar claves de sala diff --git a/library/ui-strings/src/main/res/values-et/strings.xml b/library/ui-strings/src/main/res/values-et/strings.xml index 55fb9dfef0..495f32415f 100644 --- a/library/ui-strings/src/main/res/values-et/strings.xml +++ b/library/ui-strings/src/main/res/values-et/strings.xml @@ -612,7 +612,7 @@ Need on alles katsejärgus olevad funktsionaalsused. Ole kasutamisel ettevaatlik. Dekrüptimise viga Avalik nimi - Sessiooni tunnus + Sessiooni tunnus Sessiooni võti Ekspordi jututubade läbiva krüptimise võtmed Ekspordi jututoa võtmed diff --git a/library/ui-strings/src/main/res/values-eu/strings.xml b/library/ui-strings/src/main/res/values-eu/strings.xml index 7b27d1cc1d..f1f834ee04 100644 --- a/library/ui-strings/src/main/res/values-eu/strings.xml +++ b/library/ui-strings/src/main/res/values-eu/strings.xml @@ -406,7 +406,7 @@ Kontuan izan ekintza honek aplikazioa berrabiaraziko duela eta denbora bat behar Deszifratze errorea Izen publikoa - IDa + IDa Saioaren gakoa Esportatu E2E geletako gakoak diff --git a/library/ui-strings/src/main/res/values-fa/strings.xml b/library/ui-strings/src/main/res/values-fa/strings.xml index e104225389..be6d4b97b7 100644 --- a/library/ui-strings/src/main/res/values-fa/strings.xml +++ b/library/ui-strings/src/main/res/values-fa/strings.xml @@ -678,7 +678,7 @@ این‌ها ویژگی‌های آزمایشی‌ای هستند که ممکن است به روش‌های نامنتظره‌ای حراب شوندا. با احتیاط استفاده کنید. تنظیم به عنوان نشانی اصلی نام عمومی - شناسهٔ نشست + شناسهٔ نشست کلید نشست برون‌ریزی کلید‌های اتاق‌های سرتاسری برون‌ریزی کلید‌های اتاق‌ها diff --git a/library/ui-strings/src/main/res/values-fi/strings.xml b/library/ui-strings/src/main/res/values-fi/strings.xml index fde2502ae0..a576e7f0dc 100644 --- a/library/ui-strings/src/main/res/values-fi/strings.xml +++ b/library/ui-strings/src/main/res/values-fi/strings.xml @@ -366,7 +366,7 @@ Kumoa pääosoitteeksi asettaminen Salauksenpurkuvirhe Julkinen nimi - Istunnon tunnus + Istunnon tunnus Istunnon avain Vie salatun huoneen avaimet Vie huoneen avaimet diff --git a/library/ui-strings/src/main/res/values-fr-rCA/strings.xml b/library/ui-strings/src/main/res/values-fr-rCA/strings.xml index 29a618f415..94db2935a7 100644 --- a/library/ui-strings/src/main/res/values-fr-rCA/strings.xml +++ b/library/ui-strings/src/main/res/values-fr-rCA/strings.xml @@ -778,7 +778,7 @@ Exporter les clés des salons Exporter les clés E2E des salons Clé de la session - Identifiant de session + Identifiant de session Nom public Erreur de déchiffrement Thème diff --git a/library/ui-strings/src/main/res/values-fr/strings.xml b/library/ui-strings/src/main/res/values-fr/strings.xml index 55b5f88134..d4738f7b2f 100644 --- a/library/ui-strings/src/main/res/values-fr/strings.xml +++ b/library/ui-strings/src/main/res/values-fr/strings.xml @@ -346,7 +346,7 @@ Désactiver comme adresse principale Erreur de déchiffrement Nom public - Identifiant de session + Identifiant de session Clé de la session Exporter les clés E2E des salons Exporter les clés des salons diff --git a/library/ui-strings/src/main/res/values-gl/strings.xml b/library/ui-strings/src/main/res/values-gl/strings.xml index e6d26a63e5..c1e4e40a81 100644 --- a/library/ui-strings/src/main/res/values-gl/strings.xml +++ b/library/ui-strings/src/main/res/values-gl/strings.xml @@ -380,7 +380,7 @@ Tema Fallo ao descifrar Nome do dispositivo - ID de sesión + ID de sesión Chave do dispositivo Exportar chaves E2E da sala Exportar chaves da sala diff --git a/library/ui-strings/src/main/res/values-hr/strings.xml b/library/ui-strings/src/main/res/values-hr/strings.xml index dc5930b933..6d52e5cd96 100644 --- a/library/ui-strings/src/main/res/values-hr/strings.xml +++ b/library/ui-strings/src/main/res/values-hr/strings.xml @@ -572,7 +572,7 @@ Tema Greška u dešifriranju Javni naziv - Identitet + Identitet Ključ sesije Izvezi sobne ključeve za E2E Izvezi sobne ključeve diff --git a/library/ui-strings/src/main/res/values-hu/strings.xml b/library/ui-strings/src/main/res/values-hu/strings.xml index af8bf26b2e..5a4d951dc1 100644 --- a/library/ui-strings/src/main/res/values-hu/strings.xml +++ b/library/ui-strings/src/main/res/values-hu/strings.xml @@ -351,7 +351,7 @@ Kiszedés fő címek közül Visszafejtés hiba Nyilvános név - Munkamenet-azonosító + Munkamenet-azonosító Munkamenet kulcs E2E szoba kulcsok exportálása Szoba kulcsok exportálása diff --git a/library/ui-strings/src/main/res/values-in/strings.xml b/library/ui-strings/src/main/res/values-in/strings.xml index d1e68b4529..d2861a326b 100644 --- a/library/ui-strings/src/main/res/values-in/strings.xml +++ b/library/ui-strings/src/main/res/values-in/strings.xml @@ -301,7 +301,7 @@ Di masa mendatang proses verifikasi ini akan dimutakhirkan. Tema Kesalahan dekripsi Nama perangkat - ID Sesi + ID Sesi Kunci perangkat Ekspor kunci ruangan terenkripsi Ekspor ruangan kunci diff --git a/library/ui-strings/src/main/res/values-is/strings.xml b/library/ui-strings/src/main/res/values-is/strings.xml index 7818761145..d25d66bfba 100644 --- a/library/ui-strings/src/main/res/values-is/strings.xml +++ b/library/ui-strings/src/main/res/values-is/strings.xml @@ -193,7 +193,7 @@ Þema Afkóðunarvilla Heiti tækis - Auðkenni setu + Auðkenni setu Dulritunarlykill setu Flytja út Settu inn lykilsetningu diff --git a/library/ui-strings/src/main/res/values-it/strings.xml b/library/ui-strings/src/main/res/values-it/strings.xml index ecb29d1586..984837679a 100644 --- a/library/ui-strings/src/main/res/values-it/strings.xml +++ b/library/ui-strings/src/main/res/values-it/strings.xml @@ -430,7 +430,7 @@ Tema Errore di decriptazione Nome pubblico - ID sessione + ID sessione Chiave sessione Esporta le chiavi di crittografia E2E delle stanze Esporta le chiavi delle stanze diff --git a/library/ui-strings/src/main/res/values-iw/strings.xml b/library/ui-strings/src/main/res/values-iw/strings.xml index 6d9533852b..ff19310c8e 100644 --- a/library/ui-strings/src/main/res/values-iw/strings.xml +++ b/library/ui-strings/src/main/res/values-iw/strings.xml @@ -542,7 +542,7 @@ יצא מפתחות חדר ייצא מפתחות חדר E2E מזהה מפתח - מזהה מושב + מזהה מושב שם ציבורי שגיאת פענוח ערכת נושא diff --git a/library/ui-strings/src/main/res/values-ja/strings.xml b/library/ui-strings/src/main/res/values-ja/strings.xml index b781e4d7f0..3e817e398c 100644 --- a/library/ui-strings/src/main/res/values-ja/strings.xml +++ b/library/ui-strings/src/main/res/values-ja/strings.xml @@ -197,7 +197,7 @@ これらは予期しない不具合が生じるかもしれない実験的機能です。慎重に使用してください。 メインアドレスとして設定 メインアドレスとしての設定を解除 - セッションID + セッションID 文字の大きさ とても小さい 小さい diff --git a/library/ui-strings/src/main/res/values-kab/strings.xml b/library/ui-strings/src/main/res/values-kab/strings.xml index a79b72efde..353fb99f53 100644 --- a/library/ui-strings/src/main/res/values-kab/strings.xml +++ b/library/ui-strings/src/main/res/values-kab/strings.xml @@ -291,7 +291,7 @@ Talqayt Tinarimin Asentel - Asulay n tqimit + Asulay n tqimit Tasarut n tɣimit Sifeḍ tisura n texxamt E2E Sifeḍ tisura n texxamt diff --git a/library/ui-strings/src/main/res/values-ko/strings.xml b/library/ui-strings/src/main/res/values-ko/strings.xml index ba0cbe5abd..37e8849fa8 100644 --- a/library/ui-strings/src/main/res/values-ko/strings.xml +++ b/library/ui-strings/src/main/res/values-ko/strings.xml @@ -431,7 +431,7 @@ 테마 암호 복호화 오류 공개 이름 - ID + ID 기기 키 종단간 암호화 방 키 내보내기 방 키 내보내기 diff --git a/library/ui-strings/src/main/res/values-lo/strings.xml b/library/ui-strings/src/main/res/values-lo/strings.xml index 1a9a2820b8..a92adb0225 100644 --- a/library/ui-strings/src/main/res/values-lo/strings.xml +++ b/library/ui-strings/src/main/res/values-lo/strings.xml @@ -909,7 +909,7 @@ ສົ່ງອອກກະແຈຫ້ອງ ສົ່ງອອກກະແຈຫ້ອງ E2E ລະຫັດລະບົບ - ID ລະບົບ + ID ລະບົບ ຊື່ສາທາລະນະ ການຖອດລະຫັດຜິດພາດ ຫົວຂໍ້ diff --git a/library/ui-strings/src/main/res/values-lv/strings.xml b/library/ui-strings/src/main/res/values-lv/strings.xml index f1fa1502c1..1787653fae 100644 --- a/library/ui-strings/src/main/res/values-lv/strings.xml +++ b/library/ui-strings/src/main/res/values-lv/strings.xml @@ -469,7 +469,7 @@ Tēma Atšifrēšanas kļūda Ierīces nosaukums - Sesijas ID + Sesijas ID Sesijas atslēga Eksportēt istabas šifrēšanas atslēgas Eksportēt istabas atslēgas diff --git a/library/ui-strings/src/main/res/values-nb-rNO/strings.xml b/library/ui-strings/src/main/res/values-nb-rNO/strings.xml index 031b380c7e..7af718d920 100644 --- a/library/ui-strings/src/main/res/values-nb-rNO/strings.xml +++ b/library/ui-strings/src/main/res/values-nb-rNO/strings.xml @@ -119,7 +119,7 @@ Bannlyste brukere Avansert Tema - Økt-ID + Økt-ID Øktnøkkel Eksporter Importer diff --git a/library/ui-strings/src/main/res/values-nl/strings.xml b/library/ui-strings/src/main/res/values-nl/strings.xml index b1d239963e..2669143a7e 100644 --- a/library/ui-strings/src/main/res/values-nl/strings.xml +++ b/library/ui-strings/src/main/res/values-nl/strings.xml @@ -275,7 +275,7 @@ Niet instellen als hoofdadres Ontsleutelingsfout Publieke naam - Sessie ID + Sessie ID Sessiesleutel E2E-gesprekssleutels exporteren Gesprekssleutels exporteren diff --git a/library/ui-strings/src/main/res/values-nn/strings.xml b/library/ui-strings/src/main/res/values-nn/strings.xml index a56ba0ac30..45c8679736 100644 --- a/library/ui-strings/src/main/res/values-nn/strings.xml +++ b/library/ui-strings/src/main/res/values-nn/strings.xml @@ -310,7 +310,7 @@ Preg Noko gjekk gale med dekrypteringa Offentleg namn - Økt-ID + Økt-ID Sesjonsnøkkel Eksporter E2E-romnøkklar Eksporter romnøkklar diff --git a/library/ui-strings/src/main/res/values-pl/strings.xml b/library/ui-strings/src/main/res/values-pl/strings.xml index 18b0de078c..ce8b22bcd2 100644 --- a/library/ui-strings/src/main/res/values-pl/strings.xml +++ b/library/ui-strings/src/main/res/values-pl/strings.xml @@ -231,7 +231,7 @@ Ustaw jako główny adres Motyw Nazwa publiczna - ID sesji + ID sesji Eksportuj Wprowadź hasło Potwierdź hasło @@ -2734,4 +2734,4 @@ Niestety, ten pokój nie został znaleziony. \nSpróbuj ponownie później.%s Zaproszenia - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-pt-rBR/strings.xml b/library/ui-strings/src/main/res/values-pt-rBR/strings.xml index 08c41db365..e9d0c66fd9 100644 --- a/library/ui-strings/src/main/res/values-pt-rBR/strings.xml +++ b/library/ui-strings/src/main/res/values-pt-rBR/strings.xml @@ -418,7 +418,7 @@ Des-definir como endereço principal Erro de decriptação Nome público - ID de sessão + ID de sessão Chave de sessão Exportar chaves de sala E2E Exportar chaves de sala diff --git a/library/ui-strings/src/main/res/values-pt/strings.xml b/library/ui-strings/src/main/res/values-pt/strings.xml index 4daaef83b0..87b6297b2b 100644 --- a/library/ui-strings/src/main/res/values-pt/strings.xml +++ b/library/ui-strings/src/main/res/values-pt/strings.xml @@ -246,7 +246,7 @@ Note que esta acção irá reiniciar a aplicação e poderá levar algum tempo.< Erro de decifragem Nome do dispositivo - ID do dispositivo + ID do dispositivo Chave do dispositivo Exportar chaves E2E da sala Exportar chaves de sala diff --git a/library/ui-strings/src/main/res/values-ru/strings.xml b/library/ui-strings/src/main/res/values-ru/strings.xml index 4852be1f82..9bbb1dc1c9 100644 --- a/library/ui-strings/src/main/res/values-ru/strings.xml +++ b/library/ui-strings/src/main/res/values-ru/strings.xml @@ -432,7 +432,7 @@ Сбросить основной адрес Ошибка дешифровки Публичное имя - ID сессии + ID сессии Ключ сессии Экспорт E2E ключей комнаты Экспорт ключей комнаты @@ -2678,4 +2678,4 @@ Обзор комнат Начать беседу Создать комнату - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-sk/strings.xml b/library/ui-strings/src/main/res/values-sk/strings.xml index 2cc2d0280e..328cbb78cb 100644 --- a/library/ui-strings/src/main/res/values-sk/strings.xml +++ b/library/ui-strings/src/main/res/values-sk/strings.xml @@ -388,7 +388,7 @@ Vzhľad Chyba dešifrovania Verejné meno - ID relácie + ID relácie Kľúč relácie Exportovať šifrovacie kľúče miestnosti Exportovať kľúče miestnosti diff --git a/library/ui-strings/src/main/res/values-sq/strings.xml b/library/ui-strings/src/main/res/values-sq/strings.xml index 8fdf4ee310..a6af0a4921 100644 --- a/library/ui-strings/src/main/res/values-sq/strings.xml +++ b/library/ui-strings/src/main/res/values-sq/strings.xml @@ -431,7 +431,7 @@ Temë Gabim shfshehtëzimi Emër publik - ID Sesioni + ID Sesioni Kyç sesioni Eksporto kyçe dhome E2E Eksporto kyçe dhome diff --git a/library/ui-strings/src/main/res/values-sv/strings.xml b/library/ui-strings/src/main/res/values-sv/strings.xml index 025713272c..30b63c213c 100644 --- a/library/ui-strings/src/main/res/values-sv/strings.xml +++ b/library/ui-strings/src/main/res/values-sv/strings.xml @@ -918,7 +918,7 @@ Sätt upp på den här enheten Generera en ny säkerhetskopia eller sätt en ny lösenfras för din existerande säkerhetskopia. Detta är experimentella funktioner som kan gå sönder på oväntade sätt. Använd varsamt. - Sessions-ID + Sessions-ID Sessionsnyckel Exportera krypteringsnycklar Exportera rumsnycklar diff --git a/library/ui-strings/src/main/res/values-te/strings.xml b/library/ui-strings/src/main/res/values-te/strings.xml index 5ed2462ce8..0154d54c2e 100644 --- a/library/ui-strings/src/main/res/values-te/strings.xml +++ b/library/ui-strings/src/main/res/values-te/strings.xml @@ -260,7 +260,7 @@ ప్రధాన చిరునామాగా సెట్ చేయండి పరికరం పేరు - పరికరం ID + పరికరం ID పరికరం కీ E2E గది కీలను ఎగుమతి చేయండి diff --git a/library/ui-strings/src/main/res/values-tr/strings.xml b/library/ui-strings/src/main/res/values-tr/strings.xml index c097bfce6a..1f0e5be153 100644 --- a/library/ui-strings/src/main/res/values-tr/strings.xml +++ b/library/ui-strings/src/main/res/values-tr/strings.xml @@ -376,7 +376,7 @@ Tema Çözme hatası Görünür Ad - Oturum kimliği + Oturum kimliği Oturum anahtarı E2E Oda anahtarlarını dışa aktar Oda anahtarlarını dışa aktar diff --git a/library/ui-strings/src/main/res/values-uk/strings.xml b/library/ui-strings/src/main/res/values-uk/strings.xml index 1c809fff3e..8e390801f3 100644 --- a/library/ui-strings/src/main/res/values-uk/strings.xml +++ b/library/ui-strings/src/main/res/values-uk/strings.xml @@ -354,7 +354,7 @@ Зробити не основною адресою Помилка розшифрування Загальнодоступна назва - ID сеансу + ID сеансу Ключ сеансу Експортувати E2E ключі кімнати Експортувати ключі кімнати diff --git a/library/ui-strings/src/main/res/values-vi/strings.xml b/library/ui-strings/src/main/res/values-vi/strings.xml index 2803128843..c6dc97f782 100644 --- a/library/ui-strings/src/main/res/values-vi/strings.xml +++ b/library/ui-strings/src/main/res/values-vi/strings.xml @@ -594,7 +594,7 @@ Hủy tài khoản Xem lại ngay Chìa khóa phiên - Mã phiên + Mã phiên Tên công khai Lỗi giải mã Những chức năng này mang tính thí nghiệm có thể còn nhiều lỗi. Lưu ý khi dùng. diff --git a/library/ui-strings/src/main/res/values-zh-rCN/strings.xml b/library/ui-strings/src/main/res/values-zh-rCN/strings.xml index 4e1c8e61c8..e92aafc8c6 100644 --- a/library/ui-strings/src/main/res/values-zh-rCN/strings.xml +++ b/library/ui-strings/src/main/res/values-zh-rCN/strings.xml @@ -242,7 +242,7 @@ 你的密码已更新 解密错误 公开名称 - 会话 ID + 会话 ID 会话密钥 导入 已验证 @@ -2583,4 +2583,4 @@ 已验证的会话 未知的设备类型 邀请 - \ No newline at end of file + diff --git a/library/ui-strings/src/main/res/values-zh-rTW/strings.xml b/library/ui-strings/src/main/res/values-zh-rTW/strings.xml index 0f5208bcde..4f699b1c02 100644 --- a/library/ui-strings/src/main/res/values-zh-rTW/strings.xml +++ b/library/ui-strings/src/main/res/values-zh-rTW/strings.xml @@ -469,7 +469,7 @@ 主題 解密錯誤 公開名稱 - 工作階段 ID + 工作階段 ID 工作階段金鑰 匯出聊天室的端到端加密金鑰 匯出聊天室的加密金鑰 diff --git a/library/ui-strings/src/main/res/values/strings.xml b/library/ui-strings/src/main/res/values/strings.xml index c33185ba26..fbe35f57ce 100644 --- a/library/ui-strings/src/main/res/values/strings.xml +++ b/library/ui-strings/src/main/res/values/strings.xml @@ -1212,7 +1212,6 @@ Decryption error Public name - Session ID Session key Export E2E room keys @@ -3263,15 +3262,14 @@ Current Session Session + Device Last activity %1$s Session details Application, device, and activity information. - Session Session name Session ID Last activity - Device IP address diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt index 5635b936dd..1fb5be4d78 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/details/SessionDetailsController.kt @@ -87,7 +87,7 @@ class SessionDetailsController @Inject constructor( val sessionId = data.deviceId val sessionLastSeenTs = data.lastSeenTs - buildHeaderItem(R.string.device_manager_session_details_section_session_title) + buildHeaderItem(R.string.device_manager_session_title) sessionName?.let { val hasDivider = sessionId != null || sessionLastSeenTs != null @@ -111,7 +111,7 @@ class SessionDetailsController @Inject constructor( private fun buildSectionDevice(data: DeviceInfo, addExtraTopMargin: Boolean) { val lastSeenIp = data.lastSeenIp - buildHeaderItem(R.string.device_manager_session_details_section_device_title, addExtraTopMargin) + buildHeaderItem(R.string.device_manager_device_title, addExtraTopMargin) lastSeenIp?.let { val hasDivider = false diff --git a/vector/src/main/res/layout/dialog_device_verify.xml b/vector/src/main/res/layout/dialog_device_verify.xml index bbf346c8dc..475ffc69af 100644 --- a/vector/src/main/res/layout/dialog_device_verify.xml +++ b/vector/src/main/res/layout/dialog_device_verify.xml @@ -39,7 +39,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="6dp" - android:text="@string/encryption_information_device_id" + android:text="@string/device_manager_session_details_session_id" android:textStyle="bold" /> - \ No newline at end of file + diff --git a/vector/src/main/res/xml/vector_settings_security_privacy.xml b/vector/src/main/res/xml/vector_settings_security_privacy.xml index c246a40f71..1e8997e9c8 100644 --- a/vector/src/main/res/xml/vector_settings_security_privacy.xml +++ b/vector/src/main/res/xml/vector_settings_security_privacy.xml @@ -35,7 +35,7 @@ Date: Wed, 14 Sep 2022 09:37:42 -0400 Subject: [PATCH 28/51] Removes unneeded code in BottomSheetDialog.kt --- .../app/core/extensions/BottomSheetDialog.kt | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt index 3b5cab7a80..63264c2602 100644 --- a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt +++ b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt @@ -16,32 +16,11 @@ package im.vector.app.core.extensions -import android.os.Build -import android.util.DisplayMetrics import androidx.annotation.FloatRange -import androidx.annotation.RequiresApi import com.google.android.material.bottomsheet.BottomSheetDialog +import io.github.hyuwah.draggableviewlib.Utils.getScreenHeight fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - setPeekHeightPostApi30(percentage) - } else { - setPeekHeightPreApi30(percentage) - } -} - -@RequiresApi(Build.VERSION_CODES.R) -private fun BottomSheetDialog.setPeekHeightPostApi30(percentage: Float) { - window?.windowManager?.currentWindowMetrics?.let { windowMetrics -> - val height = windowMetrics.bounds.height() - behavior.setPeekHeight((height * percentage).toInt(), true) - } -} - -private fun BottomSheetDialog.setPeekHeightPreApi30(percentage: Float) { - val displayMetrics = DisplayMetrics() - @Suppress("DEPRECATION") - window?.windowManager?.defaultDisplay?.getMetrics(displayMetrics) - val height = displayMetrics.heightPixels - behavior.setPeekHeight((height * percentage).toInt(), true) + val screenHeight = getScreenHeight(context) + behavior.setPeekHeight((screenHeight * percentage).toInt(), true) } From f4b5cfc71fdb853ef9e4501f17fbd22d4075667a Mon Sep 17 00:00:00 2001 From: ericdecanini Date: Wed, 14 Sep 2022 09:46:00 -0400 Subject: [PATCH 29/51] Makes bottom sheets inherit VectorBaseBottomSheetDialogFragment --- .../app/core/extensions/BottomSheetDialog.kt | 26 ------------------- .../VectorBaseBottomSheetDialogFragment.kt | 9 +++++++ .../home/room/list/home/NewChatBottomSheet.kt | 22 +++++++--------- .../features/spaces/SpaceListBottomSheet.kt | 16 +++++------- 4 files changed, 26 insertions(+), 47 deletions(-) delete mode 100644 vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt diff --git a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt b/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt deleted file mode 100644 index 63264c2602..0000000000 --- a/vector/src/main/java/im/vector/app/core/extensions/BottomSheetDialog.kt +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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.core.extensions - -import androidx.annotation.FloatRange -import com.google.android.material.bottomsheet.BottomSheetDialog -import io.github.hyuwah.draggableviewlib.Utils.getScreenHeight - -fun BottomSheetDialog.setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { - val screenHeight = getScreenHeight(context) - behavior.setPeekHeight((screenHeight * percentage).toInt(), true) -} diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt index ddc281fdd1..ec6f3288f8 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseBottomSheetDialogFragment.kt @@ -25,6 +25,7 @@ import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import androidx.annotation.CallSuper +import androidx.annotation.FloatRange import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.lifecycleScope import androidx.viewbinding.ViewBinding @@ -39,6 +40,7 @@ import im.vector.app.core.extensions.toMvRxBundle import im.vector.app.core.utils.DimensionConverter import im.vector.app.features.analytics.AnalyticsTracker import im.vector.app.features.analytics.plan.MobileScreen +import io.github.hyuwah.draggableviewlib.Utils import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import reactivecircus.flowbinding.android.view.clicks @@ -165,6 +167,13 @@ abstract class VectorBaseBottomSheetDialogFragment : BottomShe forceExpandState() } + protected fun setPeekHeightAsScreenPercentage(@FloatRange(from = 0.0, to = 1.0) percentage: Float) { + context?.let { + val screenHeight = Utils.getScreenHeight(it) + bottomSheetBehavior?.setPeekHeight((screenHeight * percentage).toInt(), true) + } + } + protected fun forceExpandState() { if (showExpanded) { // Force the bottom sheet to be expanded diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt index 4db47e53b8..4f1b235b4b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/NewChatBottomSheet.kt @@ -21,44 +21,42 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.google.android.material.bottomsheet.BottomSheetDialog -import com.google.android.material.bottomsheet.BottomSheetDialogFragment import dagger.hilt.android.AndroidEntryPoint -import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.databinding.FragmentNewChatBottomSheetBinding import im.vector.app.features.navigation.Navigator import javax.inject.Inject @AndroidEntryPoint -class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() { +class NewChatBottomSheet @Inject constructor() : VectorBaseBottomSheetDialogFragment() { @Inject lateinit var navigator: Navigator - private lateinit var binding: FragmentNewChatBottomSheetBinding + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentNewChatBottomSheetBinding { + return FragmentNewChatBottomSheetBinding.inflate(inflater, container, false) + } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { initFABs() - return binding.root } private fun initFABs() { - binding.startChat.setOnClickListener { + views.startChat.debouncedClicks { navigator.openCreateDirectRoom(requireActivity()) } - binding.createRoom.setOnClickListener { + views.createRoom.debouncedClicks { navigator.openCreateRoom(requireActivity()) } - binding.exploreRooms.setOnClickListener { + views.exploreRooms.debouncedClicks { navigator.openRoomDirectory(requireContext()) } } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return super.onCreateDialog(savedInstanceState).apply { - (this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.5f) + setPeekHeightAsScreenPercentage(0.5f) } } diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt index c28d877f30..4787aed8ae 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListBottomSheet.kt @@ -21,28 +21,26 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import com.google.android.material.bottomsheet.BottomSheetDialog -import com.google.android.material.bottomsheet.BottomSheetDialogFragment import im.vector.app.R import im.vector.app.core.extensions.replaceChildFragment -import im.vector.app.core.extensions.setPeekHeightAsScreenPercentage +import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.databinding.FragmentSpacesBottomSheetBinding -class SpaceListBottomSheet : BottomSheetDialogFragment() { +class SpaceListBottomSheet : VectorBaseBottomSheetDialogFragment() { - private lateinit var binding: FragmentSpacesBottomSheetBinding + override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentSpacesBottomSheetBinding { + return FragmentSpacesBottomSheetBinding.inflate(inflater, container, false) + } - override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { - binding = FragmentSpacesBottomSheetBinding.inflate(inflater, container, false) + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { if (savedInstanceState == null) { replaceChildFragment(R.id.space_list, SpaceListFragment::class.java) } - return binding.root } override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return super.onCreateDialog(savedInstanceState).apply { - (this as BottomSheetDialog).setPeekHeightAsScreenPercentage(0.75f) + setPeekHeightAsScreenPercentage(0.75f) } } From 3b1599763c0b60d8152cc83bc186a059892c4b0e Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Wed, 14 Sep 2022 00:55:58 +0200 Subject: [PATCH 30/51] Start DM - Fix glitch by not showing the local rooms in the room list --- .../android/sdk/api/query/QueryStringValue.kt | 5 +++++ .../session/room/RoomSummaryQueryParams.kt | 8 ++++++++ .../room/model/localecho/RoomLocalEcho.kt | 2 +- .../query/QueryStringValueProcessor.kt | 1 + .../room/summary/RoomSummaryDataSource.kt | 1 + .../home/room/list/RoomListViewModel.kt | 20 ++++++------------- .../home/room/list/RoomListViewState.kt | 2 +- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt index d3f6ec2287..1d6e79c8f6 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/query/QueryStringValue.kt @@ -68,6 +68,11 @@ sealed interface QueryStringValue { */ data class Contains(override val string: String, override val case: Case = Case.SENSITIVE) : ContentQueryStringValue + /** + * The tested field must not contain the [string]. + */ + data class NotContains(override val string: String, override val case: Case = Case.SENSITIVE) : ContentQueryStringValue + /** * Case enum for [ContentQueryStringValue]. */ diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt index 60963ef25a..d651f06e23 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/RoomSummaryQueryParams.kt @@ -20,8 +20,10 @@ import org.matrix.android.sdk.api.query.QueryStringValue import org.matrix.android.sdk.api.query.RoomCategoryFilter import org.matrix.android.sdk.api.query.RoomTagQueryFilter import org.matrix.android.sdk.api.query.SpaceFilter +import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams.Builder import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.RoomType +import org.matrix.android.sdk.api.session.room.model.localecho.RoomLocalEcho import org.matrix.android.sdk.api.session.space.SpaceSummaryQueryParams /** @@ -52,6 +54,10 @@ fun spaceSummaryQueryParams(init: (RoomSummaryQueryParams.Builder.() -> Unit) = * [roomSummaryQueryParams] and [spaceSummaryQueryParams] can also be used to build an instance of this class. */ data class RoomSummaryQueryParams( + /** + * Query for the roomId. + */ + val roomId: QueryStringValue, /** * Query for the displayName of the room. The display name can be the value of the state event, * or a value returned by [org.matrix.android.sdk.api.RoomDisplayNameFallbackProvider]. @@ -94,6 +100,7 @@ data class RoomSummaryQueryParams( * [roomSummaryQueryParams] and [spaceSummaryQueryParams] can also be used to build an instance of [RoomSummaryQueryParams]. */ class Builder { + var roomId: QueryStringValue = QueryStringValue.NotContains(RoomLocalEcho.PREFIX) var displayName: QueryStringValue = QueryStringValue.NoCondition var canonicalAlias: QueryStringValue = QueryStringValue.NoCondition var memberships: List = Membership.all() @@ -104,6 +111,7 @@ data class RoomSummaryQueryParams( var spaceFilter: SpaceFilter = SpaceFilter.NoFilter fun build() = RoomSummaryQueryParams( + roomId = roomId, displayName = displayName, canonicalAlias = canonicalAlias, memberships = memberships, diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/localecho/RoomLocalEcho.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/localecho/RoomLocalEcho.kt index 7ef0d63924..ec0e642ad3 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/localecho/RoomLocalEcho.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/model/localecho/RoomLocalEcho.kt @@ -20,7 +20,7 @@ import java.util.UUID object RoomLocalEcho { - private const val PREFIX = "!local." + const val PREFIX = "!local." /** * Tell whether the provider room id is a local id. diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt index b2ab9879df..a93ff42c9e 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/query/QueryStringValueProcessor.kt @@ -38,6 +38,7 @@ internal class QueryStringValueProcessor @Inject constructor( is ContentQueryStringValue -> when (queryStringValue) { is QueryStringValue.Equals -> equalTo(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase()) is QueryStringValue.Contains -> contains(field, queryStringValue.toRealmValue(), queryStringValue.case.toRealmCase()) + is QueryStringValue.NotContains -> not().process(field, QueryStringValue.Contains(queryStringValue.string, queryStringValue.case)) } } } diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt index 82fc94df7c..afc1d5012f 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/room/summary/RoomSummaryDataSource.kt @@ -272,6 +272,7 @@ internal class RoomSummaryDataSource @Inject constructor( val query = with(queryStringValueProcessor) { RoomSummaryEntity.where(realm) .process(RoomSummaryEntityFields.ROOM_ID, QueryStringValue.IsNotEmpty) + .process(RoomSummaryEntityFields.ROOM_ID, queryParams.roomId) .process(queryParams.displayName.toDisplayNameField(), queryParams.displayName) .process(RoomSummaryEntityFields.CANONICAL_ALIAS, queryParams.canonicalAlias) .process(RoomSummaryEntityFields.MEMBERSHIP_STR, queryParams.memberships) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index ca64a0f991..9332acc0c9 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -47,7 +47,6 @@ import org.matrix.android.sdk.api.session.getRoom import org.matrix.android.sdk.api.session.getRoomSummary import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState -import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.localecho.RoomLocalEcho import org.matrix.android.sdk.api.session.room.model.tag.RoomTag import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams @@ -127,20 +126,13 @@ class RoomListViewModel @AssistedInject constructor( } private fun observeLocalRooms() { - val queryParams = roomSummaryQueryParams { - memberships = listOf(Membership.JOIN) - } session .flow() - .liveRoomSummaries(queryParams) - .map { roomSummaries -> - roomSummaries.mapNotNull { summary -> - summary.roomId.takeIf { RoomLocalEcho.isLocalEchoId(it) } - }.toSet() - } - .setOnEach { roomIds -> - copy(localRoomIds = roomIds) - } + .liveRoomSummaries(roomSummaryQueryParams { + roomId = QueryStringValue.Contains(RoomLocalEcho.PREFIX) + }) + .map { page -> page.map { it.roomId } } + .setOnEach { copy(localRoomIds = it) } } companion object : MavericksViewModelFactory by hiltMavericksViewModelFactory() @@ -181,7 +173,7 @@ class RoomListViewModel @AssistedInject constructor( return session.getRoom(roomId)?.stateService()?.isPublic().orFalse() } - fun deleteLocalRooms(roomsIds: Set) { + fun deleteLocalRooms(roomsIds: List) { viewModelScope.launch { roomsIds.forEach { session.roomService().deleteLocalRoom(it) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt index 3f46293346..5f62cba948 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewState.kt @@ -31,7 +31,7 @@ data class RoomListViewState( val asyncSuggestedRooms: Async> = Uninitialized, val currentUserName: String? = null, val asyncSelectedSpace: Async = Uninitialized, - val localRoomIds: Set = emptySet() + val localRoomIds: List = emptyList() ) : MavericksState { constructor(args: RoomListParams) : this(displayMode = args.displayMode) From e792228879b9cc00516f6dca91e33c896939b00b Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Wed, 14 Sep 2022 16:39:28 +0200 Subject: [PATCH 31/51] Changelog --- changelog.d/7121.wip | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7121.wip diff --git a/changelog.d/7121.wip b/changelog.d/7121.wip new file mode 100644 index 0000000000..2081b0d77a --- /dev/null +++ b/changelog.d/7121.wip @@ -0,0 +1 @@ +Create DM room only on first message - Fix glitch in the room list From 7631c7ac9f5387c8b7936f66036773382f439ded Mon Sep 17 00:00:00 2001 From: Nikita Fedrunov <66663241+fedrunov@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:54:40 +0200 Subject: [PATCH 32/51] room leaving prompt dialog now waits user to confirm leaving before do so (#7124) --- changelog.d/7122.bugfix | 1 + .../app/features/home/room/list/home/HomeRoomListFragment.kt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 changelog.d/7122.bugfix diff --git a/changelog.d/7122.bugfix b/changelog.d/7122.bugfix new file mode 100644 index 0000000000..f088eed4b0 --- /dev/null +++ b/changelog.d/7122.bugfix @@ -0,0 +1 @@ +[App Layout] Room leaving prompt dialog now waits user to confirm leaving before do so diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt index a4738a550c..4ae2c7d514 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/HomeRoomListFragment.kt @@ -123,7 +123,6 @@ class HomeRoomListFragment : roomListViewModel.handle(HomeRoomListAction.ToggleTag(quickAction.roomId, RoomTag.ROOM_TAG_LOW_PRIORITY)) } is RoomListQuickActionsSharedAction.Leave -> { - roomListViewModel.handle(HomeRoomListAction.LeaveRoom(quickAction.roomId)) promptLeaveRoom(quickAction.roomId) } } From 1d3c191153d72d48a4a304b42a1fe1911b95170b Mon Sep 17 00:00:00 2001 From: Nikita Fedrunov <66663241+fedrunov@users.noreply.github.com> Date: Wed, 14 Sep 2022 22:55:01 +0200 Subject: [PATCH 33/51] scroll recents carouse to start when item added/moved to start (#7120) --- changelog.d/6776.bugfix | 1 + .../home/header/HomeRoomsHeadersController.kt | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 changelog.d/6776.bugfix diff --git a/changelog.d/6776.bugfix b/changelog.d/6776.bugfix new file mode 100644 index 0000000000..ceb1d52ebf --- /dev/null +++ b/changelog.d/6776.bugfix @@ -0,0 +1 @@ +[App Layout] Recents carousel now scrolled to first position when new item added to or moved to this position diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/home/header/HomeRoomsHeadersController.kt b/vector/src/main/java/im/vector/app/features/home/room/list/home/header/HomeRoomsHeadersController.kt index 8be9bf12f9..f7c9eccd0b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/home/header/HomeRoomsHeadersController.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/home/header/HomeRoomsHeadersController.kt @@ -18,6 +18,7 @@ package im.vector.app.features.home.room.list.home.header import android.content.res.Resources import android.util.TypedValue +import androidx.recyclerview.widget.RecyclerView import com.airbnb.epoxy.Carousel import com.airbnb.epoxy.CarouselModelBuilder import com.airbnb.epoxy.EpoxyController @@ -44,6 +45,25 @@ class HomeRoomsHeadersController @Inject constructor( var recentsRoomListener: RoomListListener? = null var invitesClickListener: (() -> Unit)? = null + private var carousel: Carousel? = null + + private val carouselAdapterObserver = object : RecyclerView.AdapterDataObserver() { + override fun onItemRangeMoved(fromPosition: Int, toPosition: Int, itemCount: Int) { + if (toPosition == 0 || fromPosition == 0) { + carousel?.post { + carousel?.layoutManager?.scrollToPosition(0) + } + } + super.onItemRangeMoved(fromPosition, toPosition, itemCount) + } + + override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { + if (positionStart == 0) { + carousel?.layoutManager?.scrollToPosition(0) + } + } + } + private val recentsHPadding = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, 4f, @@ -92,9 +112,28 @@ class HomeRoomsHeadersController @Inject constructor( ) ) onBind { _, view, _ -> + host.carousel = view + val colorSurface = MaterialColors.getColor(view, R.attr.vctr_toolbar_background) view.setBackgroundColor(colorSurface) + + try { + view.adapter?.registerAdapterDataObserver(host.carouselAdapterObserver) + } catch (e: IllegalStateException) { + // do nothing + } } + + onUnbind { _, view -> + host.carousel = null + + try { + view.adapter?.unregisterAdapterDataObserver(host.carouselAdapterObserver) + } catch (e: IllegalStateException) { + // do nothing + } + } + withModelsFrom(recents) { roomSummary -> val onClick = host.recentsRoomListener?.let { it::onRoomClicked } val onLongClick = host.recentsRoomListener?.let { it::onRoomLongClicked } From 6c9ae331e324edc20dd6d9bcf7c64db20b41c46c Mon Sep 17 00:00:00 2001 From: Florian Renaud Date: Thu, 15 Sep 2022 15:16:51 +0200 Subject: [PATCH 34/51] transform list to iterable --- .../im/vector/app/features/home/room/list/RoomListViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index 9332acc0c9..8283447a4d 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -173,7 +173,7 @@ class RoomListViewModel @AssistedInject constructor( return session.getRoom(roomId)?.stateService()?.isPublic().orFalse() } - fun deleteLocalRooms(roomsIds: List) { + fun deleteLocalRooms(roomsIds: Iterable) { viewModelScope.launch { roomsIds.forEach { session.roomService().deleteLocalRoom(it) From e53972cf2d9b2e74401c395073bca25f0f3c2528 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 15 Sep 2022 14:42:56 +0100 Subject: [PATCH 35/51] adding changelog entry --- changelog.d/7142.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/7142.misc diff --git a/changelog.d/7142.misc b/changelog.d/7142.misc new file mode 100644 index 0000000000..d3424185e4 --- /dev/null +++ b/changelog.d/7142.misc @@ -0,0 +1 @@ +Pulling no longer hosted im.dlg:android-dialer directly into the repository and removing legacy support library usages From b72a174edf29e636908076dad459a6c024fa74c0 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 14:33:02 +0100 Subject: [PATCH 36/51] lifting nightly to the application module --- vector-app/build.gradle | 4 ++++ {vector => vector-app}/src/nightly/res/xml/shortcuts.xml | 0 vector/build.gradle | 8 -------- 3 files changed, 4 insertions(+), 8 deletions(-) rename {vector => vector-app}/src/nightly/res/xml/shortcuts.xml (100%) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 235c92cfc5..5f039dfbd5 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -340,6 +340,10 @@ android { "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", ] } + + buildFeatures { + viewBinding true + } } dependencies { diff --git a/vector/src/nightly/res/xml/shortcuts.xml b/vector-app/src/nightly/res/xml/shortcuts.xml similarity index 100% rename from vector/src/nightly/res/xml/shortcuts.xml rename to vector-app/src/nightly/res/xml/shortcuts.xml diff --git a/vector/build.gradle b/vector/build.gradle index a5538053fc..0e9e03f31a 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -66,10 +66,6 @@ android { testCoverageEnabled = coverage.enableTestCoverage } } - nightly { - initWith release - matchingFallbacks = ['release'] - } release } @@ -111,10 +107,6 @@ android { test { java.srcDirs += "src/sharedTest/java" } - // Add sourceSets for `release` version when building `nightly` - nightly { - java.srcDirs += "src/release/java" - } } buildFeatures { From a947a53e14292ca59cdad2730e1645da2f4ff1dd Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 14:42:16 +0100 Subject: [PATCH 37/51] lifting the release build type to the application module --- .../src/release/java/im/vector/app/core/di/DebugModule.kt | 0 .../src/release/java/im/vector/app/core/di/FeaturesModule.kt | 0 .../src/release/java/im/vector/app/receivers/DebugReceiver.kt | 0 {vector => vector-app}/src/release/res/xml/shortcuts.xml | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename {vector => vector-app}/src/release/java/im/vector/app/core/di/DebugModule.kt (100%) rename {vector => vector-app}/src/release/java/im/vector/app/core/di/FeaturesModule.kt (100%) rename {vector => vector-app}/src/release/java/im/vector/app/receivers/DebugReceiver.kt (100%) rename {vector => vector-app}/src/release/res/xml/shortcuts.xml (100%) diff --git a/vector/src/release/java/im/vector/app/core/di/DebugModule.kt b/vector-app/src/release/java/im/vector/app/core/di/DebugModule.kt similarity index 100% rename from vector/src/release/java/im/vector/app/core/di/DebugModule.kt rename to vector-app/src/release/java/im/vector/app/core/di/DebugModule.kt diff --git a/vector/src/release/java/im/vector/app/core/di/FeaturesModule.kt b/vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt similarity index 100% rename from vector/src/release/java/im/vector/app/core/di/FeaturesModule.kt rename to vector-app/src/release/java/im/vector/app/core/di/FeaturesModule.kt diff --git a/vector/src/release/java/im/vector/app/receivers/DebugReceiver.kt b/vector-app/src/release/java/im/vector/app/receivers/DebugReceiver.kt similarity index 100% rename from vector/src/release/java/im/vector/app/receivers/DebugReceiver.kt rename to vector-app/src/release/java/im/vector/app/receivers/DebugReceiver.kt diff --git a/vector/src/release/res/xml/shortcuts.xml b/vector-app/src/release/res/xml/shortcuts.xml similarity index 100% rename from vector/src/release/res/xml/shortcuts.xml rename to vector-app/src/release/res/xml/shortcuts.xml From 5d533d4ec9f0d445e07c2aaa3642f0e796b0b150 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 14:45:40 +0100 Subject: [PATCH 38/51] lifting debug build type to the application module --- vector-app/build.gradle | 11 +++++++++++ .../src/debug/AndroidManifest.xml | 0 .../app/features/debug/DebugMenuActivity.kt | 0 .../features/debug/DebugPermissionActivity.kt | 0 .../app/features/debug/TestLinkifyActivity.kt | 0 .../debug/analytics/DebugAnalyticsActivity.kt | 0 .../debug/analytics/DebugAnalyticsFragment.kt | 0 .../debug/analytics/DebugAnalyticsViewActions.kt | 0 .../debug/analytics/DebugAnalyticsViewModel.kt | 0 .../debug/analytics/DebugAnalyticsViewState.kt | 0 .../vector/app/features/debug/di/DebugModule.kt | 0 .../app/features/debug/di/FeaturesModule.kt | 0 .../debug/di/MavericksViewModelDebugModule.kt | 0 .../debug/features/BooleanFeatureItem.kt | 0 .../features/DebugFeaturesSettingsActivity.kt | 0 .../debug/features/DebugFeaturesStateFactory.kt | 0 .../debug/features/DebugVectorFeatures.kt | 0 .../debug/features/DebugVectorOverrides.kt | 0 .../features/debug/features/EnumFeatureItem.kt | 0 .../debug/features/FeaturesController.kt | 0 .../debug/leak/DebugMemoryLeaksActivity.kt | 0 .../debug/leak/DebugMemoryLeaksFragment.kt | 1 + .../debug/leak/DebugMemoryLeaksViewActions.kt | 0 .../debug/leak/DebugMemoryLeaksViewModel.kt | 2 +- .../debug/leak/DebugMemoryLeaksViewState.kt | 0 .../features/debug/sas/DebugSasEmojiActivity.kt | 0 .../app/features/debug/sas/SasEmojiController.kt | 0 .../app/features/debug/sas/SasEmojiItem.kt | 0 .../settings/DebugPrivateSettingsActivity.kt | 0 .../settings/DebugPrivateSettingsFragment.kt | 0 .../settings/DebugPrivateSettingsViewActions.kt | 0 .../settings/DebugPrivateSettingsViewModel.kt | 0 .../settings/DebugPrivateSettingsViewState.kt | 0 .../debug/settings/OverrideDropdownView.kt | 0 .../debug/settings/PrivateSettingOverrides.kt | 0 .../im/vector/app/flipper/VectorFlipperProxy.kt | 0 .../app/leakcanary/LeakCanaryLeakDetector.kt | 0 .../vector/app/receivers/VectorDebugReceiver.kt | 0 .../src/debug/res/layout/activity_debug_menu.xml | 0 .../res/layout/activity_debug_permission.xml | 0 .../debug/res/layout/activity_test_linkify.xml | 0 .../src/debug/res/layout/demo_theme_sample.xml | 0 .../src/debug/res/layout/demo_themes.xml | 0 .../res/layout/fragment_debug_analytics.xml | 0 .../res/layout/fragment_debug_memory_leaks.xml | 0 .../layout/fragment_debug_private_settings.xml | 0 .../src/debug/res/layout/item_feature.xml | 0 .../src/debug/res/layout/item_sas_emoji.xml | 0 .../src/debug/res/layout/item_test_linkify.xml | 0 .../debug/res/layout/view_boolean_dropdown.xml | 0 .../src/debug/res/values/strings.xml | 0 .../src/debug/res/xml/shortcuts.xml | 0 vector/build.gradle | 16 +--------------- 53 files changed, 14 insertions(+), 16 deletions(-) rename {vector => vector-app}/src/debug/AndroidManifest.xml (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/TestLinkifyActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsFragment.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewActions.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewModel.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewState.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/di/DebugModule.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/features/FeaturesController.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt (96%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewActions.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt (98%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewState.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/sas/DebugSasEmojiActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/sas/SasEmojiController.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/flipper/VectorFlipperProxy.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/leakcanary/LeakCanaryLeakDetector.kt (100%) rename {vector => vector-app}/src/debug/java/im/vector/app/receivers/VectorDebugReceiver.kt (100%) rename {vector => vector-app}/src/debug/res/layout/activity_debug_menu.xml (100%) rename {vector => vector-app}/src/debug/res/layout/activity_debug_permission.xml (100%) rename {vector => vector-app}/src/debug/res/layout/activity_test_linkify.xml (100%) rename {vector => vector-app}/src/debug/res/layout/demo_theme_sample.xml (100%) rename {vector => vector-app}/src/debug/res/layout/demo_themes.xml (100%) rename {vector => vector-app}/src/debug/res/layout/fragment_debug_analytics.xml (100%) rename {vector => vector-app}/src/debug/res/layout/fragment_debug_memory_leaks.xml (100%) rename {vector => vector-app}/src/debug/res/layout/fragment_debug_private_settings.xml (100%) rename {vector => vector-app}/src/debug/res/layout/item_feature.xml (100%) rename {vector => vector-app}/src/debug/res/layout/item_sas_emoji.xml (100%) rename {vector => vector-app}/src/debug/res/layout/item_test_linkify.xml (100%) rename {vector => vector-app}/src/debug/res/layout/view_boolean_dropdown.xml (100%) rename {vector => vector-app}/src/debug/res/values/strings.xml (100%) rename {vector => vector-app}/src/debug/res/xml/shortcuts.xml (100%) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 5f039dfbd5..783f8e0a4a 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -353,6 +353,16 @@ dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation "androidx.sharetarget:sharetarget:1.1.0" + // Flipper, debug builds only + debugImplementation(libs.flipper.flipper) { + exclude group: 'com.facebook.fbjni', module: 'fbjni' + } + debugImplementation(libs.flipper.flipperNetworkPlugin) { + exclude group: 'com.facebook.fbjni', module: 'fbjni' + } + debugImplementation 'com.facebook.soloader:soloader:0.10.4' + debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0" + kapt libs.dagger.hiltCompiler androidTestImplementation libs.androidx.testCore @@ -378,5 +388,6 @@ dependencies { androidTestImplementation libs.androidx.fragmentTesting androidTestImplementation "org.jetbrains.kotlin:kotlin-reflect:1.7.10" debugImplementation libs.androidx.fragmentTesting + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' } diff --git a/vector/src/debug/AndroidManifest.xml b/vector-app/src/debug/AndroidManifest.xml similarity index 100% rename from vector/src/debug/AndroidManifest.xml rename to vector-app/src/debug/AndroidManifest.xml diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/DebugMenuActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/DebugPermissionActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/TestLinkifyActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/TestLinkifyActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/TestLinkifyActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/TestLinkifyActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsFragment.kt b/vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsFragment.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsFragment.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsFragment.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewActions.kt b/vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewActions.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewActions.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewActions.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewModel.kt b/vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewModel.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewModel.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewModel.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewState.kt b/vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewState.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewState.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/analytics/DebugAnalyticsViewState.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/di/DebugModule.kt b/vector-app/src/debug/java/im/vector/app/features/debug/di/DebugModule.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/di/DebugModule.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/di/DebugModule.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt b/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt b/vector-app/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/di/MavericksViewModelDebugModule.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesSettingsActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/FeaturesController.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/FeaturesController.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/features/FeaturesController.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/features/FeaturesController.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt similarity index 96% rename from vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt index 2abf6487e2..d62dc5dc4d 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt @@ -26,6 +26,7 @@ import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.epoxy.onClick import im.vector.app.core.platform.VectorBaseFragment import im.vector.app.databinding.FragmentDebugMemoryLeaksBinding +import im.vector.application.databinding.FragmentDebugMemoryLeaksBinding @AndroidEntryPoint class DebugMemoryLeaksFragment : diff --git a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewActions.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewActions.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewActions.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewActions.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt similarity index 98% rename from vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt index 5432cb0888..26eb1c1025 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewModel.kt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 New Vector Ltd + * 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. diff --git a/vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewState.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewState.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewState.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksViewState.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/sas/DebugSasEmojiActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/sas/DebugSasEmojiActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/sas/DebugSasEmojiActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/sas/DebugSasEmojiActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiController.kt b/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiController.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiController.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiController.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsActivity.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewActions.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewModel.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsViewState.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt diff --git a/vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt rename to vector-app/src/debug/java/im/vector/app/features/debug/settings/PrivateSettingOverrides.kt diff --git a/vector/src/debug/java/im/vector/app/flipper/VectorFlipperProxy.kt b/vector-app/src/debug/java/im/vector/app/flipper/VectorFlipperProxy.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/flipper/VectorFlipperProxy.kt rename to vector-app/src/debug/java/im/vector/app/flipper/VectorFlipperProxy.kt diff --git a/vector/src/debug/java/im/vector/app/leakcanary/LeakCanaryLeakDetector.kt b/vector-app/src/debug/java/im/vector/app/leakcanary/LeakCanaryLeakDetector.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/leakcanary/LeakCanaryLeakDetector.kt rename to vector-app/src/debug/java/im/vector/app/leakcanary/LeakCanaryLeakDetector.kt diff --git a/vector/src/debug/java/im/vector/app/receivers/VectorDebugReceiver.kt b/vector-app/src/debug/java/im/vector/app/receivers/VectorDebugReceiver.kt similarity index 100% rename from vector/src/debug/java/im/vector/app/receivers/VectorDebugReceiver.kt rename to vector-app/src/debug/java/im/vector/app/receivers/VectorDebugReceiver.kt diff --git a/vector/src/debug/res/layout/activity_debug_menu.xml b/vector-app/src/debug/res/layout/activity_debug_menu.xml similarity index 100% rename from vector/src/debug/res/layout/activity_debug_menu.xml rename to vector-app/src/debug/res/layout/activity_debug_menu.xml diff --git a/vector/src/debug/res/layout/activity_debug_permission.xml b/vector-app/src/debug/res/layout/activity_debug_permission.xml similarity index 100% rename from vector/src/debug/res/layout/activity_debug_permission.xml rename to vector-app/src/debug/res/layout/activity_debug_permission.xml diff --git a/vector/src/debug/res/layout/activity_test_linkify.xml b/vector-app/src/debug/res/layout/activity_test_linkify.xml similarity index 100% rename from vector/src/debug/res/layout/activity_test_linkify.xml rename to vector-app/src/debug/res/layout/activity_test_linkify.xml diff --git a/vector/src/debug/res/layout/demo_theme_sample.xml b/vector-app/src/debug/res/layout/demo_theme_sample.xml similarity index 100% rename from vector/src/debug/res/layout/demo_theme_sample.xml rename to vector-app/src/debug/res/layout/demo_theme_sample.xml diff --git a/vector/src/debug/res/layout/demo_themes.xml b/vector-app/src/debug/res/layout/demo_themes.xml similarity index 100% rename from vector/src/debug/res/layout/demo_themes.xml rename to vector-app/src/debug/res/layout/demo_themes.xml diff --git a/vector/src/debug/res/layout/fragment_debug_analytics.xml b/vector-app/src/debug/res/layout/fragment_debug_analytics.xml similarity index 100% rename from vector/src/debug/res/layout/fragment_debug_analytics.xml rename to vector-app/src/debug/res/layout/fragment_debug_analytics.xml diff --git a/vector/src/debug/res/layout/fragment_debug_memory_leaks.xml b/vector-app/src/debug/res/layout/fragment_debug_memory_leaks.xml similarity index 100% rename from vector/src/debug/res/layout/fragment_debug_memory_leaks.xml rename to vector-app/src/debug/res/layout/fragment_debug_memory_leaks.xml diff --git a/vector/src/debug/res/layout/fragment_debug_private_settings.xml b/vector-app/src/debug/res/layout/fragment_debug_private_settings.xml similarity index 100% rename from vector/src/debug/res/layout/fragment_debug_private_settings.xml rename to vector-app/src/debug/res/layout/fragment_debug_private_settings.xml diff --git a/vector/src/debug/res/layout/item_feature.xml b/vector-app/src/debug/res/layout/item_feature.xml similarity index 100% rename from vector/src/debug/res/layout/item_feature.xml rename to vector-app/src/debug/res/layout/item_feature.xml diff --git a/vector/src/debug/res/layout/item_sas_emoji.xml b/vector-app/src/debug/res/layout/item_sas_emoji.xml similarity index 100% rename from vector/src/debug/res/layout/item_sas_emoji.xml rename to vector-app/src/debug/res/layout/item_sas_emoji.xml diff --git a/vector/src/debug/res/layout/item_test_linkify.xml b/vector-app/src/debug/res/layout/item_test_linkify.xml similarity index 100% rename from vector/src/debug/res/layout/item_test_linkify.xml rename to vector-app/src/debug/res/layout/item_test_linkify.xml diff --git a/vector/src/debug/res/layout/view_boolean_dropdown.xml b/vector-app/src/debug/res/layout/view_boolean_dropdown.xml similarity index 100% rename from vector/src/debug/res/layout/view_boolean_dropdown.xml rename to vector-app/src/debug/res/layout/view_boolean_dropdown.xml diff --git a/vector/src/debug/res/values/strings.xml b/vector-app/src/debug/res/values/strings.xml similarity index 100% rename from vector/src/debug/res/values/strings.xml rename to vector-app/src/debug/res/values/strings.xml diff --git a/vector/src/debug/res/xml/shortcuts.xml b/vector-app/src/debug/res/xml/shortcuts.xml similarity index 100% rename from vector/src/debug/res/xml/shortcuts.xml rename to vector-app/src/debug/res/xml/shortcuts.xml diff --git a/vector/build.gradle b/vector/build.gradle index 0e9e03f31a..b84f9f96d1 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -66,7 +66,6 @@ android { testCoverageEnabled = coverage.enableTestCoverage } } - release } flavorDimensions "store" @@ -311,20 +310,7 @@ dependencies { testImplementation(libs.jetbrains.coroutinesTest) { exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug" } - - // Flipper, debug builds only - debugImplementation(libs.flipper.flipper) { - exclude group: 'com.facebook.fbjni', module: 'fbjni' - } - debugImplementation(libs.flipper.flipperNetworkPlugin) { - exclude group: 'com.facebook.fbjni', module: 'fbjni' - } - debugImplementation 'com.facebook.soloader:soloader:0.10.4' - debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0" - - // Activate when you want to check for leaks, from time to time. - debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' - + androidTestImplementation libs.androidx.testCore androidTestImplementation libs.androidx.testRunner androidTestImplementation libs.androidx.testRules From 373a0ca4fb8358e1c3dc29a84070795fe5376bf8 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 14:55:53 +0100 Subject: [PATCH 39/51] split commit to make debug changes to avoid files being seen as new! --- vector-app/build.gradle | 2 ++ vector-app/src/debug/AndroidManifest.xml | 19 +++++++++---------- .../app/features/debug/DebugMenuActivity.kt | 2 +- .../features/debug/DebugPermissionActivity.kt | 4 ++-- .../app/features/debug/TestLinkifyActivity.kt | 6 +++--- .../debug/analytics/DebugAnalyticsFragment.kt | 2 +- .../debug/features/BooleanFeatureItem.kt | 6 +++--- .../debug/features/DebugVectorOverrides.kt | 8 ++++---- .../debug/features/EnumFeatureItem.kt | 6 +++--- .../debug/leak/DebugMemoryLeaksFragment.kt | 1 - .../app/features/debug/sas/SasEmojiItem.kt | 2 +- .../settings/DebugPrivateSettingsFragment.kt | 2 +- .../debug/settings/OverrideDropdownView.kt | 2 +- vector/build.gradle | 2 +- 14 files changed, 32 insertions(+), 32 deletions(-) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 783f8e0a4a..ea321c9e83 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -349,6 +349,7 @@ android { dependencies { implementation project(':vector') implementation project(':vector-config') + debugImplementation project(':library:ui-styles') implementation libs.dagger.hilt implementation 'androidx.multidex:multidex:2.0.1' implementation "androidx.sharetarget:sharetarget:1.1.0" @@ -364,6 +365,7 @@ dependencies { debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0" kapt libs.dagger.hiltCompiler + kapt libs.airbnb.epoxyProcessor androidTestImplementation libs.androidx.testCore androidTestImplementation libs.androidx.testRunner diff --git a/vector-app/src/debug/AndroidManifest.xml b/vector-app/src/debug/AndroidManifest.xml index 94fdb1b389..3860a37319 100644 --- a/vector-app/src/debug/AndroidManifest.xml +++ b/vector-app/src/debug/AndroidManifest.xml @@ -1,16 +1,15 @@ - + - - - - - - - - + + + + + + + + () { diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt index 1e9b88c048..38765bfa9b 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/BooleanFeatureItem.kt @@ -23,9 +23,9 @@ import android.widget.Spinner import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass -import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.application.R @EpoxyModelClass abstract class BooleanFeatureItem : VectorEpoxyModel(R.layout.item_feature) { @@ -70,8 +70,8 @@ abstract class BooleanFeatureItem : VectorEpoxyModel( } class Holder : VectorEpoxyHolder() { - val label by bind(im.vector.app.R.id.feature_label) - val optionsSpinner by bind(im.vector.app.R.id.feature_options) + val label by bind(R.id.feature_label) + val optionsSpinner by bind(R.id.feature_options) } interface Listener { diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt index 5e16182f3c..57138b9a47 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorOverrides.kt @@ -66,13 +66,13 @@ class DebugVectorOverrides(private val context: Context) : VectorOverrides { suspend fun setHomeserverCapabilities(block: HomeserverCapabilitiesOverride.() -> HomeserverCapabilitiesOverride) { val capabilitiesOverride = block(forceHomeserverCapabilities.firstOrNull() ?: HomeserverCapabilitiesOverride(null, null)) context.dataStore.edit { settings -> - when (capabilitiesOverride.canChangeDisplayName) { + when (val canChangeDisplayName = capabilitiesOverride.canChangeDisplayName) { null -> settings.remove(forceCanChangeDisplayName) - else -> settings[forceCanChangeDisplayName] = capabilitiesOverride.canChangeDisplayName + else -> settings[forceCanChangeDisplayName] = canChangeDisplayName } - when (capabilitiesOverride.canChangeAvatar) { + when (val canChangeAvatar = capabilitiesOverride.canChangeAvatar) { null -> settings.remove(forceCanChangeAvatar) - else -> settings[forceCanChangeAvatar] = capabilitiesOverride.canChangeAvatar + else -> settings[forceCanChangeAvatar] = canChangeAvatar } } } diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt index 5231e591da..00f74515cc 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/EnumFeatureItem.kt @@ -23,9 +23,9 @@ import android.widget.Spinner import android.widget.TextView import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass -import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.application.R @EpoxyModelClass abstract class EnumFeatureItem : VectorEpoxyModel(R.layout.item_feature) { @@ -70,8 +70,8 @@ abstract class EnumFeatureItem : VectorEpoxyModel(R.layo } class Holder : VectorEpoxyHolder() { - val label by bind(im.vector.app.R.id.feature_label) - val optionsSpinner by bind(im.vector.app.R.id.feature_options) + val label by bind(R.id.feature_label) + val optionsSpinner by bind(R.id.feature_options) } interface Listener { diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt index d62dc5dc4d..e9afa9aea9 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/leak/DebugMemoryLeaksFragment.kt @@ -25,7 +25,6 @@ import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint import im.vector.app.core.epoxy.onClick import im.vector.app.core.platform.VectorBaseFragment -import im.vector.app.databinding.FragmentDebugMemoryLeaksBinding import im.vector.application.databinding.FragmentDebugMemoryLeaksBinding @AndroidEntryPoint diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt b/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt index 179ee35693..bbc438e4b2 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/sas/SasEmojiItem.kt @@ -21,9 +21,9 @@ import android.widget.TextView import androidx.core.content.ContextCompat import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass -import im.vector.app.R import im.vector.app.core.epoxy.VectorEpoxyHolder import im.vector.app.core.epoxy.VectorEpoxyModel +import im.vector.application.R import me.gujun.android.span.image import me.gujun.android.span.span import org.matrix.android.sdk.api.session.crypto.verification.EmojiRepresentation diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt index be3d41e0e1..020c228521 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/settings/DebugPrivateSettingsFragment.kt @@ -25,8 +25,8 @@ import android.view.ViewGroup 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 +import im.vector.application.databinding.FragmentDebugPrivateSettingsBinding class DebugPrivateSettingsFragment : VectorBaseFragment() { diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt b/vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt index 7f510ee5e9..2800b7bd8d 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/settings/OverrideDropdownView.kt @@ -24,7 +24,7 @@ import android.view.View import android.widget.AdapterView import android.widget.ArrayAdapter import android.widget.LinearLayout -import im.vector.app.databinding.ViewBooleanDropdownBinding +import im.vector.application.databinding.ViewBooleanDropdownBinding class OverrideDropdownView @JvmOverloads constructor( context: Context, diff --git a/vector/build.gradle b/vector/build.gradle index b84f9f96d1..3b802c8316 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -195,7 +195,7 @@ dependencies { // UI implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' implementation libs.google.material - implementation 'me.gujun.android:span:1.7' + api 'me.gujun.android:span:1.7' implementation libs.markwon.core implementation libs.markwon.extLatex implementation libs.markwon.inlineParser From 3a38898961f9e3b3499d47bb3c97322a2d725729 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 15:00:46 +0100 Subject: [PATCH 40/51] lifting fdroid and gplay variants to the application module --- vector-app/build.gradle | 16 +++++++++ .../src/fdroid/AndroidManifest.xml | 0 .../java/im/vector/app/di/FlavorModule.kt | 0 .../vector/app/di/NotificationTestModule.kt | 0 .../app/fdroid/BackgroundSyncStarter.kt | 0 .../troubleshoot/TestAutoStartBoot.kt | 0 .../TestBackgroundRestrictions.kt | 0 .../troubleshoot/TestBatteryOptimization.kt | 0 .../java/im/vector/app/fdroid/package-info.kt | 0 .../receiver/AlarmSyncBroadcastReceiver.kt | 0 .../OnApplicationUpgradeOrRebootReceiver.kt | 0 .../service/FDroidGuardServiceStarter.kt | 0 .../app/fdroid/service/GuardAndroidService.kt | 0 .../im/vector/app/push/fcm/FdroidFcmHelper.kt | 0 ...ificationTroubleshootTestManagerFactory.kt | 0 .../java/im/vector/app/GoogleFlavorLegals.kt | 0 .../java/im/vector/app/di/FlavorModule.kt | 0 .../vector/app/di/NotificationTestModule.kt | 0 .../troubleshoot/TestFirebaseToken.kt | 0 .../settings/troubleshoot/TestPlayServices.kt | 0 .../troubleshoot/TestTokenRegistration.kt | 0 .../java/im/vector/app/gplay/package-info.kt | 0 .../app/nightly/FirebaseNightlyProxy.kt | 0 .../im/vector/app/push/fcm/GoogleFcmHelper.kt | 0 ...ificationTroubleshootTestManagerFactory.kt | 0 .../fcm/VectorFirebaseMessagingService.kt | 0 vector/build.gradle | 35 ++----------------- 27 files changed, 19 insertions(+), 32 deletions(-) rename {vector => vector-app}/src/fdroid/AndroidManifest.xml (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/di/FlavorModule.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/package-info.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/service/FDroidGuardServiceStarter.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/fdroid/service/GuardAndroidService.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/push/fcm/FdroidFcmHelper.kt (100%) rename {vector => vector-app}/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/GoogleFlavorLegals.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/di/FlavorModule.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/di/NotificationTestModule.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/gplay/package-info.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/push/fcm/GoogleFcmHelper.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt (100%) rename {vector => vector-app}/src/gplay/java/im/vector/app/push/fcm/VectorFirebaseMessagingService.kt (100%) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index ea321c9e83..3f5c7a6c16 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -364,6 +364,22 @@ dependencies { debugImplementation 'com.facebook.soloader:soloader:0.10.4' debugImplementation "com.kgurgul.flipper:flipper-realm-android:2.2.0" + gplayImplementation "com.google.android.gms:play-services-location:16.0.0" + // UnifiedPush gplay flavor only + gplayImplementation('com.github.UnifiedPush:android-embedded_fcm_distributor:2.1.2') { + exclude group: 'com.google.firebase', module: 'firebase-core' + exclude group: 'com.google.firebase', module: 'firebase-analytics' + exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' + } + + // Nightly + // API-only library + gplayImplementation libs.google.appdistributionApi + // Full SDK implementation + gplayImplementation libs.google.appdistribution + + // OSS License, gplay flavor only + gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' kapt libs.dagger.hiltCompiler kapt libs.airbnb.epoxyProcessor diff --git a/vector/src/fdroid/AndroidManifest.xml b/vector-app/src/fdroid/AndroidManifest.xml similarity index 100% rename from vector/src/fdroid/AndroidManifest.xml rename to vector-app/src/fdroid/AndroidManifest.xml diff --git a/vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt b/vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt rename to vector-app/src/fdroid/java/im/vector/app/di/FlavorModule.kt diff --git a/vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt b/vector-app/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt rename to vector-app/src/fdroid/java/im/vector/app/di/NotificationTestModule.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/BackgroundSyncStarter.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestAutoStartBoot.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBackgroundRestrictions.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/features/settings/troubleshoot/TestBatteryOptimization.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/package-info.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/package-info.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/package-info.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/package-info.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/OnApplicationUpgradeOrRebootReceiver.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/service/FDroidGuardServiceStarter.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/service/FDroidGuardServiceStarter.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/service/FDroidGuardServiceStarter.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/service/FDroidGuardServiceStarter.kt diff --git a/vector/src/fdroid/java/im/vector/app/fdroid/service/GuardAndroidService.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/service/GuardAndroidService.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/fdroid/service/GuardAndroidService.kt rename to vector-app/src/fdroid/java/im/vector/app/fdroid/service/GuardAndroidService.kt diff --git a/vector/src/fdroid/java/im/vector/app/push/fcm/FdroidFcmHelper.kt b/vector-app/src/fdroid/java/im/vector/app/push/fcm/FdroidFcmHelper.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/push/fcm/FdroidFcmHelper.kt rename to vector-app/src/fdroid/java/im/vector/app/push/fcm/FdroidFcmHelper.kt diff --git a/vector/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt b/vector-app/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt similarity index 100% rename from vector/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt rename to vector-app/src/fdroid/java/im/vector/app/push/fcm/FdroidNotificationTroubleshootTestManagerFactory.kt diff --git a/vector/src/gplay/java/im/vector/app/GoogleFlavorLegals.kt b/vector-app/src/gplay/java/im/vector/app/GoogleFlavorLegals.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/GoogleFlavorLegals.kt rename to vector-app/src/gplay/java/im/vector/app/GoogleFlavorLegals.kt diff --git a/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt b/vector-app/src/gplay/java/im/vector/app/di/FlavorModule.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/di/FlavorModule.kt rename to vector-app/src/gplay/java/im/vector/app/di/FlavorModule.kt diff --git a/vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt b/vector-app/src/gplay/java/im/vector/app/di/NotificationTestModule.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/di/NotificationTestModule.kt rename to vector-app/src/gplay/java/im/vector/app/di/NotificationTestModule.kt diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt b/vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt rename to vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestFirebaseToken.kt diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt b/vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt rename to vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestPlayServices.kt diff --git a/vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt b/vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt rename to vector-app/src/gplay/java/im/vector/app/gplay/features/settings/troubleshoot/TestTokenRegistration.kt diff --git a/vector/src/gplay/java/im/vector/app/gplay/package-info.kt b/vector-app/src/gplay/java/im/vector/app/gplay/package-info.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/gplay/package-info.kt rename to vector-app/src/gplay/java/im/vector/app/gplay/package-info.kt diff --git a/vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt b/vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt rename to vector-app/src/gplay/java/im/vector/app/nightly/FirebaseNightlyProxy.kt diff --git a/vector/src/gplay/java/im/vector/app/push/fcm/GoogleFcmHelper.kt b/vector-app/src/gplay/java/im/vector/app/push/fcm/GoogleFcmHelper.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/push/fcm/GoogleFcmHelper.kt rename to vector-app/src/gplay/java/im/vector/app/push/fcm/GoogleFcmHelper.kt diff --git a/vector/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt b/vector-app/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt rename to vector-app/src/gplay/java/im/vector/app/push/fcm/GoogleNotificationTroubleshootTestManagerFactory.kt diff --git a/vector/src/gplay/java/im/vector/app/push/fcm/VectorFirebaseMessagingService.kt b/vector-app/src/gplay/java/im/vector/app/push/fcm/VectorFirebaseMessagingService.kt similarity index 100% rename from vector/src/gplay/java/im/vector/app/push/fcm/VectorFirebaseMessagingService.kt rename to vector-app/src/gplay/java/im/vector/app/push/fcm/VectorFirebaseMessagingService.kt diff --git a/vector/build.gradle b/vector/build.gradle index 3b802c8316..f6db2a61df 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -68,18 +68,6 @@ android { } } - flavorDimensions "store" - - productFlavors { - gplay { - dimension "store" - } - - fdroid { - dimension "store" - } - } - compileOptions { sourceCompatibility versions.sourceCompat targetCompatibility versions.targetCompat @@ -174,12 +162,6 @@ dependencies { // Snap Helper https://github.com/rubensousa/GravitySnapHelper api 'com.github.rubensousa:gravitysnaphelper:2.2.2' - // Nightly - // API-only library - gplayImplementation libs.google.appdistributionApi - // Full SDK implementation - gplayImplementation libs.google.appdistribution - // Work api libs.androidx.work @@ -247,15 +229,6 @@ dependencies { // UnifiedPush implementation 'com.github.UnifiedPush:android-connector:2.0.1' - // UnifiedPush gplay flavor only - gplayImplementation('com.google.firebase:firebase-messaging:23.0.8') { - exclude group: 'com.google.firebase', module: 'firebase-core' - exclude group: 'com.google.firebase', module: 'firebase-analytics' - exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' - } - - // OSS License, gplay flavor only - gplayImplementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' implementation "androidx.emoji2:emoji2:1.1.0" @@ -291,14 +264,12 @@ dependencies { implementation 'commons-codec:commons-codec:1.15' // MapTiler - fdroidApi(libs.maplibre.androidSdk) { + api(libs.maplibre.androidSdk) { exclude group: 'com.google.android.gms', module: 'play-services-location' } - fdroidApi(libs.maplibre.pluginAnnotation) { + api(libs.maplibre.pluginAnnotation) { exclude group: 'com.google.android.gms', module: 'play-services-location' } - gplayApi libs.maplibre.androidSdk - gplayApi libs.maplibre.pluginAnnotation // TESTS testImplementation libs.tests.junit @@ -310,7 +281,7 @@ dependencies { testImplementation(libs.jetbrains.coroutinesTest) { exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug" } - + androidTestImplementation libs.androidx.testCore androidTestImplementation libs.androidx.testRunner androidTestImplementation libs.androidx.testRules From 069104660131dc9e2d0faf9a2f5a0cc5e41ecc34 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 9 Aug 2022 15:07:35 +0100 Subject: [PATCH 41/51] enabling build caching by default to improve build times --- gradle.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/gradle.properties b/gradle.properties index 2af9214ed5..0e561faa8d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,6 +12,7 @@ org.gradle.jvmargs=-Xmx4g -Xms512M -XX:MaxPermSize=2048m -XX:MaxMetaspaceSize=1g org.gradle.configureondemand=true org.gradle.parallel=true org.gradle.vfs.watch=true +org.gradle.caching=true # Android Settings android.enableJetifier=true From 32a15bee04ba4b8bb5fab6107e22122f4b2252cc Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 1 Sep 2022 16:47:52 +0100 Subject: [PATCH 42/51] adding changelog entry --- changelog.d/6779.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/6779.misc diff --git a/changelog.d/6779.misc b/changelog.d/6779.misc new file mode 100644 index 0000000000..70eda0eb2f --- /dev/null +++ b/changelog.d/6779.misc @@ -0,0 +1 @@ +[Modules] Lifts the application variants to the app module From 0c469ae07999028a2ca4c4687c6d50c36487c60a Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 12 Sep 2022 13:51:37 +0100 Subject: [PATCH 43/51] removing extra application id declaration --- vector-app/src/fdroid/AndroidManifest.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vector-app/src/fdroid/AndroidManifest.xml b/vector-app/src/fdroid/AndroidManifest.xml index 15db89ca13..65630590d2 100644 --- a/vector-app/src/fdroid/AndroidManifest.xml +++ b/vector-app/src/fdroid/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools"> From 1d50bbdbda3ffd2804031b899e1b5bf74c70f634 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 12 Sep 2022 16:15:03 +0100 Subject: [PATCH 44/51] fixing manifest imports and giving androidTest its own dedicated manifest --- vector-app/src/debug/AndroidManifest.xml | 2 -- vector-app/src/fdroid/AndroidManifest.xml | 6 +++--- vector/src/androidTest/AndroidManifest.xml | 8 ++++++++ 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 vector/src/androidTest/AndroidManifest.xml diff --git a/vector-app/src/debug/AndroidManifest.xml b/vector-app/src/debug/AndroidManifest.xml index 3860a37319..a7867f4081 100644 --- a/vector-app/src/debug/AndroidManifest.xml +++ b/vector-app/src/debug/AndroidManifest.xml @@ -15,8 +15,6 @@ android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity" android:exported="true" /> - - diff --git a/vector-app/src/fdroid/AndroidManifest.xml b/vector-app/src/fdroid/AndroidManifest.xml index 65630590d2..354d450958 100644 --- a/vector-app/src/fdroid/AndroidManifest.xml +++ b/vector-app/src/fdroid/AndroidManifest.xml @@ -14,7 +14,7 @@ @@ -23,12 +23,12 @@ diff --git a/vector/src/androidTest/AndroidManifest.xml b/vector/src/androidTest/AndroidManifest.xml new file mode 100644 index 0000000000..002b12f0db --- /dev/null +++ b/vector/src/androidTest/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + + + + From 9e5f07a855df480d39a20c68f0903f5e80198aee Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 12 Sep 2022 16:15:11 +0100 Subject: [PATCH 45/51] suppressing lint warning for constant that delegates to the correct value --- .../vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt b/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt index bd1e0eb0ee..bccbf42e92 100644 --- a/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt +++ b/vector-app/src/fdroid/java/im/vector/app/fdroid/receiver/AlarmSyncBroadcastReceiver.kt @@ -16,6 +16,7 @@ package im.vector.app.fdroid.receiver +import android.annotation.SuppressLint import android.app.AlarmManager import android.app.PendingIntent import android.content.BroadcastReceiver @@ -65,6 +66,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { companion object { private const val REQUEST_CODE = 0 + @SuppressLint("WrongConstant") // PendingIntentCompat.FLAG_IMMUTABLE is a false positive fun scheduleAlarm(context: Context, sessionId: String, delayInSeconds: Int, clock: Clock) { // Reschedule Timber.v("## Sync: Scheduling alarm for background sync in $delayInSeconds seconds") @@ -87,6 +89,7 @@ class AlarmSyncBroadcastReceiver : BroadcastReceiver() { } } + @SuppressLint("WrongConstant") // PendingIntentCompat.FLAG_IMMUTABLE is a false positive fun cancelAlarm(context: Context) { Timber.v("## Sync: Cancel alarm for background sync") val intent = Intent(context, AlarmSyncBroadcastReceiver::class.java) From e9e29603de140d7dad9f8ab0a75361c3d4c1cee9 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Mon, 12 Sep 2022 16:58:27 +0100 Subject: [PATCH 46/51] adding missing nightly source inclusions --- vector-app/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 3f5c7a6c16..82c433d2df 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -291,6 +291,12 @@ android { } } + sourceSets { + nightly { + java.srcDirs += "src/release/java" + } + } + flavorDimensions "store" productFlavors { From 68da403f2f22c555757f7ae548d3d2d9ba2173e2 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 14 Sep 2022 11:23:16 +0100 Subject: [PATCH 47/51] using the top level debug unit test task when executing tests for coverage to avoid needing to specify every module --- coverage.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage.gradle b/coverage.gradle index 716f9b7cc7..8f6feacee2 100644 --- a/coverage.gradle +++ b/coverage.gradle @@ -81,7 +81,7 @@ task generateCoverageReport(type: JacocoReport) { task unitTestsWithCoverage(type: GradleBuild) { // the 7.1.3 android gradle plugin has a bug where enableTestCoverage generates invalid coverage startParameter.projectProperties.coverage = [enableTestCoverage: false] - tasks = [':vector:testGplayDebugUnitTest', ':matrix-sdk-android:testDebugUnitTest'] + tasks = ['testDebugUnitTest'] } task instrumentationTestsWithCoverage(type: GradleBuild) { From 619ea819edc8253237ef4dc435531ce16c22e403 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 14 Sep 2022 14:47:04 +0100 Subject: [PATCH 48/51] using debug variant for the vector CA tests, gplay only exists at the root level --- coverage.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage.gradle b/coverage.gradle index 8f6feacee2..2c0af25368 100644 --- a/coverage.gradle +++ b/coverage.gradle @@ -87,5 +87,5 @@ task unitTestsWithCoverage(type: GradleBuild) { task instrumentationTestsWithCoverage(type: GradleBuild) { startParameter.projectProperties.coverage = [enableTestCoverage: true] startParameter.projectProperties['android.testInstrumentationRunnerArguments.notPackage'] = 'im.vector.app.ui' - tasks = [':vector-app:connectedGplayDebugAndroidTest', ':vector:connectedGplayDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest'] + tasks = [':vector-app:connectedGplayDebugAndroidTest', ':vector:connectedDebugAndroidTest', 'matrix-sdk-android:connectedDebugAndroidTest'] } From e9d15b46d8ed11452efe9fbe6a06f2c0a02d09c4 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Wed, 14 Sep 2022 16:50:11 +0100 Subject: [PATCH 49/51] lifting the activity alias entry to the application module - fixes the androidTests expecting a shortcuts xml --- vector-app/src/main/AndroidManifest.xml | 18 ++++++++++++++++++ vector/src/main/AndroidManifest.xml | 17 ----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/vector-app/src/main/AndroidManifest.xml b/vector-app/src/main/AndroidManifest.xml index 84607cf3d7..bff594c0de 100644 --- a/vector-app/src/main/AndroidManifest.xml +++ b/vector-app/src/main/AndroidManifest.xml @@ -18,6 +18,24 @@ tools:ignore="UnusedAttribute" tools:replace="android:allowBackup"> + + + + + + + + + + + + + diff --git a/vector/src/main/AndroidManifest.xml b/vector/src/main/AndroidManifest.xml index 94f2abe78b..d60620dddf 100644 --- a/vector/src/main/AndroidManifest.xml +++ b/vector/src/main/AndroidManifest.xml @@ -90,23 +90,6 @@ android:name=".features.MainActivity" android:theme="@style/Theme.Vector.Launcher" /> - - - - - - - - - - - - Date: Thu, 15 Sep 2022 15:17:11 +0100 Subject: [PATCH 50/51] using fully qualified path to test activity, fixes missing reference --- vector/src/androidTest/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/androidTest/AndroidManifest.xml b/vector/src/androidTest/AndroidManifest.xml index 002b12f0db..5c3b99d4d1 100644 --- a/vector/src/androidTest/AndroidManifest.xml +++ b/vector/src/androidTest/AndroidManifest.xml @@ -2,7 +2,7 @@ - + From e86b72b8db91f99cdd89384c4bc07ccba0b140b9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Sep 2022 23:11:49 +0000 Subject: [PATCH 51/51] Bump appDistribution from 16.0.0-beta03 to 16.0.0-beta04 Bumps `appDistribution` from 16.0.0-beta03 to 16.0.0-beta04. Updates `firebase-appdistribution-api-ktx` from 16.0.0-beta03 to 16.0.0-beta04 Updates `firebase-appdistribution` from 16.0.0-beta03 to 16.0.0-beta04 --- updated-dependencies: - dependency-name: com.google.firebase:firebase-appdistribution-api-ktx dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.google.firebase:firebase-appdistribution dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index c7b441738b..9641a63f26 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -15,7 +15,7 @@ def gradle = "7.1.3" def kotlin = "1.6.21" def kotlinCoroutines = "1.6.4" def dagger = "2.42" -def appDistribution = "16.0.0-beta03" +def appDistribution = "16.0.0-beta04" def retrofit = "2.9.0" def arrow = "0.8.2" def markwon = "4.6.2"