aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt13
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt24
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt20
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt18
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt4
8 files changed, 40 insertions, 56 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
index 6212b2be..46f0ad46 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
@@ -1,7 +1,13 @@
package com.pitchedapps.frost
+import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
+import android.support.v7.widget.Toolbar
+import ca.allanwang.kau.utils.darken
+import ca.allanwang.kau.utils.navigationBarColor
+import ca.allanwang.kau.utils.statusBarColor
+import ca.allanwang.kau.utils.withAlpha
import com.pitchedapps.frost.utils.Prefs
import com.pitchedapps.frost.utils.materialDialogThemed
import com.pitchedapps.frost.utils.setFrostTheme
@@ -27,4 +33,5 @@ open class BaseActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setFrostTheme()
}
+
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
index c3dad579..303b9987 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
@@ -23,6 +23,7 @@ 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.utils.setFrostColors
import com.pitchedapps.frost.web.LoginWebView
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
@@ -64,7 +65,7 @@ class LoginActivity : BaseActivity() {
setContentView(R.layout.activity_login)
setSupportActionBar(toolbar)
setTitle(R.string.login)
- theme()
+ setFrostColors(toolbar)
web.loginObservable = loginObservable
web.progressObservable = progressObservable
loginObservable.observeOn(AndroidSchedulers.mainThread()).subscribe {
@@ -79,16 +80,6 @@ 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 bbbe4e52..6f72d8c7 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -25,12 +25,10 @@ import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.materialdrawer.AccountHeader
import com.mikepenz.materialdrawer.Drawer
import com.pitchedapps.frost.dbflow.loadFbTabs
-import com.pitchedapps.frost.dbflow.saveAsync
import com.pitchedapps.frost.facebook.FbCookie.switchUser
import com.pitchedapps.frost.facebook.FbTab
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
import com.pitchedapps.frost.fragments.WebFragment
-import com.pitchedapps.frost.services.requestNotifications
import com.pitchedapps.frost.utils.*
import io.reactivex.subjects.PublishSubject
import org.jetbrains.anko.childrenSequence
@@ -88,22 +86,7 @@ class MainActivity : BaseActivity() {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show()
}
- theme()
- }
-
- fun theme() {
- val darkAccent = Prefs.headerColor.darken()
- statusBarColor = darkAccent.darken().withAlpha(255)
- navigationBarColor = darkAccent
- tabs.setBackgroundColor(darkAccent)
- appBar.setBackgroundColor(darkAccent)
- toolbar.setBackgroundColor(darkAccent)
- toolbar.setTitleTextColor(Prefs.iconColor)
-// toolbar.tint
- viewPager.setBackgroundColor(Prefs.bgColor)
- window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor))
- toolbar.overflowIcon?.setTint(Prefs.iconColor)
- drawer
+ setFrostColors(toolbar, headers = arrayOf(tabs, appBar), backgrounds = arrayOf(viewPager))
}
fun setupTabs() {
@@ -199,11 +182,6 @@ class MainActivity : BaseActivity() {
})
}
R.id.action_changelog -> showChangelog(R.xml.changelog, { theme() })
- R.id.action_call -> {
- requestNotifications(Prefs.userId)
- }
- R.id.action_db -> adapter.pages.saveAsync(this)
- R.id.action_restart -> restart()
else -> return super.onOptionsItemSelected(item)
}
return true
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
index 7c4866cf..103ae227 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SelectorActivity.kt
@@ -1,19 +1,19 @@
package com.pitchedapps.frost
-import android.graphics.drawable.ColorDrawable
import android.os.Bundle
+import android.support.constraint.ConstraintLayout
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.*
+import ca.allanwang.kau.utils.bindView
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.utils.setFrostColors
import com.pitchedapps.frost.views.AccountItem
/**
@@ -24,6 +24,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)
+ val container: ConstraintLayout by bindView(R.id.container)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -40,17 +41,6 @@ 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)
+ setFrostColors(texts = arrayOf(text), backgrounds = arrayOf(container))
}
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index 998b551e..3c6a75e0 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -27,7 +27,7 @@ class SettingsActivity : KPrefActivity() {
if (item.pref != which) {
item.pref = which
reload()
- setFrostTheme(true)
+ setFrostTheme()
themeExterior()
}
true
@@ -99,7 +99,6 @@ class SettingsActivity : KPrefActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
themeExterior(false)
- setFrostTheme(true)
}
fun themeExterior(animate: Boolean = true) {
@@ -111,8 +110,6 @@ class SettingsActivity : KPrefActivity() {
this.navigationBarColor = darkAccent
}
- private fun relativeDuration(canvas: RippleCanvas): Long = Math.hypot(canvas.height.toDouble(), canvas.width.toDouble() / 2).toLong()
-
override fun onBackPressed() {
startActivitySlideOut(MainActivity::class.java, clearStack = true, intentBuilder = {
putParcelableArrayListExtra(EXTRA_COOKIES, cookies())
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
index 632313b5..28b01486 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -7,9 +7,9 @@ import android.support.v7.widget.Toolbar
import ca.allanwang.kau.utils.*
import com.jude.swipbackhelper.SwipeBackHelper
import com.pitchedapps.frost.utils.Prefs
+import com.pitchedapps.frost.utils.setFrostColors
import com.pitchedapps.frost.utils.url
import com.pitchedapps.frost.web.FrostWebView
-import io.reactivex.disposables.Disposable
/**
@@ -37,7 +37,8 @@ class WebOverlayActivity : AppCompatActivity() {
.setSwipeRelateEnable(true)
.setSwipeRelateOffset(300)
frostWeb.web.addTitleListener({ toolbar.title = it })
- theme()
+ setFrostColors(toolbar, themeWindow = false)
+ coordinator.setBackgroundColor(Prefs.bgColor.withAlpha(255))
}
/**
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
index eb9f83d8..7000253d 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -4,8 +4,12 @@ import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Color
+import android.graphics.drawable.ColorDrawable
import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.content.ContextCompat
+import android.support.v7.widget.Toolbar
+import android.view.View
+import android.widget.TextView
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
import com.pitchedapps.frost.LoginActivity
@@ -81,4 +85,18 @@ fun Activity.setFrostTheme(forceTransparent: Boolean = false) {
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)
+}
+
+fun Activity.setFrostColors(toolbar: Toolbar? = null, themeWindow: Boolean = true,
+ texts: Array<TextView> = arrayOf(), headers: Array<View> = arrayOf(), backgrounds: Array<View> = arrayOf()) {
+ val darkAccent = Prefs.headerColor.darken()
+ statusBarColor = darkAccent.darken().withAlpha(255)
+ navigationBarColor = darkAccent
+ if (themeWindow) window.setBackgroundDrawable(ColorDrawable(Prefs.bgColor))
+ toolbar?.setBackgroundColor(darkAccent)
+ toolbar?.setTitleTextColor(Prefs.iconColor)
+ toolbar?.overflowIcon?.setTint(Prefs.iconColor)
+ texts.forEach { it.setTextColor(Prefs.textColor) }
+ headers.forEach { it.setBackgroundColor(darkAccent) }
+ backgrounds.forEach { it.setBackgroundColor(Prefs.bgColor) }
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
index 244c1388..eb804a53 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
@@ -20,6 +20,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.R
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.facebook.PROFILE_PICTURE_URL
+import com.pitchedapps.frost.utils.Prefs
/**
* Created by Allan Wang on 2017-06-05.
@@ -36,6 +37,7 @@ class AccountItem(val cookie: CookieModel?) : AbstractItem<AccountItem, AccountI
super.bindView(viewHolder, payloads)
with(viewHolder) {
text.visibility = View.INVISIBLE
+ text.setTextColor(Prefs.textColor)
if (cookie != null) {
text.text = cookie.name
val options = RequestOptions().transform(CircleCrop())
@@ -52,7 +54,7 @@ class AccountItem(val cookie: CookieModel?) : AbstractItem<AccountItem, AccountI
}).into(image)
} else {
text.visibility = View.VISIBLE
- image.setImageDrawable(GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(itemView.context, 100))
+ image.setImageDrawable(GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(itemView.context, 100, Prefs.textColor))
text.text = itemView.context.getString(R.string.add_account)
//todo add plus image
}