Skip to content
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-24080] Implementing ParagraphStyle Ti.UI.AttributedString #8558

Closed
wants to merge 3 commits into from

Conversation

kopiro
Copy link
Contributor

@kopiro kopiro commented Oct 27, 2016

@hansemannn hansemannn changed the title [AC-4583] Add AttributeNameLineHeight [TIMOB-24080] Expose line-height in Ti.UI.AttributedString Oct 28, 2016
@hansemannn
Copy link
Collaborator

@kopiro Please check my comments in the JIRA ticket for further discussions, thx!

@hansemannn hansemannn added this to the 6.1.0 milestone Oct 30, 2016
@hansemannn hansemannn self-assigned this Oct 30, 2016
@kopiro
Copy link
Contributor Author

kopiro commented Oct 31, 2016

Hi, @hansemannn I added the Android implementation, but I can't test because of this error (is the new scons.js build system)

➜  build git:(PR-AC-4583) ✗ node scons.js cleanbuild
Building MobileSDK version 6.1.0, githash aff294a
Buildfile: /Users/flavio.destefano/Repos/titanium/android/build.xml

clean.all:

[mkdir] Created dir: /Users/flavio.destefano/Repos/titanium/dist/android/classes/ant-tasks
[javac] Compiling 8 source files to /Users/flavio.destefano/Repos/titanium/dist/android/classes/ant-tasks
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] 1 warning
[jar] Building jar: /Users/flavio.destefano/Repos/titanium/dist/android/ant-tasks.jar
update.libv8:
download.libv8:
[exec] Android NDK: ERROR:/Users/flavio.destefano/Repos/titanium/android/runtime/v8/src/ndk-modules/libv8/Android.mk:v8_libbase: LOCAL_/opt/ndk/build/core/prebuilt-library.mk:45: *** SRC_FILES points to a missing file
[exec] Android NDK: Check that /Users/flavio.destefano/Repos/titanium/android/runtime/v8/src/ndk-modules/libv8/../../../../../../dist/android/libv8/5.1.281.59/release/libs/arm/libv8_libbase.a exists  or that its path is correct

[exec] Android NDK: Aborting    .  Stop.
BUILD FAILED
/Users/flavio.destefano/Repos/titanium/android/build/common.xml:624: exec returned: 2

Total time: 2 seconds

Any hint about that?

@sgtcoolguy
Copy link
Contributor

ok to test

@sgtcoolguy
Copy link
Contributor

@kopiro Looks like it's failing to grab the updated V8 libraries for Android. As part of the build it should download the new pre-built V8 libraries, and I'm guessing it timed out or had a network failure or something? Because it then errors saying it can't find one of the library files compiled against ARM.

Maybe just retry and hopefully it grabs the zip properly this time?

@hansemannn
Copy link
Collaborator

I noticed we don't have any unit-tests for attributed strings, yet, so it would be a good chance to add all of them. Since they are constant-based, we are able to test them pretty straight forward. I can assist you with writing them, as soon as the build itself passes.

@kopiro
Copy link
Contributor Author

kopiro commented Nov 2, 2016

@hansemannn we noticed (me and @progress44) that is a "mistake" in the implementation.

To implement the line height, we used the NSMutableParagraphStyle, but, by doing this, the user can't use another property of NSMutableParagraphStyle in the same range, otherwise the property is overwritten.

Example: alignment + line-height.

Maybe, a better implementation could be to expose the NSMutableParagraphStyle directly.

