Skip to content

Commit

Permalink
fix(Activation area): Use SliderPreference
Browse files Browse the repository at this point in the history
  • Loading branch information
axel358 committed Feb 8, 2024
1 parent a8d994f commit 3f323e8
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
23 changes: 21 additions & 2 deletions app/src/main/java/cu/axel/smartdock/fragments/DockPreferences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,26 @@ class DockPreferences : PreferenceFragmentCompat() {
showAutopinDialog(requireContext())
false
}
val activationArea = findPreference<Preference>("dock_activation_area")
val activationArea = findPreference<SliderPreference>("dock_activation_area")
activationArea!!.isVisible =
activationArea.sharedPreferences!!.getString("activation_method", "swipe") == "swipe"
activationArea.setOnDialogShownListener(object : SliderPreference.OnDialogShownListener {
override fun onDialogShown() {
val slider = activationArea.slider
slider.isTickVisible = false
slider.labelBehavior = LabelFormatter.LABEL_GONE
slider.stepSize = 1f
slider.value =
activationArea.sharedPreferences!!.getString(activationArea.key, "10")!!
.toFloat()
slider.valueFrom = 1f
slider.valueTo = 50f
slider.addOnChangeListener { _, value, _ ->
activationArea.sharedPreferences!!.edit()
.putString(activationArea.key, value.toInt().toString()).apply()
}
}
})
val handleOpacity = findPreference<SliderPreference>("handle_opacity")
handleOpacity!!.isVisible =
handleOpacity.sharedPreferences!!.getString("activation_method", "swipe") == "handle"
Expand All @@ -30,7 +47,9 @@ class DockPreferences : PreferenceFragmentCompat() {
slider.isTickVisible = false
slider.labelBehavior = LabelFormatter.LABEL_GONE
slider.stepSize = 0.1f
slider.value = handleOpacity.sharedPreferences!!.getString(handleOpacity.key, "0.5f")!!.toFloat()
slider.value =
handleOpacity.sharedPreferences!!.getString(handleOpacity.key, "0.5f")!!
.toFloat()
slider.valueFrom = 0.2f
slider.valueTo = 1f
slider.addOnChangeListener { _, value, _ ->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<string name="running_apps_number_summary">Esta configuración puede ayudar a los dispositivos con pantallas más pequeñas a evitar el desbordamiento de aplicaciones en el Dock</string>
<string name="dock_hide_delay_title">Retardo de ocultación del Dock en ms</string>
<string name="center_running_apps_title">Centrar de aplicaciones en ejecución</string>
<string name="dock_activation_area_title">Área de activación del Dock (máx. 50)</string>
<string name="dock_activation_area_title">Área de activación del Dock</string>
<string name="dock_activation_area_summary">La altura del área de activación invisible en la parte inferior de la pantalla</string>

<!-- Desktop -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values-pa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<string name="running_apps_number_summary">ਇਹ ਸੈਟਿੰਗ ਛੋਟੀਆਂ ਸਕ੍ਰੀਨਾਂ ਵਾਲੇ ਡਿਵਾਈਸਾਂ ਨੂੰ ਡੌਕ \'ਤੇ ਐਪ ਓਵਰਫਲੋ ਤੋਂ ਬਚਣ ਵਿੱਚ ਮਦਦ ਕਰ ਸਕਦੀ ਹੈ</string>
<string name="dock_hide_delay_title">ਡੌਕ ਲੁਕਾਓ ਲਈ ms ਵਿੱਚ ਦੇਰੀ</string>
<string name="center_running_apps_title">ਸੈਂਟਰ ਚੱਲ ਰਹੀਆਂ ਐਪਾਂ</string>
<string name="dock_activation_area_title">ਡੌਕ ਐਕਟੀਵੇਸ਼ਨ ਖੇਤਰ (ਅਧਿਕਤਮ 50)</string>
<string name="dock_activation_area_title">ਡੌਕ ਐਕਟੀਵੇਸ਼ਨ ਖੇਤਰ</string>
<string name="dock_activation_area_summary">ਸਕ੍ਰੀਨ ਦੇ ਹੇਠਾਂ ਇਨਵਿਜੀਵਲ ਐਕਟੀਵੇਸ਼ਨ ਖੇਤਰ ਦੀ ਉਚਾਈ</string>

<!-- Desktop -->
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
<string name="running_apps_number_summary">This setting can help devices with smaller screens avoid app overflow on the Dock</string>
<string name="dock_hide_delay_title">Dock hide delay in ms</string>
<string name="center_running_apps_title">Center running apps</string>
<string name="dock_activation_area_title">Dock activation area (max 50)</string>
<string name="dock_activation_area_title">Dock activation area</string>
<string name="dock_activation_area_summary">The height of the invisible activation area at the bottom of the screen</string>

<!-- Desktop -->
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/xml/preferences_dock.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,8 @@
android:defaultValue="start"
android:title="@string/handle_position"/>

<EditTextPreference
android:inputType="number"
<cu.axel.smartdock.preferences.SliderPreference
android:key="dock_activation_area"
android:hint="10"
android:defaultValue="10"
android:summary="@string/dock_activation_area_summary"
android:title="@string/dock_activation_area_title"/>
Expand Down

0 comments on commit 3f323e8

Please sign in to comment.