mirror of
https://github.com/YTVanced/VancedManager
synced 2025-01-06 23:41:00 +00:00
commit
229952435c
15 changed files with 150 additions and 5 deletions
|
@ -7,6 +7,11 @@ import android.view.MenuItem
|
|||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.crowdin.platform.Crowdin
|
||||
import com.crowdin.platform.LoadingStateListener
|
||||
|
@ -18,11 +23,13 @@ import com.vanced.manager.R
|
|||
import com.vanced.manager.adapter.SectionVariantAdapter
|
||||
import com.vanced.manager.databinding.ActivityMainBinding
|
||||
import com.vanced.manager.ui.dialogs.DialogContainer
|
||||
import com.vanced.manager.ui.fragments.MainFragment
|
||||
import com.vanced.manager.ui.fragments.UpdateCheckFragment
|
||||
import com.vanced.manager.utils.AppUtils.installing
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import com.vanced.manager.utils.PackageHelper
|
||||
import com.vanced.manager.utils.ThemeHelper.setFinalTheme
|
||||
import kotlinx.android.synthetic.main.fragment_main.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
|
@ -7,13 +7,17 @@ import android.view.MotionEvent
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentAboutBinding
|
||||
import com.vanced.manager.ui.viewmodels.AboutViewModel
|
||||
import kotlinx.android.synthetic.main.fragment_main.*
|
||||
|
||||
class AboutFragment : Fragment() {
|
||||
|
||||
|
@ -38,6 +42,13 @@ class AboutFragment : Fragment() {
|
|||
val viewModel: AboutViewModel by viewModels()
|
||||
binding.viewModel = viewModel
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
view.setOnTouchListener { _, event: MotionEvent ->
|
||||
|
||||
val eventAction = event.action
|
||||
|
|
|
@ -7,9 +7,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.core.content.edit
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentChosenPreferencesBinding
|
||||
import java.util.*
|
||||
|
@ -40,6 +42,14 @@ class ChosenPreferenceDialogFragment : DialogFragment() {
|
|||
newPrefs.add(loc.getDisplayLanguage(loc).capitalize(Locale.ROOT))
|
||||
}
|
||||
}
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(this, callback)
|
||||
|
||||
binding.chosenTheme.text = requireActivity().getString(R.string.chosen_theme, prefs.getString("theme", "dark")?.capitalize(Locale.ROOT))
|
||||
binding.chosenLang.text = requireActivity().getString(R.string.chosen_lang, newPrefs.joinToString())
|
||||
|
||||
|
|
|
@ -6,8 +6,10 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import androidx.preference.PreferenceManager
|
||||
|
@ -24,6 +26,13 @@ class DevSettingsFragment: PreferenceFragmentCompat() {
|
|||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(R.xml.dev_settings, rootKey)
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
val ftSwitch: Preference? = findPreference("firststart_switch")
|
||||
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(requireContext())
|
||||
|
|
|
@ -5,12 +5,14 @@ import android.os.Bundle
|
|||
import android.view.*
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.vanced.manager.R
|
||||
|
@ -56,7 +58,14 @@ open class HomeFragment : Fragment(), View.OnClickListener {
|
|||
view.findNavController().navigate(content)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
with(binding) {
|
||||
includeChangelogsLayout.changelogButton.setOnClickListener(this@HomeFragment)
|
||||
|
||||
|
|
|
@ -6,18 +6,22 @@ import android.view.MenuItem
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AnimationUtils
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.activity.addCallback
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentMainBinding
|
||||
import com.vanced.manager.ui.MainActivity
|
||||
|
||||
class MainFragment : Fragment() {
|
||||
|
||||
|
@ -32,12 +36,19 @@ class MainFragment : Fragment() {
|
|||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_main, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val navHostFragment = childFragmentManager.findFragmentById(R.id.nav_host) as NavHostFragment
|
||||
navHost = navHostFragment.navController
|
||||
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
requireActivity().finish()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
||||
requireActivity().findViewById<MaterialToolbar>(R.id.home_toolbar).setupWithNavController(navHost, appBarConfiguration)
|
||||
val tabLayout = requireActivity().findViewById<TabLayout>(R.id.main_tablayout)
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentManagerChangelogBinding
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
@ -25,4 +27,14 @@ class ManagerChangelogFragment : Fragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentMicrogChangelogBinding
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
@ -25,4 +27,14 @@ class MicrogChangelogFragment : Fragment() {
|
|||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentMusicChangelogBinding
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
@ -27,6 +29,12 @@ class MusicChangelogFragment : Fragment() {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.viewModel = viewModel
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,9 +4,13 @@ import android.os.Bundle
|
|||
import android.view.Menu
|
||||
import android.view.MenuInflater
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.*
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.vanced.manager.R
|
||||
import kotlinx.android.synthetic.main.fragment_main.*
|
||||
import java.io.File
|
||||
|
||||
class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
@ -17,6 +21,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
activity?.title = getString(R.string.title_settings)
|
||||
setHasOptionsMenu(true)
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(this, callback)
|
||||
|
||||
findPreference<Preference>("update_check")?.setOnPreferenceClickListener {
|
||||
UpdateCheckFragment().show(childFragmentManager.beginTransaction(), "Update Center")
|
||||
true
|
||||
|
|
|
@ -8,7 +8,9 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.vanced.manager.R
|
||||
|
@ -42,6 +44,14 @@ class URLChangeFragment : DialogFragment() {
|
|||
prefs.edit().putString("install_url", finalUrl).apply()
|
||||
dismiss()
|
||||
}
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
view.findViewById<MaterialButton>(R.id.url_reset).setOnClickListener {
|
||||
prefs.edit().putString("install_url", baseUrl).apply()
|
||||
dismiss()
|
||||
|
|
|
@ -14,8 +14,10 @@ import android.widget.Button
|
|||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.core.content.FileProvider
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.downloader.OnDownloadListener
|
||||
import com.downloader.PRDownloader
|
||||
import com.google.android.material.button.MaterialButton
|
||||
|
@ -46,6 +48,13 @@ class UpdateCheckFragment : DialogFragment() {
|
|||
view.findViewById<Button>(R.id.update_center_dismiss).setOnClickListener { dismiss() }
|
||||
view.findViewById<MaterialButton>(R.id.update_center_recheck).setOnClickListener{ checkUpdates() }
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
|
||||
downLoadingState(false)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.viewModels
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentVancedChangelogBinding
|
||||
import com.vanced.manager.ui.viewmodels.HomeViewModel
|
||||
|
@ -24,5 +26,14 @@ class VancedChangelogFragment : Fragment() {
|
|||
binding.viewModel = viewModel
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,11 @@ import android.view.ViewGroup
|
|||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
import android.widget.LinearLayout
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.checkbox.MaterialCheckBox
|
||||
import com.vanced.manager.R
|
||||
|
@ -36,6 +38,12 @@ class VancedLanguageSelectionFragment : Fragment() {
|
|||
@ExperimentalStdlibApi
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
val app = activity?.application as App
|
||||
langs = app.vanced?.array<String>("langs")?.value ?: mutableListOf("null")
|
||||
loadBoxes(view.findViewById(R.id.lang_button_ll))
|
||||
|
|
|
@ -7,8 +7,10 @@ import android.view.View
|
|||
import android.view.ViewGroup
|
||||
import android.widget.Button
|
||||
import android.widget.RadioGroup
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.google.android.material.radiobutton.MaterialRadioButton
|
||||
import com.vanced.manager.R
|
||||
|
||||
|
@ -24,7 +26,12 @@ class VancedThemeSelectionFragment : Fragment() {
|
|||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
val callback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
findNavController().popBackStack()
|
||||
}
|
||||
}
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, callback)
|
||||
val nextButton = view.findViewById<Button>(R.id.vanced_next_to_variant)
|
||||
val themeGroup = view.findViewById<RadioGroup>(R.id.theme_radiogroup)
|
||||
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
|
||||
|
|
Loading…
Reference in a new issue