1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-08 20:12:39 +01:00

Tint more things

This commit is contained in:
Allan Wang 2017-06-15 16:19:56 -07:00
parent 9e0044f878
commit 15d8a70a6c
6 changed files with 61 additions and 23 deletions

View File

@ -20,12 +20,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/FrostThemeBase">
<activity
android:name=".StartActivity"
android:configChanges="orientation|screenSize|locale"
android:label="@string/app_name"
android:theme="@style/Theme.Splash">
android:theme="@style/FrostTheme.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@ -36,10 +36,10 @@
android:configChanges="orientation|screenSize|locale"
android:hardwareAccelerated="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/FrostTheme" />
<activity
android:name=".WebOverlayActivity"
android:theme="@style/AppTheme.Overlay">
android:theme="@style/FrostTheme.Overlay">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
@ -92,13 +92,13 @@
</activity>
<activity
android:name=".LoginActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/FrostTheme" />
<activity
android:name=".SelectorActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/FrostTheme" />
<activity
android:name=".SettingsActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/FrostTheme" />
<service
android:name=".services.NotificationService"

View File

@ -1,8 +1,10 @@
package com.pitchedapps.frost
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.materialDialog
import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostTheme
/**
* Created by Allan Wang on 2017-06-12.
@ -10,7 +12,7 @@ import com.pitchedapps.frost.utils.materialDialog
open class BaseActivity : AppCompatActivity() {
override fun onBackPressed() {
if (isTaskRoot && Prefs.exitConfirmation) {
materialDialog {
materialDialogThemed {
title(R.string.exit)
content(R.string.exit_confirmation)
positiveText(android.R.string.yes)
@ -21,4 +23,9 @@ open class BaseActivity : AppCompatActivity() {
}
} else super.onBackPressed()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setFrostTheme()
}
}

View File

@ -5,10 +5,7 @@ import ca.allanwang.kau.kpref.KPrefActivity
import ca.allanwang.kau.kpref.KPrefAdapterBuilder
import ca.allanwang.kau.utils.*
import ca.allanwang.kau.views.RippleCanvas
import com.pitchedapps.frost.utils.EXTRA_COOKIES
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.Theme
import com.pitchedapps.frost.utils.cookies
import com.pitchedapps.frost.utils.*
/**
* Created by Allan Wang on 2017-06-06.
@ -20,15 +17,17 @@ class SettingsActivity : KPrefActivity() {
header(R.string.settings)
text<Int>(title = R.string.theme, itemBuilder = {
onClick = {
itemView, innerContent, item ->
this@SettingsActivity.materialDialog {
_, _, item ->
this@SettingsActivity.materialDialogThemed {
title(R.string.theme)
items(Theme.values().map { this@SettingsActivity.string(it.textRes) })
itemsDisabledIndices(Theme.CUSTOM.ordinal)
itemsCallbackSingleChoice(item.pref, {
_, _, which, _ ->
if (item.pref != which) {
item.pref = which
reload()
setFrostTheme()
themeExterior()
}
true

View File

@ -3,9 +3,11 @@ package com.pitchedapps.frost.utils
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.content.ContextCompat
import ca.allanwang.kau.utils.adjustAlpha
import ca.allanwang.kau.utils.isColorDark
import ca.allanwang.kau.utils.lighten
import ca.allanwang.kau.utils.startActivity
import com.afollestad.materialdialogs.MaterialDialog
@ -43,7 +45,8 @@ fun WebOverlayActivity.url(): String {
return intent.extras?.getString(ARG_URL) ?: FbTab.FEED.url
}
fun Activity.materialDialog(action: MaterialDialog.Builder.() -> Unit) {
fun Activity.materialDialogThemed(action: MaterialDialog.Builder.() -> Unit): MaterialDialog {
val builder = MaterialDialog.Builder(this)
val dimmerTextColor = Prefs.textColor.adjustAlpha(0.8f)
builder.titleColor(Prefs.textColor)
@ -54,4 +57,13 @@ fun Activity.materialDialog(action: MaterialDialog.Builder.() -> Unit) {
.negativeColor(Prefs.textColor)
.neutralColor(Prefs.textColor)
builder.action()
return builder.show()
}
fun Activity.setFrostTheme() {
val isTransparent = Color.alpha(Prefs.bgColor) != 255
if (Prefs.bgColor.isColorDark())
setTheme(if (isTransparent) R.style.FrostTheme_Transparent else R.style.FrostTheme)
else
setTheme(if (isTransparent) R.style.FrostTheme_Light_Transparent else R.style.FrostTheme_Light)
}

View File

@ -8,8 +8,11 @@ import android.view.View
import android.widget.FrameLayout
import android.widget.ProgressBar
import ca.allanwang.kau.utils.bindView
import ca.allanwang.kau.utils.tint
import ca.allanwang.kau.utils.withAlpha
import com.pitchedapps.frost.R
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.utils.Prefs
import io.reactivex.android.schedulers.AndroidSchedulers
/**
@ -23,6 +26,9 @@ class FrostWebView @JvmOverloads constructor(context: Context, attrs: AttributeS
init {
inflate(getContext(), R.layout.swipe_webview, this)
progress.tint(Prefs.iconColor.withAlpha(180))
refresh.setColorSchemeColors(Prefs.iconColor)
refresh.setProgressBackgroundColorSchemeColor(Prefs.headerColor.withAlpha(255))
web.progressObservable.observeOn(AndroidSchedulers.mainThread()).subscribe {
progress.visibility = if (it == 100) View.INVISIBLE else View.VISIBLE
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) progress.setProgress(it, true)

View File

@ -1,17 +1,31 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="MaterialDrawerTheme.Light.DarkToolbar.ActionBar">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<style name="FrostThemeBase" parent="MaterialDrawerTheme.ActionBar">
<item name="colorPrimary">@color/facebook_blue</item>
<item name="colorPrimaryDark">@color/facebook_blue_dark</item>
</style>
<style name="AppTheme.NoActionBar">
<style name="FrostTheme" parent="@style/FrostThemeBase">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.Overlay" parent="AppTheme.NoActionBar">
<style name="FrostTheme.Light" parent="MaterialDrawerTheme.Light.DarkToolbar">
<item name="colorPrimary">@color/facebook_blue</item>
<item name="colorPrimaryDark">@color/facebook_blue_dark</item>
</style>
<style name="FrostTheme.Transparent">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="FrostTheme.Light.Transparent">
<item name="android:windowShowWallpaper">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
<style name="FrostTheme.Overlay">
<item name="android:windowIsTranslucent">true</item>
<item name="android:activityOpenEnterAnimation">@anim/slide_in_right</item>
<item name="android:activityOpenExitAnimation">@anim/slide_out_right</item>
@ -23,7 +37,7 @@
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Dark" />
<style name="Theme.Splash" parent="Theme.AppCompat.NoActionBar">
<style name="FrostTheme.Splash" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:navigationBarColor">@color/splashBackground</item>
<item name="colorPrimaryDark">@color/splashBackground</item>