From fc1f8c1e4231c8c8f80208702f9926bffb06e293 Mon Sep 17 00:00:00 2001 From: Alexander Djenkov Date: Fri, 23 Nov 2018 10:05:49 +0200 Subject: [PATCH 1/3] fix(back-navigation): app freeze on going back in parent frame with states (#6595) Endless loop while searching for parent frame that can go back. Caught in Angular app when trying to go back from nested named lazy loaded outlet using the android hadrware back button. --- tns-core-modules/ui/frame/frame-common.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tns-core-modules/ui/frame/frame-common.ts b/tns-core-modules/ui/frame/frame-common.ts index a86798ee4..5533f98d1 100644 --- a/tns-core-modules/ui/frame/frame-common.ts +++ b/tns-core-modules/ui/frame/frame-common.ts @@ -616,7 +616,7 @@ export function goBack(): boolean { if (parentFrame && parentFrame.canGoBack()) { parentFrameCanGoBack = true; } else { - parentFrame = getAncestor(top, "Frame"); + parentFrame = getAncestor(parentFrame, "Frame"); } } From 5b9b335489292ef73467de37022d07535ee4621b Mon Sep 17 00:00:00 2001 From: Manol Donev Date: Fri, 23 Nov 2018 14:48:41 +0200 Subject: [PATCH 2/3] fix(android-fragment): child already has a parent (#6589) --- tns-core-modules/ui/frame/frame.android.ts | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index 81d6cf7fc..417d817bb 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -834,6 +834,24 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { entry.viewSavedState = null; } + // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. + // on app resume in nested frame scenarios with support library version greater than 26.0.0 + // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent + // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a + // parent while its supposed parent believes it properly removed its children; in order to "force" the child to + // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) + const nativeView = page.nativeViewProtected; + if (nativeView != null) { + const parentView = nativeView.getParent(); + if (parentView instanceof android.view.ViewGroup) { + if (parentView.getChildCount() === 0) { + parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); + } + + parentView.removeView(nativeView); + } + } + return page.nativeViewProtected; } @@ -873,24 +891,6 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { traceError(`${fragment}.onDestroy: entry has no resolvedPage`); return null; } - - // fixes 'java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first'. - // on app resume in nested frame scenarios with support library version greater than 26.0.0 - // HACK: this whole code block shouldn't be necessary as the native view is supposedly removed from its parent - // right after onDestroyView(...) is called but for some reason the fragment view (page) still thinks it has a - // parent while its supposed parent believes it properly removed its children; in order to "force" the child to - // lose its parent we temporarily add it to the parent, and then remove it (addViewInLayout doesn't trigger layout pass) - const nativeView = page.nativeViewProtected; - if (nativeView != null) { - const parentView = nativeView.getParent(); - if (parentView instanceof android.view.ViewGroup) { - if (parentView.getChildCount() === 0) { - parentView.addViewInLayout(nativeView, -1, new org.nativescript.widgets.CommonLayoutParams()); - } - - parentView.removeView(nativeView); - } - } } @profile From 1045958d95fd0c82c9d8a028939bc7d6448e337c Mon Sep 17 00:00:00 2001 From: SvetoslavTsenov Date: Mon, 26 Nov 2018 12:48:59 +0200 Subject: [PATCH 3/3] doc: cut the 5.0.4 release --- CHANGELOG.md | 11 +++++++++++ tns-core-modules/package.json | 2 +- tns-platform-declarations/package.json | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac1f29fef..91fa22463 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ + +## [5.0.4](https://github.com/NativeScript/NativeScript/compare/5.0.3...5.0.4) (2018-11-26) + + +### Bug Fixes + +* **android-fragment:** child already has a parent ([#6589](https://github.com/NativeScript/NativeScript/issues/6589)) ([5b9b335](https://github.com/NativeScript/NativeScript/commit/5b9b335)) +* **back-navigation:** app freeze on going back in parent frame with states ([#6595](https://github.com/NativeScript/NativeScript/issues/6595)) ([fc1f8c1](https://github.com/NativeScript/NativeScript/commit/fc1f8c1)) + + + ## [5.0.3](https://github.com/NativeScript/NativeScript/compare/5.0.2...5.0.3) (2018-11-20) diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index ec101a84b..9fe85da7d 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.1.0", + "version": "5.0.4", "homepage": "https://www.nativescript.org", "repository": { "type": "git", diff --git a/tns-platform-declarations/package.json b/tns-platform-declarations/package.json index 89d347ebe..bb7873d25 100644 --- a/tns-platform-declarations/package.json +++ b/tns-platform-declarations/package.json @@ -1,6 +1,6 @@ { "name": "tns-platform-declarations", - "version": "5.1.0", + "version": "5.0.4", "description": "Platform-specific TypeScript declarations for NativeScript for accessing native objects", "main": "", "scripts": {