Skip to content
Permalink
Browse files

New BCL approach & BuildTasks

  • Loading branch information...
atanasovg committed Mar 12, 2014
0 parents commit 39b505384a3c16d3cfc9c9804fcab1ed55593263
Showing with 2,907 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +131 −0 Application/application.android.ts
  3. +50 −0 Application/application.d.ts
  4. +91 −0 Application/application.ios.ts
  5. +26 −0 Application/application_common.ts
  6. +170 −0 BCL.csproj
  7. +22 −0 BCL.sln
  8. +24 −0 Camera/camera.android.ts
  9. +22 −0 Camera/camera.d.ts
  10. +15 −0 Camera/camera.ios.ts
  11. +28 −0 Database/Readme.md
  12. +92 −0 Database/database.android.ts
  13. +16 −0 Database/database.d.ts
  14. +53 −0 Database/database.ios.ts
  15. +21 −0 Database/database_query_result.ts
  16. +138 −0 FileSystem/file_system.d.ts
  17. +364 −0 FileSystem/file_system.ts
  18. +305 −0 FileSystem/file_system_access.android.ts
  19. +28 −0 FileSystem/file_system_access.d.ts
  20. +82 −0 FileSystem/file_system_access.ios.ts
  21. +5 −0 Image/Readme.md
  22. +68 −0 Image/image.android.ts
  23. +18 −0 Image/image.d.ts
  24. +59 −0 Image/image.ios.ts
  25. +88 −0 Location/location.android.ts
  26. +66 −0 Location/location.d.ts
  27. +44 −0 Location/location.ios.ts
  28. +46 −0 Location/location_types.ts
  29. +5 −0 Readme.md
  30. +6 −0 UserPreferences/Readme.md
  31. +103 −0 UserPreferences/user_preferences.android.ts
  32. +19 −0 UserPreferences/user_preferences.d.ts
  33. +114 −0 UserPreferences/user_preferences.ios.ts
  34. +29 −0 Utils/utils_android.ts
  35. +27 −0 Utils/utils_ios.ts
  36. +25 −0 WebClient/Readme.md
  37. +48 −0 WebClient/web_client.android.ts
  38. +15 −0 WebClient/web_client.d.ts
  39. +40 −0 WebClient/web_client.ios.ts
  40. +331 −0 declarations.android.d.ts
  41. +9 −0 declarations.d.ts
  42. +61 −0 declarations.ios.d.ts
@@ -0,0 +1,3 @@
# generated files
*.map
*.js
@@ -0,0 +1,131 @@
import app_common_module = require("Application/application_common");
var currentApp = app_common_module.tk.ui.Application.current;

export module tk {
// TODO: This is tricky, we have a module named android down in the hierarchy and we need to declare it here
var callbacks = android.app.Application.ActivityLifecycleCallbacks;

export module ui {
export module android {
var initEvents = function () {
var androidApp = <Application>app_common_module.tk.ui.Application.current.android;

var lifecycleCallbacks = new callbacks({
onActivityCreated: function (activity: any, bundle: any) {
if (!androidApp.startActivity) {
androidApp.startActivity = activity;

//if (UI.Application.current.onLaunch) {
// UI.Application.current.onLaunch();
//}

if (androidApp.onActivityCreated) {
androidApp.onActivityCreated(activity, bundle);
}
}
},
onActivityDestroyed: function (activity: any) {
// Clear the current activity reference to prevent leak
if (activity === androidApp.currentActivity) {
androidApp.currentActivity = undefined;
}

//if (activity === UI.Application.android.startActivity) {
// UI.Application.android.currentActivity = undefined;
// if (UI.Application.current.onExit) {
// UI.Application.current.onExit();
// }
//}

if (androidApp.onActivityDestroyed) {
androidApp.onActivityDestroyed(activity);
}
},
onActivityPaused: function (activity: any) {
//if (UI.Application.android.currentActivity === activity) {
// if (UI.Application.current.onSuspend) {
// UI.Application.current.onSuspend();
// }
//}

if (androidApp.onActivityPaused) {
androidApp.onActivityPaused(activity);
}
},
onActivityResumed: function (activity: any) {
//if (UI.Application.android.currentActivity === activity) {
// if (UI.Application.current.onResume) {
// UI.Application.current.onResume();
// }
//}

if (androidApp.onActivityResumed) {
androidApp.onActivityResumed(activity);
}
},
onActivitySaveInstanceState: function (activity: any, bundle: any) {
if (androidApp.onSaveActivityState) {
androidApp.onSaveActivityState(activity, bundle);
}
},
onActivityStarted: function (activity: any) {
androidApp.currentActivity = activity;

//if (activity === UI.Application.android.startActivity) {
// if (UI.Application.current.onStart) {
// UI.Application.current.onStart();
// }
//}

if (androidApp.onActivityStarted) {
androidApp.onActivityStarted(activity);
}
},
onActivityStopped: function (activity: any) {
if (androidApp.onActivityStopped) {
androidApp.onActivityStopped(activity);
}
}
});

return lifecycleCallbacks;
}

export var initApp = function (nativeApp: any) {
var app = new Application(nativeApp);
currentApp.os = app_common_module.tk.TargetOS.Android;
currentApp.android = app;
app.init();
}

class Application {
public nativeApp: any;
public context: any;
public currentActivity: any;
public startActivity: any;
public packageName: string;

// TODO: Provide type information once definitions are done - e.g. activity: android.widget.activity
public onActivityCreated: (activity: any, bundle: any) => any;
public onActivityDestroyed: (activity: any) => any;
public onActivityStarted: (activity: any) => any;
public onActivityPaused: (activity: any) => any;
public onActivityResumed: (activity: any) => any;
public onActivityStopped: (activity: any) => any;
public onSaveActivityState: (activity: any, bundle: any) => any;

private _eventsToken: any;

constructor(nativeApp: any) {
this.nativeApp = nativeApp;
this.packageName = nativeApp.getPackageName();
}

public init() {
this._eventsToken = initEvents();
this.nativeApp.registerActivityLifecycleCallbacks(this._eventsToken);
}
}
}
}
}
@@ -0,0 +1,50 @@
export declare module tk {
export enum TargetOS {
iOS,
Android,
//WP
}

export module ui {
export class Application {
static current: Application;
public os: TargetOS;

public onLaunch: () => any;
public onSuspend: () => any;
public onResume: () => any;
public onExit: () => any;
public onLowMemory: () => any;

public android: android.Application;
public ios: ios.Application;
}

export module android {
export function initApp(nativeApp: any);
export class Application {
public nativeApp: any; // TODO: android.app
public context: any; // TODO: android.context
public currentActivity: any; // TODO: android.activity
public startActivity: any; // TODO: android.activity
public packageName: string;

// TODO: Provide type information once definitions are done - e.g. activity: android.widget.activity
public onActivityCreated: (activity: any, bundle: any) => any;
public onActivityDestroyed: (activity: any) => any;
public onActivityStarted: (activity: any) => any;
public onActivityPaused: (activity: any) => any;
public onActivityResumed: (activity: any) => any;
public onActivityStopped: (activity: any) => any;
public onSaveActivityState: (activity: any, bundle: any) => any;
}
}

export module ios {
export function initApp(nativeApp: any);
export class Application {
public rootController: any;
}
}
}
}
@@ -0,0 +1,91 @@
import app_common_module = require("Application/application_common");
var currentApp = app_common_module.tk.ui.Application.current;

