From 6710a6178758bf1670f7f818fc5d0787dc769a10 Mon Sep 17 00:00:00 2001 From: X1nto Date: Sat, 2 May 2020 01:46:15 +0400 Subject: [PATCH] theme changes --- .../vanced/manager/ui/core/BaseActivity.kt | 14 ++++---- .../manager/ui/fragments/HomeFragment.kt | 2 +- .../manager/ui/fragments/SettingsFragment.kt | 32 ++++++------------- app/src/main/res/values-night/themes.xml | 4 ++- app/src/main/res/values/styles.xml | 9 +----- app/src/main/res/values/themes.xml | 3 +- 6 files changed, 24 insertions(+), 40 deletions(-) diff --git a/app/src/main/java/com/vanced/manager/ui/core/BaseActivity.kt b/app/src/main/java/com/vanced/manager/ui/core/BaseActivity.kt index 091636d0..f0b832ec 100644 --- a/app/src/main/java/com/vanced/manager/ui/core/BaseActivity.kt +++ b/app/src/main/java/com/vanced/manager/ui/core/BaseActivity.kt @@ -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 = 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 97ecede1..445fd18c 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 @@ -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) diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/SettingsFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/SettingsFragment.kt index e3c3ee88..7b32864d 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/SettingsFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/SettingsFragment.kt @@ -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() - } - } \ No newline at end of file diff --git a/app/src/main/res/values-night/themes.xml b/app/src/main/res/values-night/themes.xml index 39425db3..eb44e2b7 100644 --- a/app/src/main/res/values-night/themes.xml +++ b/app/src/main/res/values-night/themes.xml @@ -1,7 +1,7 @@ - diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index cc1fe065..c060ceea 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -6,16 +6,9 @@ true - - - diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 01b187f0..a73dc25f 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -1,7 +1,7 @@ -