mirror of
https://github.com/He4eT/yamf_launcher.git
synced 2026-05-04 17:37:25 +00:00
Added in a preference button for selecting the default home app
This commit is contained in:
parent
797c7203e0
commit
b05d26aa66
2 changed files with 22 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
|||
package eu.ottop.yamlauncher
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.widget.Toast
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.SwitchPreference
|
||||
|
|
@ -23,6 +26,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
rightSwipePref = findPreference("rightSwipeApp")
|
||||
val aboutPref = findPreference<Preference?>("aboutPage")
|
||||
val hiddenPref = findPreference<Preference?>("hiddenApps")
|
||||
val homePref = findPreference<Preference?>("defaultHome")
|
||||
|
||||
// Only enable manual location when gps location is disabled
|
||||
if (gpsLocationPref != null && manualLocationPref != null) {
|
||||
|
|
@ -81,6 +85,16 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
.addToBackStack(null)
|
||||
.commit()
|
||||
true }
|
||||
|
||||
homePref?.onPreferenceClickListener =
|
||||
Preference.OnPreferenceClickListener {
|
||||
val intent = Intent(Settings.ACTION_HOME_SETTINGS)
|
||||
if (intent.resolveActivity(requireContext().packageManager) != null) {
|
||||
startActivity(intent)
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Unable to launch settings", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
true }
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,14 @@
|
|||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
|
||||
<Preference
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:key="defaultHome"
|
||||
app:selectable="true"
|
||||
app:title="Set Default Home" />
|
||||
|
||||
<PreferenceCategory
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue