namespaces removed (except Application)

This commit is contained in:
Vladimir Enchev
2014-03-24 11:16:38 +02:00
parent d5a91269f6
commit 1b6fdae4a9
29 changed files with 1930 additions and 2040 deletions

View File

@@ -100,7 +100,7 @@ export module tk {
currentApp.os = app_common_module.tk.TargetOS.Android;
currentApp.android = app;
app.init();
console = new console_module.tk.TKConsole();
console = new console_module.TKConsole();
}
class Application {

View File

@@ -36,7 +36,7 @@ export module tk {
currentApp.os = app_common_module.tk.TargetOS.iOS;
currentApp.ios = app;
app.init();
console = new console_module.tk.TKConsole();
console = new console_module.TKConsole();
}
class Application {

View File

@@ -108,6 +108,9 @@
<TypeScriptCompile Include="Image\image.android.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Image\image_types.ts">
<DependentUpon>image.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="Image\image.d.ts" />
<TypeScriptCompile Include="Location\location.android.ts">
<DependentUpon>location.d.ts</DependentUpon>
@@ -161,8 +164,10 @@
<Content Include="Readme.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Deploy\Eclipse\" />
<Content Include="Console\Readme.md" />
</ItemGroup>
<ItemGroup>
<Folder Include="Deploy\Eclipse\" />
<Folder Include="Deploy\xCode\" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'iOS'">
@@ -206,12 +211,7 @@
</PropertyGroup>
<UsingTask TaskName="BuildTasks.CopyForPlatformBuildTask" AssemblyFile="../../Build/lib/BuildTasks.dll" />
<Target Name="AfterBuild">
<CopyForPlatformBuildTask TargetPlatform="$(Configuration)"
Platforms="iOS;Android"
InputFiles="@(GeneratedJavascript)"
DestinationFolder="$(OutputPath)\$(Configuration)\"
JSConfigFile="$(JSConfig)"
AppMainJSFile="$(JSMainFile)"/>
<CopyForPlatformBuildTask TargetPlatform="$(Configuration)" Platforms="iOS;Android" InputFiles="@(GeneratedJavascript)" DestinationFolder="$(OutputPath)\$(Configuration)\" JSConfigFile="$(JSConfig)" AppMainJSFile="$(JSMainFile)" />
</Target>
<PropertyGroup>
<PostBuildEvent>

View File

@@ -1,7 +1,5 @@
import app_module = require("Application/application");
export module tk {
export module io {
var REQUEST_IMAGE_CAPTURE: number = 1;
var REQUEST_SELECT_PICTURE: number = 2;
@@ -27,5 +25,3 @@ export module tk {
REQUEST_SELECT_PICTURE);
}
}
}
}

10
Camera/camera.d.ts vendored
View File

