mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-22 22:11:27 +01:00
Merge pull request #74 from finnmglas/feature/sensitivity-setting
Feature/sensitivity-setting
This commit is contained in:
commit
179448007f
7 changed files with 53 additions and 2 deletions
|
@ -78,6 +78,8 @@ const val PREF_DATE_FORMAT = "dateFormat"
|
|||
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
|
||||
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
|
||||
|
||||
const val PREF_SLIDE_SENSITIVITY = "slideSensitivity"
|
||||
|
||||
const val PREF_STARTED = "startedBefore"
|
||||
const val PREF_STARTED_TIME = "firstStartup"
|
||||
|
||||
|
@ -462,6 +464,7 @@ fun resetSettings(context: Context) {
|
|||
.putInt(PREF_DATE_FORMAT, 0)
|
||||
.putBoolean(PREF_SCREEN_FULLSCREEN, true)
|
||||
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
.putInt(PREF_SLIDE_SENSITIVITY, 50)
|
||||
|
||||
// load action defaults
|
||||
for (actionKey in ACTIONS)
|
||||
|
|
|
@ -153,7 +153,8 @@ class HomeActivity: UIObject, AppCompatActivity(),
|
|||
val doubleActions = launcherPreferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
|
||||
|
||||
// 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
|
||||
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.Manifest
|
|||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.PorterDuff
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.provider.MediaStore
|
||||
|
@ -13,6 +14,8 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
|
@ -116,6 +119,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
settings_launcher_container.setBackgroundColor(dominantColor)
|
||||
setButtonColor(settings_theme_custom_button_select, vibrantColor)
|
||||
settings_seekbar_sensitivity.progressDrawable.setColorFilter(vibrantColor, PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
override fun setOnClicks() {
|
||||
|
@ -155,6 +159,18 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
intendedSettingsPause = true
|
||||
activity!!.recreate()
|
||||
}
|
||||
|
||||
settings_seekbar_sensitivity.setOnSeekBarChangeListener(
|
||||
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()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun resetToCustomTheme(context: Activity) {
|
||||
|
@ -213,7 +229,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
staticThemeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
|
||||
settings_launcher_theme_spinner.adapter = staticThemeAdapter
|
||||
|
||||
var themeInt = when (getSavedTheme(activity!!)) {
|
||||
val themeInt = when (getSavedTheme(activity!!)) {
|
||||
"finn" -> 0
|
||||
"dark" -> 1
|
||||
"custom" -> 2
|
||||
|
@ -235,5 +251,7 @@ class SettingsFragmentLauncher : Fragment(), UIObject {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
settings_seekbar_sensitivity.progress = launcherPreferences.getInt(PREF_SLIDE_SENSITIVITY, 50)
|
||||
}
|
||||
}
|
|
@ -201,6 +201,29 @@
|
|||
android:orientation="horizontal"
|
||||
android:paddingLeft="8sp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_launcher_text_sensitivity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/settings_launcher_sensitivity"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/settings_seekbar_sensitivity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:progress="50" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="16sp"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="8sp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_launcher_text_auto_launch"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
@ -80,6 +80,8 @@
|
|||
<string name="settings_launcher_enable_double">Doppelte Wischaktionen</string>
|
||||
<string name="settings_launcher_auto_launch">Suchergebisse launchen</string>
|
||||
|
||||
<string name="settings_launcher_sensitivity">Empfindlichkeit</string>
|
||||
|
||||
<!--
|
||||
-
|
||||
- Settings : Meta
|
||||
|
|
|
@ -80,6 +80,8 @@
|
|||
<string name="settings_launcher_enable_double">Double balayage actions</string>
|
||||
<string name="settings_launcher_auto_launch">Lancer apps par recherche</string>
|
||||
|
||||
<string name="settings_launcher_sensitivity">Sensibilité</string>
|
||||
|
||||
<!--
|
||||
-
|
||||
- Settings : Meta
|
||||
|
|
|
@ -100,6 +100,8 @@
|
|||
<string name="settings_launcher_enable_double">Double swipe actions</string>
|
||||
<string name="settings_launcher_auto_launch">Launch search results</string>
|
||||
|
||||
<string name="settings_launcher_sensitivity">Sensitivity</string>
|
||||
|
||||
<!--
|
||||
-
|
||||
- Settings : Meta
|
||||
|
|
Loading…
Add table
Reference in a new issue