Add article title
This commit is contained in:
parent
03ee8e66d7
commit
974fcd1110
2 changed files with 20 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Reference in a new issue