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.kt10
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt2
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt68
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt110
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt9
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt8
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt14
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt2
11 files changed, 149 insertions, 98 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
index 46f0ad46..a408e461 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/BaseActivity.kt
@@ -19,12 +19,12 @@ open class BaseActivity : AppCompatActivity() {
override fun onBackPressed() {
if (isTaskRoot && Prefs.exitConfirmation) {
materialDialogThemed {
- title(R.string.exit)
- content(R.string.exit_confirmation)
- positiveText(android.R.string.yes)
- negativeText(android.R.string.no)
+ title(R.string.kau_exit)
+ content(R.string.kau_exit_confirmation)
+ positiveText(R.string.kau_yes)
+ negativeText(R.string.kau_no)
onPositive { _, _ -> super.onBackPressed() }
- checkBoxPromptRes(R.string.do_not_show_again, false, { _, b -> Prefs.exitConfirmation = !b })
+ checkBoxPromptRes(R.string.kau_do_not_show_again, false, { _, b -> Prefs.exitConfirmation = !b })
}
} else super.onBackPressed()
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
index d4f35a7e..63a537f6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/FrostApp.kt
@@ -1,7 +1,6 @@
package com.pitchedapps.frost
import android.app.Application
-import android.content.Context
import android.graphics.drawable.Drawable
import android.net.Uri
import android.widget.ImageView
@@ -11,7 +10,6 @@ import com.crashlytics.android.Crashlytics
import com.crashlytics.android.answers.Answers
import com.mikepenz.materialdrawer.util.AbstractDrawerImageLoader
import com.mikepenz.materialdrawer.util.DrawerImageLoader
-import com.mikepenz.materialdrawer.util.DrawerUIUtils
import com.pitchedapps.frost.facebook.FbCookie
import com.pitchedapps.frost.utils.CrashReportingTree
import com.pitchedapps.frost.utils.Prefs
@@ -38,10 +36,9 @@ class FrostApp : Application() {
FlowManager.init(FlowConfig.Builder(this).build())
Prefs.initialize(this, "${BuildConfig.APPLICATION_ID}.prefs")
FbCookie()
- if (Prefs.installDate == -1L) {
- Prefs.installDate = System.currentTimeMillis()
- Prefs.identifier = Random().nextInt(Int.MAX_VALUE)
- }
+ if (Prefs.installDate == -1L) Prefs.installDate = System.currentTimeMillis()
+ if (Prefs.identifier == -1) Prefs.identifier = Random().nextInt(Int.MAX_VALUE)
+ Prefs.lastLaunch = System.currentTimeMillis()
// if (LeakCanary.isInAnalyzerProcess(this)) return
// refWatcher = LeakCanary.install(this)
if (BuildConfig.DEBUG) {
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
index 85112fdc..5ad0517a 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/LoginActivity.kt
@@ -63,7 +63,7 @@ class LoginActivity : BaseActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
setSupportActionBar(toolbar)
- setTitle(R.string.login)
+ setTitle(R.string.kau_login)
setFrostColors(toolbar)
web.loginObservable = loginObservable
web.progressObservable = progressObservable
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
index d6583a50..1d52ed34 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/MainActivity.kt
@@ -1,11 +1,14 @@
package com.pitchedapps.frost
+import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
+import android.support.annotation.StringRes
import android.support.design.widget.AppBarLayout
import android.support.design.widget.FloatingActionButton
import android.support.design.widget.Snackbar
import android.support.design.widget.TabLayout
+import android.support.v4.app.ActivityOptionsCompat
import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.view.ViewPager
@@ -13,11 +16,13 @@ import android.support.v7.widget.Toolbar
import android.view.Menu
import android.view.MenuItem
import android.widget.ImageButton
+import ca.allanwang.kau.email.sendEmail
import ca.allanwang.kau.utils.*
import co.zsmb.materialdrawerkt.builders.Builder
import co.zsmb.materialdrawerkt.builders.accountHeader
import co.zsmb.materialdrawerkt.builders.drawer
import co.zsmb.materialdrawerkt.draweritems.badgeable.primaryItem
+import co.zsmb.materialdrawerkt.draweritems.badgeable.secondaryItem
import co.zsmb.materialdrawerkt.draweritems.divider
import co.zsmb.materialdrawerkt.draweritems.profile.profile
import co.zsmb.materialdrawerkt.draweritems.profile.profileSetting
@@ -58,6 +63,7 @@ class MainActivity : BaseActivity() {
companion object {
const val FRAGMENT_REFRESH = 99
+ const val REQUEST_RESTART = 90909
}
override fun onCreate(savedInstanceState: Bundle?) {
@@ -176,18 +182,18 @@ class MainActivity : BaseActivity() {
identifier = id
}
}
- profileSetting(nameRes = R.string.logout) {
+ profileSetting(nameRes = R.string.kau_logout) {
iicon = GoogleMaterial.Icon.gmd_exit_to_app
iconColor = Prefs.textColor.toLong()
textColor = Prefs.textColor.toLong()
identifier = -2L
}
- profileSetting(nameRes = R.string.add_account) {
+ profileSetting(nameRes = R.string.kau_add_account) {
iconDrawable = IconicsDrawable(this@MainActivity, GoogleMaterial.Icon.gmd_add).actionBar().paddingDp(5).color(Prefs.textColor)
textColor = Prefs.textColor.toLong()
identifier = -3L
}
- profileSetting(nameRes = R.string.manage_account) {
+ profileSetting(nameRes = R.string.kau_manage_account) {
iicon = GoogleMaterial.Icon.gmd_settings
iconColor = Prefs.textColor.toLong()
textColor = Prefs.textColor.toLong()
@@ -203,10 +209,10 @@ class MainActivity : BaseActivity() {
FbCookie.reset { launchLogin(cookies(), true) }
} else {
materialDialogThemed {
- title(R.string.logout)
- content(String.format(string(R.string.logout_confirm), currentCookie.name ?: Prefs.userId.toString()))
- positiveText(R.string.yes)
- negativeText(R.string.no)
+ title(R.string.kau_logout)
+ content(String.format(string(R.string.kau_logout_confirm_as_x), currentCookie.name ?: Prefs.userId.toString()))
+ positiveText(R.string.kau_yes)
+ negativeText(R.string.kau_no)
onPositive { _, _ ->
FbCookie.logout(Prefs.userId) {
val allCookies = cookies()
@@ -228,23 +234,24 @@ class MainActivity : BaseActivity() {
}
}
drawerHeader.setActiveProfile(Prefs.userId)
- primaryItem(FbTab.FEED_MOST_RECENT)
- primaryItem(FbTab.FEED_TOP_STORIES)
- primaryItem(FbTab.ACTIVITY_LOG)
+ primaryFrostItem(FbTab.FEED_MOST_RECENT)
+ primaryFrostItem(FbTab.FEED_TOP_STORIES)
+ primaryFrostItem(FbTab.ACTIVITY_LOG)
divider()
- primaryItem(FbTab.EVENTS)
- primaryItem(FbTab.BIRTHDAYS)
+ primaryFrostItem(FbTab.PHOTOS)
+ primaryFrostItem(FbTab.GROUPS)
+ primaryFrostItem(FbTab.PAGES)
divider()
- primaryItem(FbTab.PHOTOS)
- primaryItem(FbTab.GROUPS)
- primaryItem(FbTab.PAGES)
- primaryItem(FbTab.SAVED)
+ primaryFrostItem(FbTab.EVENTS)
+ primaryFrostItem(FbTab.BIRTHDAYS)
+ primaryFrostItem(FbTab.ON_THIS_DAY)
divider()
-
+ primaryFrostItem(FbTab.NOTES)
+ primaryFrostItem(FbTab.SAVED)
}
}
- fun Builder.primaryItem(item: FbTab) = this.primaryItem(item.titleId) {
+ fun Builder.primaryFrostItem(item: FbTab) = this.primaryItem(item.titleId) {
iicon = item.icon
iconColor = Prefs.textColor.toLong()
textColor = Prefs.textColor.toLong()
@@ -263,29 +270,44 @@ class MainActivity : BaseActivity() {
}
}
+ fun Builder.secondaryFrostItem(@StringRes title: Int, onClick: () -> Unit) = this.secondaryItem(title) {
+ textColor = Prefs.textColor.toLong()
+ selectedIconColor = Prefs.textColor.toLong()
+ selectedTextColor = Prefs.textColor.toLong()
+ selectedColor = 0x00000001.toLong()
+ identifier = title.toLong()
+ onClick { _ -> onClick(); false }
+ }
+
fun refreshAll() {
webFragmentObservable.onNext(FRAGMENT_REFRESH)
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
- toolbar.childrenSequence().forEach { (it as? ImageButton)?.setColorFilter(Prefs.iconColor) }
+ toolbar.tint(Prefs.iconColor)
+ setMenuIcons(menu, Prefs.iconColor,
+ R.id.action_settings to GoogleMaterial.Icon.gmd_settings)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_settings -> {
- startActivity(SettingsActivity::class.java, clearStack = true, intentBuilder = {
- putParcelableArrayListExtra(EXTRA_COOKIES, cookies())
- })
+ val intent = Intent(this, SettingsActivity::class.java)
+ val bundle = ActivityOptionsCompat.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle()
+ startActivityForResult(intent, 99, bundle)
}
- R.id.action_changelog -> showChangelog(R.xml.changelog, { theme() })
else -> return super.onOptionsItemSelected(item)
}
return true
}
+ override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
+ super.onActivityResult(requestCode, resultCode, data)
+ if (resultCode == REQUEST_RESTART) restart()
+ }
+
override fun onResume() {
super.onResume()
FbCookie.switchBackUser { }
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
index ef8345d0..7cf90cc6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/SettingsActivity.kt
@@ -1,12 +1,17 @@
package com.pitchedapps.frost
import android.os.Bundle
+import android.view.Menu
+import android.view.MenuItem
+import ca.allanwang.kau.email.sendEmail
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.mikepenz.google_material_typeface_library.GoogleMaterial
import com.pitchedapps.frost.utils.*
+
/**
* Created by Allan Wang on 2017-06-06.
*/
@@ -21,15 +26,19 @@ class SettingsActivity : KPrefActivity() {
_, _, item ->
this@SettingsActivity.materialDialogThemed {
title(R.string.theme)
- items(Theme.values().map { this@SettingsActivity.string(it.textRes) })
- itemsDisabledIndices(Theme.CUSTOM.ordinal)
+ items(Theme.values()
+ .filter { it != Theme.CUSTOM || BuildConfig.DEBUG } //TODO actually add custom theme
+ .map { this@SettingsActivity.string(it.textRes) })
+// itemsDisabledIndices(Theme.CUSTOM.ordinal)
itemsCallbackSingleChoice(item.pref, {
_, _, which, text ->
if (item.pref != which) {
item.pref = which
+ shouldRestartMain()
reload()
setFrostTheme(true)
themeExterior()
+ invalidateOptionsMenu()
frostAnswersCustom("Theme") { putCustomAttribute("Count", text.toString()) }
}
true
@@ -40,44 +49,47 @@ class SettingsActivity : KPrefActivity() {
textGetter = { this@SettingsActivity.string(Theme(it).textRes) }
}
- colorPicker(R.string.text_color, { Prefs.customTextColor }, { Prefs.customTextColor = it; reload() }) {
- enabler = { Prefs.isCustomTheme }
- onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
- allowCustomAlpha = false
- allowCustom = true
- }
+ if (BuildConfig.DEBUG) {
+ colorPicker(R.string.text_color, { Prefs.customTextColor }, { Prefs.customTextColor = it; reload() }) {
+ enabler = { Prefs.isCustomTheme }
+ onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
+ allowCustomAlpha = false
+ allowCustom = true
+ }
- colorPicker(R.string.background_color, { Prefs.customBackgroundColor },
- { Prefs.customBackgroundColor = it; bgCanvas.ripple(it, duration = 500L) }) {
- enabler = { Prefs.isCustomTheme }
- onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
- allowCustomAlpha = true
- allowCustom = true
- }
+ colorPicker(R.string.background_color, { Prefs.customBackgroundColor },
+ { Prefs.customBackgroundColor = it; bgCanvas.ripple(it, duration = 500L) }) {
+ enabler = { Prefs.isCustomTheme }
+ onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
+ allowCustomAlpha = true
+ allowCustom = true
+ }
- colorPicker(R.string.header_color, { Prefs.customHeaderColor }, {
- Prefs.customHeaderColor = it
- val darkerColor = it.darken()
- this@SettingsActivity.navigationBarColor = darkerColor
- toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
- }) {
- enabler = { Prefs.isCustomTheme }
- onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
- allowCustomAlpha = true
- allowCustom = true
- }
+ colorPicker(R.string.header_color, { Prefs.customHeaderColor }, {
+ Prefs.customHeaderColor = it
+ val darkerColor = it.darken()
+ this@SettingsActivity.navigationBarColor = darkerColor
+ toolbarCanvas.ripple(darkerColor, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
+ }) {
+ enabler = { Prefs.isCustomTheme }
+ onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
+ allowCustomAlpha = true
+ allowCustom = true
+ }
- fun Long.timeToText(): String =
- if (this == -1L) string(R.string.none)
- else if (this == 60L) string(R.string.one_hour)
- else if (this == 1440L) string(R.string.one_day)
- else if (this % 1440L == 0L) String.format(string(R.string.x_days), this / 1440L)
- else if (this % 60L == 0L) String.format(string(R.string.x_hours), this / 60L)
- else String.format(string(R.string.x_minutes), this)
+ colorPicker(R.string.icon_color, { Prefs.customIconColor }, {
+ Prefs.customIconColor = it
+ invalidateOptionsMenu()
+ }) {
+ enabler = { Prefs.isCustomTheme }
+ onDisabledClick = { itemView, _, _ -> itemView.snackbar(R.string.requires_custom_theme); true }
+ allowCustom = true
+ }
+ }
text(R.string.notifications, { Prefs.notificationFreq }, { Prefs.notificationFreq = it; reloadByTitle(R.string.notifications) }) {
val options = longArrayOf(-1, 15, 30, 60, 120, 180, 300, 1440, 2880)
- val texts = options.map { it.timeToText() }
+ val texts = options.map { this@SettingsActivity.minuteToText(it) }
onClick = {
_, _, item ->
this@SettingsActivity.materialDialogThemed {
@@ -92,11 +104,15 @@ class SettingsActivity : KPrefActivity() {
}
true
}
- textGetter = { it.timeToText() }
+ textGetter = { this@SettingsActivity.minuteToText(it) }
}
}
+ fun shouldRestartMain() {
+ setResult(MainActivity.REQUEST_RESTART)
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
setFrostTheme(true)
super.onCreate(savedInstanceState)
@@ -113,8 +129,26 @@ class SettingsActivity : KPrefActivity() {
}
override fun onBackPressed() {
- startActivity(MainActivity::class.java, clearStack = true, intentBuilder = {
- putParcelableArrayListExtra(EXTRA_COOKIES, cookies())
- })
+ finishSlideOut()
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu): Boolean {
+ menuInflater.inflate(R.menu.menu_settings, menu)
+ toolbar.tint(Prefs.iconColor)
+ setMenuIcons(menu, Prefs.iconColor,
+ R.id.action_email to GoogleMaterial.Icon.gmd_email,
+ R.id.action_changelog to GoogleMaterial.Icon.gmd_info)
+ return true
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.action_email -> sendEmail(R.string.dev_email, R.string.frost_feedback) {
+ addItem("Random Frost ID", "${Prefs.installDate}-${Prefs.identifier}")
+ }
+ R.id.action_changelog -> showChangelog(R.xml.changelog, { theme() })
+ else -> return super.onOptionsItemSelected(item)
+ }
+ return true
}
} \ 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 665e32b4..7cc3dfe8 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/WebOverlayActivity.kt
@@ -39,7 +39,7 @@ open class WebOverlayActivity : AppCompatActivity() {
supportActionBar?.setDisplayShowHomeEnabled(true)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
toolbar.navigationIcon = GoogleMaterial.Icon.gmd_close.toDrawable(this, 16, Prefs.iconColor)
- toolbar.setNavigationOnClickListener { slideOut() }
+ toolbar.setNavigationOnClickListener { finishSlideOut() }
SwipeBackHelper.onCreate(this)
SwipeBackHelper.getCurrentPage(this)
.setSwipeBackEnable(true)
@@ -95,12 +95,7 @@ open class WebOverlayActivity : AppCompatActivity() {
override fun onBackPressed() {
if (!frostWeb.onBackPressed()) {
- slideOut()
+ finishSlideOut()
}
}
-
- fun slideOut() {
- finish()
- overridePendingTransition(R.anim.kau_fade_in, R.anim.kau_slide_out_right_top)
- }
} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
index 4deef24c..c91792a2 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/FbTab.kt
@@ -15,7 +15,7 @@ enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: Stri
FEED_MOST_RECENT(R.string.most_recent, GoogleMaterial.Icon.gmd_history, "/?sk=h_chr"),
FEED_TOP_STORIES(R.string.top_stories, GoogleMaterial.Icon.gmd_star, "/?sk=h_nor"),
PROFILE(R.string.profile, CommunityMaterial.Icon.cmd_account, "me"),
- EVENTS(R.string.events, GoogleMaterial.Icon.gmd_event, "events/upcoming"),
+ EVENTS(R.string.events, GoogleMaterial.Icon.gmd_event_note, "events/upcoming"),
FRIENDS(R.string.friends, GoogleMaterial.Icon.gmd_people, "friends/center/requests"),
MESSAGES(R.string.messages, MaterialDesignIconic.Icon.gmi_comments, "messages"),
NOTIFICATIONS(R.string.notifications, MaterialDesignIconic.Icon.gmi_globe, "notifications"),
@@ -27,10 +27,12 @@ enum class FbTab(@StringRes val titleId: Int, val icon: IIcon, relativeUrl: Stri
CHAT(R.string.chat, GoogleMaterial.Icon.gmd_chat, "buddylist"),
PHOTOS(R.string.photos, GoogleMaterial.Icon.gmd_photo, "me/photos"),
SETTINGS(R.string.settings, GoogleMaterial.Icon.gmd_settings, "settings"),
- MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings", { FrostWebViewClientMenu(it) })
+ MENU(R.string.menu, GoogleMaterial.Icon.gmd_menu, "settings", { FrostWebViewClientMenu(it) }),
+ NOTES(R.string.notes, CommunityMaterial.Icon.cmd_note, "notes"),
+ ON_THIS_DAY(R.string.on_this_day, GoogleMaterial.Icon.gmd_today, "onthisday")
;
val url = "$FB_URL_BASE$relativeUrl"
}
-fun defaultTabs(): List<FbTab> = listOf(FbTab.FEED, FbTab.MESSAGES, FbTab.NOTIFICATIONS, FbTab.MENU) \ No newline at end of file
+fun defaultTabs(): List<FbTab> = listOf(FbTab.FEED, FbTab.MESSAGES, FbTab.NOTIFICATIONS, FbTab.MENU)
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 9f37ff2e..83564be9 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -13,7 +13,7 @@ import com.pitchedapps.frost.injectors.InjectorContract
*/
object Prefs : KPref() {
- var lastActive: Long by kpref("last_active", -1L)
+ var lastLaunch: Long by kpref("last_launch", -1L)
var userId: Long by kpref("user_id", -1L)
@@ -37,7 +37,7 @@ object Prefs : KPref() {
var installDate: Long by kpref("install_date", -1L)
- var identifier: Int by kpref("indentifier", -1)
+ var identifier: Int by kpref("identifier", -1)
private val loader = lazyResettable { Theme.values[Prefs.theme] }
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 1eff6780..43bb6ec6 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Theme.kt
@@ -12,13 +12,13 @@ import com.pitchedapps.frost.injectors.JsActions
enum class Theme(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._default, JsActions.EMPTY, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
- LIGHT(R.string.light, CssAssets.MATERIAL_LIGHT, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
- DARK(R.string.dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
- AMOLED(R.string.amoled, CssAssets.MATERIAL_AMOLED, { Color.WHITE }, { Color.BLACK }, { Color.BLACK }, { Color.WHITE }),
- GLASS(R.string.glass, CssAssets.MATERIAL_GLASS, { Color.WHITE }, { 0x80000000.toInt() }, { 0xb3000000.toInt() }, { Color.WHITE }),
- CUSTOM(R.string.custom, JsActions.EMPTY, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor });
- //todo create custom
+ DEFAULT(R.string.kau_default, JsActions.EMPTY, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
+ LIGHT(R.string.kau_light, CssAssets.MATERIAL_LIGHT, { Color.BLACK }, { 0xfffafafa.toInt() }, { 0xff3b5998.toInt() }, { Color.WHITE }),
+ DARK(R.string.kau_dark, CssAssets.MATERIAL_DARK, { Color.WHITE }, { 0xff303030.toInt() }, { 0xff3b5998.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, JsActions.EMPTY, { Prefs.customTextColor }, { Prefs.customBackgroundColor }, { Prefs.customHeaderColor }, { Prefs.customIconColor })
+ ;
val textColor: Int
get() = textColorGetter.invoke()
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 b9de13af..8accffde 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Utils.kt
@@ -5,18 +5,19 @@ import android.app.job.JobInfo
import android.app.job.JobScheduler
import android.content.ComponentName
import android.content.Context
-import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
+import android.support.annotation.ColorInt
import android.support.v4.app.NotificationCompat
-import android.support.v4.content.ContextCompat
import android.support.v7.widget.Toolbar
+import android.view.Menu
import android.view.View
import android.widget.TextView
import ca.allanwang.kau.utils.*
import com.afollestad.materialdialogs.MaterialDialog
import com.crashlytics.android.answers.Answers
import com.crashlytics.android.answers.CustomEvent
+import com.mikepenz.iconics.typeface.IIcon
import com.pitchedapps.frost.*
import com.pitchedapps.frost.dbflow.CookieModel
import com.pitchedapps.frost.facebook.FB_URL_BASE
@@ -58,9 +59,9 @@ val String.formattedFbUrl: String
fun Context.launchWebOverlay(url: String) {
val argUrl = url.formattedFbUrl
L.i("Launch web overlay: $argUrl")
- val intent = Intent(this, WebOverlayActivity::class.java)
- intent.putExtra(ARG_URL, argUrl)
- ContextCompat.startActivity(this, intent, null)
+ startActivity(WebOverlayActivity::class.java, false, {
+ putExtra(ARG_URL, argUrl)
+ })
}
fun WebOverlayActivity.url(): String {
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 eb804a53..3de038bf 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/AccountItem.kt
@@ -55,7 +55,7 @@ class AccountItem(val cookie: CookieModel?) : AbstractItem<AccountItem, AccountI
} else {
text.visibility = View.VISIBLE
image.setImageDrawable(GoogleMaterial.Icon.gmd_add_circle_outline.toDrawable(itemView.context, 100, Prefs.textColor))
- text.text = itemView.context.getString(R.string.add_account)
+ text.text = itemView.context.getString(R.string.kau_add_account)
//todo add plus image
}
}