aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-10-04 02:37:11 -0700
committerGitHub <noreply@github.com>2020-10-04 02:37:11 -0700
commit4440326f4bb9f57fd1635403b1966cb81f3d359f (patch)
tree49437ccd2f465ddfd71093eee7ea536cbf3f19e8
parent019067430fce1fdd6cc4ff0a4e63937927de2c17 (diff)
parent70563777b84fb475a5100054cb53bca261a7a0a7 (diff)
downloadfrost-4440326f4bb9f57fd1635403b1966cb81f3d359f.tar.gz
frost-4440326f4bb9f57fd1635403b1966cb81f3d359f.tar.bz2
frost-4440326f4bb9f57fd1635403b1966cb81f3d359f.zip
Merge pull request #1720 from AllanWang/textbox
-rw-r--r--.idea/codeStyles/Project.xml11
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/prefs/sections/BehaviourPrefs.kt4
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/settings/Behaviour.kt7
-rw-r--r--app/src/main/kotlin/com/pitchedapps/frost/web/FrostWebViewClients.kt5
-rw-r--r--app/src/main/play/en-US/whatsnew4
-rw-r--r--app/src/main/res/values/strings_pref_behaviour.xml2
-rw-r--r--app/src/main/res/xml/frost_changelog.xml4
-rw-r--r--app/src/web/ts/auto_resize_textarea.ts16
-rw-r--r--docs/Changelog.md2
9 files changed, 48 insertions, 7 deletions
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 7d1ace49..f9ad7a67 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -3,7 +3,16 @@
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
- <package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
+ <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
+ </value>
+ </option>
+ <option name="PACKAGES_IMPORT_LAYOUT">
+ <value>
+ <package name="" alias="false" withSubpackages="true" />
+ <package name="java" alias="false" withSubpackages="true" />
+ <package name="javax" alias="false" withSubpackages="true" />
+ <package name="kotlin" alias="false" withSubpackages="true" />
+ <package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="NAME_COUNT_TO_USE_STAR_IMPORT" value="2147483647" />
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..45a3e5c0 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; shouldRefreshMain() }) {
+ 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/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" }
}
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/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 @@
<string name="autoplay_settings_desc">Open Facebook\'s auto play settings. Note that it must be disabled for PIP to work.</string>
<string name="exit_confirmation">Exit Confirmation</string>
<string name="exit_confirmation_desc">Show confirmation dialog before exiting the app</string>
+ <string name="auto_expand_text_box">Auto expand text box</string>
+ <string name="auto_expand_text_box_desc">Increase text box height while typing. Disable if there are scroll issues.</string>
<string name="analytics">Analytics</string>
<string name="analytics_desc">Enable anonymous analytics and bug reports to help improve the app. No personal information is ever exposed.</string>
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 @@
<version title="v2.4.6" />
<item text="Add option to hide likes and action bar in newsfeed" />
- <item text="" />
- <item text="" />
+ <item text="Fix textbox scroll position when typing multiple lines" />
+ <item text="Add option to disable textbox auto resize (settings > behaviour)" />
<version title="v2.4.5" />
<item text="Fix url query encoding" />
diff --git a/app/src/web/ts/auto_resize_textarea.ts b/app/src/web/ts/auto_resize_textarea.ts
index e170d14e..c71a75a1 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 = <NodeListOf<HTMLTextAreaElement>>document.querySelectorAll('textarea:not(.frostAutoExpand)');
+ const classTag = 'frostAutoExpand';
+ const textareas = <NodeListOf<HTMLTextAreaElement>>document.querySelectorAll(`textarea:not(.${classTag})`);
const dataAttribute = 'data-frost-minHeight';
@@ -11,14 +12,25 @@
// 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);
}
textareas.forEach(el => {
- el.classList.add('frostAutoExpand')
+ el.classList.add(classTag)
const __frostAutoExpand = () => {
_frostAutoExpand(el)
};
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