mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-03 14:10:59 +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
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.widget.CompoundButton
|
||||
|
@ -31,6 +32,12 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
|
||||
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
|
||||
|
||||
val binding: ViewPreferenceSwitchBinding
|
||||
|
@ -38,11 +45,7 @@ class PreferenceSwitch @JvmOverloads constructor(
|
|||
|
||||
init {
|
||||
_binding = ViewPreferenceSwitchBinding.inflate(LayoutInflater.from(context), this, true)
|
||||
prefs.registerOnSharedPreferenceChangeListener { sharedPreferences, key ->
|
||||
if (key == prefKey) {
|
||||
binding.preferenceSwitch.isChecked = sharedPreferences.getBoolean(key, defValue)
|
||||
}
|
||||
}
|
||||
prefs.registerOnSharedPreferenceChangeListener(prefListener)
|
||||
attrs?.let { mAttrs ->
|
||||
with(context.obtainStyledAttributes(mAttrs, R.styleable.PreferenceSwitch, 0, 0)) {
|
||||
val title = getText(R.styleable.PreferenceSwitch_switch_title)
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.view.MenuInflater
|
|||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.firebase.analytics.FirebaseAnalytics
|
||||
|
@ -34,6 +35,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
|||
private val prefs by lazy { getDefaultSharedPreferences(requireActivity()) }
|
||||
|
||||
private lateinit var variant: String
|
||||
private lateinit var parentActivity: FragmentActivity
|
||||
|
||||
override fun binding(
|
||||
inflater: LayoutInflater,
|
||||
|
@ -43,6 +45,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
|||
|
||||
override fun otherSetups() {
|
||||
setHasOptionsMenu(true)
|
||||
parentActivity = requireActivity()
|
||||
bindData()
|
||||
}
|
||||
|
||||
|
@ -63,8 +66,8 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
|||
|
||||
private fun FragmentSettingsBinding.bindRecycler() {
|
||||
notificationsRecycler.apply {
|
||||
layoutManager = LinearLayoutManager(requireActivity())
|
||||
adapter = GetNotifAdapter(requireActivity())
|
||||
layoutManager = LinearLayoutManager(parentActivity)
|
||||
adapter = GetNotifAdapter(parentActivity)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +75,7 @@ class SettingsFragment : BindingFragment<FragmentSettingsBinding>() {
|
|||
firebase.setOnCheckedListener { _, isChecked ->
|
||||
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(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() {
|
||||
val langPref = prefs.getString("manager_lang", "System Default")
|
||||
managerLanguage.apply {
|
||||
setSummary(getLanguageFormat(requireActivity(), requireNotNull(langPref)))
|
||||
setSummary(getLanguageFormat(parentActivity, requireNotNull(langPref)))
|
||||
setOnClickListener { showDialog(ManagerLanguageDialog()) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue