From 5db787d642aac7776cd5abd563f77f507e58b72a Mon Sep 17 00:00:00 2001 From: X1nto Date: Fri, 22 May 2020 18:28:24 +0400 Subject: [PATCH] moved manager changelog to home page --- .../manager/adapter/SectionPageAdapter.kt | 2 ++ .../manager/ui/fragments/HomeFragment.kt | 1 + .../ui/fragments/ManagerChangelogFragment.kt | 35 +++++++++++++++++++ .../ui/fragments/UpdateCheckFragment.kt | 7 ---- .../res/layout/fragment_manager_changelog.xml | 16 +++++++++ .../main/res/layout/fragment_update_check.xml | 17 --------- 6 files changed, 54 insertions(+), 24 deletions(-) create mode 100644 app/src/main/java/com/vanced/manager/ui/fragments/ManagerChangelogFragment.kt create mode 100644 app/src/main/res/layout/fragment_manager_changelog.xml diff --git a/app/src/main/java/com/vanced/manager/adapter/SectionPageAdapter.kt b/app/src/main/java/com/vanced/manager/adapter/SectionPageAdapter.kt index 90b19419..2d81450d 100644 --- a/app/src/main/java/com/vanced/manager/adapter/SectionPageAdapter.kt +++ b/app/src/main/java/com/vanced/manager/adapter/SectionPageAdapter.kt @@ -2,6 +2,7 @@ package com.vanced.manager.adapter import androidx.fragment.app.Fragment import androidx.viewpager2.adapter.FragmentStateAdapter +import com.vanced.manager.ui.fragments.ManagerChangelogFragment import com.vanced.manager.ui.fragments.MicrogChangelogFragment import com.vanced.manager.ui.fragments.VancedChangelogFragment @@ -17,6 +18,7 @@ class SectionPageAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) { when (position) { 0 -> fragment = VancedChangelogFragment() 1 -> fragment = MicrogChangelogFragment() + 2 -> fragment = ManagerChangelogFragment() } return fragment!! } diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt index 145aaac7..bed41a8c 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt @@ -49,6 +49,7 @@ class HomeFragment : Home() { when (position) { 0 -> tab.text = "Vanced" 1 -> tab.text = "MicroG" + 2 -> tab.text = "Manager" } }.attach() diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/ManagerChangelogFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/ManagerChangelogFragment.kt new file mode 100644 index 00000000..b2d63f85 --- /dev/null +++ b/app/src/main/java/com/vanced/manager/ui/fragments/ManagerChangelogFragment.kt @@ -0,0 +1,35 @@ +package com.vanced.manager.ui.fragments + +import android.os.Bundle +import androidx.fragment.app.Fragment +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import com.dezlum.codelabs.getjson.GetJson +import com.vanced.manager.R + +/** + * A simple [Fragment] subclass. + */ +class ManagerChangelogFragment : Fragment() { + + override fun onCreateView( + inflater: LayoutInflater, container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + return inflater.inflate(R.layout.fragment_manager_changelog, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + + val changelogTxt = view.findViewById(R.id.manager_changelog) + + val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json") + val changelog = checkUrl.get("versionCode").asString + + if (GetJson().isConnected(requireContext())) + changelogTxt.text = changelog + } +} diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt index 94e6efd2..0342c410 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/UpdateCheckFragment.kt @@ -54,17 +54,12 @@ class UpdateCheckFragment : DialogFragment() { val recheckbtn = view.findViewById