From ec07a99c236c7c72f8264322252a5e8d9b5c1ad8 Mon Sep 17 00:00:00 2001 From: Eduardo Speroni Date: Thu, 21 Mar 2019 14:25:12 -0300 Subject: [PATCH 01/11] feat(android): implement BorderDrawable outline --- .../nativescript/widgets/BorderDrawable.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java index 3608a195d..247caa6a6 100644 --- a/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java +++ b/tns-core-modules-widgets/android/widgets/src/main/java/org/nativescript/widgets/BorderDrawable.java @@ -8,6 +8,7 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.LinearGradient; import android.graphics.Matrix; +import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PointF; @@ -16,6 +17,7 @@ import android.graphics.RectF; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.Shader; +import android.support.annotation.NonNull; import org.nativescript.widgets.image.BitmapOwner; import org.nativescript.widgets.image.Fetcher; @@ -804,6 +806,23 @@ public class BorderDrawable extends ColorDrawable implements BitmapOwner { return drawable; } + @Override + public void getOutline(@NonNull Outline outline) { + if (android.os.Build.VERSION.SDK_INT >= 21) { + Path backgroundPath = new Path(); + float[] backgroundRadii = { + Math.max(0, borderTopLeftRadius), Math.max(0, borderTopLeftRadius), + Math.max(0, borderTopRightRadius), Math.max(0, borderTopRightRadius), + Math.max(0, borderBottomRightRadius), Math.max(0, borderBottomRightRadius), + Math.max(0, borderBottomLeftRadius), Math.max(0, borderBottomLeftRadius) + }; + backgroundPath.addRoundRect(new RectF(getBounds()), backgroundRadii, Path.Direction.CW); + outline.setConvexPath(backgroundPath); + } else { + throw new IllegalStateException("Method supported on API 21 or higher"); + } + } + private class BackgroundDrawParams { private boolean repeatX = true; private boolean repeatY = true; From 26679d42ff41ecd483295c6e824749863cad6cc2 Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Mon, 25 Mar 2019 14:07:23 +0200 Subject: [PATCH 02/11] refactor(): add better err msg for missing main entry (#7063) --- tns-core-modules/application/application.ios.ts | 7 +++---- tns-core-modules/ui/frame/frame.android.ts | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index df635cf5f..5d49fb857 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -273,16 +273,15 @@ function createRootView(v?: View) { let rootView = v; if (!rootView) { // try to navigate to the mainEntry (if specified) - if (mainEntry) { + if (!mainEntry) { + throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap."); + } else { if (createRootFrame.value) { const frame = rootView = new Frame(); frame.navigate(mainEntry); } else { rootView = createViewFromEntry(mainEntry); } - } else { - // TODO: Throw an exception? - throw new Error("A Frame must be used to navigate to a Page."); } } diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index 387c9b193..f2a9ef38e 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -1171,6 +1171,10 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { if (!rootView) { const mainEntry = application.getMainEntry(); + if (!mainEntry) { + throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap."); + } + const intent = activity.getIntent(); if (fireLaunchEvent) { From 761cd47360e9a8feba745fd999fa5a26add50b37 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Mon, 25 Mar 2019 16:04:48 +0200 Subject: [PATCH 03/11] chore: fix app.start deprecation (#7067) --- tns-core-modules/application/application.android.ts | 10 +++++++--- tns-core-modules/application/application.ios.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts index 1d2f0c76b..14ff82693 100644 --- a/tns-core-modules/application/application.android.ts +++ b/tns-core-modules/application/application.android.ts @@ -131,9 +131,8 @@ let mainEntry: NavigationEntry; let started = false; // NOTE: for backwards compatibility. Remove for 4.0.0. const createRootFrame = { value: true }; -export function start(entry?: NavigationEntry | string) { - console.log("application.start() is deprecated; use application.run() instead"); +function _start(entry?: NavigationEntry | string) { if (started) { throw new Error("Application is already started."); } @@ -146,13 +145,18 @@ export function start(entry?: NavigationEntry | string) { } } +export function start(entry?: NavigationEntry | string) { + console.log("application.start() is deprecated; use application.run() instead"); + _start(entry); +} + export function shouldCreateRootFrame(): boolean { return createRootFrame.value; } export function run(entry?: NavigationEntry | string) { createRootFrame.value = false; - start(entry); + _start(entry); } const CALLBACKS = "_callbacks"; diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 5d49fb857..53941c9ef 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -299,9 +299,7 @@ export function getRootView() { // NOTE: for backwards compatibility. Remove for 4.0.0. const createRootFrame = { value: true }; let started: boolean = false; -export function start(entry?: string | NavigationEntry) { - console.log("application.start() is deprecated; use application.run() instead"); - +function _start(entry?: string | NavigationEntry) { mainEntry = typeof entry === "string" ? { moduleName: entry } : entry; started = true; @@ -333,9 +331,14 @@ export function start(entry?: string | NavigationEntry) { } } +export function start(entry?: string | NavigationEntry) { + console.log("application.start() is deprecated; use application.run() instead"); + _start(entry); +} + export function run(entry?: string | NavigationEntry) { createRootFrame.value = false; - start(entry); + _start(entry); } export function _resetRootView(entry?: NavigationEntry | string) { From 4f0d6d36e361f2ddb9ece914fe18ce4b24fba989 Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Tue, 26 Mar 2019 12:35:43 +0200 Subject: [PATCH 04/11] refactor: guard ng and vue entry points (#7071) --- tns-core-modules/ui/frame/frame.android.ts | 64 ++++++++++++---------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index f2a9ef38e..f3f2decbe 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -1171,46 +1171,50 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { if (!rootView) { const mainEntry = application.getMainEntry(); - if (!mainEntry) { - throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap."); - } - const intent = activity.getIntent(); if (fireLaunchEvent) { + // entry point for Angular and Vue frameworks rootView = notifyLaunch(intent, savedInstanceState); } - if (shouldCreateRootFrame) { - const extras = intent.getExtras(); - let frameId = -1; - - // We have extras when we call - new Frame().navigate(); - // savedInstanceState is used when activity is recreated. - // NOTE: On API 23+ we get extras on first run. - // Check changed - first try to get frameId from Extras if not from saveInstanceState. - if (extras) { - frameId = extras.getInt(INTENT_EXTRA, -1); + if (!rootView) { + // entry point for NS Core + if (!mainEntry) { + // Also handles scenarios with Angular and Vue where the notifyLaunch didn't return a root view. + throw new Error("Main entry is missing. App cannot be started. Verify app bootstrap."); } - if (savedInstanceState && frameId < 0) { - frameId = savedInstanceState.getInt(INTENT_EXTRA, -1); - } - - if (!rootView) { - // If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate())) - // Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend) - rootView = getFrameByNumberId(frameId) || new Frame(); - } - - if (rootView instanceof Frame) { - rootView.navigate(mainEntry); + if (shouldCreateRootFrame) { + const extras = intent.getExtras(); + let frameId = -1; + + // We have extras when we call - new Frame().navigate(); + // savedInstanceState is used when activity is recreated. + // NOTE: On API 23+ we get extras on first run. + // Check changed - first try to get frameId from Extras if not from saveInstanceState. + if (extras) { + frameId = extras.getInt(INTENT_EXTRA, -1); + } + + if (savedInstanceState && frameId < 0) { + frameId = savedInstanceState.getInt(INTENT_EXTRA, -1); + } + + if (!rootView) { + // If we have frameId from extras - we are starting a new activity from navigation (e.g. new Frame().navigate())) + // Then we check if we have frameId from savedInstanceState - this happens when Activity is destroyed but app was not (e.g. suspend) + rootView = getFrameByNumberId(frameId) || new Frame(); + } + + if (rootView instanceof Frame) { + rootView.navigate(mainEntry); + } else { + throw new Error("A Frame must be used to navigate to a Page."); + } } else { - throw new Error("A Frame must be used to navigate to a Page."); + rootView = createViewFromEntry(mainEntry); } - } else { - // Create the root view if the notifyLaunch didn't return it - rootView = rootView || createViewFromEntry(mainEntry); } this._rootView = rootView; From 0a45540a7145e76163a6e0cf7ffe7ada0bb5739d Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Thu, 28 Mar 2019 13:17:42 +0200 Subject: [PATCH 05/11] fix: revert fromUrl deprecate warning (#7082) --- tns-core-modules/image-source/image-source.android.ts | 2 -- tns-core-modules/image-source/image-source.ios.ts | 2 -- 2 files changed, 4 deletions(-) diff --git a/tns-core-modules/image-source/image-source.android.ts b/tns-core-modules/image-source/image-source.android.ts index 56140ba5e..175495321 100644 --- a/tns-core-modules/image-source/image-source.android.ts +++ b/tns-core-modules/image-source/image-source.android.ts @@ -246,8 +246,6 @@ export function fromNativeSource(source: any): ImageSource { } export function fromUrl(url: string): Promise { - console.log("imageSource.fromUrl(url) is deprecated; use http.getImage(url) instead"); - ensureHttp(); return http.getImage(url); } diff --git a/tns-core-modules/image-source/image-source.ios.ts b/tns-core-modules/image-source/image-source.ios.ts index c5228b80f..d4771f4f7 100644 --- a/tns-core-modules/image-source/image-source.ios.ts +++ b/tns-core-modules/image-source/image-source.ios.ts @@ -236,8 +236,6 @@ export function fromNativeSource(source: any): ImageSource { } export function fromUrl(url: string): Promise { - console.log("imageSource.fromUrl(url) is deprecated; use http.getImage(url) instead"); - ensureHttp(); return http.getImage(url); } From 325f727accba8d6a193c925182d6b462dd4749f6 Mon Sep 17 00:00:00 2001 From: Dimitar Topuzov Date: Thu, 28 Mar 2019 13:41:33 +0200 Subject: [PATCH 06/11] release: cut the 5.3.1 release (#7084) --- CHANGELOG.md | 8 ++++++++ tns-core-modules/package.json | 2 +- tns-platform-declarations/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 704a46a4e..3bd7f8cc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## [5.3.1](https://github.com/NativeScript/NativeScript/compare/5.3.0...5.3.1) (2019-03-28) + + +### Bug Fixes + +* revert fromUrl deprecate warning ([#7082](https://github.com/NativeScript/NativeScript/issues/7082)) ([0a45540](https://github.com/NativeScript/NativeScript/commit/0a45540)) + + # [5.3.0](https://github.com/NativeScript/NativeScript/compare/5.2.1...5.3.0) (2019-03-21) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index bf25e81a7..f64331cb4 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -1,7 +1,7 @@ { "name": "tns-core-modules", "description": "Telerik NativeScript Core Modules", - "version": "5.3.0", + "version": "5.3.1", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index e22938abe..6d073a7ac 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,6 +1,6 @@ { "name": "tns-platform-declarations", - "version": "5.3.0", + "version": "5.3.1", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", "main": "", "scripts": { From 1dc395215df050dcc840185a2b0a750dbdfe57ec Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Fri, 29 Mar 2019 13:36:45 +0200 Subject: [PATCH 07/11] fix(ios): flat action bar incorrect layout after navigation (#7077) * fix(action-bar): incorrect layout after navigation * set extended layout for opaque bars earlier --- tns-core-modules/ui/core/view/view.ios.ts | 11 ++++++++--- tns-core-modules/ui/page/page.ios.ts | 11 ++++++++--- tns-core-modules/ui/tab-view/tab-view.ios.ts | 11 ++++++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tns-core-modules/ui/core/view/view.ios.ts b/tns-core-modules/ui/core/view/view.ios.ts index d44e59823..19e01ed0f 100644 --- a/tns-core-modules/ui/core/view/view.ios.ts +++ b/tns-core-modules/ui/core/view/view.ios.ts @@ -904,6 +904,14 @@ export namespace ios { return controller; } + public viewDidLoad(): void { + super.viewDidLoad(); + + // Unify translucent and opaque bars layout + // this.edgesForExtendedLayout = UIRectEdgeBottom; + this.extendedLayoutIncludesOpaqueBars = true; + } + public viewWillLayoutSubviews(): void { super.viewWillLayoutSubviews(); const owner = this.owner.get(); @@ -959,9 +967,6 @@ export namespace ios { return; } - // Unify translucent and opaque bars layout - this.extendedLayoutIncludesOpaqueBars = true; - updateAutoAdjustScrollInsets(this, owner); if (!owner.parent) { diff --git a/tns-core-modules/ui/page/page.ios.ts b/tns-core-modules/ui/page/page.ios.ts index 2c288be1d..9da43e2eb 100644 --- a/tns-core-modules/ui/page/page.ios.ts +++ b/tns-core-modules/ui/page/page.ios.ts @@ -68,6 +68,14 @@ class UIViewControllerImpl extends UIViewController { return controller; } + public viewDidLoad(): void { + super.viewDidLoad(); + + // Unify translucent and opaque bars layout + // this.edgesForExtendedLayout = UIRectEdgeBottom; + this.extendedLayoutIncludesOpaqueBars = true; + } + public viewWillAppear(animated: boolean): void { super.viewWillAppear(animated); const owner = this._owner.get(); @@ -100,9 +108,6 @@ class UIViewControllerImpl extends UIViewController { frame._updateActionBar(owner); } - // Unify translucent and opaque bars layout - this.extendedLayoutIncludesOpaqueBars = true; - // Set autoAdjustScrollInsets in will appear - as early as possible iosView.updateAutoAdjustScrollInsets(this, owner); diff --git a/tns-core-modules/ui/tab-view/tab-view.ios.ts b/tns-core-modules/ui/tab-view/tab-view.ios.ts index 75d5f6b34..3201e9a2c 100644 --- a/tns-core-modules/ui/tab-view/tab-view.ios.ts +++ b/tns-core-modules/ui/tab-view/tab-view.ios.ts @@ -28,6 +28,14 @@ class UITabBarControllerImpl extends UITabBarController { return handler; } + public viewDidLoad(): void { + super.viewDidLoad(); + + // Unify translucent and opaque bars layout + // this.edgesForExtendedLayout = UIRectEdgeBottom; + this.extendedLayoutIncludesOpaqueBars = true; + } + @profile public viewWillAppear(animated: boolean): void { super.viewWillAppear(animated); @@ -36,9 +44,6 @@ class UITabBarControllerImpl extends UITabBarController { return; } - // Unify translucent and opaque bars layout - this.extendedLayoutIncludesOpaqueBars = true; - iosView.updateAutoAdjustScrollInsets(this, owner); if (!owner.parent) { From db4d7177e6d73236917fb471e2e31e1aeb642a70 Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Tue, 2 Apr 2019 18:09:42 +0300 Subject: [PATCH 08/11] chore: update tests --- apps/app/ui-tests-app/button/button-border.css | 2 +- apps/app/ui-tests-app/css/pixels.xml | 8 ++++---- apps/app/ui-tests-app/flexbox/flexbox.css | 1 + apps/app/ui-tests-app/issues/issue-3113.css | 5 ++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/app/ui-tests-app/button/button-border.css b/apps/app/ui-tests-app/button/button-border.css index 644d827a6..3b404e027 100644 --- a/apps/app/ui-tests-app/button/button-border.css +++ b/apps/app/ui-tests-app/button/button-border.css @@ -46,7 +46,7 @@ Button { } #s10 { - border-width: 5 0; border-color: black; + border-width: 5 0; border-color: black; background-color: white; } #s11 { diff --git a/apps/app/ui-tests-app/css/pixels.xml b/apps/app/ui-tests-app/css/pixels.xml index b2b61157d..30f25d526 100644 --- a/apps/app/ui-tests-app/css/pixels.xml +++ b/apps/app/ui-tests-app/css/pixels.xml @@ -4,7 +4,7 @@