From d1f42ab59c86bbc7027b2337982405df78081947 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:07:45 -0700 Subject: Add setting --- .../kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt | 4 ++++ app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt | 7 +++++++ app/src/main/res/values/strings_pref_behaviour.xml | 2 ++ 3 files changed, 13 insertions(+) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt index ad0cb6be..f023d4af 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt @@ -46,6 +46,8 @@ interface BehaviourPrefs : PrefsBase { var showCreateFab: Boolean var fullSizeImage: Boolean + + var autoExpandTextBox: Boolean } class BehaviourPrefsImpl( @@ -106,4 +108,6 @@ class BehaviourPrefsImpl( "full_size_image", oldPrefs.fullSizeImage /* false */ ) + + override var autoExpandTextBox: Boolean by kpref("auto_expand_text_box", true) } 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 f6110756..e38314ea 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt @@ -65,6 +65,13 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = { descRes = R.string.force_message_bottom_desc } + checkbox( + R.string.auto_expand_text_box, + prefs::autoExpandTextBox, + { prefs.autoExpandTextBox = it }) { + descRes = R.string.auto_expand_text_box_desc + } + checkbox(R.string.enable_pip, prefs::enablePip, { prefs.enablePip = it }) { descRes = R.string.enable_pip_desc } diff --git a/app/src/main/res/values/strings_pref_behaviour.xml b/app/src/main/res/values/strings_pref_behaviour.xml index 32188698..b6d0aebc 100644 --- a/app/src/main/res/values/strings_pref_behaviour.xml +++ b/app/src/main/res/values/strings_pref_behaviour.xml @@ -23,6 +23,8 @@ Open Facebook\'s auto play settings. Note that it must be disabled for PIP to work. Exit Confirmation Show confirmation dialog before exiting the app + Auto expand text box + Increase text box height while typing. Disable if there are scroll issues. Analytics Enable anonymous analytics and bug reports to help improve the app. No personal information is ever exposed. -- cgit v1.2.3 From c86207a3baba6a1c2b4ebab611f0ae552d2607cd Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:14:51 -0700 Subject: Link settings with injection --- app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt index 5826f383..dd1d45cb 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt @@ -82,7 +82,10 @@ open class FrostWebViewClient(val web: FrostWebView) : BaseWebViewClient() { super.doUpdateVisitedHistory(view, url, isReload) urlSupportsRefresh = urlSupportsRefresh(url) web.parent.swipeEnabled = urlSupportsRefresh - view.jsInject(JsAssets.AUTO_RESIZE_TEXTAREA, prefs = prefs) + view.jsInject( + JsAssets.AUTO_RESIZE_TEXTAREA.maybe(prefs.autoExpandTextBox), + prefs = prefs + ) v { "History $url; refresh $urlSupportsRefresh" } } -- cgit v1.2.3 From ad9fdf9f6718918e9daf5c0afb378f0bc4e47283 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:22:24 -0700 Subject: Force refresh on settings change and use shared class tag --- app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt | 2 +- app/src/web/ts/auto_resize_textarea.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'app') 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 e38314ea..45a3e5c0 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt @@ -68,7 +68,7 @@ fun SettingsActivity.getBehaviourPrefs(): KPrefAdapterBuilder.() -> Unit = { checkbox( R.string.auto_expand_text_box, prefs::autoExpandTextBox, - { prefs.autoExpandTextBox = it }) { + { prefs.autoExpandTextBox = it; shouldRefreshMain() }) { descRes = R.string.auto_expand_text_box_desc } diff --git a/app/src/web/ts/auto_resize_textarea.ts b/app/src/web/ts/auto_resize_textarea.ts index e170d14e..1f1b3613 100644 --- a/app/src/web/ts/auto_resize_textarea.ts +++ b/app/src/web/ts/auto_resize_textarea.ts @@ -1,6 +1,7 @@ // Credits to https://codepen.io/tomhodgins/pen/KgazaE (function () { - const textareas = >document.querySelectorAll('textarea:not(.frostAutoExpand)'); + const classTag = 'frostAutoExpand'; + const textareas = >document.querySelectorAll(`textarea:not(.${classTag})`); const dataAttribute = 'data-frost-minHeight'; @@ -18,7 +19,7 @@ textareas.forEach(_frostAutoExpand); } textareas.forEach(el => { - el.classList.add('frostAutoExpand') + el.classList.add(classTag) const __frostAutoExpand = () => { _frostAutoExpand(el) }; -- cgit v1.2.3 From 6af10978aa5a4aaf1f596c54c4c5ef3373bec905 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:27:10 -0700 Subject: Add back scroll position after height change --- app/src/web/ts/auto_resize_textarea.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'app') diff --git a/app/src/web/ts/auto_resize_textarea.ts b/app/src/web/ts/auto_resize_textarea.ts index 1f1b3613..c71a75a1 100644 --- a/app/src/web/ts/auto_resize_textarea.ts +++ b/app/src/web/ts/auto_resize_textarea.ts @@ -12,8 +12,19 @@ // If no height is defined, have min bound to current height; // otherwise we will allow for height decreases in case user deletes text const minHeight = parseInt(el.getAttribute(dataAttribute) ?? '0'); + + // Save scroll position prior to height update + // See https://stackoverflow.com/a/18262927/4407321 + const scrollLeft = window.pageXOffset || + (document.documentElement || document.body.parentNode || document.body).scrollLeft; + const scrollTop = window.pageYOffset || + (document.documentElement || document.body.parentNode || document.body).scrollTop; + el.style.height = 'inherit'; el.style.height = `${Math.max(el.scrollHeight, minHeight)}px`; + + // Go to original scroll position + window.scrollTo(scrollLeft, scrollTop); }; function _frostExpandAll() { textareas.forEach(_frostAutoExpand); -- cgit v1.2.3 From 13593d0f13362494ab6ac8e9165622ac63ecc3dd Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:27:59 -0700 Subject: Update changelog --- app/src/main/res/xml/frost_changelog.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/main/res/xml/frost_changelog.xml b/app/src/main/res/xml/frost_changelog.xml index c380b27a..654f4a72 100644 --- a/app/src/main/res/xml/frost_changelog.xml +++ b/app/src/main/res/xml/frost_changelog.xml @@ -8,8 +8,8 @@ - - + + -- cgit v1.2.3 From 70563777b84fb475a5100054cb53bca261a7a0a7 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 3 Oct 2020 21:28:11 -0700 Subject: Update gen files --- app/src/main/play/en-US/whatsnew | 4 +++- docs/Changelog.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/play/en-US/whatsnew b/app/src/main/play/en-US/whatsnew index 9c5d8706..84e08a03 100644 --- a/app/src/main/play/en-US/whatsnew +++ b/app/src/main/play/en-US/whatsnew @@ -1,3 +1,5 @@ v2.4.6 -* Add option to hide likes and action bar in newsfeed \ No newline at end of file +* Add option to hide likes and action bar in newsfeed +* Fix textbox scroll position when typing multiple lines +* Add option to disable textbox auto resize (settings > behaviour) \ No newline at end of file diff --git a/docs/Changelog.md b/docs/Changelog.md index ac484d96..c404f43f 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,6 +2,8 @@ ## v2.4.6 * Add option to hide likes and action bar in newsfeed +* Fix textbox scroll position when typing multiple lines +* Add option to disable textbox auto resize (settings > behaviour) ## v2.4.5 * Fix url query encoding -- cgit v1.2.3