aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-15 17:02:52 -0700
committerAllan Wang <me@allanwang.ca>2017-06-15 17:02:52 -0700
commit0d1f0e215b1890f2f5d45373b2746b7ef91da494 (patch)
tree9153570f548e1199e6358ef7017f973ec07b7598 /app/src/main/kotlin
parent15d8a70a6c7596bb9f59a4383df7dccbba3a7012 (diff)
downloadfrost-0d1f0e215b1890f2f5d45373b2746b7ef91da494.tar.gz
frost-0d1f0e215b1890f2f5d45373b2746b7ef91da494.tar.bz2
frost-0d1f0e215b1890f2f5d45373b2746b7ef91da494.zip
Theme remaining activities
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt15
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt3
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt18
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt1
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt21
7 files changed, 64 insertions, 15 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
index 386bf4d3..c4cf7a97 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
@@ -1,5 +1,6 @@
package com.pitchedapps.frost
+import android.graphics.drawable.ColorDrawable
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.os.Handler
@@ -7,7 +8,7 @@ import android.support.v4.widget.SwipeRefreshLayout
import android.support.v7.widget.AppCompatTextView
import android.support.v7.widget.Toolbar
import android.widget.ImageView
-import ca.allanwang.kau.utils.bindView
+import ca.allanwang.kau.utils.*
import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException
@@ -20,6 +21,7 @@ import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.views.fadeIn
import com.pitchedapps.frost.views.fadeOut
@@ -65,6 +67,7 @@ class LoginActivity : BaseActivity() {
setContentView(R.layout.activity_login)
setSupportActionBar(toolbar)
setTitle(R.string.login)
+ theme()
web.loginObservable = loginObservable
web.progressObservable = progressObservable
loginObservable.observeOn(AndroidSchedulers.mainThread()).subscribe {
@@ -79,6 +82,16 @@ class LoginActivity : BaseActivity() {
web.loadLogin()
}
+ fun theme() {
+ val darkAccent = Prefs.headerColor.darken()
+ statusBarColor = darkAccent.darken().withAlpha(255)
+ navigationBarColor = darkAccent
+ toolbar.setBackgroundColor(darkAccent)
+ toolbar.setTitleTextColor(Prefs.iconColor)
+ window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor))
+ toolbar.overflowIcon?.setTint(Prefs.iconColor)
+ }
+
fun loadInfo(cookie: CookieModel) {
refresh = true
Observable.zip(SingleToObservable(profileObservable), SingleToObservable(usernameObservable),
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index f60d31a0..932c0339 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -87,7 +87,7 @@ class MainActivity : BaseActivity() {
fun theme() {
val darkAccent = Prefs.headerColor.darken()
- statusBarColor = darkAccent.withAlpha(255)
+ statusBarColor = darkAccent.darken().withAlpha(255)
navigationBarColor = darkAccent
tabs.setBackgroundColor(darkAccent)
appBar.setBackgroundColor(darkAccent)
@@ -128,6 +128,7 @@ class MainActivity : BaseActivity() {
textColor = Prefs.iconColor.toLong()
backgroundDrawable = ColorDrawable(navHeader)
selectionSecondLineShown = false
+ paddingBelow = false
cookies().forEach { (id, name) ->
profile(name = name ?: "") {
iconUrl = PROFILE_PICTURE_URL(id)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
index 082d7887..7c4866cf 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
@@ -1,14 +1,17 @@
package com.pitchedapps.frost
+import android.graphics.drawable.ColorDrawable
import android.os.Bundle
+import android.support.v7.widget.AppCompatTextView
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
-import ca.allanwang.kau.utils.bindView
+import ca.allanwang.kau.utils.*
import com.mikepenz.fastadapter.FastAdapter
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
import com.mikepenz.fastadapter.listeners.ClickEventHook
import com.pitchedapps.frost.facebook.FbCookie
+import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.cookies
import com.pitchedapps.frost.utils.launchNewTask
import com.pitchedapps.frost.views.AccountItem
@@ -20,6 +23,7 @@ class SelectorActivity : BaseActivity() {
val recycler: RecyclerView by bindView(R.id.selector_recycler)
val adapter = FastItemAdapter<AccountItem>()
+ val text: AppCompatTextView by bindView(R.id.text_select_account)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -36,5 +40,17 @@ class SelectorActivity : BaseActivity() {
else FbCookie.switchUser(item.cookie, { launchNewTask(MainActivity::class.java, cookies()) })
}
})
+ theme()
+ }
+
+ fun theme() {
+ val darkAccent = Prefs.headerColor.darken()
+ statusBarColor = darkAccent.darken().withAlpha(255)
+ navigationBarColor = darkAccent
+ text.setTextColor(Prefs.textColor)
+// toolbar.setBackgroundColor(darkAccent)
+// toolbar.setTitleTextColor(Prefs.iconColor)
+ window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor))
+// toolbar.overflowIcon?.setTint(Prefs.iconColor)
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index cc190004..846d6298 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -1,10 +1,12 @@
package com.pitchedapps.frost
import android.os.Bundle
+import android.support.design.widget.CoordinatorLayout
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.Toolbar
-import ca.allanwang.kau.utils.bindView
+import ca.allanwang.kau.utils.*
import com.jude.swipbackhelper.SwipeBackHelper
+import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.url
import com.pitchedapps.frost.web.FrostWebView
@@ -16,6 +18,7 @@ class WebOverlayActivity : AppCompatActivity() {
val toolbar: Toolbar by bindView(R.id.overlay_toolbar)
val frostWeb: FrostWebView by bindView(R.id.overlay_frost_webview)
+ val coordinator: CoordinatorLayout by bindView(R.id.overlay_main_content)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -33,6 +36,20 @@ class WebOverlayActivity : AppCompatActivity() {
.setSwipeRelateEnable(true)
.setSwipeRelateOffset(300)
frostWeb.web.addTitleListener({ toolbar.title = it })
+ theme()
+ }
+
+ /**
+ * Our theme for the overlay should be fully opaque
+ */
+ fun theme() {
+ val darkAccent = Prefs.headerColor.darken().withAlpha(255)
+ statusBarColor = darkAccent.darken()
+ navigationBarColor = darkAccent
+ toolbar.setBackgroundColor(darkAccent)
+ toolbar.setTitleTextColor(Prefs.iconColor)
+ coordinator.setBackgroundColor(Prefs.bgColor.withAlpha(255))
+ toolbar.overflowIcon?.setTint(Prefs.iconColor)
}
override fun onPostCreate(savedInstanceState: Bundle?) {
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 45ece582..d207dddc 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssAssets.kt
@@ -10,7 +10,7 @@ import com.pitchedapps.frost.utils.L
* //TODO add folder mapping using Prefs
*/
enum class CssAssets(val folder: String = "themes") : InjectorContract {
- LOGIN("core"), MATERIAL_LIGHT, MATERIAL_DARK, MATERIAL_AMOLED, MATERIAL_GLASS, CUSTOM
+ MATERIAL_LIGHT, MATERIAL_DARK, MATERIAL_AMOLED, MATERIAL_GLASS, CUSTOM
;
var file = "${name.toLowerCase()}.compact.css"
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt
index 5ecc6d66..72279ee3 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/injectors/CssHider.kt
@@ -6,6 +6,7 @@ import android.webkit.WebView
* Created by Allan Wang on 2017-05-31.
*/
enum class CssHider(vararg val items: String) : InjectorContract {
+ CORE("[data-sigil=\"m_login_upsell\"]"),
HEADER("#header[data-sigil=\"MTopBlueBarHeader\"]", "#header-notices", "[data-sigil*=\"m-promo-jewel-header\"]"),
ADS("[data-xt*=\"is_sponsored.1\"]")
;
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
index 721a75de..aa10e602 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/web/LoginWebView.kt
@@ -8,8 +8,10 @@ import android.webkit.*
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.facebook.FACEBOOK_COM
import com.pitchedapps.frost.facebook.FbCookie
-import com.pitchedapps.frost.injectors.CssAssets
+import com.pitchedapps.frost.injectors.CssHider
+import com.pitchedapps.frost.injectors.jsInject
import com.pitchedapps.frost.utils.L
+import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.views.fadeIn
import com.pitchedapps.frost.views.snackbar
import io.reactivex.subjects.PublishSubject
@@ -19,9 +21,6 @@ import io.reactivex.subjects.Subject
/**
* Created by Allan Wang on 2017-05-29.
*
- * Courtesy of takahirom
- *
- * https://github.com/takahirom/webview-in-coordinatorlayout/blob/master/app/src/main/java/com/github/takahirom/webview_in_coodinator_layout/NestedWebView.java
*/
@@ -64,8 +63,8 @@ class LoginWebView @JvmOverloads constructor(
fun setupWebview() {
settings.javaScriptEnabled = true
setLayerType(View.LAYER_TYPE_HARDWARE, null)
- setWebViewClient(LoginClient())
- setWebChromeClient(LoginChromeClient())
+ webViewClient = LoginClient()
+ webChromeClient = LoginChromeClient()
}
fun loadLogin() {
@@ -83,10 +82,12 @@ class LoginWebView @JvmOverloads constructor(
return
}
cookieObservable.onNext(Pair(url, CookieManager.getInstance().getCookie(url)))
- CssAssets.LOGIN.inject(view, {
- if (view.visibility == View.INVISIBLE)
- view.fadeIn(offset = 150L)
- })
+ view.jsInject(CssHider.HEADER, CssHider.CORE,
+ Prefs.themeInjector,
+ callback = {
+ if (view.visibility != View.VISIBLE)
+ view.fadeIn(offset = 150L)
+ })
}
}