Browse Source

the license dialog will now follow the theme too

pull/31/head
Jannik 3 years ago
parent
commit
be916a74ab
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 18
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  2. 33
      app/src/main/res/layouts/activities/values/css_styles.xml
  3. 4
      app/src/main/res/values/styles.xml

18
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -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()
}

33
app/src/main/res/layouts/activities/values/css_styles.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="license_dialog_style_light" translatable="false">
body {
background-color: #ffffff;
color: #000000;
font-family: sans-serif;
overflow-wrap: break-word;
}
pre {
background-color: #eeeeee;
padding: 1em;
white-space: pre-wrap;
}
</string>
<string name="license_dialog_style_dark" translatable="false">
body {
background-color: #303030;
color: #ffffff;
font-family: sans-serif;
overflow-wrap: break-word;
}
pre {
background-color: #424242;
padding: 1em;
white-space: pre-wrap;
}
li a {
color: #21a3df;
}
</string>
</resources>

4
app/src/main/res/values/styles.xml

@ -58,4 +58,8 @@
<item name="android:windowBackground">@drawable/background_splash</item>
</style>
<style name="LicensesDialogTheme.Dark" parent="Theme.AppCompat.Dialog">
<item name="android:windowBackground">@color/themeSecondaryDark</item>
</style>
</resources>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close