The main problem is that the AttributeNameLineBreak is already based on NSMutableParagraphStyle attribute, so we have to deprecate it :(

@hansemannn
Copy link
Collaborator

@kopiro Is it possible to logical AND ( | ) both? I can check the architecture design later this week.

@kopiro
Copy link
Contributor Author

kopiro commented Nov 2, 2016

@hansemannn I implemented totally the ParagraphStyle and removed the LINE_BREAK.
Let's talk about consequences :D

var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});
var label = Ti.UI.createLabel();
var str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent quis dolor consequat turpis pharetra laoreet vitae a sapien. Aliquam erat volutpat. Nulla sit amet tellus sapien, a pulvinar metus. Suspendisse risus elit, dictum id molestie ac, ullamcorper id dui. Vivamus dapibus, eros nec sodales semper, sem dui semper eros, id condimentum quam tellus at ligula. Ut justo magna, tempor et vestibulum id, tincidunt sit amet quam. Maecenas dictum metus vel diam blandit facilisis. Ut tincidunt nibh non ligula sagittis nec tincidunt augue vehicula. Suspendisse sem dui, ornare in condimentum ut, convallis ut quam. Proin pharetra augue sed tortor aliquam iaculis. Etiam non erat lectus. In ac metus massa, quis dictum metus. Quisque faucibus quam non leo fringilla sit amet mattis mauris dictum. Duis viverra ipsum blandit dolor congue sed adipiscing tortor porta. Nullam malesuada felis ut dolor dignissim faucibus.";

label.attributedString = Ti.UI.createAttributedString({
    text: str,
    attributes: [{
        type: Ti.UI.ATTRIBUTE_PARAGRAPH_STYLE,
        value: {
            alignment: Ti.UI.ATTRIBUTE_PARAGRAPH_STYLE_ALIGNMENT_JUSTIFIED,
            lineHeight: 3,
            headIndent: 5,
            unsupportedAndShouldWarn: "fefifo"
        },
        range: [0,str.length]
    }]
});

win.add(label);
win.open();

@kopiro kopiro changed the title [TIMOB-24080] Expose line-height in Ti.UI.AttributedString [TIMOB-24080] Implementing ParagraphStyle Ti.UI.AttributedString Nov 2, 2016
@kopiro kopiro force-pushed the PR-AC-4583 branch 4 times, most recently from ca06434 to e4ed741 Compare November 7, 2016 11:23
@kopiro
Copy link
Contributor Author

kopiro commented Dec 28, 2016

@hansemannn what here? We use this code in production and it seems stable.
Maybe we have to talk about a deprecation of AttributeNameLineBreak ?

@hansemannn
Copy link
Collaborator

hansemannn commented Dec 28, 2016

Give some time to think about it next week. Github should have a ping functionality for being pinged after x days / weeks :-)

@hansemannn hansemannn closed this Dec 28, 2016
@kopiro
Copy link
Contributor Author

kopiro commented Dec 28, 2016

Let me know if you want to know more info and if it's all clears, oherwise I'll explain.

@hansemannn hansemannn reopened this Dec 28, 2016
@hansemannn
Copy link
Collaborator

Whoops, didn't want to close it. Sure will do

@kopiro
Copy link
Contributor Author

kopiro commented May 29, 2017

@hansemannn Aligned with master

@@ -599,30 +598,45 @@ -(NSString *)ATTRIBUTE_LETTERPRESS_STYLE
{
return NSTextEffectLetterpressStyle;
}
-(NSNumber*)ATTRIBUTE_LINE_BREAK_BY_WORD_WRAPPING
-(NSNumber*)ATTRIBUTE_PARAGRAPH_STYLE_LINE_BREAK_BY_WORD_WRAPPING
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a breaking change. We should deprecate them like in the above example + remove it in the next major release.

NSNumber * num = [TiUtils numberFromObject:value];
[paragraphStyle setLineBreakMode:[num unsignedIntegerValue]];
attrValue = paragraphStyle;
DebugLog(@"[WARN] Ti.UI.AttributeNameLineBreak is deprecated, you must use AttributeNameParagraphStyle.lineBreak");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the DEPRECATED_REPLACED macro instead. This could work:

DEPRECATED_REPLACED(@"UI.ATTRIBUTE_LINE_BREAK", @"UI.ATTRIBUTE_PARAGRAPH_STYLE.linebreak", @"6.2.0");

Basically, this will generate a unified warning for you. The "Ti" is not needed, since it will be processed by the macro definition. Bu

@hansemannn hansemannn removed this from the 6.2.0 milestone Aug 8, 2017
@sgtcoolguy
Copy link
Contributor

@hansemannn ping!

@kopiro I don't see the Android changes in this PR. Do you still have them?

@hansemannn
Copy link
Collaborator

Cherry picked and rebased into #10032

@hansemannn hansemannn closed this May 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants