From 98deec232ba81da921f2309abc38fbf6286b3285 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 5 Nov 2021 13:55:18 -0700 Subject: [PATCH] Minor adjustments --- .../com/topjohnwu/magisk/arch/BaseMainActivity.kt | 7 +------ .../java/com/topjohnwu/magisk/core/JobService.kt | 6 +++--- .../com/topjohnwu/magisk/core/base/BaseActivity.kt | 13 ++++++++----- app/src/main/res/values-v31/themes.xml | 3 ++- app/src/main/res/values/styles_md2.xml | 1 + 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt index 85a34970c..bb4fe3021 100644 --- a/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/arch/BaseMainActivity.kt @@ -2,7 +2,6 @@ package com.topjohnwu.magisk.arch import android.content.Intent import android.net.Uri -import android.os.Build.VERSION.SDK_INT import android.os.Bundle import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.databinding.ViewDataBinding @@ -35,11 +34,7 @@ abstract class BaseMainActivity if (isRunningAsStub && doPreload) { // Manually apply splash theme for stub - if (SDK_INT >= 31) { - theme.applyStyle(R.style.StubSplashTheme, true) - } else { - theme.applyStyle(R.style.SplashTheme, true) - } + theme.applyStyle(R.style.StubSplashTheme, true) } super.onCreate(savedInstanceState) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt b/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt index eb283ddd8..94a908d14 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/JobService.kt @@ -39,7 +39,7 @@ class JobService : BaseJobService() { companion object { fun schedule(context: Context) { - val svc = context.getSystemService() ?: return + val scheduler = context.getSystemService() ?: return if (Config.checkUpdate) { val cmp = JobService::class.java.cmp(context.packageName) val info = JobInfo.Builder(Const.ID.JOB_SERVICE_ID, cmp) @@ -47,9 +47,9 @@ class JobService : BaseJobService() { .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setRequiresDeviceIdle(true) .build() - svc.schedule(info) + scheduler.schedule(info) } else { - svc.cancel(Const.ID.JOB_SERVICE_ID) + scheduler.cancel(Const.ID.JOB_SERVICE_ID) } } } diff --git a/app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt b/app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt index c2099df0e..b673ac2a9 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/base/BaseActivity.kt @@ -15,6 +15,7 @@ import androidx.collection.SparseArrayCompat import androidx.core.app.ActivityCompat import androidx.core.content.ContextCompat import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.core.isRunningAsStub import com.topjohnwu.magisk.core.utils.currentLocale import com.topjohnwu.magisk.core.wrap import com.topjohnwu.magisk.ktx.reflectField @@ -46,11 +47,13 @@ abstract class BaseActivity : AppCompatActivity() { } override fun onCreate(savedInstanceState: Bundle?) { - // Overwrite private members to avoid nasty "false" stack traces being logged - val delegate = delegate - val clz = delegate.javaClass - clz.reflectField("mActivityHandlesUiModeChecked").set(delegate, true) - clz.reflectField("mActivityHandlesUiMode").set(delegate, false) + if (isRunningAsStub) { + // Overwrite private members to avoid nasty "false" stack traces being logged + val delegate = delegate + val clz = delegate.javaClass + clz.reflectField("mActivityHandlesUiModeChecked").set(delegate, true) + clz.reflectField("mActivityHandlesUiMode").set(delegate, false) + } super.onCreate(savedInstanceState) } diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xml index 7f70a2f72..9f1ee2c39 100644 --- a/app/src/main/res/values-v31/themes.xml +++ b/app/src/main/res/values-v31/themes.xml @@ -1,6 +1,7 @@ - + +