mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-16 16:25:11 +00:00
changed dev settings preference
This commit is contained in:
parent
aefde31ecb
commit
46a30af955
2 changed files with 21 additions and 15 deletions
|
@ -1,10 +1,13 @@
|
||||||
package com.vanced.manager.ui.fragments
|
package com.vanced.manager.ui.fragments
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.SwitchPreference
|
import androidx.preference.SwitchPreference
|
||||||
import com.vanced.manager.R
|
import com.vanced.manager.R
|
||||||
|
import com.vanced.manager.ui.MainActivity
|
||||||
|
|
||||||
class DevSettingsFragment: PreferenceFragmentCompat() {
|
class DevSettingsFragment: PreferenceFragmentCompat() {
|
||||||
|
|
||||||
|
@ -12,24 +15,27 @@ class DevSettingsFragment: PreferenceFragmentCompat() {
|
||||||
setPreferencesFromResource(R.xml.dev_settings, rootKey)
|
setPreferencesFromResource(R.xml.dev_settings, rootKey)
|
||||||
|
|
||||||
val ftSwitch: SwitchPreference? = findPreference("firststart_switch")
|
val ftSwitch: SwitchPreference? = findPreference("firststart_switch")
|
||||||
//val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
|
||||||
|
|
||||||
//ftSwitch?.isChecked = sharedPrefs.getBoolean("firststart_switch", false)
|
|
||||||
val prefs = activity?.getSharedPreferences("prefs", AppCompatActivity.MODE_PRIVATE)
|
val prefs = activity?.getSharedPreferences("prefs", AppCompatActivity.MODE_PRIVATE)
|
||||||
val editor = prefs?.edit()
|
val editor = prefs?.edit()
|
||||||
ftSwitch?.setOnPreferenceChangeListener { _, isChecked ->
|
ftSwitch?.setOnPreferenceChangeListener { _, _ ->
|
||||||
when (isChecked) {
|
|
||||||
true -> {
|
AlertDialog.Builder(requireContext())
|
||||||
editor?.putBoolean("firstStart", true)
|
.setTitle("FirstStart activated")
|
||||||
editor?.apply()
|
.setMessage("boolean will be activated on next app start")
|
||||||
true
|
.setPositiveButton("Restart") { _, _ ->
|
||||||
|
run {
|
||||||
|
startActivity(Intent(requireContext(), MainActivity::class.java))
|
||||||
|
activity?.finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
.create()
|
||||||
editor?.putBoolean("firstStart", false)
|
.show()
|
||||||
editor?.apply()
|
|
||||||
true
|
editor?.putBoolean("firstStart", true)
|
||||||
}
|
editor?.apply()
|
||||||
}
|
true
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<SwitchPreference
|
<Preference
|
||||||
android:key="firststart_switch"
|
android:key="firststart_switch"
|
||||||
android:title="First start switcher"
|
android:title="First start switcher"
|
||||||
android:summary="Dev only please"/>
|
android:summary="Dev only please"/>
|
||||||
|
|
Loading…
Reference in a new issue