@@ -1,22 +1,18 @@
export declare module tk {
export module camera {
export enum CameraPosition {
export declare enum CameraPosition {
FRONT = 0,
BACK = 1,
}
export enum FlashMode {
export declare enum FlashMode {
AUTO = 0, // default
ON = 1,
OFF = 2
}
// TODO most of hardware related parts need to handle onPause and onResume of the calling activities
export class CameraManager {
export declare class CameraManager {
takePicture(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
// options { useSavedPhotos: true }
pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any);
}
}
}

View File

@@ -1,6 +1,4 @@
export module tk {
export module io {
var REQUEST_IMAGE_CAPTURE: number = 1;
var REQUEST_IMAGE_CAPTURE: number = 1;
var REQUEST_SELECT_PICTURE: number = 2;
export class CameraManager {
@@ -11,5 +9,3 @@
public pictureFromLibrary(params: any, onSuccess: (imageData: any) => any, onError?: (error: any) => any) {
}
}
}
}

View File

@@ -1,5 +1,3 @@
export module tk {
export class ConsoleHelper {
static TAG: string = 'JS';
@@ -24,4 +22,3 @@ export module tk {
return java.lang.System.nanoTime() / 1000000; // 1 ms = 1000000 ns
}
}
}

View File

@@ -1,7 +1,4 @@
export declare module tk {
export class TKConsole implements i.IConsole {
export declare class TKConsole implements i.IConsole {
public time(reportName: string): void;
public timeEnd(reportName: string): void;
public assert(test: boolean, message: string, ...optionalParams: any[]): void;
@@ -13,11 +10,10 @@ export declare module tk {
public dump(obj: any): void;
}
export class ConsoleHelper {
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;
}
}

View File

@@ -1,5 +1,3 @@
export module tk {
export class ConsoleHelper {
// FIXME: we should use Foundation.NSLog() but it currently does not work
static log(message: string): void {
@@ -22,5 +20,3 @@ export module tk {
return QuartzCore.CACurrentMediaTime() * 1000;
}
}
}

View File

@@ -1,14 +1,12 @@
import native_module = require("Console/console");
export module tk {
export class TKConsole {
private _nativeClass: any;
private _timers: any;
constructor() {
this._nativeClass = native_module.tk.ConsoleHelper;
this._nativeClass = native_module.ConsoleHelper;
this._timers = {};
}
@@ -336,5 +334,3 @@ export module tk {
this.log(result.join('\n'));
}
}
}

View File

@@ -1,6 +1,4 @@
export declare module tk {
export module io {
export class FileSystemEntity {
export declare class FileSystemEntity {
public readonly: boolean;
public lastModified: Date;
/**
@@ -25,7 +23,7 @@
public rename(newName: string, onSuccess?: Function, onError?: Function);
}
export class File extends FileSystemEntity {
export declare class File extends FileSystemEntity {
/**
* Gets the extension of the file.
*/
@@ -52,7 +50,7 @@
public openWrite(): FileWriter;
}
export class Folder extends FileSystemEntity {
export declare class Folder extends FileSystemEntity {
/**
* Determines whether this instance is a KnownFolder (accessed through the KnownFolders object).
*/
@@ -91,7 +89,7 @@
/**
* Provides access to the top-level Folders instances that are accessible from the application. Use these as entry points to access the FileSystem.
*/
export class KnownFolders {
export declare class KnownFolders {
/**
* Gets the Documents folder available for the current application. This Folder is private for the application and not accessible from Users/External apps.
*/
@@ -106,7 +104,7 @@
/**
* Base class for FileReader and FileWriter APIs.
*/
export class FileAccess {
export declare class FileAccess {
constructor(file: File);
/**
* Unlocks the file and allows other operations over it.
@@ -121,7 +119,7 @@
/**
* Enables reading the content of a File entity.
*/
export class FileReader extends FileAccess {
export declare class FileReader extends FileAccess {
/**
* Reads the content of the underlying File as a UTF8 encoded string.
*/
@@ -131,8 +129,6 @@
/**
* Enables saving data to a File entity.
*/
export class FileWriter extends FileAccess {
export declare class FileWriter extends FileAccess {
public writeText(content: string, onSuccess?: () => any, onError?: (error: any) => any);
}
}
}

View File

@@ -1,12 +1,10 @@
import file_access_module = require("FileSystem/file_system_access");
export module tk {
export module io {
// The FileSystemAccess implementation, used through all the APIs.
var fileAccess;
var getFileAccess = function (): file_access_module.tk.io.FileSystemAccess {
var getFileAccess = function (): file_access_module.FileSystemAccess {
if (!fileAccess) {
fileAccess = new file_access_module.tk.io.FileSystemAccess();
fileAccess = new file_access_module.FileSystemAccess();
}
return fileAccess;
@@ -360,5 +358,3 @@ export module tk {
getFileAccess().writeText(this.file.path, content, onSuccess, onError);
}
}
}
}

View File

@@ -1,7 +1,5 @@
import app_module = require("Application/application");
export module tk {
export module io {
export class FileSystemAccess {
private _encoding = "UTF-8";
private _pathSeparator = "/";
@@ -301,5 +299,3 @@ export module tk {
}
}
}
}
}

View File

@@ -1,8 +1,6 @@
// TODO: Implement "hidden" notation so that such declarations are not included in the d.ts file we will provide for the users.
//@hidden
export declare module tk {
export module io {
export class FileSystemAccess {
export declare class FileSystemAccess {
getReadonly(path: string): boolean;
getLastModified(path: string): Date;
@@ -22,5 +20,3 @@ export declare module tk {
readText(path: string, onSuccess: (content: string) => any, onError?: (error: any) => any);
writeText(path: string, content: string, onSuccess?: () => any, onError?: (error: any) => any);
}
}
}

View File

@@ -1,7 +1,5 @@
import app_module = require("Application/application");
export module tk {
export module io {
export class FileSystemAccess {
private keyFileType = "NSFileType";
private keyModificationTime = "NSFileModificationDate";
@@ -89,5 +87,3 @@ export module tk {
// return folder;
//}
}
}
}

View File

@@ -1,11 +1,5 @@
import app_module = require("Application/application");
export module tk {
export module ui {
export enum ImageType {
PNG = 0,
JPEG = 1,
}
import types_module = require("Image/image_types");
export class Image {
public android: any;
@@ -42,11 +36,11 @@ export module tk {
return (this.android != null);
}
public saveToFile(path: string, format: ImageType, quality?: number): boolean {
public saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean {
if (this.android) {
var targetFormat = android.graphics.Bitmap.CompressFormat.PNG;
switch (format) {
case ImageType.JPEG:
case types_module.ImageType.JPEG:
targetFormat = android.graphics.Bitmap.CompressFormat.JPEG;
break;
}
@@ -69,5 +63,3 @@ export module tk {
return (this.android) ? this.android.getWidth() : NaN;
}
}
}
}

13
Image/image.d.ts vendored
View File

@@ -1,19 +1,12 @@
export declare module tk {
export module ui {
export enum ImageType {
PNG = 0,
JPEG = 1,
}
import types_module = require("Image/image_types");
export class Image {
export declare class Image {
loadFromResource(name: string): boolean;
loadFromFile(path: string): boolean;
loadFromData(data: any): boolean;
loadFromBitmap(source: any): boolean;
saveToFile(path: string, format: ImageType, quality?: number): boolean;
saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean;
getHeight(): number;
getWidth(): number;
}
}
}

View File

@@ -1,9 +1,4 @@
export module tk {
export module ui {
export enum ImageType {
PNG = 0,
JPEG = 1,
}
import types_module = require("Image/image_types");
export class Image {
public ios: any;
@@ -32,17 +27,17 @@
return (this.ios != null);
}
public saveToFile(path: string, format: ImageType, quality?: number): boolean {
public saveToFile(path: string, format: types_module.ImageType, quality?: number): boolean {
if (null == this.ios) {
return false;
}
var res = false;
var data = null;
switch (format) {
case ImageType.JPEG:
case types_module.ImageType.JPEG:
data = UIKit.UIImageJPEGRepresentation(this.ios, ('undefined' == typeof quality) ? 1.0 : quality);
break;
case ImageType.PNG:
case types_module.ImageType.PNG:
data = UIKit.UIImagePNGRepresentation(this.ios);
break;
}
@@ -60,5 +55,3 @@
return (this.ios) ? this.ios.size().width : NaN;
}
}
}
}

4
Image/image_types.ts Normal file
View File

@@ -0,0 +1,4 @@
export enum ImageType {
PNG = 0,
JPEG = 1,
}

View File

@@ -1,8 +1,6 @@
import types_module = require("Location/location_types");
import app_module = require("Application/application");
export module tk {
export module location {
export class LocationManager {
//public regions: LocationRegion[];
@@ -17,7 +15,7 @@ export module tk {
constructor() {
//this.regions = [];
this.desiredAccuracy = types_module.tk.location.DesiredAccuracy.ANY;
this.desiredAccuracy = types_module.DesiredAccuracy.ANY;
this._locationManager = app_module.tk.ui.Application.current.android.context.getSystemService('location');
Log('location manager: ' + this._locationManager);
@@ -38,7 +36,7 @@ export module tk {
public desiredAccuracy: number;
// listeners
public locationChangeListener: types_module.tk.location.LocationChangeListener;
public locationChangeListener: types_module.LocationChangeListener;
// public regionChangeListener: RegionChangeListener;
@@ -60,7 +58,7 @@ export module tk {
public startLocationMonitoring() {
var criteria = new android.location.Criteria();
criteria.setAccuracy((this.desiredAccuracy === types_module.tk.location.DesiredAccuracy.HIGH) ? 3 : 1);
criteria.setAccuracy((this.desiredAccuracy === types_module.DesiredAccuracy.HIGH) ? 3 : 1);
var providers = this._locationManager.getProviders(criteria, false);
var it = providers.iterator();
while (it.hasNext()) {
@@ -76,13 +74,11 @@ export module tk {
// other
public getLastKnownLocation(): types_module.tk.location.LocationPoint {
public getLastKnownLocation(): types_module.LocationPoint {
return null;
}
public distanceInMeters(loc1: types_module.tk.location.LocationPoint, loc2: types_module.tk.location.LocationPoint): number {
public distanceInMeters(loc1: types_module.LocationPoint, loc2: types_module.LocationPoint): number {
return 0;
}
}
}
}

View File

@@ -1,12 +1,10 @@
export declare module tk {
export module location {
export enum DesiredAccuracy {
export declare enum DesiredAccuracy {
// in meters
ANY,
HIGH,
}
export class LocationPoint {
export declare class LocationPoint {
public latitude: number;
public longitude: number;
@@ -22,23 +20,23 @@
public timestamp: any;
}
export class LocationRegion {
export declare class LocationRegion {
public latitude: number;
public longitude: number;
public raduis: number; // radius in meters
}
export class LocationChangeListener {
export declare class LocationChangeListener {
//onLocationChange(location: Location);
}
export class RegionChangeListener {
export declare class RegionChangeListener {
onRegionEnter(region: LocationRegion);
onRegionExit(region: LocationRegion);
}
export class LocationManager {
export declare class LocationManager {
isLocationEnabled(): boolean;
desiredAccuracy: number;
@@ -62,5 +60,3 @@
getLastKnownLocation(): LocationPoint;
distanceInMeters(loc1: LocationPoint, loc2: LocationPoint): number;
}
}
}

View File

@@ -1,7 +1,5 @@
import types = require("Location/location_types");
export module tk {
export module location {
export class LocationManager {
public isLocationEnabled(): boolean {
@@ -18,7 +16,7 @@ export module tk {
public desiredAccuracy: number;
// listeners
public locationChangeListener: types.tk.location.LocationChangeListener;
public locationChangeListener: types.LocationChangeListener;
// monitoring
@@ -32,13 +30,11 @@ export module tk {
// other
public getLastKnownLocation(): types.tk.location.LocationPoint {
public getLastKnownLocation(): types.LocationPoint {
return null;
}
public distanceInMeters(loc1: types.tk.location.LocationPoint, loc2: types.tk.location.LocationPoint): number {
public distanceInMeters(loc1: types.LocationPoint, loc2: types.LocationPoint): number {
return 0;
}
}
}
}

View File

@@ -1,6 +1,4 @@
export module tk {
export module location {
export enum DesiredAccuracy {
export enum DesiredAccuracy {
// in meters
ANY = 300,
HIGH = 3,
@@ -42,5 +40,3 @@
onRegionExit(region: LocationRegion) {
}
}
}
}

View File

@@ -1,10 +1,6 @@
import utils_module = require("Utils/utils_android");
import app_module = require("Application/application");
export module tk {
// TODO: Think better naming and namespaces - e.g. tk.storage
export module preferences {
export class UserPreferences {
private sharedPreferences: any;
@@ -99,5 +95,3 @@ export module tk {
editor.commit();
}
}
}
}

View File

@@ -1,6 +1,4 @@
export declare module tk {
export module preferences {
export class UserPreferences {
export declare class UserPreferences {
containsKey(key: string): boolean;
getBoolean(key: string, defaultValue?: boolean): boolean;
getDouble(key: string, defaultValue?: number): number;
@@ -15,5 +13,3 @@
setString(key: string, value: string);
setStrings(key: string, value: string[]);
}
}
}

View File

@@ -1,9 +1,5 @@
import utils_module = require("Utils/utils_ios");
export module tk {
// TODO: Think better naming and namespaces - e.g. tk.storage
export module preferences {
export class UserPreferences {
private userDefaults: any;
@@ -110,5 +106,3 @@ export module tk {
this.userDefaults.synchronize();
}
}
}
}

View File

@@ -1,11 +1,10 @@
import image_module = require("Image/image");
import app_module = require("Application/application");
export module tk {
export module web {
/**
/**
* Android specific WebClient implementation.
*/
import image_module = require("Image/image");
import app_module = require("Application/application");
export class Client {
/**
* Downloads string from url.
@@ -34,8 +33,7 @@ export module tk {
}
public getJSON(url: string, successCallback: (result: Object) => void, errorCallback?: (e: Error) => void) {
try
{
try {
this.getString(url, function (data) {
if (successCallback) {
successCallback(JSON.parse(data));
@@ -48,7 +46,7 @@ export module tk {
}
}
public getImage(url: string, successCallback: (result: image_module.tk.ui.Image) => void, errorCallback?: (e: Error) => void) {
public getImage(url: string, successCallback: (result: image_module.Image) => void, errorCallback?: (e: Error) => void) {
try {
if (successCallback) {
var context = app_module.tk.ui.Application.current.android.context;
@@ -59,7 +57,7 @@ export module tk {
return;
}
var image = new image_module.tk.ui.Image();
var image = new image_module.Image();
image.loadFromBitmap(result);
successCallback(image);
@@ -85,5 +83,3 @@ export module tk {
}
}
}
}
}

View File

@@ -1,17 +1,11 @@
import image_module = require("Image/image");
/**
* Web (WebClient) module.
*/
export declare module tk {
export module web {
/**
/**
* The Client interface.
*/
export class Client {
import image_module = require("Image/image");
declare class Client {
private static get(url: string, successCallback: (result: any) => void, errorCallback?: (e: Error) => void)
getString(url: string, successCallback: (result: string) => void, errorCallback?: (e: Error) => void)
getJSON(url: string, successCallback: (result: Object) => void, errorCallback?: (e: Error) => void)
getImage(url: string, successCallback: (result: image_module.tk.ui.Image) => void, errorCallback?: (e: Error) => void)
}
}
getImage(url: string, successCallback: (result: image_module.Image) => void, errorCallback?: (e: Error) => void)
}

View File

@@ -1,10 +1,9 @@
import image_module = require("Image/image");
export module tk {
export module web {
/**
/**
* iOS specific WebClient implementation.
*/
import image_module = require("Image/image");
export class Client {
/**
* Downloads string from url.
@@ -37,10 +36,10 @@ export module tk {
}
}
public getImage(url: string, successCallback: (result: image_module.tk.ui.Image) => void, errorCallback?: (e: Error) => void) {
public getImage(url: string, successCallback: (result: image_module.Image) => void, errorCallback?: (e: Error) => void) {
Client.get(url, function (data) {
if (successCallback) {
var image = new image_module.tk.ui.Image();
var image = new image_module.Image();
image.loadFromData(data);
successCallback(image);
}
@@ -71,5 +70,3 @@ export module tk {
}
}
}
}
}