export module tk {
export module ui {
export module ios {
// TODO: Declarations
export var initApp = function (nativeApp: any) {
var app = new Application(nativeApp);
currentApp.os = app_common_module.tk.TargetOS.iOS;
currentApp.ios = app;
app.init();
}

class Application {
public nativeApp: any;
public rootController: any;

constructor(nativeApp: any) {
this.nativeApp = nativeApp;
}

public init() {
UIKit.UIResponder.extends({/*TODO: Empty parameter here, needs API improvement*/}, {
name: "KimeraAppDelegate",
}).extends({
protocol: "UIApplicationDelegate",
implementation: {
applicationDidFinishLaunchingWithOptions: function () {
log("Application launched: applicationDidFinishLaunchingWithOptions.");

this.window = new UIKit.UIWindow(UIKit.UIScreen.mainScreen().bounds());
this.window.setBackgroundColor(UIKit.UIColor.whiteColor());

var iosApp = <Application>currentApp.ios;
this.window.setRootViewController(iosApp.rootController);

if (currentApp.onLaunch) {
currentApp.onLaunch();
} else {
log("Missing TK.UI.Application.current.onLaunch");
}

this.window.makeKeyAndVisible();

log("applicationDidFinishLaunchingWithOptions finished.");
return true;
},

applicationDidBecomeActive: function (application) {
log("applicationDidBecomeActive: " + application);
if (currentApp.onResume) {
currentApp.onResume();
}
},

applicationWillResignActive: function (application) {
log("applicationWillResignActive: " + application);
},

applicationDidEnterBackground: function (application) {
log("applicationDidEnterBackground: " + application);
if (currentApp.onSuspend) {
currentApp.onSuspend();
}
},

applicationWillEnterForeground: function (application) {
log("applicationWillEnterForeground: " + application);
},

applicationWillTerminate: function (application) {
log("applicationWillTerminate: " + application);
if (currentApp.onExit) {
currentApp.onExit();
}
},

applicationDidReceiveMemoryWarning: function (application) {
log("applicationDidReceiveMemoryWarning: " + application);
if (currentApp.onLowMemory) {
currentApp.onLowMemory();
}
}
}
});
}
}
}
}
}
@@ -0,0 +1,26 @@
export module tk {
export enum TargetOS {
iOS,
Android,
//WP
}

export module ui {
export class Application {

public os: TargetOS;

public onLaunch: () => any;
public onSuspend: () => any;
public onResume: () => any;
public onExit: () => any;
public onLowMemory: () => any;

public static current: Application = new Application();

// TODO: These fields are declared by the application.d.ts file and intellisense will come from there
public android: any;
public ios: any;
}
}
}

0 comments on commit 39b5053

Please sign in to comment.
You can’t perform that action at this time.