kotovalexarian
/
android
Archived
1
0
Fork 0

Add article title

This commit is contained in:
Alex Kotov 2021-08-14 07:58:09 +05:00
parent 03ee8e66d7
commit 974fcd1110
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
2 changed files with 20 additions and 3 deletions

View File

@ -1,12 +1,12 @@
package com.causa_arcana
class HtmlGenerator(private val contentHtml: String) {
class HtmlGenerator(private val title: String, private val contentHtml: String) {
fun fullHtml(): String {
return """
<!DOCTYPE html>
<html>
<head>${headInnerHtml()}</head>
<body>$contentHtml</body>
<body>${bodyInnerHtml()}</body>
</html>
"""
}
@ -18,6 +18,19 @@ class HtmlGenerator(private val contentHtml: String) {
"""
}
private fun bodyInnerHtml(): String {
return """
<main>
<article>
<header>
<h1>$title</h1>
</header>
<div>$contentHtml</div>
</article>
</main>
"""
}
private fun fullCss(): String {
return """
body {

View File

@ -12,7 +12,11 @@ class MainActivity : AppCompatActivity() {
val mainWebView: WebView = findViewById(R.id.mainWebView)
val htmlGenerator = HtmlGenerator(contentHtml)
val htmlGenerator = HtmlGenerator(
"Почему сложно писать о передовых информационных технологиях?",
contentHtml,
)
val fullHtml = htmlGenerator.fullHtml()
val encodedFullHtml = Base64.encodeToString(fullHtml.toByteArray(), Base64.NO_PADDING)