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

feat(android): add letterSpacing to Label #13984

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,10 @@ public void processProperties(KrollDict d)
TiConvert.toFloat(dict.get(TiC.PROPERTY_MULTIPLY), 0));
}
}
if (d.containsKey(TiC.PROPERTY_LETTER_SPACING)) {
float value = TiConvert.toFloat(d.get(TiC.PROPERTY_LETTER_SPACING));
tv.setLetterSpacing(value);
}
if (d.containsKey(TiC.PROPERTY_COLOR)) {
Object color = d.get(TiC.PROPERTY_COLOR);
if (color == null) {
Expand Down Expand Up @@ -591,8 +595,11 @@ public void propertyChanged(String key, Object oldValue, Object newValue, KrollP
if (newValue instanceof HashMap) {
HashMap dict = (HashMap) newValue;
tv.setLineSpacing(TiConvert.toFloat(dict.get(TiC.PROPERTY_ADD), 0),
TiConvert.toFloat(dict.get(TiC.PROPERTY_MULTIPLY), 0));
TiConvert.toFloat(dict.get(TiC.PROPERTY_MULTIPLY), 0));
}
} else if (key.equals(TiC.PROPERTY_LETTER_SPACING)) {
float val = TiConvert.toFloat(newValue);
tv.setLetterSpacing(val);
} else if (key.equals(TiC.PROPERTY_HEIGHT)) {
// Update the view's height.
// Note: We may need to update lines/maxLines settings when switching to an auto-sized height.
Expand Down
2 changes: 2 additions & 0 deletions android/titanium/src/java/org/appcelerator/titanium/TiC.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ public class TiC
public static final String PROPERTY_LAYOUT = "layout";
public static final String PROPERTY_LAYOUT_ID = "layoutId";
public static final String PROPERTY_LEFT_DRAWER_LOCK_MODE = "leftDrawerLockMode";

public static final String PROPERTY_LETTER_SPACING = "letterSpacing";
public static final String PROPERTY_LINES = "lines";
public static final String PROPERTY_LINE_SPACING = "lineSpacing";
public static final String PROPERTY_LIFECYCLE_CONTAINER = "lifecycleContainer";
Expand Down
6 changes: 6 additions & 0 deletions apidoc/Titanium/UI/Label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ properties:
permission: read-only
since: "12.3.0"

- name: letterSpacing
summary: Letter spacing of the [text](Titanium.UI.Label.text) as a float value.
platforms: [android]
type: Number
since: "12.4.0"

- name: lineSpacing
summary: Line spacing of the [text](Titanium.UI.Label.text), as a dictionary with the properties `add` and `multiply`.
platforms: [android]
Expand Down
Loading