Set in onCreate dark window background if dark theme is default
This commit is contained in:
@@ -121,6 +121,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
BaresipService.callActionUri = URLDecoder.decode(intent.data.toString(), "UTF-8")
|
BaresipService.callActionUri = URLDecoder.decode(intent.data.toString(), "UTF-8")
|
||||||
|
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES)
|
window.addFlags(WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES)
|
||||||
|
if (Utils.darkTheme())
|
||||||
|
window.setBackgroundDrawableResource(R.color.colorDark)
|
||||||
|
|
||||||
setContentView(binding.root)
|
setContentView(binding.root)
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.widget.TextView
|
|||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatDelegate
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.Lifecycle
|
import androidx.lifecycle.Lifecycle
|
||||||
import androidx.lifecycle.ProcessLifecycleOwner
|
import androidx.lifecycle.ProcessLifecycleOwner
|
||||||
@@ -662,6 +663,10 @@ object Utils {
|
|||||||
BaresipService.activities.add(0, activity)
|
BaresipService.activities.add(0, activity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun darkTheme(): Boolean {
|
||||||
|
return AppCompatDelegate.getDefaultNightMode() == AppCompatDelegate.MODE_NIGHT_YES
|
||||||
|
}
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
fun setShowWhenLocked(activity: Activity, show: Boolean) {
|
fun setShowWhenLocked(activity: Activity, show: Boolean) {
|
||||||
when {
|
when {
|
||||||
|
|||||||
Reference in New Issue
Block a user