This commit is contained in:
Amine Bou 2017-12-17 20:40:14 +01:00
parent 9559af3637
commit 5e7897bcf4
4 changed files with 26 additions and 16 deletions

View File

@ -4,7 +4,7 @@
- Added an option to use a webview in the article viewer (see #149)
- Fixes (#151 #155)
- Fixes (#151 #152 #155)
**1.5.5.x (didn't last long) AND 1.5.6.x**

View File

@ -87,19 +87,19 @@ class MyApp : MultiDexApplication() {
private fun initTheme() {
Scoop.waffleCone()
.addFlavor(getString(R.string.default_theme), R.style.NoBar, true)
.addFlavor(getString(R.string.default_dark_theme), R.style.NoBarDark)
.addDayNightFlavor(getString(R.string.default_dark_theme), R.style.NoBarDark)
.addFlavor(getString(R.string.teal_orange_theme), R.style.NoBarTealOrange)
.addFlavor(getString(R.string.teal_orange_dark_theme), R.style.NoBarTealOrangeDark)
.addDayNightFlavor(getString(R.string.teal_orange_dark_theme), R.style.NoBarTealOrangeDark)
.addFlavor(getString(R.string.cyan_pink_theme), R.style.NoBarCyanPink)
.addFlavor(getString(R.string.cyan_pink_dark_theme), R.style.NoBarCyanPinkDark)
.addDayNightFlavor(getString(R.string.cyan_pink_dark_theme), R.style.NoBarCyanPinkDark)
.addFlavor(getString(R.string.grey_orange_theme), R.style.NoBarGreyOrange)
.addFlavor(getString(R.string.grey_orange_dark_theme), R.style.NoBarGreyOrangeDark)
.addDayNightFlavor(getString(R.string.grey_orange_dark_theme), R.style.NoBarGreyOrangeDark)
.addFlavor(getString(R.string.blue_amber_theme), R.style.NoBarBlueAmber)
.addFlavor(getString(R.string.blue_amber_dark_theme), R.style.NoBarBlueAmberDark)
.addDayNightFlavor(getString(R.string.blue_amber_dark_theme), R.style.NoBarBlueAmberDark)
.addFlavor(getString(R.string.indigo_pink_theme), R.style.NoBarIndigoPink)
.addFlavor(getString(R.string.indigo_pink_dark_theme), R.style.NoBarIndigoPinkDark)
.addDayNightFlavor(getString(R.string.indigo_pink_dark_theme), R.style.NoBarIndigoPinkDark)
.addFlavor(getString(R.string.red_teal_theme), R.style.NoBarRedTeal)
.addFlavor(getString(R.string.red_teal_dark_theme), R.style.NoBarRedTealDark)
.addDayNightFlavor(getString(R.string.red_teal_dark_theme), R.style.NoBarRedTealDark)
.setSharedPreferences(PreferenceManager.getDefaultSharedPreferences(this))
.initialize()
}

View File

@ -7,6 +7,7 @@ import android.preference.PreferenceManager
import android.support.customtabs.CustomTabsIntent
import android.support.design.widget.FloatingActionButton
import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.support.v4.widget.NestedScrollView
import android.text.Html
import android.text.method.LinkMovementMethod
@ -30,6 +31,7 @@ import apps.amine.bou.readerforselfoss.utils.sourceAndDateText
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.crashlytics.android.Crashlytics
import com.ftinc.scoop.Scoop
import com.github.rubensousa.floatingtoolbar.FloatingToolbar
import kotlinx.android.synthetic.main.fragment_article.view.*
import org.sufficientlysecure.htmltextview.HtmlHttpImageGetter
@ -237,12 +239,6 @@ class ArticleFragment : Fragment() {
}
private fun htmlToWebview(c: String) {
val attrBackground = TypedValue()
activity!!.baseContext.theme.resolveAttribute(
android.R.attr.colorBackground,
attrBackground,
true
)
val defaultColor = TypedValue()
activity!!.baseContext.theme.resolveAttribute(
@ -254,7 +250,16 @@ class ArticleFragment : Fragment() {
val stringColor = String.format("#%06X", 0xFFFFFF and accentColor)
rootView.webcontent.visibility = View.VISIBLE
rootView.webcontent.setBackgroundColor(attrBackground.data)
val textColor = if (Scoop.getInstance().currentFlavor.isDayNight) {
rootView.webcontent.setBackgroundColor(ContextCompat.getColor(activity!!.baseContext, R.color.dark_webview))
ContextCompat.getColor(activity!!.baseContext, R.color.dark_webview_text)
} else {
rootView.webcontent.setBackgroundColor(ContextCompat.getColor(activity!!.baseContext, R.color.light_webview))
ContextCompat.getColor(activity!!.baseContext, R.color.light_webview_text)
}
val stringTextColor = String.format("#%06X", 0xFFFFFF and textColor)
rootView.webcontent.settings.useWideViewPort = true
rootView.webcontent.settings.loadWithOverviewMode = true
rootView.webcontent.settings.javaScriptEnabled = false
@ -266,7 +271,7 @@ class ArticleFragment : Fragment() {
}
rootView.webcontent.loadData(
"<style>img{display: inline-block;height: auto; width: 100%; max-width: 100%;} a{color: $stringColor}</style>$c",
"<style>img{display: inline-block;height: auto; width: 100%; max-width: 100%;} a{color: $stringColor;} *:not(a){color: $stringTextColor;}</style>$c",
"text/html; charset=utf-8",
"utf-8"
)

View File

@ -11,4 +11,9 @@
<color name="refresh_progress_2">@color/colorAccent</color>
<color name="refresh_progress_3">@color/pink</color>
<color name="background_grey">#FFe4e4e4</color>
<color name="dark_webview">#FF303030</color>
<color name="dark_webview_text">@color/md_white_1000</color>
<color name="light_webview">@color/md_grey_50</color>
<color name="light_webview_text">@color/md_grey_900</color>
</resources>