0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-10 12:55:06 +00:00

theme changes

This commit is contained in:
X1nto 2020-05-02 01:46:15 +04:00
parent 7dc93a0ea1
commit 6710a61787
6 changed files with 24 additions and 40 deletions

View file

@ -54,21 +54,21 @@ open class ThemeActivity : AppCompatActivity() {
//This stupid ass AppCompatDelegate does
//not want to work, so I have to use my
//own implementation of theme switching
private fun setFinalTheme(currentTheme: String) {
open fun setFinalTheme(currentTheme: String) {
when (currentTheme) {
"LIGHT" -> setTheme(R.style.LightTheme_Blue)
"DARK" -> setTheme(R.style.DarkTheme_Blue)
"LIGHT" -> setTheme(R.style.MainTheme_Light)
"DARK" -> setTheme(R.style.MainTheme_Dark)
"FOLLOW" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.DarkTheme_Blue)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.LightTheme_Blue)
Configuration.UI_MODE_NIGHT_YES -> setTheme(R.style.MainTheme_Light)
Configuration.UI_MODE_NIGHT_NO -> setTheme(R.style.MainTheme_Dark)
}
}
else -> setTheme(R.style.LightTheme_Blue)
else -> setTheme(R.style.MainTheme_Light)
}
}
private fun setTaskBG() {
fun setTaskBG() {
val label = getString(R.string.app_name)
val color = ResourcesCompat.getColor(resources, R.color.Black, null)
val taskDec: ActivityManager.TaskDescription =

View file

@ -104,7 +104,7 @@ class HomeFragment : Home() {
}
private fun connectionStatus() {
fun connectionStatus() {
val connectivityManager = context?.applicationContext?.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networkRequest = NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)

View file

@ -1,6 +1,5 @@
package com.vanced.manager.ui.fragments
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.view.Menu
@ -11,7 +10,6 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import com.vanced.manager.R
import com.vanced.manager.ui.MainActivity
class SettingsFragment : PreferenceFragmentCompat() {
@ -33,33 +31,28 @@ class SettingsFragment : PreferenceFragmentCompat() {
when (themeSwitch.value){
"LIGHT" -> {
//activity?.setTheme(R.style.LightTheme_Blue)
//activity?.recreate()
recreate()
activity?.setTheme(R.style.MainTheme_Light)
activity?.recreate()
}
"DARK" -> {
//activity?.setTheme(R.style.DarkTheme_Blue)
//activity?.recreate()
recreate()
activity?.setTheme(R.style.MainTheme_Dark)
activity?.recreate()
}
"FOLLOW" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES ->{
//activity?.setTheme(R.style.DarkTheme_Blue)
//activity?.recreate()
recreate()
activity?.setTheme(R.style.MainTheme_Dark)
activity?.recreate()
}
Configuration.UI_MODE_NIGHT_NO -> {
//activity?.setTheme(R.style.LightTheme_Blue)
//activity?.recreate()
recreate()
activity?.setTheme(R.style.MainTheme_Light)
activity?.recreate()
}
}
}
else -> {
//activity?.setTheme(R.style.LightTheme_Blue)
//activity?.recreate()
recreate()
activity?.setTheme(R.style.MainTheme_Light)
activity?.recreate()
}
}
true
@ -71,9 +64,4 @@ class SettingsFragment : PreferenceFragmentCompat() {
super .onCreateOptionsMenu(menu, inflater)
}
private fun recreate() {
startActivity(Intent(requireContext(), MainActivity::class.java))
activity?.finish()
}
}

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="DarkTheme.Blue">
<style name="MainTheme.Dark">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#804EAFF5</item>
@ -23,6 +23,8 @@
<item name="iconColor">?colorPrimaryVariant</item>
<item name="toolbarIconColor">?colorOnPrimary</item>
<item name="DialogBG">#111111</item>
<item name="colorBackgroundFloating">#111111</item>
<item name="android:statusBarColor">#000000</item>
</style>

View file

@ -6,16 +6,9 @@
<item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="LightTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="MainTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#787777</item>
</style>
<style name="DarkTheme" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorBackgroundFloating">#111111</item>
<item name="android:windowBackground">?colorSurface</item>
<item name="android:statusBarColor">#000000</item>
</style>
</resources>

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="LightTheme.Blue">
<style name="MainTheme.Light">
<item name="colorPrimary">#1490D7</item>
<item name="colorPrimaryVariant">#2C7EB9</item>
@ -23,6 +23,7 @@
<item name="iconColor">?colorPrimaryVariant</item>
<item name="toolbarIconColor">#111111</item>
<item name="DialogBG">#ffffff</item>
<item name="android:statusBarColor">#787777</item>
</style>