mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 11:45:11 +00:00
layout initialization fix
This commit is contained in:
parent
b5ee717bad
commit
7a8322eef2
19 changed files with 305 additions and 176 deletions
|
@ -0,0 +1,20 @@
|
|||
package com.vanced.manager.adapter
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.vanced.manager.ui.fragments.MicrogChangelogFragment
|
||||
import com.vanced.manager.ui.fragments.MusicChangelogFragment
|
||||
|
||||
class SectionPageMusicAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
|
||||
|
||||
override fun getItemCount(): Int = 2
|
||||
|
||||
override fun createFragment(position: Int): Fragment {
|
||||
return when (position) {
|
||||
0 -> MusicChangelogFragment()
|
||||
1 -> MicrogChangelogFragment()
|
||||
else -> throw NotImplementedError()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,11 +2,10 @@ package com.vanced.manager.adapter
|
|||
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.vanced.manager.ui.fragments.MainFragment
|
||||
|
||||
class SectionVariantAdapter(fragmentActivity: FragmentActivity): FragmentStateAdapter(fragmentActivity) {
|
||||
class SectionVariantAdapter(fragmentActivity: FragmentActivity) : FragmentStateAdapter(fragmentActivity) {
|
||||
|
||||
override fun getItemCount(): Int = 3
|
||||
|
||||
|
|
|
@ -4,11 +4,19 @@ import android.content.Context
|
|||
import android.graphics.drawable.Drawable
|
||||
import android.os.Build
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.vanced.manager.utils.InternetTools.baseUrl
|
||||
import com.vanced.manager.utils.InternetTools.getJsonInt
|
||||
import com.vanced.manager.utils.InternetTools.getJsonString
|
||||
import com.vanced.manager.utils.InternetTools.getObjectFromJson
|
||||
import com.vanced.manager.utils.PackageHelper.isPackageInstalled
|
||||
import com.vanced.manager.R
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
open class DataModel(
|
||||
private val jsonName: String,
|
||||
|
@ -24,30 +32,54 @@ open class DataModel(
|
|||
else -> "com.vanced.android.youtube.music"
|
||||
}
|
||||
|
||||
/*
|
||||
private var versionName: String = ""
|
||||
private var installedVersionName: String = ""
|
||||
private var changelog: String = ""
|
||||
|
||||
private var versionCode: Int = 0
|
||||
private var installedVersionCode: Int = 0
|
||||
*/
|
||||
|
||||
open fun isAppInstalled(): Boolean = isPackageInstalled(appPkg, context.packageManager)
|
||||
|
||||
open fun getVersionName(): String = runBlocking { getJsonString("$jsonName.json", "version", context) }
|
||||
open fun getVersionName(): String = runBlocking(Dispatchers.IO) {
|
||||
getJsonString("$jsonName.json", "version", context)
|
||||
}
|
||||
|
||||
open fun getVersionCode(): Int = runBlocking { getJsonInt("$jsonName.json", "versionCode", context) }
|
||||
open fun getVersionCode(): Int = runBlocking(Dispatchers.IO) {
|
||||
getJsonInt("$jsonName.json", "versionCode", context)
|
||||
}
|
||||
|
||||
open fun getInstalledVersionName(): String = getPkgVersion(isAppInstalled(), appPkg)
|
||||
open fun getInstalledVersionName(): String = runBlocking(Dispatchers.IO) {
|
||||
getPkgVersionName(isAppInstalled(), appPkg)
|
||||
}
|
||||
|
||||
open fun getInstalledVersionCode(): Int = runBlocking { getJsonInt("$jsonName.json", "versionCode", context) }
|
||||
open fun getInstalledVersionCode(): Int = runBlocking(Dispatchers.IO) {
|
||||
getPkgVersionCode(isAppInstalled(), appPkg)
|
||||
}
|
||||
|
||||
open fun getButtonTxt(): String = compareInt(getInstalledVersionCode(), getVersionCode())
|
||||
|
||||
open fun getButtonIcon(): Drawable? = compareIntDrawable(getInstalledVersionCode(), getVersionCode())
|
||||
|
||||
open fun getChangelog(): String = runBlocking(Dispatchers.IO) {
|
||||
if (jsonName == "vanced")
|
||||
getObjectFromJson("$baseUrl/changelog/${getVersionName().replace('.', '_')}.json", "message")
|
||||
else
|
||||
getObjectFromJson("https://ytvanced.github.io/VancedBackend/$jsonName.json", "changelog")
|
||||
}
|
||||
|
||||
private fun getPkgVersion(toCheck: Boolean, pkg: String): String {
|
||||
private fun getPkgVersionName(toCheck: Boolean, pkg: String): String {
|
||||
return if (toCheck) {
|
||||
context.packageManager.getPackageInfo(pkg, 0).versionName
|
||||
context.packageManager.getPackageInfo(pkg, 0).versionName.removeSuffix("-vanced")
|
||||
} else {
|
||||
context.getString(R.string.unavailable)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
private fun getPkgVerCode(toCheck: Boolean, pkg: String): Int {
|
||||
private fun getPkgVersionCode(toCheck: Boolean, pkg: String): Int {
|
||||
return if (toCheck) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
|
||||
context.packageManager.getPackageInfo(pkg, 0).longVersionCode.and(0xFFFFFFFF).toInt()
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.crowdin.platform.Crowdin
|
|||
import com.crowdin.platform.LoadingStateListener
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.vanced.manager.adapter.SectionVariantAdapter
|
||||
import com.google.firebase.messaging.FirebaseMessaging
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.ActivityMainBinding
|
||||
|
@ -21,7 +22,6 @@ 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 com.vanced.manager.adapter.SectionVariantAdapter
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -41,32 +41,26 @@ class MainActivity : AppCompatActivity() {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private val tabListener = object : TabLayout.OnTabSelectedListener {
|
||||
|
||||
override fun onTabSelected(tab: TabLayout.Tab) {
|
||||
getDefaultSharedPreferences(this@MainActivity).edit().apply {
|
||||
getDefaultSharedPreferences(this@MainActivity).edit().putString("vanced_variant",
|
||||
when (tab.position) {
|
||||
0 -> putString("vanced_variant", "nonroot").apply()
|
||||
1 -> putString("vanced_variant", "music").apply()
|
||||
2 -> putString("vanced_variant", "root").apply()
|
||||
1 -> "music"
|
||||
2 -> "root"
|
||||
else -> "nonroot"
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
override fun onTabUnselected(tab: TabLayout.Tab) {
|
||||
TODO("There's nothing to do here actually")
|
||||
return
|
||||
}
|
||||
|
||||
override fun onTabReselected(tab: TabLayout.Tab) {
|
||||
getDefaultSharedPreferences(this@MainActivity).edit().apply {
|
||||
when (tab.position) {
|
||||
0 -> putString("vanced_variant", "nonroot").apply()
|
||||
1 -> putString("vanced_variant", "music").apply()
|
||||
2 -> putString("vanced_variant", "root").apply()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -75,27 +69,26 @@ class MainActivity : AppCompatActivity() {
|
|||
setFinalTheme(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_main)
|
||||
val tabToSelect =
|
||||
when (getDefaultSharedPreferences(this@MainActivity).getString("vanced_variant", "nonroot")) {
|
||||
"music" -> 1
|
||||
"root" -> 2
|
||||
else -> 0
|
||||
}
|
||||
|
||||
with(binding) {
|
||||
lifecycleOwner = this@MainActivity
|
||||
setSupportActionBar(homeToolbar)
|
||||
mainViewpager.adapter = SectionVariantAdapter(this@MainActivity)
|
||||
mainViewpager.setUserInputEnabled(false)
|
||||
TabLayoutMediator(mainTablayout, mainViewpager) { tab, position ->
|
||||
when (position) {
|
||||
0 -> tab.text = "nonroot"
|
||||
1 -> tab.text = "Music"
|
||||
2 -> tab.text = "root"
|
||||
tab.text = when (position) {
|
||||
1 -> "music"
|
||||
2 -> "root"
|
||||
else -> "nonroot"
|
||||
}
|
||||
}.attach()
|
||||
|
||||
when (getDefaultSharedPreferences(this@MainActivity).getString("vanced_variant", "nonroot")) {
|
||||
"nonroot" -> mainTablayout.getTabAt(0)?.select()
|
||||
"music" -> mainTablayout.getTabAt(1)?.select()
|
||||
"root" -> mainTablayout.getTabAt(2)?.select()
|
||||
}
|
||||
|
||||
mainTablayout.addOnTabSelectedListener(tabListener)
|
||||
|
||||
mainTablayout.getTabAt(tabToSelect)?.select()
|
||||
}
|
||||
|
||||
initDialogs()
|
||||
|
@ -104,14 +97,15 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
binding.mainTablayout.removeOnTabSelectedListener(tabListener)
|
||||
Crowdin.unregisterDataLoadingObserver(loadingObserver)
|
||||
binding.mainTablayout.removeOnTabSelectedListener(tabListener)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
setFinalTheme(this)
|
||||
super.onResume()
|
||||
Crowdin.registerDataLoadingObserver(loadingObserver)
|
||||
binding.mainTablayout.addOnTabSelectedListener(tabListener)
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
|
|
|
@ -13,6 +13,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
|||
import androidx.navigation.findNavController
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.google.android.material.tabs.TabLayoutMediator
|
||||
import com.topjohnwu.superuser.Shell
|
||||
import com.vanced.manager.R
|
||||
|
@ -47,53 +48,61 @@ class HomeFragment : Fragment(), View.OnClickListener {
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
binding.viewModel = viewModel
|
||||
|
||||
val arg = "variant"
|
||||
|
||||
val variant = getDefaultSharedPreferences(requireActivity()).getString("vanced_variant", "nonroot")
|
||||
|
||||
val selectedTab = requireActivity().findViewById<TabLayout>(R.id.main_tablayout).getSelectedTabPosition()
|
||||
|
||||
with(binding) {
|
||||
when (variant) {
|
||||
"nonroot" -> includeMusicLayout.musicCard.visibility = View.GONE
|
||||
"music" -> includeVancedLayout.vancedCard.visibility = View.GONE
|
||||
"root" -> {
|
||||
when (selectedTab) {
|
||||
1 -> includeVancedLayout.vancedCard.visibility = View.GONE
|
||||
2 -> {
|
||||
includeMusicLayout.musicCard.visibility = View.GONE
|
||||
includeMicrogLayout.microgCard.visibility = View.GONE
|
||||
}
|
||||
else -> includeMusicLayout.musicCard.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
with(binding) {
|
||||
|
||||
includeVancedLayout.vancedInstallbtn.setOnClickListener(this@HomeFragment)
|
||||
includeVancedLayout.vancedUninstallbtn.setOnClickListener(this@HomeFragment)
|
||||
includeMicrogLayout.microgInstallbtn.setOnClickListener(this@HomeFragment)
|
||||
includeMicrogLayout.microgUninstallbtn.setOnClickListener(this@HomeFragment)
|
||||
includeChangelogsLayout.changelogButton.setOnClickListener(this@HomeFragment)
|
||||
}
|
||||
|
||||
binding.includeVancedLayout.vancedCard.setOnLongClickListener {
|
||||
versionToast("Vanced", viewModel.vanced.get()?.getInstalledVersionName()!!)
|
||||
true
|
||||
}
|
||||
includeVancedLayout.vancedCard.setOnLongClickListener {
|
||||
versionToast("Vanced", viewModel?.vanced?.get()?.getInstalledVersionName()!!)
|
||||
true
|
||||
}
|
||||
|
||||
binding.includeMicrogLayout.microgCard.setOnLongClickListener {
|
||||
versionToast("MicroG", viewModel.microg.get()?.getInstalledVersionName()!!)
|
||||
true
|
||||
includeMicrogLayout.microgCard.setOnLongClickListener {
|
||||
versionToast("MicroG", viewModel?.microg?.get()?.getInstalledVersionName()!!)
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
with(binding.includeChangelogsLayout) {
|
||||
viewpager.adapter = if (variant == "root") SectionPageRootAdapter(this@HomeFragment) else SectionPageAdapter(this@HomeFragment)
|
||||
viewpager.adapter =
|
||||
when (selectedTab) {
|
||||
1 -> SectionPageMusicAdapter(this@HomeFragment)
|
||||
2 -> SectionPageRootAdapter(this@HomeFragment)
|
||||
else -> SectionPageAdapter(this@HomeFragment)
|
||||
}
|
||||
TabLayoutMediator(tablayout, viewpager) { tab, position ->
|
||||
if (variant == "root")
|
||||
when (position) {
|
||||
0 -> tab.text = "Vanced"
|
||||
1 -> tab.text = "Manager"
|
||||
}
|
||||
else
|
||||
when (position) {
|
||||
0 -> tab.text = "Vanced"
|
||||
1 -> tab.text = "MicroG"
|
||||
2 -> tab.text = "Manager"
|
||||
}
|
||||
tab.text =
|
||||
when (selectedTab) {
|
||||
1 -> when (position) {
|
||||
0 -> "Vanced"
|
||||
else -> "Manager"
|
||||
}
|
||||
2 -> when (position) {
|
||||
0 -> "Music"
|
||||
else -> "MicroG"
|
||||
}
|
||||
else -> when (position) {
|
||||
0 -> "Vanced"
|
||||
1 -> "MicroG"
|
||||
else -> "Manager"
|
||||
}
|
||||
}
|
||||
|
||||
}.attach()
|
||||
}
|
||||
|
|
|
@ -9,18 +9,21 @@ import android.view.animation.AnimationUtils
|
|||
import android.widget.LinearLayout
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.AppBarConfiguration
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.vanced.manager.databinding.FragmentMainBinding
|
||||
import com.vanced.manager.R
|
||||
|
||||
class MainFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentMainBinding
|
||||
private val navHost by lazy { activity?.findNavController(R.id.nav_host) }
|
||||
private lateinit var navHost: NavController
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
|
@ -33,42 +36,51 @@ class MainFragment : Fragment() {
|
|||
|
||||
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 appBarConfiguration = AppBarConfiguration(navHost?.graph!!)
|
||||
activity?.findViewById<MaterialToolbar>(R.id.home_toolbar)?.setupWithNavController(navHost!!, appBarConfiguration)
|
||||
val appBarConfiguration = AppBarConfiguration(navHost.graph)
|
||||
requireActivity().findViewById<MaterialToolbar>(R.id.home_toolbar).setupWithNavController(navHost, appBarConfiguration)
|
||||
val tabLayout = requireActivity().findViewById<TabLayout>(R.id.main_tablayout)
|
||||
|
||||
navHost?.addOnDestinationChangedListener { _, currFrag: NavDestination, _ ->
|
||||
setDisplayHomeAsUpEnabled(currFrag.id != R.id.home_fragment)
|
||||
with (activity) {
|
||||
val tabHide = this.let { AnimationUtils.loadAnimation(it, R.anim.tablayout_exit) }
|
||||
val tabShow = this.let { AnimationUtils.loadAnimation(it, R.anim.tablayout_enter) }
|
||||
with (requireActivity()) {
|
||||
val tabHide = AnimationUtils.loadAnimation(this, R.anim.tablayout_exit)
|
||||
val tabShow = AnimationUtils.loadAnimation(this, R.anim.tablayout_enter)
|
||||
if (currFrag.id != R.id.home_fragment) {
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.startAnimation(tabHide)
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.visibility = View.GONE
|
||||
if (tabLayout.visibility != View.GONE) {
|
||||
tabLayout.startAnimation(tabHide)
|
||||
tabLayout.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.visibility = View.VISIBLE
|
||||
this?.findViewById<LinearLayout>(R.id.variant_tab_container)?.startAnimation(tabShow)
|
||||
if (tabLayout.visibility != View.VISIBLE) {
|
||||
tabLayout.visibility = View.VISIBLE
|
||||
tabLayout.startAnimation(tabShow)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setDisplayHomeAsUpEnabled(isNeeded: Boolean) {
|
||||
activity?.findViewById<MaterialToolbar>(R.id.home_toolbar)?.navigationIcon = if (isNeeded) activity?.getDrawable(R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
with(requireActivity()) {
|
||||
findViewById<MaterialToolbar>(R.id.home_toolbar).navigationIcon = if (isNeeded) getDrawable(R.drawable.ic_keyboard_backspace_black_24dp) else null
|
||||
}
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
when (item.itemId) {
|
||||
R.id.toolbar_about -> {
|
||||
navHost?.navigate(R.id.toAboutFragment)
|
||||
navHost.navigate(R.id.toAboutFragment)
|
||||
return true
|
||||
}
|
||||
R.id.toolbar_settings -> {
|
||||
navHost?.navigate(R.id.action_settingsFragment)
|
||||
navHost.navigate(R.id.action_settingsFragment)
|
||||
return true
|
||||
}
|
||||
R.id.dev_settings -> {
|
||||
navHost?.navigate(R.id.toDevSettingsFragment)
|
||||
navHost.navigate(R.id.toDevSettingsFragment)
|
||||
return true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
|
|
|
@ -4,28 +4,21 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import com.vanced.manager.databinding.FragmentManagerChangelogBinding
|
||||
|
||||
class ManagerChangelogFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentManagerChangelogBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_manager_changelog, container, false)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_manager_changelog, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val changelog = InternetTools.getObjectFromJson("https://ytvanced.github.io/VancedBackend/manager.json", "changelog")
|
||||
view.findViewById<TextView>(R.id.manager_changelog).text = changelog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,29 +4,21 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import com.vanced.manager.databinding.FragmentMicrogChangelogBinding
|
||||
|
||||
class MicrogChangelogFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentMicrogChangelogBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_microg_changelog, container, false)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_microg_changelog, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
|
||||
view.findViewById<TextView>(R.id.microg_changelog).text = InternetTools.getObjectFromJson("$baseUrl/microg.json", "changelog")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.databinding.FragmentMicrogChangelogBinding
|
||||
|
||||
class MusicChangelogFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentMicrogChangelogBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_music_changelog, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
}
|
|
@ -4,32 +4,21 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.vanced.manager.R
|
||||
import com.vanced.manager.utils.InternetTools
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import com.vanced.manager.databinding.FragmentVancedChangelogBinding
|
||||
|
||||
class VancedChangelogFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentVancedChangelogBinding
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
return inflater.inflate(R.layout.fragment_vanced_changelog, container, false)
|
||||
binding = DataBindingUtil.inflate(inflater, R.layout.fragment_vanced_changelog, container, false)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
val vancedVersion = activity?.let { InternetTools.getJsonString("vanced.json", "version", it).replace('.', '_') }
|
||||
val baseUrl = PreferenceManager.getDefaultSharedPreferences(activity).getString("install_url", InternetTools.baseUrl)
|
||||
|
||||
val changelog = InternetTools.getObjectFromJson("$baseUrl/changelog/$vancedVersion.json", "message")
|
||||
view.findViewById<TextView>(R.id.vanced_changelog).text = changelog
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.browser.customtabs.CustomTabsIntent
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.ContextCompat.startActivity
|
||||
import androidx.databinding.ObservableField
|
||||
import androidx.databinding.ObservableBoolean
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
|
||||
import com.crowdin.platform.Crowdin
|
||||
|
@ -25,19 +26,21 @@ open class HomeViewModel(application: Application): AndroidViewModel(application
|
|||
|
||||
//val variant = getDefaultSharedPreferences(application).getString("vanced_variant", "nonroot")
|
||||
|
||||
val fetching = ObservableField<Boolean>()
|
||||
val fetching = ObservableBoolean()
|
||||
|
||||
val vanced = ObservableField<DataModel>()
|
||||
val microg = ObservableField<DataModel>()
|
||||
val music = ObservableField<DataModel>()
|
||||
val manager = ObservableField<DataModel>()
|
||||
|
||||
fun fetchData() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
fetching.set(true)
|
||||
Crowdin.forceUpdate(getApplication())
|
||||
vanced.set(DataModel("vanced.json", getApplication()))
|
||||
microg.set(DataModel("microg.json", getApplication()))
|
||||
music.set(DataModel("music.json", getApplication()))
|
||||
vanced.set(DataModel("vanced", getApplication()))
|
||||
microg.set(DataModel("microg", getApplication()))
|
||||
music.set(DataModel("music", getApplication()))
|
||||
manager.set(DataModel("manager", getApplication()))
|
||||
fetching.set(false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,14 +28,15 @@
|
|||
<LinearLayout
|
||||
android:id="@+id/variant_tab_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/home_appbar"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.tabs.TabLayout
|
||||
android:id="@+id/main_tablayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorSurfaceVariant"
|
||||
android:background="?colorSurface"
|
||||
app:tabIndicatorColor="?colorPrimary"
|
||||
app:tabSelectedTextColor="?colorPrimary"
|
||||
app:tabTextColor="?colorPrimary" />
|
||||
|
@ -46,7 +47,7 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:orientation="vertical">
|
||||
|
||||
<include
|
||||
android:id="@+id/include_vanced_layout"
|
||||
|
|
|
@ -4,20 +4,22 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<LinearLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/nav_host"
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:defaultNavHost="true"
|
||||
app:navGraph="@navigation/mobile_navigation"
|
||||
tools:context=".ui.fragments.MainFragment" />
|
||||
app:navGraph="@navigation/mobile_navigation" />
|
||||
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</layout>
|
||||
|
|
|
@ -1,16 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragments.MicrogChangelogFragment">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/manager_changelog"
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:text="" />
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp"
|
||||
android:text="@{viewModel.manager.changelog}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
|
|
@ -1,18 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragments.MicrogChangelogFragment">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/microg_changelog"
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:text="Changes:\n - Added casting support\n
|
||||
- Fixed notifications\n\nMicroG now requires Vanced 14.21.54 and up"
|
||||
tools:ignore="HardcodedText" />
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragments.MicrogChangelogFragment">
|
||||
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp"
|
||||
android:text="@{viewModel.microg.changelog}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
|
27
app/src/main/res/layout/fragment_music_changelog.xml
Normal file
27
app/src/main/res/layout/fragment_music_changelog.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragments.MusicChangelogFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp"
|
||||
android:text="@{viewModel.music.changelog}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
|
@ -1,15 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
<layout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.fragments.VancedChangelogFragment">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/vanced_changelog"
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="com.vanced.manager.ui.viewmodels.HomeViewModel" />
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp" />
|
||||
tools:context=".ui.fragments.VancedChangelogFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:textSize="16sp"
|
||||
android:text="@{viewModel.vanced.changelog}"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
||||
</FrameLayout>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<TextView
|
||||
android:id="@+id/microg_installed_version"
|
||||
style="@style/AppVer.Bold"
|
||||
android:text="@{viewModel.microg.installedVersionCode}" />
|
||||
android:text="@{viewModel.microg.installedVersionName}" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
Loading…
Reference in a new issue