From 487d484baeded78d0223e741ec5efd62b3689819 Mon Sep 17 00:00:00 2001 From: Amine Bou Date: Sun, 15 Apr 2018 11:33:37 +0200 Subject: [PATCH] More styling. --- .../apps/amine/bou/readerforselfoss/ReaderActivity.kt | 4 +--- .../bou/readerforselfoss/fragments/ArticleFragment.kt | 9 +++++---- .../bou/readerforselfoss/settings/SettingsActivity.java | 2 ++ .../apps/amine/bou/readerforselfoss/themes/AppColors.kt | 3 +++ app/src/main/res/values/colors.xml | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt index 6b2f1df..991e1ee 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/ReaderActivity.kt @@ -55,11 +55,9 @@ class ReaderActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - AppColors(this@ReaderActivity) - + val appColors = AppColors(this@ReaderActivity) setContentView(R.layout.activity_reader) - // TODO: fab Scoop.getInstance() .bind(this, Toppings.PRIMARY.value, toolBar) .bindStatusBar(this, Toppings.PRIMARY_DARK.value) diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt index 9dbff14..ae55c5f 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/fragments/ArticleFragment.kt @@ -304,14 +304,14 @@ class ArticleFragment : Fragment() { val stringColor = String.format("#%06X", 0xFFFFFF and appColors.colorAccent) rootView.webcontent.visibility = View.VISIBLE - val textColor = if (Scoop.getInstance().currentFlavor.isDayNight) { + val (textColor, backgroundColor) = if (appColors.isDarkTheme) { rootView.webcontent.setBackgroundColor( ContextCompat.getColor( context, R.color.dark_webview ) ) - ContextCompat.getColor(context, R.color.dark_webview_text) + Pair(ContextCompat.getColor(context, R.color.dark_webview_text), ContextCompat.getColor(context, R.color.light_webview_text)) } else { rootView.webcontent.setBackgroundColor( ContextCompat.getColor( @@ -319,10 +319,11 @@ class ArticleFragment : Fragment() { R.color.light_webview ) ) - ContextCompat.getColor(context, R.color.light_webview_text) + Pair(ContextCompat.getColor(context, R.color.light_webview_text), ContextCompat.getColor(context, R.color.dark_webview_text)) } val stringTextColor = String.format("#%06X", 0xFFFFFF and textColor) + val stringBackgroundColor = String.format("#%06X", 0xFFFFFF and backgroundColor) rootView.webcontent.settings.useWideViewPort = true rootView.webcontent.settings.loadWithOverviewMode = true @@ -408,7 +409,7 @@ class ArticleFragment : Fragment() { |pre, code { | white-space: pre-wrap; | width:100%; - | background-color: #EEEEEE; + | background-color: $stringBackgroundColor; |}$c""".trimMargin(), "text/html; charset=utf-8", "utf-8", diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java index eaac2a3..b968aa2 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/settings/SettingsActivity.java @@ -35,6 +35,7 @@ import java.util.List; import apps.amine.bou.readerforselfoss.BuildConfig; import apps.amine.bou.readerforselfoss.R; +import apps.amine.bou.readerforselfoss.themes.AppColors; import apps.amine.bou.readerforselfoss.utils.Config; @@ -95,6 +96,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { + new AppColors(this); super.onCreate(savedInstanceState); setupActionBar(); } diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/themes/AppColors.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/themes/AppColors.kt index 06e0731..dd752b4 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/themes/AppColors.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/themes/AppColors.kt @@ -4,8 +4,11 @@ import android.app.Activity import android.content.Context import android.preference.PreferenceManager import android.support.annotation.ColorInt +import android.support.v7.view.ContextThemeWrapper import android.util.TypedValue import apps.amine.bou.readerforselfoss.R +import android.view.LayoutInflater +import android.view.ViewGroup class AppColors(a: Activity) { diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index b999fc5..81bd571 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -19,4 +19,5 @@ #FFFFFFFF @color/md_grey_900 + #FF303030