Settings have all options now (not functional).

This commit is contained in:
ottoptj 2024-07-31 01:19:07 +03:00
commit 40c3e2dd72
7 changed files with 174 additions and 18 deletions

View file

@ -0,0 +1,31 @@
package eu.ottop.yamlauncher
import android.content.Context
import android.util.AttributeSet
import androidx.preference.Preference
import androidx.preference.PreferenceViewHolder
class ButtonPreference(context: Context?, attrs: AttributeSet?) :
Preference(context!!, attrs) {
init {
widgetLayoutResource = R.layout.location_button;
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindViewHolder(holder)
val view = holder.itemView
view.setOnClickListener {
when (this.key) {
"manual_location" -> {
println("Location pressed")
}
"hidden_apps" -> {
println("Hidden apps pressed")
}
}
}
}
}

View file

@ -16,7 +16,7 @@ class SettingsActivity : AppCompatActivity() {
setContentView(binding.root)
supportFragmentManager
.beginTransaction()
.replace(R.id.settingsLayout, SettingsFragment())
.replace(R.id.settings_layout, SettingsFragment())
.commit()
}

View file

@ -1,11 +1,29 @@
package eu.ottop.yamlauncher
import android.os.Bundle
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SwitchPreference
class SettingsFragment : PreferenceFragmentCompat() {
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
setPreferencesFromResource(R.xml.root_preferences, rootKey)
val gpsLocationPref: SwitchPreference? = findPreference("gps_location")
val manualLocationPref: ButtonPreference? = findPreference("manual_location")
if (gpsLocationPref != null && manualLocationPref != null) {
// Initial setup
manualLocationPref.isEnabled = !gpsLocationPref.isChecked
// Set up a listener to update the enabled state of manualLocationPref
gpsLocationPref.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, newValue ->
val isGpsEnabled = newValue as Boolean
manualLocationPref.isEnabled = !isGpsEnabled
true // Returning true means the change is persisted
}
}
}
}

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/settingsLayout"
@ -9,6 +9,17 @@
android:orientation="vertical"
tools:context=".SettingsActivity">
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/settings_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -449,4 +460,4 @@
tools:layout_editor_absoluteY="810dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/location_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

View file

@ -27,4 +27,10 @@
<item>Medium</item>
<item>Large</item>
</string-array>
<string-array name="size_values">
<item>small</item>
<item>medium</item>
<item>large</item>
</string-array>
</resources>

View file

@ -1,7 +1,9 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="Alignment">
<PreferenceCategory
app:allowDividerAbove="false"
app:title="Alignment">
<ListPreference
app:defaultValue="left"
@ -25,7 +27,7 @@
app:defaultValue="left"
app:entries="@array/h_alignment_options"
app:entryValues="@array/h_alignment_values"
app:key="aappMenuAlignment"
app:key="appMenuAlignment"
app:title="App Menu Alignment"
app:useSimpleSummaryProvider="true" />
<ListPreference
@ -40,19 +42,102 @@
</PreferenceCategory>
<PreferenceCategory app:title="@string/sync_header">
<SwitchPreferenceCompat
app:key="sync"
app:title="@string/sync_title" />
<SwitchPreferenceCompat
app:dependency="sync"
app:key="attachment"
app:summaryOff="@string/attachment_summary_off"
app:summaryOn="@string/attachment_summary_on"
app:title="@string/attachment_title" />
<PreferenceCategory
app:allowDividerAbove="false"
app:title="Dimensions">
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:defaultValue="medium"
app:entries="@array/size_options"
app:entryValues="@array/size_values"
app:key="clockSize"
app:title="Clock Size"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:defaultValue="medium"
app:entries="@array/size_options"
app:entryValues="@array/size_values"
app:key="dateSize"
app:title="Date Size"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:defaultValue="medium"
app:entries="@array/size_options"
app:entryValues="@array/size_values"
app:key="shortcutSize"
app:title="Home App Size"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:defaultValue="medium"
app:entries="@array/size_options"
app:entryValues="@array/size_values"
app:key="appMenuSize"
app:title="App Menu Size"
app:useSimpleSummaryProvider="true" />
<ListPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:defaultValue="medium"
app:entries="@array/size_options"
app:entryValues="@array/size_values"
app:key="searchSize"
app:title="Search Size"
app:useSimpleSummaryProvider="true" />
</PreferenceCategory>
<PreferenceCategory
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:allowDividerAbove="false"
app:title="Gestures">
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:title="Camera Swipe Left"
app:key="cameraSwipe" />
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="true"
android:title="Phone Swipe Right"
app:key="phoneSwipe" />
</PreferenceCategory>
<PreferenceCategory
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:allowDividerAbove="false"
app:title="Weather">
<SwitchPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:defaultValue="false"
android:title="GPS Location"
app:key="gps_location" />
<eu.ottop.yamlauncher.ButtonPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:key="manual_location"
app:selectable="true"
app:title="Set Manual Location" />
</PreferenceCategory>
<PreferenceCategory
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:allowDividerAbove="false"
app:title="Hidden Apps">
<eu.ottop.yamlauncher.ButtonPreference
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:key="hidden_apps"
app:selectable="true"
app:title="Manage Hidden Apps" />
</PreferenceCategory>
</PreferenceScreen>