From 83ef306b8391a9d0619faae489d0f6e01dcc8b09 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 18 May 2019 10:35:25 -0700 Subject: [PATCH] Fix styles on help-style pages --- .../view/activity/MarkdownInfoActivity.kt | 18 ++++++-- .../res/layout/activity_markdown_info.xml | 42 ++++++++++++++++--- 2 files changed, 50 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.kt b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.kt index 2842a7c..8d06107 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.kt +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MarkdownInfoActivity.kt @@ -1,8 +1,10 @@ package com.wbrawner.simplemarkdown.view.activity +import android.content.res.Configuration import android.os.Bundle import android.view.MenuItem import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.app.AppCompatDelegate import com.wbrawner.simplemarkdown.R import kotlinx.android.synthetic.main.activity_markdown_info.* @@ -11,7 +13,7 @@ class MarkdownInfoActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_markdown_info) - val supportActionBar = supportActionBar + setSupportActionBar(toolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) val intent = intent if (intent == null || !intent.hasExtra("title") || !intent.hasExtra("html")) { @@ -19,10 +21,18 @@ class MarkdownInfoActivity : AppCompatActivity() { return } title = intent.getStringExtra("title") + val isNightMode = AppCompatDelegate.getDefaultNightMode() == + AppCompatDelegate.MODE_NIGHT_YES + || resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES + val defaultCssId = if (isNightMode) { + R.string.pref_custom_css_default_dark + } else { + R.string.pref_custom_css_default + } + val css: String? = getString(defaultCssId) + infoWebview.loadDataWithBaseURL(null, - String.format(FORMAT_CSS, - getString(R.string.pref_custom_css_default) - ) + intent.getStringExtra("html"), + String.format(FORMAT_CSS, css) + intent.getStringExtra("html"), "text/html", "UTF-8", null ) diff --git a/app/src/main/res/layout/activity_markdown_info.xml b/app/src/main/res/layout/activity_markdown_info.xml index d06d64c..cadf264 100644 --- a/app/src/main/res/layout/activity_markdown_info.xml +++ b/app/src/main/res/layout/activity_markdown_info.xml @@ -1,12 +1,42 @@ - + tools:context="com.wbrawner.simplemarkdown.view.activity.MarkdownInfoActivity" + android:fitsSystemWindows="true" + android:clipToPadding="false" + android:clipChildren="false"> + - + android:layout_height="match_parent" + android:layout_marginBottom="40dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + + + + + + +