diff --git a/library/ui-styles/src/main/res/values-sw600dp/tablet.xml b/library/ui-styles/src/main/res/values-sw600dp/tablet.xml
index 39f467cf0d..86bab06371 100644
--- a/library/ui-styles/src/main/res/values-sw600dp/tablet.xml
+++ b/library/ui-styles/src/main/res/values-sw600dp/tablet.xml
@@ -2,5 +2,6 @@
0.6
+ true
\ No newline at end of file
diff --git a/library/ui-styles/src/main/res/values/tablet.xml b/library/ui-styles/src/main/res/values/tablet.xml
index a5df8fe17c..8460f0ccf8 100644
--- a/library/ui-styles/src/main/res/values/tablet.xml
+++ b/library/ui-styles/src/main/res/values/tablet.xml
@@ -2,5 +2,6 @@
1
+ false
\ No newline at end of file
diff --git a/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt b/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt
new file mode 100644
index 0000000000..4b62090d3f
--- /dev/null
+++ b/vector/src/main/java/im/vector/app/core/platform/ScreenOrientationLocker.kt
@@ -0,0 +1,42 @@
+/*
+ * 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.platform
+
+import android.annotation.SuppressLint
+import android.content.pm.ActivityInfo
+import android.content.res.Resources
+import androidx.appcompat.app.AppCompatActivity
+import im.vector.app.R
+import javax.inject.Inject
+
+class ScreenOrientationLocker @Inject constructor(
+ private val resources: Resources
+) {
+
+ // Some screens do not provide enough value for us to provide phone landscape experiences
+ @SuppressLint("SourceLockedOrientationActivity")
+ fun lockPhonesToPortrait(activity: AppCompatActivity) {
+ when (resources.getBoolean(R.bool.is_tablet)) {
+ true -> {
+ // do nothing
+ }
+ false -> {
+ activity.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
+ }
+ }
+ }
+}
diff --git a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInActivity.kt b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInActivity.kt
index f6a06ebdb7..c84031d2fd 100644
--- a/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInActivity.kt
+++ b/vector/src/main/java/im/vector/app/features/analytics/ui/consent/AnalyticsOptInActivity.kt
@@ -20,8 +20,10 @@ import com.airbnb.mvrx.viewModel
import dagger.hilt.android.AndroidEntryPoint
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.exhaustive
+import im.vector.app.core.platform.ScreenOrientationLocker
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivitySimpleBinding
+import javax.inject.Inject
/**
* Simple container for AnalyticsOptInFragment
@@ -29,6 +31,8 @@ import im.vector.app.databinding.ActivitySimpleBinding
@AndroidEntryPoint
class AnalyticsOptInActivity : VectorBaseActivity() {
+ @Inject lateinit var orientationLocker: ScreenOrientationLocker
+
private val viewModel: AnalyticsConsentViewModel by viewModel()
override fun getBinding() = ActivitySimpleBinding.inflate(layoutInflater)
@@ -36,6 +40,7 @@ class AnalyticsOptInActivity : VectorBaseActivity() {
override fun getCoordinatorLayout() = views.coordinatorLayout
override fun initUiAndData() {
+ orientationLocker.lockPhonesToPortrait(this)
if (isFirstCreation()) {
addFragment(views.simpleFragmentContainer, AnalyticsOptInFragment::class.java)
}
diff --git a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt
index c171fc223d..52423d7019 100644
--- a/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt
+++ b/vector/src/main/java/im/vector/app/features/onboarding/OnboardingVariantFactory.kt
@@ -16,6 +16,7 @@
package im.vector.app.features.onboarding
+import im.vector.app.core.platform.ScreenOrientationLocker
import im.vector.app.databinding.ActivityLoginBinding
import im.vector.app.features.VectorFeatures
import im.vector.app.features.login2.LoginViewModel2
@@ -24,6 +25,7 @@ import javax.inject.Inject
class OnboardingVariantFactory @Inject constructor(
private val vectorFeatures: VectorFeatures,
+ private val orientationLocker: ScreenOrientationLocker,
) {
fun create(activity: OnboardingActivity,
@@ -37,7 +39,8 @@ class OnboardingVariantFactory @Inject constructor(
onboardingViewModel = onboardingViewModel.value,
activity = activity,
supportFragmentManager = activity.supportFragmentManager,
- vectorFeatures = vectorFeatures
+ vectorFeatures = vectorFeatures,
+ orientationLocker = orientationLocker
)
VectorFeatures.OnboardingVariant.LOGIN_2 -> Login2Variant(
views = views,
diff --git a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt
index f177eda114..06dbad50f8 100644
--- a/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt
+++ b/vector/src/main/java/im/vector/app/features/onboarding/ftueauth/FtueAuthVariant.kt
@@ -15,6 +15,7 @@
*/
package im.vector.app.features.onboarding.ftueauth
+
import android.content.Intent
import android.view.View
import android.view.ViewGroup
@@ -31,6 +32,7 @@ import im.vector.app.core.extensions.POP_BACK_STACK_EXCLUSIVE
import im.vector.app.core.extensions.addFragment
import im.vector.app.core.extensions.addFragmentToBackstack
import im.vector.app.core.extensions.exhaustive
+import im.vector.app.core.platform.ScreenOrientationLocker
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.databinding.ActivityLoginBinding
import im.vector.app.features.VectorFeatures
@@ -62,7 +64,8 @@ class FtueAuthVariant(
private val onboardingViewModel: OnboardingViewModel,
private val activity: VectorBaseActivity,
private val supportFragmentManager: FragmentManager,
- private val vectorFeatures: VectorFeatures
+ private val vectorFeatures: VectorFeatures,
+ private val orientationLocker: ScreenOrientationLocker,
) : OnboardingVariant {
private val enterAnim = R.anim.enter_fade_in
@@ -91,6 +94,7 @@ class FtueAuthVariant(
}
with(activity) {
+ orientationLocker.lockPhonesToPortrait(this)
onboardingViewModel.onEach {
updateWithState(it)
}