Skip to content

Commit 8f5bb0e

Browse files
committed
Merge branch 'master' of github.com:Akylas/nativescript-label
2 parents f41473e + c109a96 commit 8f5bb0e

File tree

6 files changed

+64
-9
lines changed

6 files changed

+64
-9
lines changed

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.3.24](https://github.com/nativescript-community/ui-label/compare/v1.3.23...v1.3.24) (2024-03-05)
7+
8+
### Bug Fixes
9+
10+
- **android:** regression fix ([07ec72b](https://github.com/nativescript-community/ui-label/commit/07ec72b6ef92d49ced93c70cd38dcd5c9a30f6bc))
11+
12+
## [1.3.23](https://github.com/nativescript-community/ui-label/compare/v1.3.22...v1.3.23) (2024-03-05)
13+
14+
### Bug Fixes
15+
16+
- **android:** prevent enableAutoSize to be called before min and max font size are set ([b1cdfd7](https://github.com/nativescript-community/ui-label/commit/b1cdfd738a1ba9c647f1d1ffff9c6ea12cc5b908))
17+
18+
## [1.3.22](https://github.com/nativescript-community/ui-label/compare/v1.3.21...v1.3.22) (2024-02-22)
19+
20+
### Bug Fixes
21+
22+
- **android:** wrong line height rendering on android < 28 ([4276ad6](https://github.com/nativescript-community/ui-label/commit/4276ad6494271f924ae5eafedfaa6f3e65607d95))
23+
624
## [1.3.21](https://github.com/Akylas/nativescript-label/compare/v1.3.20...v1.3.21) (2024-02-15)
725

826
### Bug Fixes

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": ["plugin"],
3-
"version": "1.3.21",
3+
"version": "1.3.24",
44
"command": {
55
"publish": {
66
"conventionalCommits": true

plugin/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.3.24](https://github.com/nativescript-community/ui-label/compare/v1.3.23...v1.3.24) (2024-03-05)
7+
8+
**Note:** Version bump only for package @nativescript-community/ui-label
9+
10+
## [1.3.23](https://github.com/nativescript-community/ui-label/compare/v1.3.22...v1.3.23) (2024-03-05)
11+
12+
**Note:** Version bump only for package @nativescript-community/ui-label
13+
14+
## [1.3.22](https://github.com/nativescript-community/ui-label/compare/v1.3.21...v1.3.22) (2024-02-22)
15+
16+
### Bug Fixes
17+
18+
- **android:** wrong line height rendering on android < 28 ([4276ad6](https://github.com/nativescript-community/ui-label/commit/4276ad6494271f924ae5eafedfaa6f3e65607d95))
19+
620
## [1.3.21](https://github.com/nativescript-community/ui-label/compare/v1.3.20...v1.3.21) (2024-02-15)
721

822
**Note:** Version bump only for package @nativescript-community/ui-label

plugin/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript-community/ui-label",
3-
"version": "1.3.21",
3+
"version": "1.3.24",
44
"description": "Alternative to the built-in NativeScript Label but with better performance and additional features such as HTML rendering and more.",
55
"main": "./label",
66
"sideEffects": false,

plugin/platforms/android/java/com/nativescript/label/NSLabel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void setLineHeight(int value) {
196196
@Override
197197
public void setTypeface(Typeface value) {
198198
super.setTypeface(value);
199-
if (Build.VERSION.SDK_INT < 28 && lineHeight >= 0) {
199+
if (Build.VERSION.SDK_INT < 28 && lineHeight > 0) {
200200
float fontHeight = getPaint().getFontMetrics(null);
201201
setLineSpacing(lineHeight - fontHeight, 1.0f);
202202
}

src/label.android.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,14 @@ abstract class LabelBase extends View implements LabelViewDefinition {
127127
@cssProperty paddingLeft: CoreTypes.LengthType;
128128

129129
// for now code is duplicated as Android version is a full rewrite
130-
mCanChangeText = true;
130+
mInResumeNativeUpdates = false;
131131
mNeedSetText = false;
132+
mNeedSetAutoSize = false;
132133
public onResumeNativeUpdates(): void {
133134
// {N} suspends properties update on `_suspendNativeUpdates`. So we only need to do this in onResumeNativeUpdates
134-
this.mCanChangeText = false;
135+
this.mInResumeNativeUpdates = true;
135136
super.onResumeNativeUpdates();
136-
this.mCanChangeText = true;
137+
this.mInResumeNativeUpdates = false;
137138
if (this.mNeedSetText) {
138139
this.mNeedSetText = false;
139140
this._setNativeText();
@@ -355,21 +356,43 @@ export class Label extends LabelBase {
355356
Length.toDevicePixels(value, 0) + Length.toDevicePixels(this.style.borderLeftWidth, 0)
356357
);
357358
}
359+
360+
// for now code is duplicated as Android version is a full rewrite
361+
mNeedSetAutoSize = false;
362+
public onResumeNativeUpdates(): void {
363+
super.onResumeNativeUpdates();
364+
if (this.mNeedSetAutoSize) {
365+
this.mNeedSetAutoSize = false;
366+
if (this.autoFontSize) {
367+
this.enableAutoSize();
368+
} else {
369+
this.disableAutoSize();
370+
}
371+
}
372+
}
358373
[maxFontSizeProperty.setNative](value) {
359-
if (this.mAutoFontSize) {
374+
if (this.autoFontSize) {
360375
this.enableAutoSize();
361376
}
362377
}
363378
[minFontSizeProperty.setNative](value) {
364-
if (this.mAutoFontSize) {
379+
if (this.autoFontSize) {
365380
this.enableAutoSize();
366381
}
367382
}
368383

369384
protected enableAutoSize() {
385+
if (this.mInResumeNativeUpdates) {
386+
this.mNeedSetAutoSize = true;
387+
return;
388+
}
370389
this.nativeViewProtected.enableAutoSize(this.minFontSize || 10, this.maxFontSize || 200, this.autoFontSizeStep || 1);
371390
}
372391
protected disableAutoSize() {
392+
if (this.mInResumeNativeUpdates) {
393+
this.mNeedSetAutoSize = true;
394+
return;
395+
}
373396
this.nativeViewProtected.disableAutoSize();
374397
}
375398
[autoFontSizeProperty.setNative](value: boolean) {
@@ -434,7 +457,7 @@ export class Label extends LabelBase {
434457

435458
@profile
436459
_setNativeText(reset: boolean = false): void {
437-
if (!this.mCanChangeText) {
460+
if (this.mInResumeNativeUpdates) {
438461
this.mNeedSetText = true;
439462
return;
440463
}

0 commit comments

Comments
 (0)