aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-08-19 21:07:54 -0700
committerAllan Wang <me@allanwang.ca>2017-08-19 21:07:54 -0700
commit1240e2663413b56c5b97c8ff40cb5c1bdc2df23b (patch)
tree33dd66313ce0dba5af72b2f4046313306850dbf9 /app/src
parentbf2168ee57ded706819d1e4f49d729d4f45e1d29 (diff)
downloadfrost-1240e2663413b56c5b97c8ff40cb5c1bdc2df23b.tar.gz
frost-1240e2663413b56c5b97c8ff40cb5c1bdc2df23b.tar.bz2
frost-1240e2663413b56c5b97c8ff40cb5c1bdc2df23b.zip
Add bottom bar layout
Diffstat (limited to 'app/src')
-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
-rw-r--r--app/src/main/res/layout/activity_main_bottom_tabs.xml50
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/values/strings_pref_appearance.xml3
8 files changed, 122 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) {
diff --git a/app/src/main/res/layout/activity_main_bottom_tabs.xml b/app/src/main/res/layout/activity_main_bottom_tabs.xml
new file mode 100644
index 00000000..e10a1cb9
--- /dev/null
+++ b/app/src/main/res/layout/activity_main_bottom_tabs.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/main_content"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:fitsSystemWindows="true"
+ tools:context=".activities.MainActivity">
+
+ <android.support.design.widget.AppBarLayout
+ android:id="@+id/appbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <android.support.v7.widget.Toolbar
+ android:id="@+id/toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="?attr/actionBarSize"
+ android:background="?attr/colorPrimary"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:popupTheme="@style/AppTheme.PopupOverlay">
+
+ </android.support.v7.widget.Toolbar>
+
+ </android.support.design.widget.AppBarLayout>
+
+ <com.pitchedapps.frost.views.FrostViewPager
+ android:id="@+id/container"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+
+ <android.support.design.widget.TabLayout
+ android:id="@+id/tabs"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ app:tabIndicatorHeight="0dp" />
+
+ <android.support.design.widget.FloatingActionButton
+ android:id="@+id/fab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="end|bottom"
+ android:layout_margin="@dimen/kau_fab_margin"
+ android:visibility="gone" />
+
+</android.support.design.widget.CoordinatorLayout>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index eff04778..c8a97c92 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -64,4 +64,7 @@
<string name="html_extraction_cancelled">The request has been cancelled.</string>
<string name="html_extraction_timeout">The request has timed out.</string>
<string name="file_chooser_not_found">File chooser not found</string>
+
+ <string name="top_bar">Top Bar</string>
+ <string name="bottom_bar">Bottom Bar</string>
</resources>
diff --git a/app/src/main/res/values/strings_pref_appearance.xml b/app/src/main/res/values/strings_pref_appearance.xml
index 513baf5f..f2e0f9e0 100644
--- a/app/src/main/res/values/strings_pref_appearance.xml
+++ b/app/src/main/res/values/strings_pref_appearance.xml
@@ -12,6 +12,9 @@
<string name="global_customization">Global Customization</string>
+ <string name="main_activity_layout">Main Activity Layout</string>
+ <string name="set_main_activity_layout">Set Main Activity Layout</string>
+
<string name="rounded_icons">Rounded Icons</string>
<string name="rounded_icons_desc">Profile photos and group conversation icons will be rounded</string>