Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch auto theme mode to Android built-in mechanism #1444

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package androidx.appcompat.app

import android.content.Context
import android.content.res.Configuration

/**
* Created by mariotaku on 2017/1/7.
* Edited by 0x416c6578 on 2021/8/3
*/

object TwilightManagerAccessor {
fun isNight(context: Context): Boolean {
return TwilightManager.getInstance(context).isNight
//From https://developer.android.com/guide/topics/ui/look-and-feel/darktheme#kotlin
val currentNightMode: Int = context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK
when (currentNightMode) {
Configuration.UI_MODE_NIGHT_NO -> { return false }
Configuration.UI_MODE_NIGHT_YES -> { return true }
}
return false;
}

fun getNightState(context: Context): Int {
Expand Down