adding observer that sets requestedOrientation
This commit is contained in:
@@ -12,8 +12,7 @@
|
||||
android:theme="@style/LauncherTheme"
|
||||
android:stateNotNeeded="true"
|
||||
android:resumeWhilePausing="true"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize"
|
||||
android:screenOrientation="portrait">
|
||||
android:windowSoftInputMode="stateHidden|adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent {
|
||||
val bottomSearchBar = dataStore.data.map { it.layout.bottomSearchBar }.asLiveData()
|
||||
val reverseSearchResults = dataStore.data.map { it.layout.reverseSearchResults }.asLiveData()
|
||||
val fixedSearchBar = dataStore.data.map { it.layout.fixedSearchBar }.asLiveData()
|
||||
val fixedRotation = dataStore.data.map { it.layout.fixedRotation }.asLiveData()
|
||||
|
||||
val isSearchOpen = MutableLiveData(false)
|
||||
val isWidgetEditMode = MutableLiveData(false)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.mm20.launcher2.ui.launcher
|
||||
|
||||
import android.app.WallpaperManager
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
@@ -35,6 +36,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.core.view.WindowCompat
|
||||
import androidx.core.view.WindowInsetsControllerCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.flowWithLifecycle
|
||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||
import de.mm20.launcher2.globalactions.GlobalActionsService
|
||||
@@ -132,6 +134,15 @@ abstract class SharedLauncherActivity(
|
||||
val reverseSearchResults by viewModel.reverseSearchResults.observeAsState(false)
|
||||
val fixedSearchBar by viewModel.fixedSearchBar.observeAsState(false)
|
||||
|
||||
viewModel.fixedRotation.observe(this) { fixedRotation ->
|
||||
requestedOrientation = if (fixedRotation) {
|
||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
|
||||
} else {
|
||||
ActivityInfo.SCREEN_ORIENTATION_SENSOR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val systemUiController = rememberSystemUiController()
|
||||
|
||||
val enterTransitionProgress = remember { mutableStateOf(1f) }
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.mm20.launcher2.ui.settings.layout
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@@ -59,7 +58,7 @@ class LayoutSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
}
|
||||
}
|
||||
|
||||
val fixedRotation = dataStore.data.map { it.layout.fixedRoation }.asLiveData()
|
||||
val fixedRotation = dataStore.data.map { it.layout.fixedRotation }.asLiveData()
|
||||
fun setFixedRotation(fixedRotation: Boolean) {
|
||||
viewModelScope.launch {
|
||||
dataStore.updateData {
|
||||
|
||||
Reference in New Issue
Block a user