Prepare to add grid and icon size customisation

This commit is contained in:
Patryk Michalik
2021-03-02 23:47:08 +01:00
parent da3b5a9975
commit 06afdc137c
8 changed files with 164 additions and 1 deletions
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomSeekBarPreference">
<attr name="minValue" format="integer" />
<attr name="maxValue" format="integer" />
</declare-styleable>
</resources>
+36
View File
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lawnchair="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_app_drawer_icon_size"
android:title="Icon Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:key="pref_app_drawer_grid_width"
android:title="Grid Width"
app:showSeekBarValue="true"
lawnchair:minValue="3"
lawnchair:maxValue="7" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:key="pref_app_drawer_grid_height"
android:title="Grid Height"
app:showSeekBarValue="true"
lawnchair:minValue="4"
lawnchair:maxValue="10" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_app_drawer_label_size"
android:title="Label Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
</PreferenceScreen>
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:lawnchair="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto">
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_dock_icon_size"
android:title="Icon Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:key="pref_dock_icon_count"
android:title="Icon Count"
app:showSeekBarValue="true"
lawnchair:minValue="3"
lawnchair:maxValue="7" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_dock_label_size"
android:title="Label Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
</PreferenceScreen>
+32 -1
View File
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:lawnchair="http://schemas.android.com/apk/res-auto">
<SwitchPreference
android:key="pref_add_icon_to_home"
@@ -23,4 +24,34 @@
android:defaultValue="false"
android:persistent="true" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_home_screen_icon_size"
android:title="Icon Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:key="pref_home_screen_grid_width"
android:title="Grid Width"
app:showSeekBarValue="true"
lawnchair:minValue="3"
lawnchair:maxValue="7" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:key="pref_home_screen_grid_height"
android:title="Grid Height"
app:showSeekBarValue="true"
lawnchair:minValue="4"
lawnchair:maxValue="10" />
<ch.deletescape.lawnchair.settings.ui.preferences.CustomSeekBarPreference
android:defaultValue="100"
android:key="pref_home_screen_label_size"
android:title="Label Size"
app:showSeekBarValue="true"
lawnchair:minValue="50"
lawnchair:maxValue="150" />
</androidx.preference.PreferenceScreen>
+10
View File
@@ -14,4 +14,14 @@
android:icon="@drawable/ic_home_screen"
android:fragment="ch.deletescape.lawnchair.settings.fragments.HomeScreenSettingsFragment" />
<Preference
android:title="Dock"
android:summary="TBD"
android:fragment="ch.deletescape.lawnchair.settings.fragments.DockSettingsFragment" />
<Preference
android:title="App Drawer"
android:summary="TBD"
android:fragment="ch.deletescape.lawnchair.settings.fragments.AppDrawerSettingsFragment" />
</androidx.preference.PreferenceScreen>
@@ -0,0 +1,8 @@
package ch.deletescape.lawnchair.settings.fragments
import com.android.launcher3.R
class AppDrawerSettingsFragment : BasePreferenceFragment(R.xml.app_drawer_settings, false, true) {
override val title: String
get() = "App Drawer"
}
@@ -0,0 +1,8 @@
package ch.deletescape.lawnchair.settings.fragments
import com.android.launcher3.R
class DockSettingsFragment : BasePreferenceFragment(R.xml.dock_settings, false, true) {
override val title: String
get() = "Dock"
}
@@ -0,0 +1,34 @@
package ch.deletescape.lawnchair.settings.ui.preferences
import android.content.Context
import android.util.AttributeSet
import android.util.Log
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
import androidx.preference.SeekBarPreference
import com.android.launcher3.R
class CustomSeekBarPreference(context: Context, attrs: AttributeSet? = null) : SeekBarPreference(context, attrs), Preference.OnPreferenceChangeListener {
private val minValue: Int
private val maxValue: Int
init {
context.obtainStyledAttributes(attrs, R.styleable.CustomSeekBarPreference).apply {
minValue = this.getInt(R.styleable.CustomSeekBarPreference_minValue, 10)
maxValue = this.getInt(R.styleable.CustomSeekBarPreference_maxValue, 100)
recycle()
}
}
override fun onBindViewHolder(view: PreferenceViewHolder?) {
super.onBindViewHolder(view)
onPreferenceChangeListener = this
Log.i(null, "$minValue")
}
override fun onPreferenceChange(preference: Preference?, newValue: Any?): Boolean {
TODO("Not yet implemented")
}
}