From aa91076d071f17824e665a7415bb7f093110b35c Mon Sep 17 00:00:00 2001 From: X1nto Date: Sun, 26 Apr 2020 14:37:29 +0400 Subject: [PATCH] added some comments --- app/src/main/java/com/vanced/manager/core/Main.kt | 2 ++ .../java/com/vanced/manager/core/fragments/About.kt | 6 +----- .../java/com/vanced/manager/core/fragments/Home.kt | 2 ++ .../java/com/vanced/manager/ui/core/BaseActivity.kt | 10 ++++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/vanced/manager/core/Main.kt b/app/src/main/java/com/vanced/manager/core/Main.kt index 2ac15123..db56631c 100644 --- a/app/src/main/java/com/vanced/manager/core/Main.kt +++ b/app/src/main/java/com/vanced/manager/core/Main.kt @@ -6,6 +6,8 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.vanced.manager.R import com.vanced.manager.ui.core.ThemeActivity +// This activity will NOT be used in manifest +// since MainActivity will extend it @SuppressLint("Registered") open class Main: ThemeActivity() { diff --git a/app/src/main/java/com/vanced/manager/core/fragments/About.kt b/app/src/main/java/com/vanced/manager/core/fragments/About.kt index b9f9fbea..77facd2f 100644 --- a/app/src/main/java/com/vanced/manager/core/fragments/About.kt +++ b/app/src/main/java/com/vanced/manager/core/fragments/About.kt @@ -19,11 +19,7 @@ open class About : BaseFragment() { } license.setOnClickListener { - openUrl( - "https://raw.githubusercontent.com/YTVanced/VancedInstaller/dev/LICENSE", - R.color.GitHub - ) - + openUrl("https://raw.githubusercontent.com/YTVanced/VancedInstaller/dev/LICENSE", R.color.GitHub) } } diff --git a/app/src/main/java/com/vanced/manager/core/fragments/Home.kt b/app/src/main/java/com/vanced/manager/core/fragments/Home.kt index 822f5103..796b9af6 100644 --- a/app/src/main/java/com/vanced/manager/core/fragments/Home.kt +++ b/app/src/main/java/com/vanced/manager/core/fragments/Home.kt @@ -17,6 +17,7 @@ open class Home : BaseFragment() { val pm = activity?.packageManager + //Damn that's a lot of buttons val microginstallbtn = getView()?.findViewById(R.id.microg_installbtn) as Button val microguninstallbtn = getView()?.findViewById(R.id.microg_uninstallbtn) as Button val microgsettingsbtn = getView()?.findViewById(R.id.microg_settingsbtn) as Button @@ -29,6 +30,7 @@ open class Home : BaseFragment() { val twitterbtn = getView()?.findViewById(R.id.twitterbtn) as Button val redditbtn = getView()?.findViewById(R.id.redditbtn) as Button + //we need to check whether these apps are installed or not val microgStatus = pm?.let { isPackageInstalled("com.mgoogle.android.gms", it) } val vancedStatus = pm?.let { isPackageInstalled("com.vanced.android.youtube", it) } 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 e4a74aba..f26ef566 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 @@ -13,6 +13,7 @@ import com.vanced.manager.R @SuppressLint("Registered") open class ThemeActivity : AppCompatActivity() { + private lateinit var currentTheme: String private lateinit var pref: SharedPreferences @@ -31,12 +32,21 @@ open class ThemeActivity : AppCompatActivity() { override fun onResume() { val theme = pref.getString("theme_mode", "") super.onResume() + //if for some weird reasons we get invalid + //theme, recreate activity if (currentTheme != theme) recreate() + + //set Task Header color in recents menu for + //devices with lower Android version than Pie if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { setTaskBG() } } + + //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) { when (currentTheme) { "LIGHT" -> setTheme(R.style.LightTheme_Blue)