diff --git a/Omega/res/xml/omega_preferences_advanced.xml b/Omega/res/xml/omega_preferences_advanced.xml
index 834d9d97c4..54397adf26 100644
--- a/Omega/res/xml/omega_preferences_advanced.xml
+++ b/Omega/res/xml/omega_preferences_advanced.xml
@@ -40,11 +40,5 @@
android:key="backups"
android:summary="@string/backup_pref_summary"
android:title="@string/backups">
-
-
diff --git a/Omega/res/xml/omega_preferences_drawer.xml b/Omega/res/xml/omega_preferences_drawer.xml
index 5c1deebbf4..89186e016f 100644
--- a/Omega/res/xml/omega_preferences_drawer.xml
+++ b/Omega/res/xml/omega_preferences_drawer.xml
@@ -79,9 +79,9 @@
android:persistent="true"
android:title="@string/title_drawer_row_height"
app:defaultSeekbarValue="1.0"
- app:maxValue="1.5"
app:minValue="0.5"
- app:steps="150"
+ app:maxValue="1.5"
+ app:steps="100"
app:summaryFormat="%.0f%%"
app:summaryMultiplier="100" />
@@ -127,11 +127,13 @@
+ app:summaryMultiplier="100" />
.
*/
+
package com.saggitt.omega.preferences
import android.content.Context
import android.util.AttributeSet
import com.android.launcher3.R
-class AutoModeSeekbarPreference @JvmOverloads constructor(
- private val mContext: Context,
- attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) :
- SeekbarPreference(mContext, attrs, defStyleAttr) {
-
+class AutoModeSeekbarPreference(context: Context, attrs: AttributeSet?) :
+ SeekbarPreference(context, attrs) {
private var low = min
+
+ init {
+ min -= (max - min) / steps
+ steps += 1
+ defaultValue = min
+ }
+
public override fun updateSummary() {
if (current < low) {
- mValueText!!.text = mContext.getString(R.string.automatic_short)
+ mValueText!!.text = context.getString(R.string.automatic_short)
} else {
super.updateSummary()
}
}
- init {
- min -= (max - min) / steps
- steps += 1
- defaultValue = min
- }
+
}
\ No newline at end of file
diff --git a/Omega/src/com/saggitt/omega/preferences/CustomDialogPreference.kt b/Omega/src/com/saggitt/omega/preferences/CustomDialogPreference.kt
index 536a2b883c..8aedfff306 100644
--- a/Omega/src/com/saggitt/omega/preferences/CustomDialogPreference.kt
+++ b/Omega/src/com/saggitt/omega/preferences/CustomDialogPreference.kt
@@ -22,23 +22,11 @@ import android.util.AttributeSet
import androidx.preference.DialogPreference
import com.android.launcher3.R
-open class CustomDialogPreference : DialogPreference {
+open class CustomDialogPreference(context: Context, attrs: AttributeSet?) :
+ DialogPreference(context, attrs) {
var content = 0
- constructor(context: Context) : super(context) {
- init(context, null)
- }
-
- constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
- init(context, attrs)
- }
-
- constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
- super(context, attrs, defStyleAttr) {
- init(context, attrs)
- }
-
- private fun init(context: Context, attrs: AttributeSet?) {
+ init {
val a = context.obtainStyledAttributes(attrs, R.styleable.PreferenceDialogPreference)
content = a.getResourceId(R.styleable.PreferenceDialogPreference_content, 0)
a.recycle()
diff --git a/Omega/src/com/saggitt/omega/preferences/SeekbarPreference.kt b/Omega/src/com/saggitt/omega/preferences/SeekbarPreference.kt
index a139ce3993..0184c9743e 100644
--- a/Omega/src/com/saggitt/omega/preferences/SeekbarPreference.kt
+++ b/Omega/src/com/saggitt/omega/preferences/SeekbarPreference.kt
@@ -1,18 +1,19 @@
/*
- * This file is part of Lawnchair Launcher.
+ * This file is part of Omega Launcher
+ * Copyright (c) 2021 Saul Henriquez
*
- * Lawnchair Launcher is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
*
- * Lawnchair Launcher is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with Lawnchair Launcher. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
*/
package com.saggitt.omega.preferences
@@ -25,6 +26,7 @@ import android.view.ContextMenu
import android.view.MenuItem
import android.view.View
import android.widget.SeekBar
+import android.widget.SeekBar.OnSeekBarChangeListener
import android.widget.TextView
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
@@ -32,12 +34,10 @@ import com.android.launcher3.R
import com.android.launcher3.Utilities
import kotlin.math.roundToInt
-open class SeekbarPreference
-@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) :
- Preference(context, attrs, defStyleAttr),
- SeekBar.OnSeekBarChangeListener,
- View.OnCreateContextMenuListener,
- MenuItem.OnMenuItemClickListener {
+
+open class SeekbarPreference(context: Context, attrs: AttributeSet?) :
+ Preference(context, attrs),
+ View.OnCreateContextMenuListener, MenuItem.OnMenuItemClickListener {
private var mSeekbar: SeekBar? = null
@@ -45,31 +45,27 @@ open class SeekbarPreference
var mValueText: TextView? = null
@JvmField
- var min: Float = 0.toFloat()
+ var min: Float = 0f
@JvmField
- var max: Float = 0.toFloat()
+ var max: Float = 0f
@JvmField
- var current: Float = 0.toFloat()
+ var current: Float = 0f
@JvmField
- var defaultValue: Float = 0.toFloat()
+ var defaultValue: Float = 0f
private var multiplier: Int = 0
private var format: String? = null
@JvmField
var steps: Int = 100
- private var lastPersist = Float.NaN
open val allowResetToDefault = true
+ var mTrackingTouch = false
init {
layoutResource = R.layout.preference_seekbar
- init(context, attrs!!)
- }
-
- private fun init(context: Context, attrs: AttributeSet) {
val ta = context.obtainStyledAttributes(attrs, R.styleable.SeekbarPreference)
min = ta.getFloat(R.styleable.SeekbarPreference_minValue, 0f)
max = ta.getFloat(R.styleable.SeekbarPreference_maxValue, 100f)
@@ -90,7 +86,7 @@ open class SeekbarPreference
mValueText = view.findViewById(R.id.txtValue)
mSeekbar!!.max = steps
- mSeekbar!!.setOnSeekBarChangeListener(this)
+ mSeekbar!!.setOnSeekBarChangeListener(mSeekBarChangeListener)
val stateList = ColorStateList.valueOf(Utilities.getOmegaPrefs(context).accentColor)
mSeekbar!!.thumbTintList = stateList
mSeekbar!!.progressTintList = stateList
@@ -115,15 +111,7 @@ open class SeekbarPreference
val progress = ((current - min) / ((max - min) / steps))
mSeekbar!!.progress = progress.roundToInt()
updateSummary()
- mSeekbar?.setOnSeekBarChangeListener(this)
- }
-
- override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
- current = min + (max - min) / steps * progress
- current = (current * 100f).roundToInt() / 100f //round to .00 places
- updateSummary()
-
- persistFloat(current)
+ mSeekbar?.setOnSeekBarChangeListener(mSeekBarChangeListener)
}
@SuppressLint("SetTextI18n")
@@ -131,22 +119,25 @@ open class SeekbarPreference
if (format != "%.2f") {
mValueText!!.text = String.format(format!!, current * multiplier)
} else {
- mValueText!!.text = (current * multiplier).toInt().toString() + "dp"
+ mValueText!!.text = "${(current * multiplier).toInt()} dp"
}
}
- override fun onStartTrackingTouch(seekBar: SeekBar) {
-
- }
+ private val mSeekBarChangeListener = object : OnSeekBarChangeListener {
+ override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
+ current = min + (max - min) / steps * progress
+ current = (current * 100f).roundToInt() / 100f
+ updateSummary()
+ }
- override fun onStopTrackingTouch(seekBar: SeekBar) {
- persistFloat(current)
- }
+ override fun onStartTrackingTouch(seekBar: SeekBar) {
+ mTrackingTouch = true
+ }
- override fun persistFloat(value: Float): Boolean {
- if (value == lastPersist) return true
- lastPersist = value
- return super.persistFloat(value)
+ override fun onStopTrackingTouch(seekBar: SeekBar) {
+ mTrackingTouch = false
+ persistFloat(current)
+ }
}
override fun onCreateContextMenu(