mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-05 15:01:01 +00:00
bug fixes
This commit is contained in:
parent
5c7b953fb4
commit
365fb4aede
2 changed files with 15 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
package com.vanced.manager.ui.core
|
package com.vanced.manager.ui.core
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.SharedPreferences
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.widget.CompoundButton
|
import android.widget.CompoundButton
|
||||||
|
@ -31,6 +32,12 @@ class PreferenceSwitch @JvmOverloads constructor(
|
||||||
|
|
||||||
private var mListener: OnCheckedListener? = null
|
private var mListener: OnCheckedListener? = null
|
||||||
|
|
||||||
|
private val prefListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
|
||||||
|
if (key == prefKey) {
|
||||||
|
binding.preferenceSwitch.isChecked = sharedPreferences.getBoolean(key, defValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var _binding: ViewPreferenceSwitchBinding? = null
|
private var _binding: ViewPreferenceSwitchBinding? = null
|
||||||
|
|
||||||
val binding: ViewPreferenceSwitchBinding
|
val binding: ViewPreferenceSwitchBinding
|
||||||
|
@ -38,11 +45,7 @@ class PreferenceSwitch @JvmOverloads constructor(
|
||||||
|
|
||||||
init {
|
init {
|
||||||
_binding = ViewPreferenceSwitchBinding.inflate(LayoutInflater.from(context), this, true)
|
_binding = ViewPreferenceSwitchBinding.inflate(LayoutInflater.from(context), this, true)
|
||||||
prefs.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
|
prefs.registerOnSharedPreferenceChangeListener(prefListener)
|
||||||
if (key == prefKey) {
|
|
||||||
binding.preferenceSwitch.isChecked = sharedPreferences.getBoolean(key, defValue)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
attrs?.let { mAttrs ->
|
attrs?.let { mAttrs ->
|
||||||
with(context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceSwitch, 0, 0)) {
|
with(context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceSwitch, 0, 0)) {
|
||||||
val title = getText(R.styleable.PreferenceSwitch_switch_title)
|
val title = getText(R.styleable.PreferenceSwitch_switch_title)
|
||||||
|
|
|
@ -7,6 +7,7 @@ import android.view.MenuInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.fragment.app.FragmentActivity
|
||||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.firebase.analytics.FirebaseAnalytics
|
import com.google.firebase.analytics.FirebaseAnalytics
|
||||||
|
@ -34,6 +35,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
||||||
private val prefs by lazy { getDefaultSharedPreferences(requireActivity()) }
|
private val prefs by lazy { getDefaultSharedPreferences(requireActivity()) }
|
||||||
|
|
||||||
private lateinit var variant: String
|
private lateinit var variant: String
|
||||||
|
private lateinit var parentActivity: FragmentActivity
|
||||||
|
|
||||||
override fun binding(
|
override fun binding(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
@ -43,6 +45,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
||||||
|
|
||||||
override fun otherSetups() {
|
override fun otherSetups() {
|
||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
parentActivity = requireActivity()
|
||||||
bindData()
|
bindData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,8 +66,8 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
||||||
|
|
||||||
private fun FragmentSettingsBinding.bindRecycler() {
|
private fun FragmentSettingsBinding.bindRecycler() {
|
||||||
notificationsRecycler.apply {
|
notificationsRecycler.apply {
|
||||||
layoutManager = LinearLayoutManager(requireActivity())
|
layoutManager = LinearLayoutManager(parentActivity)
|
||||||
adapter = GetNotifAdapter(requireActivity())
|
adapter = GetNotifAdapter(parentActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
||||||
firebase.setOnCheckedListener { _, isChecked ->
|
firebase.setOnCheckedListener { _, isChecked ->
|
||||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(isChecked)
|
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(isChecked)
|
||||||
FirebasePerformance.getInstance().isPerformanceCollectionEnabled = isChecked
|
FirebasePerformance.getInstance().isPerformanceCollectionEnabled = isChecked
|
||||||
FirebaseAnalytics.getInstance(requireActivity()).setAnalyticsCollectionEnabled(isChecked)
|
FirebaseAnalytics.getInstance(parentActivity).setAnalyticsCollectionEnabled(isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +131,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
||||||
private fun FragmentSettingsBinding.bindManagerLanguage() {
|
private fun FragmentSettingsBinding.bindManagerLanguage() {
|
||||||
val langPref = prefs.getString("manager_lang", "System Default")
|
val langPref = prefs.getString("manager_lang", "System Default")
|
||||||
managerLanguage.apply {
|
managerLanguage.apply {
|
||||||
setSummary(getLanguageFormat(requireActivity(), requireNotNull(langPref)))
|
setSummary(getLanguageFormat(parentActivity, requireNotNull(langPref)))
|
||||||
setOnClickListener { showDialog(ManagerLanguageDialog()) }
|
setOnClickListener { showDialog(ManagerLanguageDialog()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue