Merge pull request #241 from Sir-Photch/main
Add layout-option to restrict rotation to portrait mode
This commit is contained in:
commit
80a1942555
@ -67,6 +67,7 @@ class LauncherScaffoldVM : ViewModel(), KoinComponent {
|
|||||||
val bottomSearchBar = dataStore.data.map { it.layout.bottomSearchBar }.asLiveData()
|
val bottomSearchBar = dataStore.data.map { it.layout.bottomSearchBar }.asLiveData()
|
||||||
val reverseSearchResults = dataStore.data.map { it.layout.reverseSearchResults }.asLiveData()
|
val reverseSearchResults = dataStore.data.map { it.layout.reverseSearchResults }.asLiveData()
|
||||||
val fixedSearchBar = dataStore.data.map { it.layout.fixedSearchBar }.asLiveData()
|
val fixedSearchBar = dataStore.data.map { it.layout.fixedSearchBar }.asLiveData()
|
||||||
|
val fixedRotation = dataStore.data.map { it.layout.fixedRotation }.asLiveData()
|
||||||
|
|
||||||
val isSearchOpen = MutableLiveData(false)
|
val isSearchOpen = MutableLiveData(false)
|
||||||
val isWidgetEditMode = MutableLiveData(false)
|
val isWidgetEditMode = MutableLiveData(false)
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package de.mm20.launcher2.ui.launcher
|
package de.mm20.launcher2.ui.launcher
|
||||||
|
|
||||||
import android.app.WallpaperManager
|
import android.app.WallpaperManager
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -35,6 +36,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.flowWithLifecycle
|
import androidx.lifecycle.flowWithLifecycle
|
||||||
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
import com.google.accompanist.systemuicontroller.rememberSystemUiController
|
||||||
import de.mm20.launcher2.globalactions.GlobalActionsService
|
import de.mm20.launcher2.globalactions.GlobalActionsService
|
||||||
@ -132,6 +134,15 @@ abstract class SharedLauncherActivity(
|
|||||||
val reverseSearchResults by viewModel.reverseSearchResults.observeAsState(false)
|
val reverseSearchResults by viewModel.reverseSearchResults.observeAsState(false)
|
||||||
val fixedSearchBar by viewModel.fixedSearchBar.observeAsState(false)
|
val fixedSearchBar by viewModel.fixedSearchBar.observeAsState(false)
|
||||||
|
|
||||||
|
viewModel.fixedRotation.observe(this) { fixedRotation ->
|
||||||
|
requestedOrientation = if (fixedRotation) {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
} else {
|
||||||
|
ActivityInfo.SCREEN_ORIENTATION_USER
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val systemUiController = rememberSystemUiController()
|
val systemUiController = rememberSystemUiController()
|
||||||
|
|
||||||
val enterTransitionProgress = remember { mutableStateOf(1f) }
|
val enterTransitionProgress = remember { mutableStateOf(1f) }
|
||||||
|
|||||||
@ -64,6 +64,15 @@ fun LayoutSettingsScreen() {
|
|||||||
if (it != null) viewModel.setReverseSearchResults(it)
|
if (it != null) viewModel.setReverseSearchResults(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
val fixedRotation by viewModel.fixedRotation.observeAsState()
|
||||||
|
SwitchPreference(
|
||||||
|
title = stringResource(R.string.preference_layout_fixed_rotation),
|
||||||
|
summary = stringResource(R.string.preference_layout_fixed_rotation_summary),
|
||||||
|
value = fixedRotation == true,
|
||||||
|
onValueChanged = {
|
||||||
|
viewModel.setFixedRotation(it)
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,4 +57,15 @@ class LayoutSettingsScreenVM: ViewModel(), KoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val fixedRotation = dataStore.data.map { it.layout.fixedRotation }.asLiveData()
|
||||||
|
fun setFixedRotation(fixedRotation: Boolean) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
dataStore.updateData {
|
||||||
|
it.toBuilder()
|
||||||
|
.setLayout(it.layout.toBuilder().setFixedRotation(fixedRotation))
|
||||||
|
.build()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -567,4 +567,6 @@
|
|||||||
<string name="gesture_failed_message">Sie haben eine „%1$s“-Geste ausgeführt. Diese Geste ist momentan konfiguriert, eine „%2$s“-Aktion auszulösen. Diese Aktion konnte aus dem folgenden Grund nicht durchgeführt werden:</string>
|
<string name="gesture_failed_message">Sie haben eine „%1$s“-Geste ausgeführt. Diese Geste ist momentan konfiguriert, eine „%2$s“-Aktion auszulösen. Diese Aktion konnte aus dem folgenden Grund nicht durchgeführt werden:</string>
|
||||||
<string name="preference_layout_fixed_search_bar">Angeheftete Suchleiste</string>
|
<string name="preference_layout_fixed_search_bar">Angeheftete Suchleiste</string>
|
||||||
<string name="preference_layout_fixed_search_bar_summary">Suchleiste nicht aus dem Sichtbereich herausscrollen</string>
|
<string name="preference_layout_fixed_search_bar_summary">Suchleiste nicht aus dem Sichtbereich herausscrollen</string>
|
||||||
|
<string name="preference_layout_fixed_rotation">Fixierte Bildschirmausrichtung</string>
|
||||||
|
<string name="preference_layout_fixed_rotation_summary">Erzwingt Porträtmodus des Launchers</string>
|
||||||
</resources>
|
</resources>
|
||||||
@ -733,6 +733,8 @@
|
|||||||
<string name="search_results_order_bottom_up">Bottom-up</string>
|
<string name="search_results_order_bottom_up">Bottom-up</string>
|
||||||
<string name="preference_layout_fixed_search_bar">Fixed search bar</string>
|
<string name="preference_layout_fixed_search_bar">Fixed search bar</string>
|
||||||
<string name="preference_layout_fixed_search_bar_summary">Don\'t scroll the search bar out of view</string>
|
<string name="preference_layout_fixed_search_bar_summary">Don\'t scroll the search bar out of view</string>
|
||||||
|
<string name="preference_layout_fixed_rotation">Fixed screen rotation</string>
|
||||||
|
<string name="preference_layout_fixed_rotation_summary">Lock screen rotation to portrait mode</string>
|
||||||
<string name="preference_screen_gestures">Gestures</string>
|
<string name="preference_screen_gestures">Gestures</string>
|
||||||
<string name="preference_screen_gestures_summary">Gestures and gesture actions</string>
|
<string name="preference_screen_gestures_summary">Gestures and gesture actions</string>
|
||||||
<string name="preference_gesture_swipe_down">Swipe down</string>
|
<string name="preference_gesture_swipe_down">Swipe down</string>
|
||||||
|
|||||||
@ -168,6 +168,7 @@ fun createFactorySettings(context: Context): Settings {
|
|||||||
.setBaseLayout(Settings.LayoutSettings.Layout.PullDown)
|
.setBaseLayout(Settings.LayoutSettings.Layout.PullDown)
|
||||||
.setBottomSearchBar(false)
|
.setBottomSearchBar(false)
|
||||||
.setReverseSearchResults(false)
|
.setReverseSearchResults(false)
|
||||||
|
.setFixedRotation(false)
|
||||||
)
|
)
|
||||||
.setGestures(
|
.setGestures(
|
||||||
Settings.GestureSettings.newBuilder()
|
Settings.GestureSettings.newBuilder()
|
||||||
|
|||||||
@ -298,6 +298,7 @@ message Settings {
|
|||||||
bool bottom_search_bar = 2;
|
bool bottom_search_bar = 2;
|
||||||
bool reverse_search_results = 3;
|
bool reverse_search_results = 3;
|
||||||
bool fixed_search_bar = 4;
|
bool fixed_search_bar = 4;
|
||||||
|
bool fixed_rotation = 5;
|
||||||
}
|
}
|
||||||
LayoutSettings layout = 27;
|
LayoutSettings layout = 27;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user