Merge remote-tracking branch 'origin/dev' into dev-5.10.0

This commit is contained in:
juntao
2022-05-09 17:50:49 +08:00

View File

@ -4,14 +4,15 @@ import android.content.Context
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatDelegate
import com.gh.common.constant.Constants
import com.gh.gamecenter.BuildConfig
object NightModeUtils {
/**
* 当前系统是否是深色模式
*/
fun isNightMode(context: Context): Boolean {
// 非测试包禁用深色模式
return if (PackageFlavorHelper.IS_TEST_FLAVOR) {
// 仅配置开启的包才提供夜间模式功能
return if (BuildConfig.IS_NIGHT_MODE_ON) {
val uiMode = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
uiMode == Configuration.UI_MODE_NIGHT_YES
} else {
@ -44,8 +45,8 @@ object NightModeUtils {
* @param nightMode 是否是深色模式
*/
fun initNightMode(systemMode: Boolean, nightMode: Boolean) {
// 非测试包禁用深色模式
if (PackageFlavorHelper.IS_TEST_FLAVOR) {
// 仅配置开启的包才提供夜间模式功能
if (BuildConfig.IS_NIGHT_MODE_ON) {
if (systemMode) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM)
} else {