0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-22 19:25:11 +00:00

app optimisation and small features

This commit is contained in:
X1nto 2020-05-30 21:00:45 +04:00
parent c2f7332d1f
commit 7ef1acc38d
5 changed files with 37 additions and 20 deletions

View file

@ -57,7 +57,7 @@ open class ThemedActivity : AppCompatActivity() {
when (currentTheme) {
"Light" -> setLightAccent(currentAccent)
"Dark" -> setDarkAccent(currentAccent)
"Follow" -> {
"Follow System" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> setDarkAccent(currentAccent)
Configuration.UI_MODE_NIGHT_NO -> setLightAccent(currentAccent)

View file

@ -1,6 +1,7 @@
package com.vanced.manager.ui.fragments
import android.animation.ObjectAnimator
import android.content.Context
import android.os.Bundle
import android.view.*
import android.widget.TextView
@ -73,11 +74,11 @@ class HomeFragment : Home() {
val pm = activity?.packageManager
val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) }
val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) }
val microginstallbtn = view?.findViewById<MaterialButton>(R.id.microg_installbtn)
val vancedinstallbtn = view?.findViewById<MaterialButton>(R.id.vanced_installbtn)
val vancedLatestTxt = view?.findViewById<TextView>(R.id.vanced_latest_version)
val microgLatestTxt = view?.findViewById<TextView>(R.id.microg_latest_version)
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
val prefs = activity?.getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val variant = prefs?.getString("vanced_variant", "nonroot")
disposable = ReactiveNetwork.observeInternetConnectivity()
.subscribeOn(Schedulers.io())
@ -86,7 +87,6 @@ class HomeFragment : Home() {
run {
if (isConnectedToInternet) {
vancedinstallbtn?.visibility = View.VISIBLE
microginstallbtn?.visibility = View.VISIBLE
val vancedRemoteVer =
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json")
@ -95,16 +95,24 @@ class HomeFragment : Home() {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json")
.get("version").asString
vancedLatestTxt?.text = vancedRemoteVer
microgLatestTxt?.text = microgRemoteVer
if (microgStatus!!) {
val microgVer =
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
if (microgRemoteVer == microgVer) {
microginstallbtn?.text =
activity?.getString(R.string.button_installed)
microginstallbtn?.icon =
activity?.getDrawable(R.drawable.outline_cloud_done_24)
if (variant == "nonroot") {
val microgLatestTxt =
view?.findViewById<TextView>(R.id.microg_latest_version)
val microginstallbtn =
view?.findViewById<MaterialButton>(R.id.microg_installbtn)
microginstallbtn?.visibility = View.VISIBLE
microgLatestTxt?.text = microgRemoteVer
if (microgStatus!!) {
val microgVer =
pm.getPackageInfo("com.mgoogle.android.gms", 0).versionName
if (microgRemoteVer == microgVer) {
microginstallbtn?.text =
activity?.getString(R.string.button_installed)
microginstallbtn?.icon =
activity?.getDrawable(R.drawable.outline_cloud_done_24)
}
}
}
@ -130,11 +138,17 @@ class HomeFragment : Home() {
start()
}
} else {
vancedinstallbtn?.visibility = View.INVISIBLE
microginstallbtn?.visibility = View.INVISIBLE
if (variant == "nonroot") {
val microgLatestTxt =
view?.findViewById<TextView>(R.id.microg_latest_version)
val microginstallbtn =
view?.findViewById<MaterialButton>(R.id.microg_installbtn)
microginstallbtn?.visibility = View.INVISIBLE
microgLatestTxt?.text = getString(R.string.unavailable)
}
vancedinstallbtn?.visibility = View.INVISIBLE
vancedLatestTxt?.text = getString(R.string.unavailable)
microgLatestTxt?.text = getString(R.string.unavailable)
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0.3f)
val oa3 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, 0f)

View file

@ -22,19 +22,22 @@ class SettingsFragment : PreferenceFragmentCompat() {
true
}
val themeSwitch: ListPreference? = findPreference("theme_mode")
val themeSwitch: ListPreference? = findPreference("theme_mode")
themeSwitch?.summary = preferenceScreen.sharedPreferences.getString("theme_mode", "Light")
themeSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
true
}
val accentSwitch: ListPreference? = findPreference("accent_color")
accentSwitch?.summary = preferenceScreen.sharedPreferences.getString("accent_color", "Blue")
accentSwitch?.setOnPreferenceChangeListener { _, _ ->
activity?.recreate()
true
}
val chosenPrefs: Preference? = findPreference("update_check")
val chosenPrefs: Preference? = findPreference("vanced_chosen_modes")
chosenPrefs?.summary = preferenceScreen.sharedPreferences.getString("vanced_variant", "nonroot")
chosenPrefs?.setOnPreferenceClickListener {
val fm = childFragmentManager.beginTransaction()
val updateDialog = ChosenPreferenceDialogFragment()

View file

@ -10,7 +10,7 @@
<string-array name="theme_modes_values">
<item>Light</item>
<item>Dark</item>
<item>Follow</item>
<item>Follow System</item>
</string-array>
<string-array name="accent_color">

View file

@ -50,7 +50,7 @@
android:title="Vanced">
<DropDownPreference
android:title="Variant"
android:title="Installation Mode"
android:entries="@array/vanced_variant"
android:entryValues="@array/vanced_variant_values"
android:key="vanced_variant"/>