mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 06:21:31 +01:00
Use sensitivity value to recognize swipe gestures
The sensitivity value can be adjusted using a slider, is stored as a integer value from 0 to 100. The default is 50, which corresponds to the sensitivity Launcher used before this feature.
This commit is contained in:
parent
1559f96838
commit
5bf2dbccbc
3 changed files with 18 additions and 14 deletions
|
@ -78,6 +78,8 @@ const val PREF_DATE_FORMAT = "dateFormat"
|
||||||
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
|
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
|
||||||
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
||||||
|
|
||||||
|
const val PREF_SLIDE_SENSITIVITY = "slideSensitivity"
|
||||||
|
|
||||||
const val PREF_STARTED = "startedBefore"
|
const val PREF_STARTED = "startedBefore"
|
||||||
const val PREF_STARTED_TIME = "firstStartup"
|
const val PREF_STARTED_TIME = "firstStartup"
|
||||||
|
|
||||||
|
@ -462,6 +464,7 @@ fun resetSettings(context: Context) {
|
||||||
.putInt(PREF_DATE_FORMAT, 0)
|
.putInt(PREF_DATE_FORMAT, 0)
|
||||||
.putBoolean(PREF_SCREEN_FULLSCREEN, true)
|
.putBoolean(PREF_SCREEN_FULLSCREEN, true)
|
||||||
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||||
|
.putInt(PREF_SLIDE_SENSITIVITY, 50)
|
||||||
|
|
||||||
// load action defaults
|
// load action defaults
|
||||||
for (actionKey in ACTIONS)
|
for (actionKey in ACTIONS)
|
||||||
|
|
|
@ -153,7 +153,8 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
||||||
val doubleActions = launcherPreferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
val doubleActions = launcherPreferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||||
|
|
||||||
// how distinguished the swipe has to be to launch something
|
// how distinguished the swipe has to be to launch something
|
||||||
val strictness = (4 / bufferedPointerCount)
|
// strictness = opposite of sensitivity. TODO - May have to be adjusted
|
||||||
|
val strictness = (4 / bufferedPointerCount) * ((100 - launcherPreferences.getInt(PREF_SLIDE_SENSITIVITY, 50)) / 50)
|
||||||
|
|
||||||
// Only open if the swipe was not from the phones top edge
|
// Only open if the swipe was not from the phones top edge
|
||||||
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) {
|
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) {
|
||||||
|
|
|
@ -160,19 +160,17 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||||
activity!!.recreate()
|
activity!!.recreate()
|
||||||
}
|
}
|
||||||
|
|
||||||
settings_seekbar_sensitivity.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
settings_seekbar_sensitivity.setOnSeekBarChangeListener(
|
||||||
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {
|
object : SeekBar.OnSeekBarChangeListener {
|
||||||
|
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {}
|
||||||
|
override fun onStartTrackingTouch(p0: SeekBar?) {}
|
||||||
|
override fun onStopTrackingTouch(p0: SeekBar?) {
|
||||||
|
launcherPreferences.edit()
|
||||||
|
.putInt(PREF_SLIDE_SENSITIVITY, p0!!.progress)
|
||||||
|
.apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
override fun onStartTrackingTouch(p0: SeekBar?) {
|
)
|
||||||
}
|
|
||||||
override fun onStopTrackingTouch(p0: SeekBar?) {
|
|
||||||
Toast.makeText(
|
|
||||||
context,
|
|
||||||
"Smooth Seekbar current progress ${p0?.progress}",
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetToCustomTheme(context: Activity) {
|
fun resetToCustomTheme(context: Activity) {
|
||||||
|
@ -231,7 +229,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||||
staticThemeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
staticThemeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||||
settings_launcher_theme_spinner.adapter = staticThemeAdapter
|
settings_launcher_theme_spinner.adapter = staticThemeAdapter
|
||||||
|
|
||||||
var themeInt = when (getSavedTheme(activity!!)) {
|
val themeInt = when (getSavedTheme(activity!!)) {
|
||||||
"finn" -> 0
|
"finn" -> 0
|
||||||
"dark" -> 1
|
"dark" -> 1
|
||||||
"custom" -> 2
|
"custom" -> 2
|
||||||
|
@ -253,5 +251,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
settings_seekbar_sensitivity.progress = launcherPreferences.getInt(PREF_SLIDE_SENSITIVITY, 50)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue