Fix styles on help-style pages

This commit is contained in:
Billy Brawner 2019-05-18 10:35:25 -07:00 committed by William Brawner
parent b5b850c605
commit 83ef306b83
2 changed files with 50 additions and 10 deletions

View file

@ -1,8 +1,10 @@
package com.wbrawner.simplemarkdown.view.activity package com.wbrawner.simplemarkdown.view.activity
import android.content.res.Configuration
import android.os.Bundle import android.os.Bundle
import android.view.MenuItem import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.app.AppCompatDelegate
import com.wbrawner.simplemarkdown.R import com.wbrawner.simplemarkdown.R
import kotlinx.android.synthetic.main.activity_markdown_info.* import kotlinx.android.synthetic.main.activity_markdown_info.*
@ -11,7 +13,7 @@ class MarkdownInfoActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_markdown_info) setContentView(R.layout.activity_markdown_info)
val supportActionBar = supportActionBar setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
val intent = intent val intent = intent
if (intent == null || !intent.hasExtra("title") || !intent.hasExtra("html")) { if (intent == null || !intent.hasExtra("title") || !intent.hasExtra("html")) {
@ -19,10 +21,18 @@ class MarkdownInfoActivity : AppCompatActivity() {
return return
} }
title = intent.getStringExtra("title") 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, infoWebview.loadDataWithBaseURL(null,
String.format(FORMAT_CSS, String.format(FORMAT_CSS, css) + intent.getStringExtra("html"),
getString(R.string.pref_custom_css_default)
) + intent.getStringExtra("html"),
"text/html", "text/html",
"UTF-8", null "UTF-8", null
) )

View file

@ -1,12 +1,42 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="com.wbrawner.simplemarkdown.view.activity.MarkdownInfoActivity"> tools:context="com.wbrawner.simplemarkdown.view.activity.MarkdownInfoActivity"
android:fitsSystemWindows="true"
android:clipToPadding="false"
android:clipChildren="false">
<WebView <WebView
android:layout_height="match_parent" android:id="@+id/infoWebview"
android:layout_width="match_parent" android:layout_width="match_parent"
android:id="@+id/infoWebview" /> android:layout_height="match_parent"
</FrameLayout> android:layout_marginBottom="40dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/bottomSheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:translationY="16dp"
app:cardCornerRadius="16dp"
app:cardElevation="4dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_marginBottom="16dp"
android:background="@color/colorBackground" />
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>