Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21b94b9

Browse filesBrowse files
committed
Merge branch 'fixing_sdk_version' of git@github.com:NativeScript/NativeScript.git
2 parents 051f851 + 75eefa6 commit 21b94b9
Copy full SHA for 21b94b9

File tree

Expand file treeCollapse file tree

14 files changed

+133
-12
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+133
-12
lines changed

‎apps/automated/src/image-source/image-source-tests.ts

Copy file name to clipboardExpand all lines: apps/automated/src/image-source/image-source-tests.ts
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as app from '@nativescript/core/application';
55
import * as TKUnit from '../tk-unit';
66
import { Font } from '@nativescript/core/ui/styling/font';
77
import { Color } from '@nativescript/core/color';
8+
import * as utils from '@nativescript/core/utils';
89

910
const imagePath = '~/assets/logo.png';
1011
const splashscreenPath = '~/assets/splashscreen.png';
@@ -20,6 +21,36 @@ export function testFromResource() {
2021
TKUnit.assert(img.height > 0, 'image.fromResource failed');
2122
}
2223

24+
export function testDrawableSetNativeSource() {
25+
if (global.isAndroid) {
26+
const context = utils.ad.getApplicationContext() as android.content.Context;
27+
const rDrawable = `${context.getPackageName()}.R$drawable`;
28+
const rClazz = java.lang.Class.forName(`${rDrawable}`);
29+
const iconId = rClazz.getDeclaredField('icon').get(null) as java.lang.Integer;
30+
const splashScreenId = rClazz.getDeclaredField('splash_screen').get(null) as java.lang.Integer;
31+
32+
const icon = androidx.appcompat.content.res.AppCompatResources.getDrawable(context, iconId?.intValue?.() ?? 0);
33+
const splashScreen = androidx.appcompat.content.res.AppCompatResources.getDrawable(context, splashScreenId?.intValue?.() ?? 0);
34+
35+
let type = icon?.getClass?.().toString?.() ?? '';
36+
37+
// >> imagesource-setNativeSource
38+
const img = new ImageSource();
39+
img.setNativeSource(icon);
40+
// << imagesource-setNativeSource
41+
42+
TKUnit.assert(img.height > 0, `image ${type} setNativeSource failed`);
43+
44+
type = splashScreen?.getClass?.().toString?.() ?? '';
45+
46+
// >> imagesource-setNativeSource
47+
img.setNativeSource(splashScreen);
48+
// << imagesource-setNativeSource
49+
50+
TKUnit.assert(img.height > 0, `image ${type} setNativeSource failed`);
51+
}
52+
}
53+
2354
export function testFromUrl(done) {
2455
let result: ImageSource;
2556

‎apps/toolbox/src/main-page.xml

Copy file name to clipboardExpand all lines: apps/toolbox/src/main-page.xml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
<Button text="a11y" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1010
<Button text="box-shadow" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1111
<Button text="css-playground" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
12-
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
12+
<Button text="datepicker" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1313
<Button text="image-async" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1414
<Button text="image-handling" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
15+
<Button text="labels" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1516
<Button text="list-page" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1617
<Button text="root-layout" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />
1718
<Button text="switch" tap="{{ viewDemo }}" class="btn btn-primary btn-view-demo" />

‎apps/toolbox/src/pages/labels.ts

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Page, Observable, EventData } from '@nativescript/core';
2+
3+
let page: Page;
4+
5+
export function navigatingTo(args: EventData) {
6+
page = <Page>args.object;
7+
page.bindingContext = new SampleData();
8+
}
9+
10+
export class SampleData extends Observable {}

‎apps/toolbox/src/pages/labels.xml

Copy file name to clipboard
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" class="page">
2+
<Page.actionBar>
3+
<ActionBar title="Labels and TextView" class="action-bar">
4+
</ActionBar>
5+
</Page.actionBar>
6+
<ScrollView>
7+
<StackLayout padding="20">
8+
<Label text="maxLines 2" fontWeight="bold" />
9+
<Label
10+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
11+
textWrap="true"
12+
maxLines="2"
13+
marginTop="2"
14+
/>
15+
16+
<Label text="maxLines 3" fontWeight="bold" marginTop="6" />
17+
<Label
18+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
19+
textWrap="true"
20+
maxLines="3"
21+
marginTop="2"
22+
/>
23+
24+
<Label text="maxLines 4" fontWeight="bold" marginTop="6" />
25+
<Label
26+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
27+
textWrap="true"
28+
maxLines="4"
29+
marginTop="2"
30+
/>
31+
32+
<Label text="NO textWrap" fontWeight="bold" marginTop="6" />
33+
<Label
34+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
35+
marginTop="2"
36+
/>
37+
38+
<Label text="NO maxLines" fontWeight="bold" marginTop="6" />
39+
<Label
40+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
41+
textWrap="true"
42+
marginTop="2"
43+
/>
44+
45+
<Label text="TextView with maxLines 4" fontWeight="bold" marginTop="6" />
46+
<TextView
47+
text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
48+
maxLines="4"
49+
textWrap="true"
50+
marginTop="2"
51+
/>
52+
</StackLayout>
53+
</ScrollView>
54+
</Page>

‎packages/core/file-system/file-system-access.android.ts

Copy file name to clipboardExpand all lines: packages/core/file-system/file-system-access.android.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as textModule from '../text';
22
import { getNativeApplication } from '../application';
3-
import { SDK_VERSION } from '../utils/utils-common';
3+
import { SDK_VERSION } from '../utils/utils';
44

55
import type { IFileSystemAccess } from './file-system-access';
66

