More styling.

This commit is contained in:
Amine Bou 2018-04-15 11:33:37 +02:00
parent 0ca4c04c61
commit 487d484bae
5 changed files with 12 additions and 7 deletions

View File

@ -55,11 +55,9 @@ class ReaderActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
AppColors(this@ReaderActivity) val appColors = AppColors(this@ReaderActivity)
setContentView(R.layout.activity_reader) setContentView(R.layout.activity_reader)
// TODO: fab
Scoop.getInstance() Scoop.getInstance()
.bind(this, Toppings.PRIMARY.value, toolBar) .bind(this, Toppings.PRIMARY.value, toolBar)
.bindStatusBar(this, Toppings.PRIMARY_DARK.value) .bindStatusBar(this, Toppings.PRIMARY_DARK.value)

View File

@ -304,14 +304,14 @@ class ArticleFragment : Fragment() {
val stringColor = String.format("#%06X", 0xFFFFFF and appColors.colorAccent) val stringColor = String.format("#%06X", 0xFFFFFF and appColors.colorAccent)
rootView.webcontent.visibility = View.VISIBLE rootView.webcontent.visibility = View.VISIBLE
val textColor = if (Scoop.getInstance().currentFlavor.isDayNight) { val (textColor, backgroundColor) = if (appColors.isDarkTheme) {
rootView.webcontent.setBackgroundColor( rootView.webcontent.setBackgroundColor(
ContextCompat.getColor( ContextCompat.getColor(
context, context,
R.color.dark_webview 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 { } else {
rootView.webcontent.setBackgroundColor( rootView.webcontent.setBackgroundColor(
ContextCompat.getColor( ContextCompat.getColor(
@ -319,10 +319,11 @@ class ArticleFragment : Fragment() {
R.color.light_webview 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 stringTextColor = String.format("#%06X", 0xFFFFFF and textColor)
val stringBackgroundColor = String.format("#%06X", 0xFFFFFF and backgroundColor)
rootView.webcontent.settings.useWideViewPort = true rootView.webcontent.settings.useWideViewPort = true
rootView.webcontent.settings.loadWithOverviewMode = true rootView.webcontent.settings.loadWithOverviewMode = true
@ -408,7 +409,7 @@ class ArticleFragment : Fragment() {
|pre, code { |pre, code {
| white-space: pre-wrap; | white-space: pre-wrap;
| width:100%; | width:100%;
| background-color: #EEEEEE; | background-color: $stringBackgroundColor;
|}</style>$c""".trimMargin(), |}</style>$c""".trimMargin(),
"text/html; charset=utf-8", "text/html; charset=utf-8",
"utf-8", "utf-8",

View File

@ -35,6 +35,7 @@ import java.util.List;
import apps.amine.bou.readerforselfoss.BuildConfig; import apps.amine.bou.readerforselfoss.BuildConfig;
import apps.amine.bou.readerforselfoss.R; import apps.amine.bou.readerforselfoss.R;
import apps.amine.bou.readerforselfoss.themes.AppColors;
import apps.amine.bou.readerforselfoss.utils.Config; import apps.amine.bou.readerforselfoss.utils.Config;
@ -95,6 +96,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
new AppColors(this);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setupActionBar(); setupActionBar();
} }

View File

@ -4,8 +4,11 @@ import android.app.Activity
import android.content.Context import android.content.Context
import android.preference.PreferenceManager import android.preference.PreferenceManager
import android.support.annotation.ColorInt import android.support.annotation.ColorInt
import android.support.v7.view.ContextThemeWrapper
import android.util.TypedValue import android.util.TypedValue
import apps.amine.bou.readerforselfoss.R import apps.amine.bou.readerforselfoss.R
import android.view.LayoutInflater
import android.view.ViewGroup
class AppColors(a: Activity) { class AppColors(a: Activity) {

View File

@ -19,4 +19,5 @@
<color name="cardBackgroundColor">#FFFFFFFF</color> <color name="cardBackgroundColor">#FFFFFFFF</color>
<color name="materialDrawerHeaderSelectionText">@color/md_grey_900</color> <color name="materialDrawerHeaderSelectionText">@color/md_grey_900</color>
<color name="darkBackground">#FF303030</color>
</resources> </resources>