From c4ba61a7c723d5080973656e3d1787f02b5c33d6 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Wed, 9 Dec 2015 11:47:33 +0200 Subject: [PATCH 01/15] dialogs and timer lazy require --- globals/globals.ts | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/globals/globals.ts b/globals/globals.ts index e3235cc239..ef1986e10e 100644 --- a/globals/globals.ts +++ b/globals/globals.ts @@ -16,29 +16,50 @@ if (platform.device.os === platform.platformNames.android) { global.console.dump = function (args) { c.dump(args); }; } +var tm; +function getTimer() { + if (!tm) { + tm = require("timer"); + } + + return tm; +} + global.setTimeout = function (callback, milliseconds) { - let tm = require("timer"); - return tm.setTimeout(callback, milliseconds); + return getTimer().setTimeout(callback, milliseconds); } global.clearTimeout = function (id) { - let tm = require("timer"); - tm.clearTimeout(id); + getTimer().clearTimeout(id); } global.setInterval = function (callback, milliseconds) { - let tm = require("timer"); - return tm.setInterval(callback, milliseconds); + return getTimer().setInterval(callback, milliseconds); } global.clearInterval = function (id) { - let tm = require("timer"); - tm.clearInterval(id); + getTimer().clearInterval(id); +} + +var dm; +function getDialogs() { + if (!dm) { + dm = require("ui/dialogs"); + } + + return dm; } global.alert = function (args) { - let dm = require("ui/dialogs"); - return dm.alert(args); + return getDialogs().alert(args); +} + +global.confirm = function (args) { + return getDialogs().confirm(args); +} + +global.prompt = function (args) { + return getDialogs().prompt(args); } var xhr = require("../xhr/xhr"); From 30e51ac4e022ff0d29a731febd90693146937d3c Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Thu, 10 Dec 2015 12:03:18 +0200 Subject: [PATCH 02/15] font-family implemented --- apps/ui-tests-app/font/tab-view.xml | 16 ++++++++ ui/styling/style.ts | 7 ++++ ui/styling/stylers.android.ts | 63 ++++++++++++++++++++++++++++- ui/styling/stylers.ios.ts | 39 +++++++++++++++++- ui/tab-view/tab-view-common.ts | 2 +- ui/tab-view/tab-view.d.ts | 2 +- ui/tab-view/tab-view.ios.ts | 13 ++++-- 7 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 apps/ui-tests-app/font/tab-view.xml diff --git a/apps/ui-tests-app/font/tab-view.xml b/apps/ui-tests-app/font/tab-view.xml new file mode 100644 index 0000000000..d52ed3ef77 --- /dev/null +++ b/apps/ui-tests-app/font/tab-view.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + diff --git a/ui/styling/style.ts b/ui/styling/style.ts index 1a0c3ceb4a..acd771cb5f 100644 --- a/ui/styling/style.ts +++ b/ui/styling/style.ts @@ -417,6 +417,13 @@ export class Style extends DependencyObservable implements styling.Style { this._setShorthandProperty("font", value); } + get _fontInternal(): font.Font { + return this._getValue(fontInternalProperty); + } + set _fontInternal(value: font.Font) { + this._setValue(fontInternalProperty, value); + } + get textAlignment(): string { return this._getValue(textAlignmentProperty); } diff --git a/ui/styling/stylers.android.ts b/ui/styling/stylers.android.ts index 42d03f21a9..4405d54922 100644 --- a/ui/styling/stylers.android.ts +++ b/ui/styling/stylers.android.ts @@ -533,7 +533,7 @@ function setTextDecoration(view: android.widget.TextView, value: string) { view.setPaintFlags(flags); } else { view.setPaintFlags(0); - } + } } function setTextTransform(view: android.widget.TextView, value: string) { @@ -1016,11 +1016,72 @@ export class TabViewStyler implements definition.stylers.Styler { } } + // font + private static setFontInternalProperty(view: view.View, newValue: any, nativeValue: any) { + var tab = view; + var fontValue = newValue; + var typeface = fontValue.getAndroidTypeface(); + + if (tab.items && tab.items.length > 0) { + var tabLayout = tab._getAndroidTabView(); + + for (var i = 0; i < tab.items.length; i++) { + let tv = tabLayout.getTextViewForItemAt(i); + if (typeface) { + tv.setTypeface(typeface); + } + else { + tv.setTypeface(nativeValue.typeface); + } + + if (fontValue.fontSize) { + tv.setTextSize(fontValue.fontSize); + } + else { + tv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, nativeValue.size); + } + } + } + } + + private static resetFontInternalProperty(view: view.View, nativeValue: any) { + var tab = view; + + if (tab.items && tab.items.length > 0) { + var tabLayout = tab._getAndroidTabView(); + + for (var i = 0; i < tab.items.length; i++) { + let tv = tabLayout.getTextViewForItemAt(i); + tv.setTypeface(nativeValue.typeface); + tv.setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, nativeValue.size); + } + } + } + + private static getNativeFontInternalValue(view: view.View): any { + var tab = view; + var tv: android.widget.TextView = tab._getAndroidTabView().getTextViewForItemAt(0); + if (tv) { + return { + typeface: tv.getTypeface(), + size: tv.getTextSize() + } + } + else { + return null; + } + } + public static registerHandlers() { style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler( TabViewStyler.setColorProperty, TabViewStyler.resetColorProperty, TabViewStyler.getColorProperty), "TabView"); + + style.registerHandler(style.fontInternalProperty, new stylersCommon.StylePropertyChangedHandler( + TabViewStyler.setFontInternalProperty, + TabViewStyler.resetFontInternalProperty, + TabViewStyler.getNativeFontInternalValue), "TabView"); } } diff --git a/ui/styling/stylers.ios.ts b/ui/styling/stylers.ios.ts index e30105666c..8c01210f01 100644 --- a/ui/styling/stylers.ios.ts +++ b/ui/styling/stylers.ios.ts @@ -921,18 +921,53 @@ export class TabViewStyler implements definition.stylers.Styler { // color private static setColorProperty(view: view.View, newValue: any) { var tab = view; - tab._updateIOSTabBarColors(); + tab._updateIOSTabBarColorsAndFonts(); } private static resetColorProperty(view: view.View, nativeValue: any) { var tab = view; - tab._updateIOSTabBarColors(); + tab._updateIOSTabBarColorsAndFonts(); + } + + // font + private static setFontInternalProperty(view: view.View, newValue: any, nativeValue: any) { + var tab = view; + tab._updateIOSTabBarColorsAndFonts(); + } + + private static resetFontInternalProperty(view: view.View, nativeValue: any) { + var tab = view; + tab._updateIOSTabBarColorsAndFonts(); + } + + private static getNativeFontValue(view: view.View) { + var tab = view; + + let currentFont; + + if (tab.ios && tab.ios.items && tab.ios.items.length > 0) { + let currentAttrs = tab.ios.items[0].titleTextAttributesForState(UIControlState.UIControlStateNormal); + if (currentAttrs) { + currentFont = currentAttrs.objectForKey(NSFontAttributeName); + } + } + + if (!currentFont) { + currentFont = UIFont.systemFontOfSize(UIFont.labelFontSize()); + } + + return currentFont; } public static registerHandlers() { style.registerHandler(style.colorProperty, new stylersCommon.StylePropertyChangedHandler( TabViewStyler.setColorProperty, TabViewStyler.resetColorProperty), "TabView"); + + style.registerHandler(style.fontInternalProperty, new stylersCommon.StylePropertyChangedHandler( + TabViewStyler.setFontInternalProperty, + TabViewStyler.resetFontInternalProperty, + TabViewStyler.getNativeFontValue), "TabView"); } } diff --git a/ui/tab-view/tab-view-common.ts b/ui/tab-view/tab-view-common.ts index 00736e749c..04d4dbe30f 100644 --- a/ui/tab-view/tab-view-common.ts +++ b/ui/tab-view/tab-view-common.ts @@ -274,7 +274,7 @@ export class TabView extends view.View implements definition.TabView, view.AddAr return undefined; } - public _updateIOSTabBarColors(): void { + public _updateIOSTabBarColorsAndFonts(): void { // iOS sepcific } } \ No newline at end of file diff --git a/ui/tab-view/tab-view.d.ts b/ui/tab-view/tab-view.d.ts index c19169fae5..2a0d712241 100644 --- a/ui/tab-view/tab-view.d.ts +++ b/ui/tab-view/tab-view.d.ts @@ -101,7 +101,7 @@ declare module "ui/tab-view" { //@private _getAndroidTabView(): any /* org.nativescript.widgets.TabLayout */; - _updateIOSTabBarColors(): void; + _updateIOSTabBarColorsAndFonts(): void; //@endprivate } } diff --git a/ui/tab-view/tab-view.ios.ts b/ui/tab-view/tab-view.ios.ts index 54038e1e98..fd75b46b23 100644 --- a/ui/tab-view/tab-view.ios.ts +++ b/ui/tab-view/tab-view.ios.ts @@ -101,7 +101,7 @@ export class TabViewItem extends common.TabViewItem { function selectedColorPropertyChanged(data: dependencyObservable.PropertyChangeData) { var tabView = data.object; - tabView._updateIOSTabBarColors(); + tabView._updateIOSTabBarColorsAndFonts(); } (common.TabView.selectedColorProperty.metadata).onSetNativeValue = selectedColorPropertyChanged; @@ -322,14 +322,14 @@ export class TabView extends common.TabView { (heightMode === utils.layout.UNSPECIFIED) ? Number.POSITIVE_INFINITY : height)); } - public _updateIOSTabBarColors(): void { + public _updateIOSTabBarColorsAndFonts(): void { if (!this.items) { return; } var tabBar = this.ios.tabBar; - tabBar.tintColor = this.selectedColor ? this.selectedColor.ios : null; + tabBar.tintColor = this.selectedColor ? this.selectedColor.ios : null; var states = getTitleAttributesForStates(this); for (var i = 0; i < this.items.length; i++) { @@ -354,8 +354,13 @@ function getTitleAttributesForStates(tabView: TabView): { normalState: any, sele selectedState[UITextAttributeTextColor] = tabView.ios.tabBar.tintColor; } + var defaultFont = UIFont.systemFontOfSize(UIFont.labelFontSize()); + var font = (tabView.style)._fontInternal.getUIFont(defaultFont); + normalState[NSFontAttributeName] = font; + selectedState[NSFontAttributeName] = font; + return { normalState: normalState, selectedState: selectedState }; -} +} \ No newline at end of file From 91dffc1e777fbb4884b71b5e050fb79663b341ec Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Thu, 10 Dec 2015 14:42:04 +0200 Subject: [PATCH 03/15] url with % fixed It seems that this url is a special case since url encoding techniques failed for both ios and android. For ios: stringByAddingPercentEscapesUsingEncoding stringByAddingPercentEncodingWithAllowedCharacters For android: java.net.URLEncoder --- apps/tests/http-tests.ts | 3 ++- http/http-request.android.ts | 3 ++- http/http-request.ios.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/tests/http-tests.ts b/apps/tests/http-tests.ts index b50f0949bd..3eece7c050 100644 --- a/apps/tests/http-tests.ts +++ b/apps/tests/http-tests.ts @@ -534,7 +534,8 @@ export var test_getString_FromVariousUrls_ShouldWorkProperly = function (done) { var urls = [ "https://it-ebooks-api.info/v1/book/1615005640", "https://www.telerik.com", - "https://spreadsheets.google.com/tq?key=1tJ64Y8hje0ui4ap9U33h3KWwpxT_-JuVMSZzxD2Er8k" + "https://spreadsheets.google.com/tq?key=1tJ64Y8hje0ui4ap9U33h3KWwpxT_-JuVMSZzxD2Er8k", + "https://chase.arborgoldcloud.net/mobilehandler/mobiledatahandler.ashx?ProcedureName=MEstimGetJobListSpeed&@prmSalesRep=%&@prmStartDate=11/1/2015&@prmEndDate=12/8/2015&@prmStatusFilter=2" ]; var i: number; diff --git a/http/http-request.android.ts b/http/http-request.android.ts index 8a8ac9baa8..e32469af3f 100644 --- a/http/http-request.android.ts +++ b/http/http-request.android.ts @@ -75,7 +75,8 @@ function buildJavaOptions(options: http.HttpRequestOptions) { var javaOptions = new com.tns.Async.Http.RequestOptions(); - javaOptions.url = options.url; + javaOptions.url = options.url.replace("%", "%25"); + if (types.isString(options.method)) { javaOptions.method = options.method; } diff --git a/http/http-request.ios.ts b/http/http-request.ios.ts index e37d79bc6e..ca1827d7bb 100644 --- a/http/http-request.ios.ts +++ b/http/http-request.ios.ts @@ -20,7 +20,7 @@ export function request(options: http.HttpRequestOptions): Promise Date: Thu, 10 Dec 2015 14:00:35 +0200 Subject: [PATCH 04/15] Location module deprecated. --- location/location-common.ts | 3 ++- location/location.android.ts | 2 ++ location/location.ios.ts | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/location/location-common.ts b/location/location-common.ts index eedb85f262..e8413c7e12 100644 --- a/location/location-common.ts +++ b/location/location-common.ts @@ -4,6 +4,7 @@ import defModule = require("location"); var defaultGetLocationTimeout = 20000; +@Deprecated export class Location implements defModule.Location { public latitude: number; public longitude: number; @@ -88,4 +89,4 @@ export var getLocation = function (options?: defModule.Options): Promise Date: Thu, 10 Dec 2015 15:50:18 +0200 Subject: [PATCH 05/15] Fix the test run on iOS The test failed due to a huge output by the `tns platform add ios` command. Change the grunt `exec` task to `shell` and specify max length. --- build/run-testsapp.grunt.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build/run-testsapp.grunt.js b/build/run-testsapp.grunt.js index 3ecb5ef01e..2fc1eed5bd 100644 --- a/build/run-testsapp.grunt.js +++ b/build/run-testsapp.grunt.js @@ -171,10 +171,6 @@ module.exports = { cmd: localCfg.tnsPath + " create " + localCfg.testsAppName, cwd: localCfg.workingDir }, - addPlatform: { - cmd: "tns platform add " + localCfg.platform.toLowerCase() + " " + localCfg.frameworkArgument, - cwd: localCfg.applicationDir - }, restartAdb: { cmd: "adb kill-server && adb start-server" }, @@ -241,6 +237,15 @@ module.exports = { } } }, + addPlatform: { + command: "tns platform add " + localCfg.platform.toLowerCase() + " " + localCfg.frameworkArgument, + options: { + execOptions: { + maxBuffer: Infinity, + cwd: localCfg.applicationDir + } + } + }, } }); @@ -294,7 +299,7 @@ module.exports = { "copy:modulesToDir", "clean:tempExtractedModules", - "exec:addPlatform", + "shell:addPlatform", getPlatformSpecificTask("copy:add{platform}Permissions"), "shell:buildApp", ]); From ef163a52ef136812cdaeec5d00b8655c81ffefeb Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 11 Dec 2015 10:27:51 +0200 Subject: [PATCH 06/15] default font size fixed --- ui/tab-view/tab-view.ios.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/tab-view/tab-view.ios.ts b/ui/tab-view/tab-view.ios.ts index fd75b46b23..bf97f79cf4 100644 --- a/ui/tab-view/tab-view.ios.ts +++ b/ui/tab-view/tab-view.ios.ts @@ -354,7 +354,7 @@ function getTitleAttributesForStates(tabView: TabView): { normalState: any, sele selectedState[UITextAttributeTextColor] = tabView.ios.tabBar.tintColor; } - var defaultFont = UIFont.systemFontOfSize(UIFont.labelFontSize()); + var defaultFont = UIFont.systemFontOfSize(10); var font = (tabView.style)._fontInternal.getUIFont(defaultFont); normalState[NSFontAttributeName] = font; selectedState[NSFontAttributeName] = font; From 7546b7fad4007e6575a9649e33474acbdd59a303 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Fri, 11 Dec 2015 13:21:12 +0200 Subject: [PATCH 07/15] Fixed Issue ##1235: ObservableArray does not raise its `change` event when its `length' property is set. --- apps/tests/observable-array-tests.ts | 40 +++++++++++++++++++++++ data/observable-array/observable-array.ts | 3 +- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/apps/tests/observable-array-tests.ts b/apps/tests/observable-array-tests.ts index 40b3b960c0..e8306b0da3 100644 --- a/apps/tests/observable-array-tests.ts +++ b/apps/tests/observable-array-tests.ts @@ -606,6 +606,46 @@ export var test_ObservableArray_lastIndexOfShouldReturnCorrectIndexStartingFrom TKUnit.assert(result === 1, "ObservableArray lastIndexOf() should return correct index!"); }; +export var test_ObservableArray_settingLengthToZeroPerformsSplice = function () { + var array = new observableArrayModule.ObservableArray([1, 2, 3]); + + var changeRaised = false; + array.on("change", (args: observableArrayModule.ChangedData) => { + changeRaised = true; + TKUnit.assertEqual(args.object, array); + TKUnit.assertEqual(args.eventName, "change"); + TKUnit.assertEqual(args.action, observableArrayModule.ChangeType.Splice); + TKUnit.assertEqual(args.index, 0); + TKUnit.assertEqual(args.addedCount, 0); + TKUnit.arrayAssert(args.removed, [1, 2, 3]); + }); + + array.length = 0; + + TKUnit.assertEqual(array.length, 0); + TKUnit.assertTrue(changeRaised); +}; + +export var test_ObservableArray_settingLengthToSomethingPerformsSplice = function () { + var array = new observableArrayModule.ObservableArray([1, 2, 3]); + + var changeRaised = false; + array.on("change", (args: observableArrayModule.ChangedData) => { + changeRaised = true; + TKUnit.assertEqual(args.object, array); + TKUnit.assertEqual(args.eventName, "change"); + TKUnit.assertEqual(args.action, observableArrayModule.ChangeType.Splice); + TKUnit.assertEqual(args.index, 1); + TKUnit.assertEqual(args.addedCount, 0); + TKUnit.arrayAssert(args.removed, [2, 3]); + }); + + array.length = 1; + + TKUnit.assertEqual(array.length, 1); + TKUnit.assertTrue(changeRaised); +}; + var array = new observableArrayModule.ObservableArray(); // We do not have indexer! diff --git a/data/observable-array/observable-array.ts b/data/observable-array/observable-array.ts index 76025f2ac9..cc50bc6fca 100644 --- a/data/observable-array/observable-array.ts +++ b/data/observable-array/observable-array.ts @@ -70,8 +70,7 @@ export class ObservableArray extends observable.Observable implements observa } set length(value: number) { if (types.isNumber(value) && this._array && this._array.length !== value) { - this._array = this._array.slice(0, value); - this._notifyLengthChange(); + this.splice(value, this._array.length - value); } } From f5ba96390e627fa36d20b5f519889dc4fe9d687d Mon Sep 17 00:00:00 2001 From: Erjan Gavalji Date: Sat, 12 Dec 2015 10:32:56 +0200 Subject: [PATCH 08/15] Update the changelog with the 1.5.1 changes --- CHANGELOG.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d64f88c45..39d96935f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,49 @@ Cross Platform Modules Changelog ============================== +##1.5.1 (2015, November 14) + +### Fixed + +- [(#1235)](https://github.com/NativeScript/NativeScript/issues/1235) ObservableArray does not raise its `change` event when its `length' property is set. + +- [(#1228)](https://github.com/NativeScript/NativeScript/pull/1228) url with % fixed + +- [(#1213)](https://github.com/NativeScript/NativeScript/issues/1213) Android build error when space exists in the folder + +- [(#1186)](https://github.com/NativeScript/NativeScript/pull/1186) Fix currentEntry to return NavigationEntry instead of BackstackEntry + +- [(#1179)](https://github.com/NativeScript/NativeScript/issues/1179) Listview doesn't seem to clear\reset + +- [(#1168)](https://github.com/NativeScript/NativeScript/issues/1168) alert with null value is not displayed + +- [(#1160)](https://github.com/NativeScript/NativeScript/issues/1160) iOS: The image supplied to Label.backgroundImage is rendered upside down. + +- [(#1149)](https://github.com/NativeScript/NativeScript/pull/1149) Correct TabView icon rendering mode + +- [(#1142)](https://github.com/NativeScript/NativeScript/issues/1142) ObservableArray does not provide removed items through EventData when an UPDATE action occurs + +- [(#1139)](https://github.com/NativeScript/NativeScript/issues/1139) Missing attributes in the NativeScript XSD schema + +- [(#1018)](https://github.com/NativeScript/NativeScript/issues/1018) BackgroundPosition & negative values + +- [(#754)](https://github.com/NativeScript/NativeScript/issues/754) The backgroundColor of a Label is not animatable in iOS. + +### New + +- [(#1171)](https://github.com/NativeScript/NativeScript/issues/1171) Expose API to get the focus point of pinch gesture + +- [(#1140)](https://github.com/NativeScript/NativeScript/issues/1140) Expose API for setting origin (a.k.a. pivot or anchor) point for view transformations + +- [(#1136)](https://github.com/NativeScript/NativeScript/pull/1136) Add Template factory function and use it in the ui/builder, Repeater and ListView components + +- [(#1109)](https://github.com/NativeScript/NativeScript/issues/1109) min/max and intervals values on date / time pickers + +- [(#691)](https://github.com/NativeScript/NativeScript/issues/691) Visibility attribute on ActionItem element + +- [(#685)](https://github.com/NativeScript/NativeScript/issues/685) Support CSS text-transform + +- [(#501)](https://github.com/NativeScript/NativeScript/issues/501) Better XML declaration error reporting for non-existing element + ##1.5.0 (2015, November 24) ### Breaking changes From 131208d58d73cd18423efe92ffa764db403896b6 Mon Sep 17 00:00:00 2001 From: Vladimir Enchev Date: Fri, 11 Dec 2015 17:23:35 +0200 Subject: [PATCH 09/15] lazy loading code refactored --- globals/globals.ts | 81 ++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 53 deletions(-) diff --git a/globals/globals.ts b/globals/globals.ts index ef1986e10e..c6006f3e62 100644 --- a/globals/globals.ts +++ b/globals/globals.ts @@ -5,6 +5,34 @@ global.moduleMerge = function (sourceExports: any, destExports: any) { destExports[key] = sourceExports[key]; } } + +function registerOnGlobalContext(name, module) { + Object.defineProperty(global, name, { + get: function () { + // We do not need to cache require() call since it is already cached in the runtime. + let m = require(module); + global.moduleMerge(m, global); + + // Redefine the property to make sure the above code is executed only once. + Object.defineProperty(this, name, { value: m[name], configurable: true, writable: true }); + + return m[name]; + }, + configurable: true + }); +} + +registerOnGlobalContext("setTimeout", "timer"); +registerOnGlobalContext("clearTimeout", "timer"); +registerOnGlobalContext("setInterval", "timer"); +registerOnGlobalContext("clearInterval", "timer"); +registerOnGlobalContext("alert", "ui/dialogs"); +registerOnGlobalContext("confirm", "ui/dialogs"); +registerOnGlobalContext("prompt", "ui/dialogs"); +registerOnGlobalContext("XMLHttpRequest", "../xhr/xhr"); +registerOnGlobalContext("FormData", "../xhr/xhr"); +registerOnGlobalContext("fetch", "fetch"); + import platform = require("platform"); import consoleModule = require("console"); @@ -16,59 +44,6 @@ if (platform.device.os === platform.platformNames.android) { global.console.dump = function (args) { c.dump(args); }; } -var tm; -function getTimer() { - if (!tm) { - tm = require("timer"); - } - - return tm; -} - -global.setTimeout = function (callback, milliseconds) { - return getTimer().setTimeout(callback, milliseconds); -} - -global.clearTimeout = function (id) { - getTimer().clearTimeout(id); -} - -global.setInterval = function (callback, milliseconds) { - return getTimer().setInterval(callback, milliseconds); -} - -global.clearInterval = function (id) { - getTimer().clearInterval(id); -} - -var dm; -function getDialogs() { - if (!dm) { - dm = require("ui/dialogs"); - } - - return dm; -} - -global.alert = function (args) { - return getDialogs().alert(args); -} - -global.confirm = function (args) { - return getDialogs().confirm(args); -} - -global.prompt = function (args) { - return getDialogs().prompt(args); -} - -var xhr = require("../xhr/xhr"); -global.moduleMerge(xhr, global); - -// Fetch module should be after XMLHttpRequest/FormData! -var fetchModule = require("fetch"); -global.moduleMerge(fetchModule, global); - if (typeof global.__decorate !== "function") { global.__decorate = function (decorators, target, key, desc) { if (typeof global.Reflect === "object" && typeof global.Reflect.decorate === "function") { From 1331d67f58f62c0de0968c4fe2e65a0c969649df Mon Sep 17 00:00:00 2001 From: Antonio Cueva Date: Fri, 22 Jan 2016 15:38:04 +0200 Subject: [PATCH 10/15] Fix the url encoding on request --- http/http-request.android.ts | 17 ++++++++++++++++- http/http-request.ios.ts | 19 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/http/http-request.android.ts b/http/http-request.android.ts index e32469af3f..60404c5a30 100644 --- a/http/http-request.android.ts +++ b/http/http-request.android.ts @@ -75,7 +75,22 @@ function buildJavaOptions(options: http.HttpRequestOptions) { var javaOptions = new com.tns.Async.Http.RequestOptions(); - javaOptions.url = options.url.replace("%", "%25"); + //HACK to fix the encoding https://github.com/NativeScript/NativeScript/pull/1228 + var originalUrl = options.url; + try { + var decodedUrl = decodeURI(originalUrl); + if (decodedUrl === originalUrl) { + //the url is not encoded, fix the % + options.url.replace("%", "%25"); + } + } + catch (e) { + //This means something crash with js decode encode (url malformed) + // if we don't catch it will be and infinite loop, revert changes + options.url = originalUrl; + } + javaOptions.url = options.url; + //End of the HACK if (types.isString(options.method)) { javaOptions.method = options.method; diff --git a/http/http-request.ios.ts b/http/http-request.ios.ts index ca1827d7bb..4342254801 100644 --- a/http/http-request.ios.ts +++ b/http/http-request.ios.ts @@ -19,8 +19,25 @@ export function request(options: http.HttpRequestOptions): Promise Date: Fri, 22 Jan 2016 15:44:07 +0200 Subject: [PATCH 11/15] =?UTF-8?q?Don=C2=B4t=20store=20automatically=20the?= =?UTF-8?q?=20image=20after=20downloaded=20on=20image=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/image-cache/image-cache-common.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ui/image-cache/image-cache-common.ts b/ui/image-cache/image-cache-common.ts index 3ab69f965f..ee69e4b2fb 100644 --- a/ui/image-cache/image-cache-common.ts +++ b/ui/image-cache/image-cache-common.ts @@ -126,7 +126,10 @@ export class Cache extends observable.Observable implements definition.Cache { var request = this._pendingDownloads[key]; if (request.key && image) { - this.set(request.key, image); + //HACK to use the image resizing + + // this.set(request.key, image); + //HACK ends here } this._currentDownloads--; From 6c9d45885ac8b11170bc8addbf832275f6b0cb5f Mon Sep 17 00:00:00 2001 From: Antonio Cueva Date: Fri, 22 Jan 2016 15:47:28 +0200 Subject: [PATCH 12/15] Catch number conversion exception --- ui/core/view.android.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/core/view.android.ts b/ui/core/view.android.ts index 6a84495b16..720f4bbb2e 100644 --- a/ui/core/view.android.ts +++ b/ui/core/view.android.ts @@ -16,7 +16,14 @@ var OWNER = "_owner"; function onIdPropertyChanged(data: dependencyObservable.PropertyChangeData) { var view = data.object; - view._nativeView.setTag(data.newValue); + //HACK to catch number conversion exception + try { + view._nativeView.setTag(data.newValue); + } + catch (e) { + console.log("error is " + e); + } + //HACK ends here } (viewCommon.View.idProperty.metadata).onSetNativeValue = onIdPropertyChanged; From 587a64607cace6d8d88fbddbfa0958736c46e07a Mon Sep 17 00:00:00 2001 From: Antonio Cueva Date: Fri, 22 Jan 2016 15:54:02 +0200 Subject: [PATCH 13/15] Skip native fragments not controlled by ns --- ui/frame/frame.android.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/frame/frame.android.ts b/ui/frame/frame.android.ts index 78ac971907..ba335eb349 100644 --- a/ui/frame/frame.android.ts +++ b/ui/frame/frame.android.ts @@ -444,6 +444,12 @@ var NativeActivity = { this.super.onAttachFragment(fragment); if (!(fragment).entry) { + //HACK to skip native fragments not controlled by ns + if (fragment.getTag() === "datePicker" || fragment.getTag() === "timePicker") { + return; + } + //End of the hack + // There is no entry set to the fragment, so this must be destroyed fragment that was recreated by Android. // We should find its corresponding page in our backstack and set it manually. findPageForFragment(fragment, this.frame); From a08e3a600cf3d7ee1371a96b8c25fbed9c132316 Mon Sep 17 00:00:00 2001 From: Antonio Cueva Date: Tue, 26 Jan 2016 16:38:27 +0200 Subject: [PATCH 14/15] Fix iOS %25 --- http/http-request.ios.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/http/http-request.ios.ts b/http/http-request.ios.ts index 4342254801..034a03ac67 100644 --- a/http/http-request.ios.ts +++ b/http/http-request.ios.ts @@ -20,23 +20,12 @@ export function request(options: http.HttpRequestOptions): Promise Date: Wed, 23 Mar 2016 13:32:18 +0200 Subject: [PATCH 15/15] add reference to NS submodule --- .gitmodules | 3 +++ vendor | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 vendor diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..ddc0725006 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor"] + path = vendor + url = https://github.com/NativeScript/NativeScript diff --git a/vendor b/vendor new file mode 160000 index 0000000000..1122c39122 --- /dev/null +++ b/vendor @@ -0,0 +1 @@ +Subproject commit 1122c391228bff18a491c181c27e826144a9c65e