adding fixedRotation to settings
This commit is contained in:
parent
17a8eda910
commit
e492a4975d
@ -64,6 +64,15 @@ fun LayoutSettingsScreen() {
|
||||
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)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package de.mm20.launcher2.ui.settings.layout
|
||||
|
||||
import android.content.pm.ActivityInfo
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.asLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
@ -57,4 +58,15 @@ class LayoutSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val fixedRotation = dataStore.data.map { it.layout.fixedRoation }.asLiveData()
|
||||
fun setFixedRotation(fixedRotation: Boolean) {
|
||||
viewModelScope.launch {
|
||||
dataStore.updateData {
|
||||
it.toBuilder()
|
||||
.setLayout(it.layout.toBuilder().setFixedRotation(fixedRotation))
|
||||
.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -734,6 +734,8 @@
|
||||
<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_summary">Don\'t scroll the search bar out of view</string>
|
||||
<string name="preference_layout_fixed_rotation">Fixed rotation</string>
|
||||
<string name="preference_layout_fixed_rotation_summary">Lock rotation to portrait mode</string>
|
||||
<string name="preference_screen_gestures">Gestures</string>
|
||||
<string name="preference_screen_gestures_summary">Gestures and gesture actions</string>
|
||||
<string name="preference_gesture_swipe_down">Swipe down</string>
|
||||
|
||||
@ -168,6 +168,7 @@ fun createFactorySettings(context: Context): Settings {
|
||||
.setBaseLayout(Settings.LayoutSettings.Layout.PullDown)
|
||||
.setBottomSearchBar(false)
|
||||
.setReverseSearchResults(false)
|
||||
.setFixedRotation(false)
|
||||
)
|
||||
.setGestures(
|
||||
Settings.GestureSettings.newBuilder()
|
||||
|
||||
@ -298,6 +298,7 @@ message Settings {
|
||||
bool bottom_search_bar = 2;
|
||||
bool reverse_search_results = 3;
|
||||
bool fixed_search_bar = 4;
|
||||
bool fixed_rotation = 5;
|
||||
}
|
||||
LayoutSettings layout = 27;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user