diff options
Diffstat (limited to 'app/src/main/kotlin/com/pitchedapps')
8 files changed, 92 insertions, 36 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt index 670e8669..b7bacbc2 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/AboutActivity.kt @@ -33,7 +33,7 @@ class AboutActivity : AboutActivityBase(null, { textColor = Prefs.textColor accentColor = Prefs.accentColor backgroundColor = Prefs.bgColor.withMinAlpha(200) - cutoutForeground = if (0xff3b5998.toInt().isColorVisibleOn(Prefs.bgColor)) 0xff3b5998.toInt() else Prefs.accentColor + cutoutForeground = Prefs.accentColor cutoutDrawableRes = R.drawable.frost_f_256 faqPageTitleRes = R.string.faq_title faqXmlRes = R.xml.frost_faq diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt index 3593f6b5..61554312 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/ImageActivity.kt @@ -102,6 +102,7 @@ class ImageActivity : KauBaseActivity() { } }) Glide.with(this).asBitmap().load(imageUrl).into(PhotoTarget(this::imageCallback)) + setFrostColors(themeWindow = false) } /** @@ -205,7 +206,7 @@ class ImageActivity : KauBaseActivity() { } } -internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconColor, val backgroundTint: Int = Prefs.iconBackgroundColor.withAlpha(255)) { +internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconColor, val backgroundTint: Int = Int.MAX_VALUE) { ERROR(GoogleMaterial.Icon.gmd_error, Color.WHITE, Color.RED) { override fun onClick(activity: ImageActivity) { activity.materialDialogThemed { @@ -255,14 +256,15 @@ internal enum class FabStates(val iicon: IIcon, val iconColor: Int = Prefs.iconC * If it's in view, give it some animations */ fun update(fab: FloatingActionButton) { + val tint = if (backgroundTint != Int.MAX_VALUE) backgroundTint else Prefs.accentColor if (fab.isHidden) { fab.setIcon(iicon, color = iconColor) - fab.backgroundTintList = ColorStateList.valueOf(backgroundTint) + fab.backgroundTintList = ColorStateList.valueOf(tint) fab.show() } else { fab.fadeScaleTransition { setIcon(iicon, color = iconColor) - backgroundTintList = ColorStateList.valueOf(backgroundTint) + backgroundTintList = ColorStateList.valueOf(tint) } } } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt index 7b612166..51aedae3 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/WebOverlayActivity.kt @@ -60,10 +60,7 @@ open class WebOverlayActivity : KauBaseActivity(), supportActionBar?.setDisplayHomeAsUpEnabled(true) toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, Prefs.iconColor) toolbar.setNavigationOnClickListener { finishSlideOut() } - kauSwipeOnCreate { - if (!Prefs.overlayFullScreenSwipe) edgeSize = 20.dpToPx - transitionSystemBars = false - } + setFrostColors(toolbar, themeWindow = false) coordinator.setBackgroundColor(Prefs.bgColor.withAlpha(255)) @@ -77,6 +74,11 @@ open class WebOverlayActivity : KauBaseActivity(), setAction(R.string.kau_got_it) { _ -> this.dismiss() } } } + + kauSwipeOnCreate { + if (!Prefs.overlayFullScreenSwipe) edgeSize = 20.dpToPx + transitionSystemBars = false + } } /** @@ -108,11 +110,6 @@ open class WebOverlayActivity : KauBaseActivity(), toolbar.overflowIcon?.setTint(Prefs.iconColor) } - override fun onPostCreate(savedInstanceState: Bundle?) { - super.onPostCreate(savedInstanceState) - kauSwipeOnPostCreate() - } - override fun onDestroy() { super.onDestroy() kauSwipeOnDestroy() diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt index e979f8ce..cf935360 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt @@ -34,6 +34,7 @@ enum class CssAssets(val folder: String = "themes") : InjectorContract { content = content .replace("\$T\$", Prefs.textColor.toRgbaString()) .replace("\$TT\$", Prefs.textColor.colorToBackground(0.05f).toRgbaString()) + .replace("\$A\$", Prefs.accentColor.toRgbaString()) .replace("\$B\$", Prefs.bgColor.toRgbaString()) .replace("\$BT\$", bt) .replace("\$BBT\$", Prefs.bgColor.withAlpha(51).colorToForeground(0.35f).toRgbaString()) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt index 0387bb99..9fafbf88 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/JsInjector.kt @@ -5,13 +5,14 @@ import com.pitchedapps.frost.web.FrostWebViewClient import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.subjects.SingleSubject +import org.apache.commons.text.StringEscapeUtils class JsBuilder { private val css = StringBuilder() private val js = StringBuilder() fun css(css: String): JsBuilder { - this.css.append(css) + this.css.append(StringEscapeUtils.escapeEcmaScript(css)) return this } diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt index e37afc33..45d4c8ae 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt @@ -73,6 +73,17 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = { allowCustomAlpha = false } + colorPicker(R.string.accent_color, { Prefs.customAccentColor }, { + Prefs.customAccentColor = it + reload() + invalidateCustomTheme() + shouldRestartMain() + }) { + dependsOnCustom() + allowCustomAlpha = false + } + + colorPicker(R.string.background_color, { Prefs.customBackgroundColor }, { Prefs.customBackgroundColor = it bgCanvas.ripple(it, duration = 500L) diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt index 9b8064a4..27405026 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt @@ -26,6 +26,8 @@ object Prefs : KPref() { var customTextColor: Int by kpref("color_text", 0xffeceff1.toInt()) + var customAccentColor: Int by kpref("color_accent", 0xff0288d1.toInt()) + var customBackgroundColor: Int by kpref("color_bg", 0xff212121.toInt()) var customHeaderColor: Int by kpref("color_header", 0xff01579b.toInt()) @@ -49,6 +51,9 @@ object Prefs : KPref() { val textColor: Int get() = t.textColor + val accentColor: Int + get() = t.accentColor + val bgColor: Int get() = t.bgColor @@ -58,18 +63,6 @@ object Prefs : KPref() { val iconColor: Int get() = t.iconColor - /** - * Ensures that the color is visible against the background - */ - val accentColor: Int - get() = if (headerColor.isColorVisibleOn(bgColor, 100)) headerColor else textColor - - /** - * Ensures that the color is visible against the background - */ - val iconBackgroundColor: Int - get() = if (headerColor.isColorVisibleOn(bgColor)) headerColor else headerColor.colorToForeground(0.2f) - val themeInjector: InjectorContract get() = t.injector diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt index cb265149..5cbb051d 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt @@ -10,20 +10,71 @@ import com.pitchedapps.frost.injectors.JsActions /** * Created by Allan Wang on 2017-06-14. */ -enum class Theme(@StringRes val textRes: Int, val injector: InjectorContract, - private val textColorGetter: () -> Int, private val backgroundColorGetter: () -> Int, - private val headerColorGetter: () -> Int, private val iconColorGetter: () -> Int) { - DEFAULT(R.string.kau_default, JsActions.EMPTY, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { 0xde000000.toInt() }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }), - DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff2e4b86.toInt() }, { Color.WHITE }), - AMOLED(R.string.kau_amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }), - GLASS(R.string.kau_glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }), - CUSTOM(R.string.kau_custom, CssAssets.CUSTOM, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor }) - ; +const val FACEBOOK_BLUE = 0xff3b5998.toInt() +const val BLUE_LIGHT = 0xff5d86dd.toInt() + +enum class Theme(@StringRes val textRes: Int, + val injector: InjectorContract, + private val textColorGetter: () -> Int, + private val accentColorGetter: () -> Int, + private val backgroundColorGetter: () -> Int, + private val headerColorGetter: () -> Int, + private val iconColorGetter: () -> Int) { + + DEFAULT(R.string.kau_default, + JsActions.EMPTY, + { 0xde000000.toInt() }, + { FACEBOOK_BLUE }, + { 0xfffafafa.toInt() }, + { FACEBOOK_BLUE }, + { Color.WHITE }), + + LIGHT(R.string.kau_light, + CssAssets.MATERIAL_LIGHT, + { 0xde000000.toInt() }, + { FACEBOOK_BLUE }, + { 0xfffafafa.toInt() }, + { FACEBOOK_BLUE }, + { Color.WHITE }), + + DARK(R.string.kau_dark, + CssAssets.MATERIAL_DARK, + { Color.WHITE }, + { BLUE_LIGHT }, + { 0xff303030.toInt() }, + { 0xff2e4b86.toInt() }, + { Color.WHITE }), + + AMOLED(R.string.kau_amoled, + CssAssets.MATERIAL_AMOLED, + { Color.WHITE }, + { BLUE_LIGHT }, + { Color.BLACK }, + { Color.BLACK }, + { Color.WHITE }), + + GLASS(R.string.kau_glass, + CssAssets.MATERIAL_GLASS, + { Color.WHITE }, + { BLUE_LIGHT }, + { 0x80000000.toInt() }, + { 0xb3000000.toInt() }, + { Color.WHITE }), + + CUSTOM(R.string.kau_custom, + CssAssets.CUSTOM, + { Prefs.customTextColor }, + { Prefs.customAccentColor }, + { Prefs.customBackgroundColor }, + { Prefs.customHeaderColor }, + { Prefs.customIconColor }); val textColor: Int get() = textColorGetter() + val accentColor: Int + get() = accentColorGetter() + val bgColor: Int get() = backgroundColorGetter() |