diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fab2d2a37..3e2c0bee7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -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"> + android:theme="@style/FrostTheme.Splash"> @@ -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" /> + android:theme="@style/FrostTheme.Overlay"> @@ -92,13 +92,13 @@ + android:theme="@style/FrostTheme" /> + android:theme="@style/FrostTheme" /> + android:theme="@style/FrostTheme" /> (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 diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt index 2053a6bf5..c2bcc2ab5 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/ContextUtils.kt @@ -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) } \ No newline at end of file diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt index 167661a41..c99feaf50 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebView.kt @@ -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) diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 75060d865..2bd938389 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,17 +1,31 @@ - - - - + + + + + +