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

reverted some changes

This commit is contained in:
X1nto 2020-04-23 22:57:33 +04:00
parent ef7abd42ca
commit f1f25fde03
3 changed files with 23 additions and 12 deletions

View file

@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.SharedPreferences
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.res.ResourcesCompat
@ -20,11 +21,11 @@ open class ThemeActivity : AppCompatActivity() {
currentTheme = pref.getString("theme_mode", "").toString()
setFinalTheme(currentTheme)
super.onCreate(savedInstanceState)
if (android.os.Build.VERSION.SDK_INT < 28) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
setTaskBG(currentTheme)
}
super.onCreate(savedInstanceState)
}
override fun onResume() {
@ -32,7 +33,7 @@ open class ThemeActivity : AppCompatActivity() {
super.onResume()
if (currentTheme != theme)
recreate()
if (android.os.Build.VERSION.SDK_INT < 28) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
setTaskBG(currentTheme)
}
}
@ -50,28 +51,34 @@ open class ThemeActivity : AppCompatActivity() {
}
}
private fun setTaskBG(currentTheme: String) {
var color = ResourcesCompat.getColor(resources, R.color.White, null)
val label = getString(R.string.app_name)
when (currentTheme) {
"LIGHT" -> {
color = ResourcesCompat.getColor(resources, R.color.Black, null)
val color = ResourcesCompat.getColor(resources, R.color.Black, null)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, null, color)
setTaskDescription(taskDec)
}
"DARK" -> {
color = ResourcesCompat.getColor(resources, R.color.Black, null)
val color = ResourcesCompat.getColor(resources, R.color.Black, null)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, null, color)
setTaskDescription(taskDec)
}
"FOLLOW" -> {
when (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> {
color = ResourcesCompat.getColor(resources, R.color.Black, null)
val color = ResourcesCompat.getColor(resources, R.color.Black, null)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, null, color)
setTaskDescription(taskDec)
}
Configuration.UI_MODE_NIGHT_NO -> {
color = ResourcesCompat.getColor(resources, R.color.White, null)
val color = ResourcesCompat.getColor(resources, R.color.White, null)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, null, color)
setTaskDescription(taskDec)
}
}
}
}
val label = getString(R.string.app_name)
val taskDec: ActivityManager.TaskDescription = ActivityManager.TaskDescription(label, null, color)
setTaskDescription(taskDec)
}
}

View file

@ -11,6 +11,7 @@ import android.os.Build
import android.view.*
import android.view.animation.Animation
import android.view.animation.AnimationUtils
import android.widget.Toast
import androidx.navigation.findNavController
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.card.MaterialCardView
@ -20,6 +21,7 @@ import com.vanced.manager.adapter.SectionPageAdapter
import com.vanced.manager.R
import com.vanced.manager.ui.core.BaseFragment
import kotlinx.android.synthetic.main.fragment_home.*
import kotlin.time.Duration
class HomeFragment : BaseFragment() {
@ -134,6 +136,7 @@ class HomeFragment : BaseFragment() {
when (item.itemId) {
R.id.toolbar_about -> {
activity?.findNavController(R.id.bottom_nav_host)?.navigate(R.id.toAboutFragment)
Toast.makeText(context, "You clicked on About menu", Toast.LENGTH_SHORT)
}
else -> super.onOptionsItemSelected(item)
}

View file

@ -5,6 +5,7 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.widget.Toast
import androidx.navigation.findNavController
import androidx.preference.ListPreference
import androidx.preference.Preference
@ -62,11 +63,11 @@ class SettingsFragment : PreferenceFragmentCompat() {
super .onCreateOptionsMenu(menu, inflater)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.secret_settings -> {
activity?.findNavController(R.id.bottom_nav_host)?.navigate(R.id.toSecretSettingsFragment)
Toast.makeText(context, "You clicked on SS menu", Toast.LENGTH_SHORT)
}
else -> super.onOptionsItemSelected(item)
}