aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2019-07-21 01:07:06 -0700
committerAllan Wang <me@allanwang.ca>2019-07-21 01:07:06 -0700
commit0055ab5fdab9c86bed7982afde1739e95b093336 (patch)
tree845468f364ba67b3b7b19af0ce7b2c7013990b3e /app/src
parentdc5979df63c71c6271d733c31a75e5f3f8faa64f (diff)
downloadfrost-0055ab5fdab9c86bed7982afde1739e95b093336.tar.gz
frost-0055ab5fdab9c86bed7982afde1739e95b093336.tar.bz2
frost-0055ab5fdab9c86bed7982afde1739e95b093336.zip
Add prefs
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt40
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt19
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt2
-rw-r--r--app/src/main/res/values/strings_pref_behaviour.xml2
4 files changed, 46 insertions, 17 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
index 29ba4a3c..73bd5b2f 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/activities/BaseMainActivity.kt
@@ -271,7 +271,10 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
profileSetting(nameRes = R.string.kau_add_account) {
iconDrawable =
- IconicsDrawable(this@BaseMainActivity, GoogleMaterial.Icon.gmd_add).actionBar().paddingDp(5)
+ IconicsDrawable(
+ this@BaseMainActivity,
+ GoogleMaterial.Icon.gmd_add
+ ).actionBar().paddingDp(5)
.color(Prefs.textColor)
textColor = Prefs.textColor.toLong()
identifier = -3L
@@ -362,14 +365,15 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
}
- private 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 }
- }
+ private 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 }
+ }
private fun refreshAll() {
L.d { "Refresh all" }
@@ -413,7 +417,8 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
}
}
textDebounceInterval = 300
- searchCallback = { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true }
+ searchCallback =
+ { query, _ -> launchWebOverlay("${FbItem._SEARCH.url}/?q=$query"); true }
closeListener = { _ -> searchViewCache.clear() }
foregroundColor = Prefs.textColor
backgroundColor = Prefs.bgColor.withMinAlpha(200)
@@ -429,7 +434,11 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
val intent = Intent(this, SettingsActivity::class.java)
intent.putParcelableArrayListExtra(EXTRA_COOKIES, cookies())
val bundle =
- ActivityOptions.makeCustomAnimation(this, R.anim.kau_slide_in_right, R.anim.kau_fade_out).toBundle()
+ ActivityOptions.makeCustomAnimation(
+ this,
+ R.anim.kau_slide_in_right,
+ R.anim.kau_fade_out
+ ).toBundle()
startActivityForResult(intent, ACTIVITY_SETTINGS, bundle)
}
else -> return super.onOptionsItemSelected(item)
@@ -490,8 +499,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
controlWebview?.resumeTimers()
launch {
FbCookie.switchBackUser()
-// if (shouldReload)
-// refreshAll()
+ if (shouldReload && Prefs.autoRefreshFeed) {
+ refreshAll()
+ }
}
}
@@ -557,7 +567,9 @@ abstract class BaseMainActivity : BaseActivity(), MainActivityContract,
this.pages.forEachIndexed { index, fbItem ->
tabs.addTab(
tabs.newTab()
- .setCustomView(BadgedIcon(this@BaseMainActivity).apply { iicon = fbItem.icon }.also {
+ .setCustomView(BadgedIcon(this@BaseMainActivity).apply {
+ iicon = fbItem.icon
+ }.also {
it.setAllAlpha(if (index == 0) SELECTED_TAB_ALPHA else UNSELECTED_TAB_ALPHA)
})
)
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
index b77c0f2d..c774892e 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt
@@ -29,6 +29,10 @@ import com.pitchedapps.frost.utils.launchWebOverlay
*/
fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
+ checkbox(R.string.auto_refresh_feed, Prefs::autoRefreshFeed, { Prefs.autoRefreshFeed = it }) {
+ descRes = R.string.auto_refresh_feed_desc
+ }
+
checkbox(R.string.fancy_animations, Prefs::animate, { Prefs.animate = it; animate = it }) {
descRes = R.string.fancy_animations_desc
}
@@ -40,11 +44,17 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.overlay_swipe_desc
}
- checkbox(R.string.overlay_full_screen_swipe, Prefs::overlayFullScreenSwipe, { Prefs.overlayFullScreenSwipe = it }) {
+ checkbox(
+ R.string.overlay_full_screen_swipe,
+ Prefs::overlayFullScreenSwipe,
+ { Prefs.overlayFullScreenSwipe = it }) {
descRes = R.string.overlay_full_screen_swipe_desc
}
- checkbox(R.string.open_links_in_default, Prefs::linksInDefaultApp, { Prefs.linksInDefaultApp = it }) {
+ checkbox(
+ R.string.open_links_in_default,
+ Prefs::linksInDefaultApp,
+ { Prefs.linksInDefaultApp = it }) {
descRes = R.string.open_links_in_default_desc
}
@@ -52,7 +62,10 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = {
descRes = R.string.viewpager_swipe_desc
}
- checkbox(R.string.force_message_bottom, Prefs::messageScrollToBottom, { Prefs.messageScrollToBottom = it }) {
+ checkbox(
+ R.string.force_message_bottom,
+ Prefs::messageScrollToBottom,
+ { Prefs.messageScrollToBottom = it }) {
descRes = R.string.force_message_bottom_desc
}
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 51eb856b..c10a95ce 100644
--- a/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
+++ b/app/src/main/kotlin/com/pitchedapps/frost/utils/Prefs.kt
@@ -173,6 +173,8 @@ object Prefs : KPref() {
var blackMediaBg: Boolean by kpref("black_media_bg", false)
+ var autoRefreshFeed: Boolean by kpref("auto_refresh_feed", false)
+
inline val mainActivityLayout: MainActivityLayout
get() = MainActivityLayout(mainActivityLayoutType)
diff --git a/app/src/main/res/values/strings_pref_behaviour.xml b/app/src/main/res/values/strings_pref_behaviour.xml
index 77c35c1c..32188698 100644
--- a/app/src/main/res/values/strings_pref_behaviour.xml
+++ b/app/src/main/res/values/strings_pref_behaviour.xml
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
+ <string name="auto_refresh_feed">Auto Refresh Feed</string>
+ <string name="auto_refresh_feed_desc">Refresh the feed after 30 minutes of inactivity</string>
<string name="fancy_animations">Fancy Animations</string>
<string name="fancy_animations_desc">Reveal webviews using ripples and animate transitions</string>
<string name="overlay_swipe">Enable Overlays</string>