‎packages/core/image-source/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/image-source/index.android.ts
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,13 @@ export class ImageSource implements ImageSourceDefinition {
291291

292292
public setNativeSource(source: any): void {
293293
if (source && !(source instanceof android.graphics.Bitmap)) {
294-
throw new Error('The method setNativeSource() expects android.graphics.Bitmap instance.');
294+
if (source instanceof android.graphics.drawable.Drawable) {
295+
this.android = org.nativescript.widgets.Utils.getBitmapFromDrawable(source);
296+
return;
297+
}
298+
throw new Error('The method setNativeSource() expects an android.graphics.Bitmap or android.graphics.drawable.Drawable instance.');
295299
}
300+
296301
this.android = source;
297302
}
298303

293 Bytes
Binary file not shown.

‎packages/core/ui/frame/index.ios.ts

Copy file name to clipboardExpand all lines: packages/core/ui/frame/index.ios.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ export class Frame extends FrameBase {
307307
}
308308

309309
public _onNavigatingTo(backstackEntry: BackstackEntry, isBack: boolean) {
310-
//
310+
super._onNavigatingTo(backstackEntry, isBack);
311311
}
312312
}
313313

‎packages/core/ui/page/index.ios.ts

Copy file name to clipboardExpand all lines: packages/core/ui/page/index.ios.ts
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,6 @@ class UIViewControllerImpl extends UIViewController {
118118
}
119119

120120
const frame = this.navigationController ? (<any>this.navigationController).owner : null;
121-
const newEntry = this[ENTRY];
122-
123-
// Don't raise event if currentPage was showing modal page.
124-
if (!owner._presentedViewController && newEntry && (!frame || frame.currentPage !== owner)) {
125-
const isBack = isBackNavigationTo(owner, newEntry);
126-
owner.onNavigatingTo(newEntry.entry.context, isBack, newEntry.entry.bindingContext);
127-
}
128121

129122
if (frame) {
130123
if (!owner.parent) {

‎packages/core/ui/text-base/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/ui/text-base/index.android.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ export class TextBase extends TextBaseCommon {
468468
nativeTextViewProtected.setMaxLines(Number.MAX_SAFE_INTEGER);
469469
} else {
470470
nativeTextViewProtected.setMaxLines(typeof value === 'string' ? parseInt(value, 10) : value);
471+
nativeTextViewProtected.setEllipsize(android.text.TextUtils.TruncateAt.END);
471472
}
472473
}
473474

‎packages/core/ui/text-base/index.ios.ts

Copy file name to clipboardExpand all lines: packages/core/ui/text-base/index.ios.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ export class TextBase extends TextBaseCommon {
244244
}
245245
} else if (nativeTextViewProtected instanceof UILabel) {
246246
nativeTextViewProtected.numberOfLines = numberOfLines;
247+
nativeTextViewProtected.lineBreakMode = NSLineBreakMode.ByTruncatingTail;
247248
} else if (nativeTextViewProtected instanceof UIButton) {
248249
nativeTextViewProtected.titleLabel.numberOfLines = numberOfLines;
249250
}

‎packages/core/utils/index.android.ts

Copy file name to clipboardExpand all lines: packages/core/utils/index.android.ts
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ad } from './native-helper';
2-
import { android as androidApp } from '../application';
32
import { SDK_VERSION } from '../utils';
43
import { FileSystemAccess } from '../file-system/file-system-access';
54
import { Trace } from '../trace';

‎packages/types-android/src/lib/android/org.nativescript.widgets.d.ts

Copy file name to clipboardExpand all lines: packages/types-android/src/lib/android/org.nativescript.widgets.d.ts
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ declare module org {
687687
export module widgets {
688688
export class Utils {
689689
public static class: java.lang.Class<org.nativescript.widgets.Utils>;
690+
public static getBitmapFromDrawable(param0: globalAndroid.graphics.drawable.Drawable): globalAndroid.graphics.Bitmap;
690691
public static getBitmapFromView(param0: globalAndroid.view.View): globalAndroid.graphics.Bitmap;
691692
public static loadImageAsync(param0: globalAndroid.content.Context, param1: string, param2: string, param3: number, param4: number, param5: org.nativescript.widgets.Utils.AsyncImageCallback): void;
692693
public static drawBoxShadow(param0: globalAndroid.view.View, param1: string): void;

‎packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/Utils.java

Copy file name to clipboardExpand all lines: packages/ui-mobile-base/android/widgets/src/main/java/org/nativescript/widgets/Utils.java
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import android.graphics.Canvas;
88
import android.graphics.Color;
99
import android.graphics.Matrix;
10+
import android.graphics.Rect;
11+
import android.graphics.drawable.BitmapDrawable;
1012
import android.graphics.drawable.ColorDrawable;
1113
import android.graphics.drawable.Drawable;
1214
import android.net.Uri;
@@ -70,6 +72,7 @@ private static Bitmap drawBitmap(View view) {
7072
return bitmap;
7173
}
7274

75+
@SuppressWarnings("deprecation")
7376
public static Bitmap getBitmapFromView(View view) {
7477
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
7578
return drawBitmap(view);
@@ -88,6 +91,28 @@ public static Bitmap getBitmapFromView(View view) {
8891
}
8992
}
9093

94+
public static Bitmap getBitmapFromDrawable(Drawable drawable) {
95+
if (drawable instanceof BitmapDrawable) {
96+
return ((BitmapDrawable) drawable).getBitmap();
97+
} else {
98+
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
99+
Canvas canvas = new Canvas(bitmap);
100+
Rect previousBounds = null;
101+
102+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
103+
previousBounds = drawable.getBounds();
104+
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
105+
}
106+
107+
drawable.draw(canvas);
108+
109+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
110+
drawable.setBounds(previousBounds);
111+
}
112+
return bitmap;
113+
}
114+
}
115+
91116
public static void drawBoxShadow(View view, String value) {
92117
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.M) {
93118
return;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.