Commit 98deec23 authored by topjohnwu's avatar topjohnwu

Minor adjustments

parent 022c217c
......@@ -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<VM : BaseViewModel, Binding : ViewDataBinding>
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)
......
......@@ -39,7 +39,7 @@ class JobService : BaseJobService() {
companion object {
fun schedule(context: Context) {
val svc = context.getSystemService<JobScheduler>() ?: return
val scheduler = context.getSystemService<JobScheduler>() ?: 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)
}
}
}
......
......@@ -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)
}
......
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- For stub APK, we need to manually handle the SplashScreen -->
<!-- For stub on API 31+, we cannot rely on the platform SplashScreen -->
<!-- Force using SplashScreenBase that was used for older APIs -->
<style name="StubSplashTheme" parent="Theme.SplashScreenBase">
<item name="android:enforceStatusBarContrast">false</item>
<item name="android:enforceNavigationBarContrast">false</item>
......
......@@ -2,6 +2,7 @@
<resources>
<style name="SplashTheme" parent="Theme.Splash" />
<style name="StubSplashTheme" parent="Theme.Splash"/>
<style name="Foundation" parent="Theme.Foundation.Light" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment