1
0
mirror of https://github.com/AllanWang/Frost-for-Facebook.git synced 2024-11-09 20:42:34 +01:00

Merge pull request #1720 from AllanWang/textbox

This commit is contained in:
Allan Wang 2020-10-04 02:37:11 -07:00 committed by GitHub
commit 4440326f4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 48 additions and 7 deletions

View File

@ -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" />

View File

@ -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)
}

View File

@ -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
}

View File

@ -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" }
}

View File

@ -1,3 +1,5 @@
v2.4.6
* Add option to hide likes and action bar in newsfeed
* 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)

View File

@ -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>

View File

@ -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" />

View File

@ -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)
};

View File

@ -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