From 974fcd11103bd41204aefcf7a0f519c040ffefc2 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 14 Aug 2021 07:58:09 +0500 Subject: [PATCH] Add article title --- .../main/java/com/causa_arcana/HtmlGenerator.kt | 17 +++++++++++++++-- .../main/java/com/causa_arcana/MainActivity.kt | 6 +++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/causa_arcana/HtmlGenerator.kt b/app/src/main/java/com/causa_arcana/HtmlGenerator.kt index 4239743..9bf2e70 100644 --- a/app/src/main/java/com/causa_arcana/HtmlGenerator.kt +++ b/app/src/main/java/com/causa_arcana/HtmlGenerator.kt @@ -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 """ ${headInnerHtml()} - $contentHtml + ${bodyInnerHtml()} """ } @@ -18,6 +18,19 @@ class HtmlGenerator(private val contentHtml: String) { """ } + private fun bodyInnerHtml(): String { + return """ +
+
+
+

$title

+
+
$contentHtml
+
+
+ """ + } + private fun fullCss(): String { return """ body { diff --git a/app/src/main/java/com/causa_arcana/MainActivity.kt b/app/src/main/java/com/causa_arcana/MainActivity.kt index 563cf44..8b3935d 100644 --- a/app/src/main/java/com/causa_arcana/MainActivity.kt +++ b/app/src/main/java/com/causa_arcana/MainActivity.kt @@ -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)