the license dialog will now follow the theme too

This commit is contained in:
2019-08-25 22:19:36 +02:00
parent 3e909ab68f
commit be916a74ab
3 changed files with 54 additions and 1 deletions

View File

@ -24,6 +24,7 @@ package org.mosad.seil0.projectlaogai.fragments
import android.content.Context
import android.os.Bundle
import android.renderscript.Sampler
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
@ -143,12 +144,27 @@ class SettingsFragment : Fragment() {
}
linLayoutLicence.setOnClickListener {
// do the theme magic, as the lib's theme support is broken
val outValue = TypedValue()
context!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
val dialogCss = when (outValue.string) {
"light" -> R.string.license_dialog_style_light
else -> R.string.license_dialog_style_dark
}
val themeId = when (outValue.string) {
"light" -> R.style.AppTheme_Light
else -> R.style.LicensesDialogTheme_Dark
}
// open a new license dialog
LicensesDialog.Builder(context!!)
.setNotices(R.raw.notices)
.setTitle(R.string.licenses)
.setIncludeOwnLicense(true)
.setThemeResourceId(R.style.AppTheme_Light)
.setThemeResourceId(themeId)
.setNoticesCssStyle(dialogCss)
.build()
.show()
}