mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 11:42:04 +08:00
Added Application module comments. Modified Console module + comments. Changed the package name of the UnitTestApp for Android.
This commit is contained in:
@ -13,10 +13,6 @@ var initEvents = function () {
|
||||
if (!androidApp.startActivity) {
|
||||
androidApp.startActivity = activity;
|
||||
|
||||
//if (UI.Application.current.onLaunch) {
|
||||
// UI.Application.current.onLaunch();
|
||||
//}
|
||||
|
||||
if (androidApp.onActivityCreated) {
|
||||
androidApp.onActivityCreated(activity, bundle);
|
||||
}
|
||||
|
1
Application/application.d.ts
vendored
1
Application/application.d.ts
vendored
@ -90,7 +90,6 @@ export declare class AndroidApplication {
|
||||
* This method is called by the JavaScript Bridge when navigation to a new activity is triggered.
|
||||
* The return value of this method should be com.tns.NativeScriptActivity.extends implementation.
|
||||
*/
|
||||
// TODO: Why is the android.content.Intent module rather than a class?
|
||||
public getActivity: (intent: android.content.Intent) => any;
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import console_module = require("Console/console_common");
|
||||
import consoleModule = require("Console/console");
|
||||
|
||||
export enum TargetOS {
|
||||
iOS,
|
||||
@ -9,7 +9,8 @@ export class Application {
|
||||
public os: TargetOS;
|
||||
|
||||
constructor() {
|
||||
console = new console_module.TKConsole();
|
||||
// TODO: This is put in the global context, is this the preferred approach
|
||||
console = new consoleModule.Console();
|
||||
}
|
||||
|
||||
public onLaunch: () => any;
|
||||
|
19
BCL.csproj
19
BCL.csproj
@ -77,6 +77,16 @@
|
||||
<TypeScriptCompile Include="Application\application.ios.ts">
|
||||
<DependentUpon>application.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Console\console.ts">
|
||||
<DependentUpon>console.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Console\console_helper.android.ts">
|
||||
<DependentUpon>console_helper.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Console\console_helper.d.ts" />
|
||||
<TypeScriptCompile Include="Console\console_helper.ios.ts">
|
||||
<DependentUpon>console_helper.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="declarations.d.ts" />
|
||||
<TypeScriptCompile Include="declarations.android.d.ts">
|
||||
<DependentUpon>declarations.d.ts</DependentUpon>
|
||||
@ -160,16 +170,7 @@
|
||||
<TypeScriptCompile Include="http\http.ts" />
|
||||
<TypeScriptCompile Include="ios7.d.ts" />
|
||||
<Content Include="_references.ts" />
|
||||
<TypeScriptCompile Include="Console\console.android.ts">
|
||||
<DependentUpon>console.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Console\console.d.ts" />
|
||||
<TypeScriptCompile Include="Console\console.ios.ts">
|
||||
<DependentUpon>console.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="Console\console_common.ts">
|
||||
<DependentUpon>console.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<Content Include="Image\Readme.md" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -1,24 +0,0 @@
|
||||
export class ConsoleHelper {
|
||||
static TAG: string = 'JS';
|
||||
|
||||
static log(message: string): void {
|
||||
android.util.Log.v(ConsoleHelper.TAG, message);
|
||||
}
|
||||
|
||||
static info(message: string): void {
|
||||
android.util.Log.i(ConsoleHelper.TAG, message);
|
||||
}
|
||||
|
||||
static error(message: string): void {
|
||||
android.util.Log.e(ConsoleHelper.TAG, message);
|
||||
}
|
||||
|
||||
static warn(message: string): void {
|
||||
android.util.Log.w(ConsoleHelper.TAG, message);
|
||||
}
|
||||
|
||||
static timeMillis(): number {
|
||||
// NOTE: we might need to use currentTimeMillis if we have troubles with the long size
|
||||
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
|
||||
}
|
||||
}
|
63
Console/console.d.ts
vendored
63
Console/console.d.ts
vendored
@ -1,19 +1,50 @@
|
||||
export declare class TKConsole implements i.IConsole {
|
||||
/**
|
||||
* Encapsulates methods used to report some information to the console.
|
||||
* Instance of this class is declared in the global JavaScript context and is accessible by directly calling console.[xxx] methods.
|
||||
*/
|
||||
export declare class Console {
|
||||
/**
|
||||
* Begins counting a time span for a given name (key).
|
||||
*/
|
||||
public time(reportName: string): void;
|
||||
public timeEnd(reportName: string): void;
|
||||
public assert(test: boolean, message: string, ...optionalParams: any[]): void;
|
||||
public info(message: any, ...optionalParams: any[]): void;
|
||||
public warn(message: any, ...optionalParams: any[]): void;
|
||||
public error(message: any, ...optionalParams: any[]): void;
|
||||
public log(message: any, ...optionalParams: any[]): void;
|
||||
public trace(): void;
|
||||
public dump(obj: any): void;
|
||||
}
|
||||
|
||||
export declare class ConsoleHelper {
|
||||
static log(message: string): void;
|
||||
static info(message: string): void;
|
||||
static error(message: string): void;
|
||||
static warn(message: string): void;
|
||||
static timeMillis(): number;
|
||||
/**
|
||||
* Ends a previously started time span through the time method.
|
||||
*/
|
||||
public timeEnd(reportName: string): void;
|
||||
|
||||
/**
|
||||
* Asserts a boolean condition and prints a message in case the assert fails.
|
||||
*/
|
||||
public assert(test: boolean, message: string, ...optionalParams: any[]): void;
|
||||
|
||||
/**
|
||||
* Reports some information.
|
||||
*/
|
||||
public info(message: any, ...optionalParams: any[]): void;
|
||||
|
||||
/**
|
||||
* Reports a warning.
|
||||
*/
|
||||
public warn(message: any, ...optionalParams: any[]): void;
|
||||
|
||||
/**
|
||||
* Reports an error.
|
||||
*/
|
||||
public error(message: any, ...optionalParams: any[]): void;
|
||||
|
||||
/**
|
||||
* Verbously logs a message.
|
||||
*/
|
||||
public log(message: any, ...optionalParams: any[]): void;
|
||||
|
||||
/**
|
||||
* Prints the current stack trace in the console.
|
||||
*/
|
||||
public trace(): void;
|
||||
|
||||
/**
|
||||
* Prints the state of the specified object to the console.
|
||||
*/
|
||||
public dump(obj: any): void;
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
export class ConsoleHelper {
|
||||
// FIXME: we should use Foundation.NSLog() but it currently does not work
|
||||
static log(message: string): void {
|
||||
log('log: ' + message);
|
||||
}
|
||||
|
||||
static info(message: string): void {
|
||||
log('info: ' + message);
|
||||
}
|
||||
|
||||
static error(message: string): void {
|
||||
log('error: ' + message);
|
||||
}
|
||||
|
||||
static warn(message: string): void {
|
||||
log('warning: ' + message);
|
||||
}
|
||||
|
||||
static timeMillis(): number {
|
||||
return QuartzCore.CACurrentMediaTime() * 1000;
|
||||
}
|
||||
}
|
@ -1,12 +1,9 @@
|
||||
import helperModule = require("Console/console_helper");
|
||||
|
||||
import native_module = require("Console/console");
|
||||
|
||||
export class TKConsole {
|
||||
private _nativeClass: any;
|
||||
export class Console {
|
||||
private _timers: any;
|
||||
|
||||
constructor() {
|
||||
this._nativeClass = native_module.ConsoleHelper;
|
||||
this._timers = {};
|
||||
}
|
||||
|
||||
@ -216,7 +213,7 @@ export class TKConsole {
|
||||
public time(reportName: string): void {
|
||||
var name = reportName ? '__' + reportName : '__internal_console_time__';
|
||||
if (('undefined' === typeof (this._timers[name])) || (this._timers.hasOwnProperty(name))) {
|
||||
this._timers[name] = this._nativeClass.timeMillis();
|
||||
this._timers[name] = helperModule.timeMillis();
|
||||
}
|
||||
else {
|
||||
this.warn('invalid name for timer console.time(' + reportName + ')');
|
||||
@ -228,7 +225,7 @@ export class TKConsole {
|
||||
if (this._timers.hasOwnProperty(name)) {
|
||||
var val = this._timers[name];
|
||||
if (val) {
|
||||
var time = this._nativeClass.timeMillis();
|
||||
var time = helperModule.timeMillis();
|
||||
this.info('console.time(' + reportName + '): %.6f ms', (time - val));
|
||||
this._timers[name] = undefined;
|
||||
}
|
||||
@ -241,7 +238,7 @@ export class TKConsole {
|
||||
public assert(test: boolean, message: string, ...optionalParams: any[]): void {
|
||||
if (!test) {
|
||||
Array.prototype.shift.apply(arguments);
|
||||
this._nativeClass.error(this.formatParams.apply(this, arguments));
|
||||
helperModule.error(this.formatParams.apply(this, arguments));
|
||||
|
||||
// duplicating trace code here because android version shows only 2 frames and if we call trace()
|
||||
// this would be assert() and trace() which leaves all important stack frames out of our view
|
||||
@ -269,19 +266,19 @@ export class TKConsole {
|
||||
}
|
||||
|
||||
public info(message: any, ...optionalParams: any[]): void {
|
||||
this._nativeClass.info(this.formatParams.apply(this, arguments));
|
||||
helperModule.info(this.formatParams.apply(this, arguments));
|
||||
}
|
||||
|
||||
public warn(message: any, ...optionalParams: any[]): void {
|
||||
this._nativeClass.warn(this.formatParams.apply(this, arguments));
|
||||
helperModule.warn(this.formatParams.apply(this, arguments));
|
||||
}
|
||||
|
||||
public error(message: any, ...optionalParams: any[]): void {
|
||||
this._nativeClass.error(this.formatParams.apply(this, arguments));
|
||||
helperModule.error(this.formatParams.apply(this, arguments));
|
||||
}
|
||||
|
||||
public log(message: any, ...optionalParams: any[]): void {
|
||||
this._nativeClass.log(this.formatParams.apply(this, arguments));
|
||||
helperModule.log(this.formatParams.apply(this, arguments));
|
||||
}
|
||||
|
||||
public trace(): void {
|
22
Console/console_helper.android.ts
Normal file
22
Console/console_helper.android.ts
Normal file
@ -0,0 +1,22 @@
|
||||
var TAG = 'JS';
|
||||
|
||||
export var log = function (message: string) {
|
||||
android.util.Log.v(TAG, message);
|
||||
}
|
||||
|
||||
export var info = function (message: string) {
|
||||
android.util.Log.i(TAG, message);
|
||||
}
|
||||
|
||||
export var error = function (message: string) {
|
||||
android.util.Log.e(TAG, message);
|
||||
}
|
||||
|
||||
export var warn = function (message: string) {
|
||||
android.util.Log.w(TAG, message);
|
||||
}
|
||||
|
||||
export var timeMillis = function (): number {
|
||||
// NOTE: we might need to use currentTimeMillis if we have troubles with the long size
|
||||
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
|
||||
}
|
5
Console/console_helper.d.ts
vendored
Normal file
5
Console/console_helper.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
export declare var log: (message: string) => void;
|
||||
export declare var info: (message: string) => void;
|
||||
export declare var error: (message: string) => void;
|
||||
export declare var warn: (message: string) => void;
|
||||
export declare var timeMillis: () => number;
|
22
Console/console_helper.ios.ts
Normal file
22
Console/console_helper.ios.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// TODO: we should use Foundation.NSLog() but it currently does not work
|
||||
// TODO: Is there a better way to implement the info/warn/error
|
||||
|
||||
export var log = function (message: string) {
|
||||
log('log: ' + message);
|
||||
}
|
||||
|
||||
export var info = function (message: string) {
|
||||
log('info: ' + message);
|
||||
}
|
||||
|
||||
export var error = function (message: string) {
|
||||
log('error: ' + message);
|
||||
}
|
||||
|
||||
export var warn = function (message: string) {
|
||||
log('warning: ' + message);
|
||||
}
|
||||
|
||||
export var timeMillis = function (): number {
|
||||
return QuartzCore.CACurrentMediaTime() * 1000;
|
||||
}
|
@ -154,7 +154,7 @@ export class FileSystemEntity {
|
||||
*/
|
||||
get lastModified(): Date {
|
||||
var value = this[lastModifiedProperty];
|
||||
if (this[lastModifiedProperty] === undefined) {
|
||||
if (!this[lastModifiedProperty]) {
|
||||
value = this[lastModifiedProperty] = getFileAccess().getLastModified(this.path);
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ export class FileSystemAccess {
|
||||
}
|
||||
|
||||
retVal = callback(info);
|
||||
if (retVal != undefined && !retVal) {
|
||||
if (retVal === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ export class FileSystemAccess {
|
||||
}
|
||||
|
||||
retVal = callback(info);
|
||||
if (retVal != undefined && !retVal) {
|
||||
if (retVal === false) {
|
||||
// the callback returned false meaning we should stop the iteration
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user