aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/kotlin/com
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/kotlin/com')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt5
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt29
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt28
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt6
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt6
5 files changed, 66 insertions, 8 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
index 45488c94..6d7f0aad 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/MainActivity.kt
@@ -125,7 +125,7 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
"Frost id" to Prefs.frostId)
}
}
- setContentView(R.layout.activity_main)
+ setContentView(Prefs.mainActivityLayout.layoutRes)
setSupportActionBar(toolbar)
adapter = SectionsPagerAdapter(supportFragmentManager, loadFbTabs())
viewPager.adapter = adapter
@@ -159,7 +159,8 @@ class MainActivity : BaseActivity(), SearchWebView.SearchContract,
// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show()
// }
- setFrostColors(toolbar, themeWindow = false, headers = arrayOf(tabs, appBar), backgrounds = arrayOf(viewPager))
+ setFrostColors(toolbar, themeWindow = false, headers = arrayOf(appBar), backgrounds = arrayOf(viewPager))
+ tabs.setBackgroundColor(Prefs.mainActivityLayout.backgroundColor())
onCreateBilling()
setNetworkObserver {
connectivity ->
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt
new file mode 100644
index 00000000..b3d71cfc
--- /dev/null
+++ b/app/src/main/kotlin/com/pitchedapps/frost/enums/MainActivityLayout.kt
@@ -0,0 +1,29 @@
+package com.pitchedapps.frost.enums
+
+import com.pitchedapps.frost.R
+import com.pitchedapps.frost.utils.Prefs
+
+/**
+ * Created by Allan Wang on 2017-08-19.
+ */
+enum class MainActivityLayout(
+ val titleRes: Int,
+ val layoutRes: Int,
+ val backgroundColor: () -> Int,
+ val iconColor: () -> Int) {
+
+ TOP_BAR(R.string.top_bar,
+ R.layout.activity_main,
+ { Prefs.headerColor },
+ { Prefs.iconColor }),
+
+ BOTTOM_BAR(R.string.bottom_bar,
+ R.layout.activity_main_bottom_tabs,
+ { Prefs.bgColor },
+ { Prefs.textColor });
+
+ companion object {
+ val values = MainActivityLayout.values() //save one instance
+ operator fun invoke(index: Int) = values[index]
+ }
+} \ No newline at end of file
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
index 7dff5b16..43a186db 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Appearance.kt
@@ -8,6 +8,7 @@ import ca.allanwang.kau.utils.string
import com.pitchedapps.frost.R
import com.pitchedapps.frost.activities.MainActivity
import com.pitchedapps.frost.activities.SettingsActivity
+import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.injectors.CssAssets
import com.pitchedapps.frost.utils.*
import com.pitchedapps.frost.utils.iab.IS_FROST_PRO
@@ -27,9 +28,9 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
title(R.string.theme)
items(Theme.values()
.map { if (it == Theme.CUSTOM && !IS_FROST_PRO) R.string.custom_pro else it.textRes }
- .map { context.string(it) })
+ .map { string(it) })
itemsCallbackSingleChoice(item.pref) {
- _, _, which, text ->
+ _, _, which, _ ->
if (item.pref != which) {
if (which == Theme.CUSTOM.ordinal && !IS_FROST_PRO) {
purchasePro()
@@ -41,7 +42,7 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
setFrostTheme(true)
themeExterior()
invalidateOptionsMenu()
- frostAnswersCustom("Theme", "Count" to text)
+ frostAnswersCustom("Theme", "Count" to Theme(which).name)
}
true
}
@@ -117,6 +118,27 @@ fun SettingsActivity.getAppearancePrefs(): KPrefAdapterBuilder.() -> Unit = {
header(R.string.global_customization)
+ text(R.string.main_activity_layout, { Prefs.mainActivityLayoutType }, { Prefs.mainActivityLayoutType = it }) {
+ textGetter = { string(Prefs.mainActivityLayout.titleRes) }
+ onClick = {
+ _, _, item ->
+ materialDialogThemed {
+ title(R.string.set_main_activity_layout)
+ items(MainActivityLayout.values.map { string(it.titleRes) })
+ itemsCallbackSingleChoice(item.pref) {
+ _, _, which, _ ->
+ if (item.pref != which) {
+ item.pref = which
+ shouldRestartMain()
+ frostAnswersCustom("Main Layout", "Type" to MainActivityLayout(which).name)
+ }
+ true
+ }
+ }
+ true
+ }
+ }
+
checkbox(R.string.rounded_icons, { Prefs.showRoundedIcons }, {
Prefs.showRoundedIcons = it
setFrostResult(MainActivity.REQUEST_REFRESH)
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 126bd500..56c33b4b 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -6,6 +6,7 @@ import ca.allanwang.kau.kpref.KPref
import ca.allanwang.kau.kpref.StringSet
import ca.allanwang.kau.kpref.kpref
import ca.allanwang.kau.utils.isColorVisibleOn
+import com.pitchedapps.frost.enums.MainActivityLayout
import com.pitchedapps.frost.facebook.FeedSort
import com.pitchedapps.frost.injectors.InjectorContract
@@ -132,4 +133,9 @@ object Prefs : KPref() {
var debugSettings: Boolean by kpref("debug_settings", false)
var linksInDefaultApp: Boolean by kpref("link_in_default_app", false)
+
+ var mainActivityLayoutType: Int by kpref("main_activity_layout_type", 0)
+
+ val mainActivityLayout: MainActivityLayout
+ get() = MainActivityLayout(mainActivityLayoutType)
}
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
index 8ae54ef3..c1015aad 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/views/BadgedIcon.kt
@@ -24,11 +24,11 @@ class BadgedIcon @JvmOverloads constructor(
init {
inflate(context, R.layout.view_badged_icon, this)
- val badgeColor = Prefs.headerColor.withAlpha(255).colorToForeground(0.2f)
+ val badgeColor = Prefs.mainActivityLayout.backgroundColor().withAlpha(255).colorToForeground(0.2f)
val badgeBackground = GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, intArrayOf(badgeColor, badgeColor))
badgeBackground.cornerRadius = 13.dpToPx.toFloat()
badgeTextView.background = badgeBackground
- badgeTextView.setTextColor(Prefs.iconColor)
+ badgeTextView.setTextColor(Prefs.mainActivityLayout.iconColor())
}
@@ -36,7 +36,7 @@ class BadgedIcon @JvmOverloads constructor(
get() = field
set(value) {
field = value
- badgeImage.setImageDrawable(value?.toDrawable(context, color = Prefs.iconColor))
+ badgeImage.setImageDrawable(value?.toDrawable(context, color = Prefs.mainActivityLayout.iconColor()))
}
fun setAllAlpha(alpha: Float) {