New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TIMOB-25855] Android: TextArea lines and maxLines support #9927
Conversation
@m1ga, I remember the call order for Google's TextView From what I remember, calling Try testing it with the following... var tf = Ti.UI.createTextArea({
lines: 2,
maxLines: 2,
});
tf.lines = 4; Also note that the Thanks. |
@jquick-axway thanks for the tips! I'm checking that. TextFields shouldn't be a problem since I only set the new values if |
I've added a better example with more cases. It actually looks correct even with setting |
} | ||
|
||
if (d.containsKey(TiC.PROPERTY_MAX_LINES)) { | ||
if (!field) tv.setMaxLines(TiConvert.toInt(d, TiC.PROPERTY_MAX_LINES)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From looking at Google's Textview
Java code, they don't expect setMaxLines()
to be set to a value <= 0. Google defaults this to Integer.MAX_VALUE
by default. We should do the same if the property is set to <= 0. This is to avoid possible layout issues.
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L658
I believe we might have a similar issue with Android's setLines()
method since it set private member variable mMaximum
(used as max lines) to the given lines
value.
https://github.com/aosp-mirror/platform_frameworks_base/blob/master/core/java/android/widget/TextView.java#L4616
So, if the lines
property is <= 0, then we should call setMinLines(0)
instead.
I think the best thing to do is to apply lines
and maxLines
property changes via a method like how I'm doing it in the code below. You don't need the setSingleLine()
call, but you do need to call setMaxLines()
after calling setLines()
since Google resets the maximum afterwards.
https://github.com/appcelerator/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/TiUILabel.java#L706
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah nice, I'll copy the parts over to the UIText!
@@ -58,6 +60,8 @@ public TextAreaProxy() | |||
{ | |||
super(); | |||
defaultValues.put(TiC.PROPERTY_VALUE, ""); | |||
defaultValues.put(TiC.PROPERTY_LINES, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think lines
should default to -1.
For backward compatibility, we should respect the TextArea's height
property. The lines
property is used to set the height of the TextArea by line height instead (definitely a good feature) but the developer should opt-in to it.
apidoc/Titanium/UI/TextArea.yml
Outdated
@@ -366,6 +366,14 @@ properties: | |||
default: <Titanium.UI.KEYBOARD_DEFAULT> | |||
platforms: [android, iphone, ipad] | |||
|
|||
- name: lines | |||
summary: Line count of text field input. | |||
description: Sets the initial size of lines that the field will have at start. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make it clear that lines
sets the TextArea height by line height... and get rid of the "text field" references since this only applies to text areas.
How about the following...
summary: Number of lines tall the text area height will be, if set.
description: Sets the height of the text are by line height. Set to -1 to respect the view's height property instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CR: Pass
Thanks @m1ga :)
Generated by 🚫 dangerJS |
Generated by 🚫 dangerJS |
@m1ga Can you sign the CLA again? There is a new server for it. Also, a unit-test for each property would be great! |
👍 test added! |
Looks great, ready for merge! |
JIRA: https://jira.appcelerator.org/browse/TIMOB-25855