mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
Snapshot refactorings, which mainly wraps Android extends within inner functions so that they are evaluated at runtime, when needed. Also some refactoring preventing circular requires.
This commit is contained in:
@ -981,6 +981,8 @@
|
||||
<TypeScriptCompile Include="ui\utils.ios.ts">
|
||||
<DependentUpon>utils.d.ts</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="utils\debug.d.ts" />
|
||||
<TypeScriptCompile Include="utils\debug.ts" />
|
||||
<TypeScriptCompile Include="utils\module-merge.ts" />
|
||||
<TypeScriptCompile Include="utils\utils.android.ts">
|
||||
<DependentUpon>utils.d.ts</DependentUpon>
|
||||
@ -2139,7 +2141,7 @@
|
||||
<AutoAssignPort>True</AutoAssignPort>
|
||||
<DevelopmentServerPort>0</DevelopmentServerPort>
|
||||
<DevelopmentServerVPath>/</DevelopmentServerVPath>
|
||||
<IISUrl>http://localhost:3128/</IISUrl>
|
||||
<IISUrl>http://localhost:60276/</IISUrl>
|
||||
<NTLMAuthentication>False</NTLMAuthentication>
|
||||
<UseCustomServer>False</UseCustomServer>
|
||||
<CustomServerUrl>
|
||||
|
@ -1,5 +1,4 @@
|
||||
|
||||
export var checkKey = function(key: string) : void {
|
||||
export var checkKey = function(key: string) : void {
|
||||
if ("string" !== typeof key) {
|
||||
throw new Error("key: '" + key + "' must be a string");
|
||||
}
|
||||
|
@ -1,16 +1,26 @@
|
||||
import Common = require("./application-settings-common");
|
||||
import common = require("./application-settings-common");
|
||||
import utils = require("utils/utils");
|
||||
|
||||
var sharedPreferences = utils.ad.getApplicationContext().getSharedPreferences("prefs.db", 0);
|
||||
var sharedPreferences;
|
||||
function ensureSharedPreferences() {
|
||||
if (!sharedPreferences) {
|
||||
sharedPreferences = utils.ad.getApplicationContext().getSharedPreferences("prefs.db", 0);
|
||||
}
|
||||
}
|
||||
|
||||
function verify(key: string) {
|
||||
common.checkKey(key);
|
||||
ensureSharedPreferences();
|
||||
}
|
||||
|
||||
export var hasKey = function (key: string): boolean {
|
||||
Common.checkKey(key);
|
||||
verify(key);
|
||||
return sharedPreferences.contains(key);
|
||||
}
|
||||
|
||||
// getters
|
||||
export var getBoolean = function (key: string, defaultValue?: boolean): boolean {
|
||||
Common.checkKey(key);
|
||||
verify(key);
|
||||
if (hasKey(key)) {
|
||||
return sharedPreferences.getBoolean(key, false);
|
||||
}
|
||||
@ -18,7 +28,7 @@ export var getBoolean = function (key: string, defaultValue?: boolean): boolean
|
||||
}
|
||||
|
||||
export var getString = function (key: string, defaultValue?: string): string {
|
||||
Common.checkKey(key);
|
||||
verify(key);
|
||||
if (hasKey(key)) {
|
||||
return sharedPreferences.getString(key, "");
|
||||
}
|
||||
@ -26,7 +36,7 @@ export var getString = function (key: string, defaultValue?: string): string {
|
||||
}
|
||||
|
||||
export var getNumber = function (key: string, defaultValue?: number): number {
|
||||
Common.checkKey(key);
|
||||
verify(key);
|
||||
if (hasKey(key)) {
|
||||
return sharedPreferences.getFloat(key, float(0.0));
|
||||
}
|
||||
@ -35,31 +45,31 @@ export var getNumber = function (key: string, defaultValue?: number): number {
|
||||
|
||||
// setters
|
||||
export var setBoolean = function (key: string, value: boolean): void {
|
||||
Common.checkKey(key);
|
||||
Common.ensureValidValue(value, "boolean");
|
||||
verify(key);
|
||||
common.ensureValidValue(value, "boolean");
|
||||
var editor = sharedPreferences.edit();
|
||||
editor.putBoolean(key, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
export var setString = function (key: string, value: string): void {
|
||||
Common.checkKey(key);
|
||||
Common.ensureValidValue(value, "string");
|
||||
verify(key);
|
||||
common.ensureValidValue(value, "string");
|
||||
var editor = sharedPreferences.edit();
|
||||
editor.putString(key, value);
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
export var setNumber = function (key: string, value: number): void {
|
||||
Common.checkKey(key);
|
||||
Common.ensureValidValue(value, "number");
|
||||
verify(key);
|
||||
common.ensureValidValue(value, "number");
|
||||
var editor = sharedPreferences.edit();
|
||||
editor.putFloat(key, float(value));
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
export var remove = function (key: string): void {
|
||||
Common.checkKey(key);
|
||||
verify(key);
|
||||
var editor = sharedPreferences.edit();
|
||||
editor.remove(key);
|
||||
editor.commit();
|
||||
|
@ -11,7 +11,7 @@ var typedExports: typeof definition = exports;
|
||||
// We are using the exports object for the common events since we merge the appModule with this module's exports, which is what users will receive when require("application") is called;
|
||||
// TODO: This is kind of hacky and is "pure JS in TypeScript"
|
||||
|
||||
var initEvents = function () {
|
||||
function initEvents() {
|
||||
// TODO: Verify whether the logic for triggerring application-wide events based on Activity callbacks is working properly
|
||||
var lifecycleCallbacks = new android.app.Application.ActivityLifecycleCallbacks({
|
||||
onActivityCreated: function (activity: any, bundle: any) {
|
||||
@ -152,17 +152,6 @@ var initEvents = function () {
|
||||
return lifecycleCallbacks;
|
||||
}
|
||||
|
||||
app.init({
|
||||
getActivity: function (activity: android.app.Activity) {
|
||||
var intent = activity.getIntent()
|
||||
return androidApp.getActivity(intent);
|
||||
},
|
||||
|
||||
onCreate: function () {
|
||||
androidApp.init(this);
|
||||
}
|
||||
});
|
||||
|
||||
export class AndroidApplication extends observable.Observable implements definition.AndroidApplication {
|
||||
public static activityCreatedEvent = "activityCreated";
|
||||
public static activityDestroyedEvent = "activityDestroyed";
|
||||
@ -264,9 +253,10 @@ export class AndroidApplication extends observable.Observable implements definit
|
||||
}
|
||||
|
||||
public registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) {
|
||||
ensureBroadCastReceiverClass();
|
||||
var that = this;
|
||||
var registerFunc = function (context: android.content.Context) {
|
||||
var receiver = new BroadcastReceiver(onReceiveCallback);
|
||||
var receiver = new BroadcastReceiverClass(onReceiveCallback);
|
||||
context.registerReceiver(receiver, new android.content.IntentFilter(intentFilter));
|
||||
that._registeredReceivers[intentFilter] = receiver;
|
||||
}
|
||||
@ -289,6 +279,12 @@ export class AndroidApplication extends observable.Observable implements definit
|
||||
}
|
||||
}
|
||||
|
||||
var BroadcastReceiverClass;
|
||||
function ensureBroadCastReceiverClass() {
|
||||
if (BroadcastReceiverClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class BroadcastReceiver extends android.content.BroadcastReceiver {
|
||||
private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void;
|
||||
|
||||
@ -305,6 +301,9 @@ class BroadcastReceiver extends android.content.BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
BroadcastReceiverClass = BroadcastReceiver;
|
||||
}
|
||||
|
||||
global.__onUncaughtError = function (error: definition.NativeScriptError) {
|
||||
var types: typeof typesModule = require("utils/types");
|
||||
|
||||
@ -320,10 +319,29 @@ function loadCss() {
|
||||
typedExports.cssSelectorsCache = typedExports.loadCss(typedExports.cssFile);
|
||||
}
|
||||
|
||||
var started = false;
|
||||
export function start (entry?: frame.NavigationEntry) {
|
||||
if (started) {
|
||||
throw new Error("Application is already started.");
|
||||
}
|
||||
|
||||
started = true;
|
||||
|
||||
if (entry) {
|
||||
typedExports.mainEntry = entry;
|
||||
}
|
||||
|
||||
// this should be the first call, to avoid issues when someone accesses the Application singleton prior to extending its onCreate method
|
||||
app.init({
|
||||
getActivity: function (activity: android.app.Activity) {
|
||||
var intent = activity.getIntent()
|
||||
return androidApp.getActivity(intent);
|
||||
},
|
||||
|
||||
onCreate: function () {
|
||||
androidApp.init(this);
|
||||
}
|
||||
});
|
||||
loadCss();
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import fs = require("file-system");
|
||||
import types = require("utils/types");
|
||||
import trace = require("trace");
|
||||
import platform = require("platform");
|
||||
import application = require("application");
|
||||
import * as appModule from "application";
|
||||
|
||||
var MIN_WH: string = "minWH";
|
||||
var MIN_W: string = "minW";
|
||||
@ -225,7 +225,8 @@ var resolverInstance: FileNameResolver;
|
||||
|
||||
export function resolveFileName(path: string, ext: string): string {
|
||||
if (!appEventAttached) {
|
||||
application.on(application.orientationChangedEvent, (data) => {
|
||||
var app: typeof appModule = require("application");
|
||||
app.on(app.orientationChangedEvent, (data) => {
|
||||
resolverInstance = undefined;
|
||||
});
|
||||
appEventAttached = true;
|
||||
|
@ -3,7 +3,7 @@ import utils = require("utils/utils");
|
||||
import * as typesModule from "utils/types";
|
||||
|
||||
export class FileSystemAccess {
|
||||
private _pathSeparator = java.io.File.separator.toString();
|
||||
private _pathSeparator = "/";
|
||||
|
||||
public getLastModified(path: string): Date {
|
||||
var javaFile = new java.io.File(path);
|
||||
|
@ -1,4 +1,5 @@
|
||||
import file_access_module = require("file-system/file-system-access");
|
||||
import * as utilsModule from "utils/utils";
|
||||
|
||||
// The FileSystemAccess implementation, used through all the APIs.
|
||||
var fileAccess;
|
||||
@ -442,17 +443,10 @@ export module knownFolders {
|
||||
|
||||
export var currentApp = function (): Folder {
|
||||
if (!_app) {
|
||||
const currentDir = __dirname;
|
||||
const tnsModulesIndex = currentDir.indexOf("/tns_modules");
|
||||
|
||||
// Module not hosted in ~/tns_modules when bundled. Use current dir.
|
||||
let appPath = currentDir;
|
||||
if (tnsModulesIndex !== -1) {
|
||||
// Strip part after tns_modules to obtain app root
|
||||
appPath = currentDir.substring(0, tnsModulesIndex);
|
||||
}
|
||||
var utils: typeof utilsModule = require("utils/utils");
|
||||
var filesDir = utils.ad.getApplicationContext().getFilesDir().getCanonicalPath();
|
||||
_app = new Folder();
|
||||
_app[pathProperty] = appPath;
|
||||
_app[pathProperty] = filesDir + "/app/";
|
||||
_app[isKnownProperty] = true;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,12 @@ function doFrame(currentTimeMillis: number) {
|
||||
}
|
||||
}
|
||||
|
||||
var native = new fpsNative.FPSCallback(doFrame);
|
||||
var native;
|
||||
function ensureNative() {
|
||||
if (!native) {
|
||||
native = new fpsNative.FPSCallback(doFrame);
|
||||
}
|
||||
}
|
||||
|
||||
export function reset() {
|
||||
_minFps = 1000;
|
||||
@ -38,6 +43,10 @@ export function reset() {
|
||||
}
|
||||
|
||||
export function running(): boolean {
|
||||
if (!native) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return native.running;
|
||||
}
|
||||
|
||||
@ -46,10 +55,15 @@ export function minFps(): number {
|
||||
}
|
||||
|
||||
export function start() {
|
||||
ensureNative();
|
||||
native.start();
|
||||
}
|
||||
|
||||
export function stop() {
|
||||
if (!native) {
|
||||
return;
|
||||
}
|
||||
|
||||
native.stop();
|
||||
reset();
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ global.loadModule = function(name: string): any {
|
||||
|
||||
global.registerModule("timer", () => require("timer"));
|
||||
global.registerModule("ui/dialogs", () => require("ui/dialogs"));
|
||||
global.registerModule("../xhr/xhr", () => require("../xhr/xhr"));
|
||||
global.registerModule("xhr", () => require("xhr"));
|
||||
global.registerModule("fetch", () => require("fetch"));
|
||||
|
||||
const __tnsGlobalMergedModules = new Map<string, boolean>();
|
||||
@ -61,8 +61,8 @@ registerOnGlobalContext("clearInterval", "timer");
|
||||
registerOnGlobalContext("alert", "ui/dialogs");
|
||||
registerOnGlobalContext("confirm", "ui/dialogs");
|
||||
registerOnGlobalContext("prompt", "ui/dialogs");
|
||||
registerOnGlobalContext("XMLHttpRequest", "../xhr/xhr");
|
||||
registerOnGlobalContext("FormData", "../xhr/xhr");
|
||||
registerOnGlobalContext("XMLHttpRequest", "xhr");
|
||||
registerOnGlobalContext("FormData", "xhr");
|
||||
registerOnGlobalContext("fetch", "fetch");
|
||||
|
||||
import platform = require("platform");
|
||||
|
@ -12,12 +12,19 @@ import http = require("http");
|
||||
var requestIdCounter = 0;
|
||||
var pendingRequests = {};
|
||||
|
||||
var completeCallback = new com.tns.Async.CompleteCallback({
|
||||
var completeCallback;
|
||||
function ensureCompleteCallback() {
|
||||
if (completeCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
completeCallback = new com.tns.Async.CompleteCallback({
|
||||
onComplete: function (result: any, context: any) {
|
||||
// as a context we will receive the id of the request
|
||||
onRequestComplete(context, result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onRequestComplete(requestId: number, result: com.tns.Async.Http.RequestResult) {
|
||||
var callbacks = pendingRequests[requestId];
|
||||
@ -132,6 +139,7 @@ export function request(options: http.HttpRequestOptions): Promise<http.HttpResp
|
||||
};
|
||||
pendingRequests[requestIdCounter] = callbacks;
|
||||
|
||||
ensureCompleteCallback();
|
||||
//make the actual async call
|
||||
com.tns.Async.Http.MakeRequest(javaOptions, completeCallback, new java.lang.Integer(requestIdCounter));
|
||||
|
||||
|
@ -60,7 +60,7 @@ export class LocationManager implements locationModule.LocationManager {
|
||||
}
|
||||
|
||||
private static locationFromAndroidLocation(androidLocation: android.location.Location): locationModule.Location {
|
||||
var location = new locationModule.Location();
|
||||
var location = new common.Location();
|
||||
location.latitude = androidLocation.getLatitude();
|
||||
location.longitude = androidLocation.getLongitude();
|
||||
location.altitude = androidLocation.getAltitude();
|
||||
|
@ -226,7 +226,7 @@ export class FormattedString extends observable.Observable implements definition
|
||||
public static addFormattedStringToView(view: definition.FormattedStringView, name: string, value: any): void {
|
||||
if(name === CHILD_SPAN) {
|
||||
if (!view.formattedText) {
|
||||
view.formattedText = new definition.FormattedString();
|
||||
view.formattedText = new FormattedString();
|
||||
}
|
||||
view.formattedText.spans.push(value);
|
||||
}
|
||||
|
@ -6,7 +6,13 @@ import fontModule = require("ui/styling/font");
|
||||
|
||||
global.moduleMerge(spanCommon, exports);
|
||||
|
||||
export class CustomTypefaceSpan extends android.text.style.TypefaceSpan {
|
||||
var CustomTypefaceSpanClass;
|
||||
function ensureCustomTypefaceSpanClass() {
|
||||
if (CustomTypefaceSpanClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class CustomTypefaceSpan extends android.text.style.TypefaceSpan {
|
||||
private typeface: any;
|
||||
|
||||
constructor(family: string, typeface: any) {
|
||||
@ -45,6 +51,9 @@ export class CustomTypefaceSpan extends android.text.style.TypefaceSpan {
|
||||
}
|
||||
}
|
||||
|
||||
CustomTypefaceSpanClass = CustomTypefaceSpan;
|
||||
}
|
||||
|
||||
export class Span extends spanCommon.Span {
|
||||
public updateSpanModifiers(parent: formattedString.FormattedString) {
|
||||
super.updateSpanModifiers(parent);
|
||||
@ -54,7 +63,8 @@ export class Span extends spanCommon.Span {
|
||||
0,
|
||||
(realFontAttributes & enums.FontAttributes.Italic) ? enums.FontStyle.italic : enums.FontStyle.normal,
|
||||
(realFontAttributes & enums.FontAttributes.Bold) ? enums.FontWeight.bold : enums.FontWeight.normal);
|
||||
let typefaceSpan = new CustomTypefaceSpan(realFontFamily, font.getAndroidTypeface());
|
||||
ensureCustomTypefaceSpanClass();
|
||||
let typefaceSpan = new CustomTypefaceSpanClass(realFontFamily, font.getAndroidTypeface());
|
||||
this.spanModifiers.push(typefaceSpan);
|
||||
}
|
||||
var realFontSize = this.fontSize ||
|
||||
|
@ -8,8 +8,19 @@ import enums = require("ui/enums");
|
||||
|
||||
global.moduleMerge(common, exports);
|
||||
|
||||
var floatType = java.lang.Float.class.getField("TYPE").get(null);
|
||||
var argbEvaluator = new android.animation.ArgbEvaluator();
|
||||
var floatType;
|
||||
function ensureFloatType() {
|
||||
if (!floatType) {
|
||||
floatType = java.lang.Float.class.getField("TYPE").get(null);
|
||||
}
|
||||
}
|
||||
|
||||
var argbEvaluator;
|
||||
function ensureArgbEvaluator() {
|
||||
if (!argbEvaluator) {
|
||||
argbEvaluator = new android.animation.ArgbEvaluator();
|
||||
}
|
||||
}
|
||||
|
||||
var keyPrefix = "ui.animation.";
|
||||
var propertyKeys = {};
|
||||
@ -155,6 +166,8 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
}
|
||||
}
|
||||
|
||||
ensureFloatType();
|
||||
|
||||
switch (propertyAnimation.property) {
|
||||
|
||||
case common.Properties.opacity:
|
||||
@ -167,6 +180,7 @@ export class Animation extends common.Animation implements definition.Animation
|
||||
break;
|
||||
|
||||
case common.Properties.backgroundColor:
|
||||
ensureArgbEvaluator();
|
||||
originalValue1 = nativeView.getBackground();
|
||||
nativeArray = java.lang.reflect.Array.newInstance(java.lang.Object.class, 2);
|
||||
nativeArray[0] = propertyAnimation.target.backgroundColor ? java.lang.Integer.valueOf((<color.Color>propertyAnimation.target.backgroundColor).argb) : java.lang.Integer.valueOf(-1);
|
||||
|
@ -131,7 +131,7 @@ export function prompt(arg: any): Promise<dialogs.PromptResult> {
|
||||
title: dialogsCommon.PROMPT,
|
||||
okButtonText: dialogsCommon.OK,
|
||||
cancelButtonText: dialogsCommon.CANCEL,
|
||||
inputType: dialogs.inputType.text,
|
||||
inputType: dialogsCommon.inputType.text,
|
||||
};
|
||||
|
||||
if (arguments.length === 1) {
|
||||
@ -155,7 +155,7 @@ export function prompt(arg: any): Promise<dialogs.PromptResult> {
|
||||
|
||||
var input = new android.widget.EditText(appmodule.android.currentContext);
|
||||
|
||||
if (options && options.inputType === dialogs.inputType.password) {
|
||||
if (options && options.inputType === dialogsCommon.inputType.password) {
|
||||
input.setInputType(android.text.InputType.TYPE_CLASS_TEXT | android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ export class EditableTextBase extends common.EditableTextBase {
|
||||
owner._dirtyTextAccumulator = editable.toString();
|
||||
break;
|
||||
case enums.UpdateTextTrigger.textChanged:
|
||||
owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, editable.toString());
|
||||
owner._onPropertyChangedFromNative(EditableTextBase.textProperty, editable.toString());
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid updateTextTrigger: " + owner.updateTextTrigger);
|
||||
@ -70,7 +70,7 @@ export class EditableTextBase extends common.EditableTextBase {
|
||||
|
||||
if (!hasFocus) {
|
||||
if (owner._dirtyTextAccumulator) {
|
||||
owner._onPropertyChangedFromNative(textBase.TextBase.textProperty, owner._dirtyTextAccumulator);
|
||||
owner._onPropertyChangedFromNative(EditableTextBase.textProperty, owner._dirtyTextAccumulator);
|
||||
owner._dirtyTextAccumulator = undefined;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,13 @@ var activityInitialized = false;
|
||||
|
||||
var navDepth = -1;
|
||||
|
||||
var PageFragmentBody = (<any>android.app.Fragment).extend({
|
||||
var FragmentClass;
|
||||
function ensureFragmentClass() {
|
||||
if (FragmentClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentClass = (<any>android.app.Fragment).extend({
|
||||
|
||||
onCreate: function (savedInstanceState: android.os.Bundle) {
|
||||
trace.write(`PageFragmentBody.onCreate(${savedInstanceState})`, trace.categories.NativeLifecycle);
|
||||
@ -77,6 +83,7 @@ var PageFragmentBody = (<any>android.app.Fragment).extend({
|
||||
utils.GC();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function onFragmentShown(fragment) {
|
||||
trace.write(`onFragmentShown(${fragment.toString()})`, trace.categories.NativeLifecycle);
|
||||
@ -215,7 +222,8 @@ export class Frame extends frameCommon.Frame {
|
||||
var fragmentTransaction = manager.beginTransaction();
|
||||
|
||||
var newFragmentTag = "fragment" + navDepth;
|
||||
var newFragment = new PageFragmentBody();
|
||||
ensureFragmentClass();
|
||||
var newFragment = new FragmentClass();
|
||||
|
||||
newFragment.frame = this;
|
||||
newFragment.entry = backstackEntry;
|
||||
|
@ -78,15 +78,18 @@ export class GesturesObserver extends common.GesturesObserver {
|
||||
this._detach();
|
||||
|
||||
if (type & definition.GestureTypes.tap || type & definition.GestureTypes.doubleTap || type & definition.GestureTypes.longPress) {
|
||||
this._simpleGestureDetector = new android.support.v4.view.GestureDetectorCompat(target._context, new TapAndDoubleTapGestureListener(this, this.target, type));
|
||||
ensureTapAndDoubleTapGestureListenerClass();
|
||||
this._simpleGestureDetector = new android.support.v4.view.GestureDetectorCompat(target._context, new TapAndDoubleTapGestureListenerClass(this, this.target, type));
|
||||
}
|
||||
|
||||
if (type & definition.GestureTypes.pinch) {
|
||||
this._scaleGestureDetector = new android.view.ScaleGestureDetector(target._context, new PinchGestureListener(this, this.target));
|
||||
ensurePinchGestureListenerClass();
|
||||
this._scaleGestureDetector = new android.view.ScaleGestureDetector(target._context, new PinchGestureListenerClass(this, this.target));
|
||||
}
|
||||
|
||||
if (type & definition.GestureTypes.swipe) {
|
||||
this._swipeGestureDetector = new android.support.v4.view.GestureDetectorCompat(target._context, new SwipeGestureListener(this, this.target));
|
||||
ensureSwipeGestureListenerClass();
|
||||
this._swipeGestureDetector = new android.support.v4.view.GestureDetectorCompat(target._context, new SwipeGestureListenerClass(this, this.target));
|
||||
}
|
||||
|
||||
if (type & definition.GestureTypes.pan) {
|
||||
@ -179,6 +182,12 @@ function _executeCallback(observer: GesturesObserver, args: definition.GestureEv
|
||||
}
|
||||
}
|
||||
|
||||
var TapAndDoubleTapGestureListenerClass;
|
||||
function ensureTapAndDoubleTapGestureListenerClass() {
|
||||
if (TapAndDoubleTapGestureListenerClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class TapAndDoubleTapGestureListener extends android.view.GestureDetector.SimpleOnGestureListener {
|
||||
private _observer: GesturesObserver;
|
||||
private _target: view.View;
|
||||
@ -221,6 +230,9 @@ class TapAndDoubleTapGestureListener extends android.view.GestureDetector.Simple
|
||||
}
|
||||
}
|
||||
|
||||
TapAndDoubleTapGestureListenerClass = TapAndDoubleTapGestureListener;
|
||||
}
|
||||
|
||||
class PinchGestureEventData implements definition.PinchGestureEventData {
|
||||
public type = definition.GestureTypes.pinch;
|
||||
public eventName = definition.toString(definition.GestureTypes.pinch);
|
||||
@ -243,6 +255,12 @@ class PinchGestureEventData implements definition.PinchGestureEventData {
|
||||
}
|
||||
}
|
||||
|
||||
var PinchGestureListenerClass;
|
||||
function ensurePinchGestureListenerClass() {
|
||||
if (PinchGestureListenerClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class PinchGestureListener extends android.view.ScaleGestureDetector.SimpleOnScaleGestureListener {
|
||||
private _observer: GesturesObserver;
|
||||
private _target: view.View;
|
||||
@ -302,6 +320,15 @@ class PinchGestureListener extends android.view.ScaleGestureDetector.SimpleOnSca
|
||||
}
|
||||
}
|
||||
|
||||
PinchGestureListenerClass = PinchGestureListener;
|
||||
}
|
||||
|
||||
var SwipeGestureListenerClass;
|
||||
function ensureSwipeGestureListenerClass() {
|
||||
if (SwipeGestureListenerClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SwipeGestureListener extends android.view.GestureDetector.SimpleOnGestureListener {
|
||||
private _observer: GesturesObserver;
|
||||
private _target: view.View;
|
||||
@ -374,6 +401,9 @@ class SwipeGestureListener extends android.view.GestureDetector.SimpleOnGestureL
|
||||
}
|
||||
}
|
||||
|
||||
SwipeGestureListenerClass = SwipeGestureListener;
|
||||
}
|
||||
|
||||
class CustomPanGestureDetector {
|
||||
private observer: GesturesObserver;
|
||||
private target: view.View;
|
||||
|
@ -42,7 +42,5 @@ export class HtmlView extends common.HtmlView {
|
||||
// This makes the html <a href...> vwork
|
||||
this._android.setLinksClickable(true);
|
||||
this._android.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,11 @@
|
||||
import common = require("./image-cache-common");
|
||||
|
||||
var LruBitmapCacheClass;
|
||||
function ensureLruBitmapCacheClass() {
|
||||
if (LruBitmapCacheClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class LruBitmapCache extends android.util.LruCache<string, android.graphics.Bitmap> {
|
||||
constructor(cacheSize: number) {
|
||||
super(cacheSize);
|
||||
@ -19,17 +25,21 @@ class LruBitmapCache extends android.util.LruCache<string, android.graphics.Bitm
|
||||
//}
|
||||
};
|
||||
|
||||
LruBitmapCacheClass = LruBitmapCache;
|
||||
}
|
||||
|
||||
export class Cache extends common.Cache {
|
||||
private _callback: any;
|
||||
private _cache: LruBitmapCache;
|
||||
private _cache;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
ensureLruBitmapCacheClass();
|
||||
var maxMemory = java.lang.Runtime.getRuntime().maxMemory() / 1024;
|
||||
var cacheSize = maxMemory / 8;
|
||||
//console.log("cacheSize: " + cacheSize);
|
||||
this._cache = new LruBitmapCache(cacheSize);
|
||||
this._cache = new LruBitmapCacheClass(cacheSize);
|
||||
|
||||
var that = new WeakRef(this);
|
||||
this._callback = new (<any>com).tns.Async.CompleteCallback({
|
||||
|
@ -6,7 +6,13 @@ import * as utilsModule from "utils/utils";
|
||||
|
||||
var OWNER = "_owner";
|
||||
|
||||
var NativeViewGroup = (<any>android.view.ViewGroup).extend({
|
||||
var NativeViewGroupClass;
|
||||
function ensureNativeViewGroupClass() {
|
||||
if (NativeViewGroupClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
NativeViewGroupClass = (<any>android.view.ViewGroup).extend({
|
||||
onMeasure: function (widthMeasureSpec, heightMeasureSpec) {
|
||||
var owner: view.View = this[OWNER];
|
||||
owner.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
@ -17,6 +23,7 @@ var NativeViewGroup = (<any>android.view.ViewGroup).extend({
|
||||
owner.onLayout(left, top, right, bottom);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export class Layout extends layoutBase.LayoutBase implements definition.Layout {
|
||||
private _viewGroup: android.view.ViewGroup;
|
||||
@ -30,7 +37,8 @@ export class Layout extends layoutBase.LayoutBase implements definition.Layout {
|
||||
}
|
||||
|
||||
public _createUI() {
|
||||
this._viewGroup = new NativeViewGroup(this._context);
|
||||
ensureNativeViewGroupClass();
|
||||
this._viewGroup = new NativeViewGroupClass(this._context);
|
||||
this._viewGroup[OWNER] = this;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,8 @@ export class ListView extends common.ListView {
|
||||
}
|
||||
this._android.setId(this._androidViewId);
|
||||
|
||||
this.android.setAdapter(new ListViewAdapter(this));
|
||||
ensureListViewAdapterClass();
|
||||
this.android.setAdapter(new ListViewAdapterClass(this));
|
||||
|
||||
var that = new WeakRef(this);
|
||||
|
||||
@ -102,7 +103,7 @@ export class ListView extends common.ListView {
|
||||
return;
|
||||
}
|
||||
|
||||
(<ListViewAdapter>this.android.getAdapter()).notifyDataSetChanged();
|
||||
(<android.widget.BaseAdapter>this.android.getAdapter()).notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public scrollToIndex(index: number) {
|
||||
@ -158,6 +159,12 @@ export class ListView extends common.ListView {
|
||||
}
|
||||
}
|
||||
|
||||
var ListViewAdapterClass;
|
||||
function ensureListViewAdapterClass() {
|
||||
if (ListViewAdapterClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class ListViewAdapter extends android.widget.BaseAdapter {
|
||||
private _listView: ListView;
|
||||
|
||||
@ -238,3 +245,5 @@ class ListViewAdapter extends android.widget.BaseAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
ListViewAdapterClass = ListViewAdapter;
|
||||
}
|
@ -9,7 +9,13 @@ import * as colorModule from "color";
|
||||
|
||||
global.moduleMerge(pageCommon, exports);
|
||||
|
||||
class DialogFragmentClass extends android.app.DialogFragment {
|
||||
var DialogFragmentClass;
|
||||
function ensureDialogFragmentClass() {
|
||||
if (DialogFragmentClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class DialogFragmentClassInner extends android.app.DialogFragment {
|
||||
private _owner: Page;
|
||||
private _fullscreen: boolean;
|
||||
private _dismissCallback: Function;
|
||||
@ -52,6 +58,9 @@ class DialogFragmentClass extends android.app.DialogFragment {
|
||||
|
||||
};
|
||||
|
||||
DialogFragmentClass = DialogFragmentClassInner;
|
||||
}
|
||||
|
||||
export class Page extends pageCommon.Page {
|
||||
private _isBackNavigation = false;
|
||||
|
||||
@ -114,7 +123,7 @@ export class Page extends pageCommon.Page {
|
||||
}
|
||||
|
||||
/* tslint:disable */
|
||||
private _dialogFragment: DialogFragmentClass;
|
||||
private _dialogFragment;
|
||||
/* tslint:enable */
|
||||
protected _showNativeModalView(parent: Page, context: any, closeCallback: Function, fullscreen?: boolean) {
|
||||
super._showNativeModalView(parent, context, closeCallback, fullscreen);
|
||||
@ -128,6 +137,7 @@ export class Page extends pageCommon.Page {
|
||||
this._isAddedToNativeVisualTree = true;
|
||||
this.onLoaded();
|
||||
|
||||
ensureDialogFragmentClass();
|
||||
var that = this;
|
||||
this._dialogFragment = new DialogFragmentClass(this, fullscreen, function () {
|
||||
that.closeModal();
|
||||
|
@ -31,7 +31,7 @@ export class ScrollView extends contentView.ContentView implements definition.Sc
|
||||
public addEventListener(arg: string, callback: any, thisArg?: any) {
|
||||
super.addEventListener(arg, callback, thisArg);
|
||||
|
||||
if (arg === definition.ScrollView.scrollEvent) {
|
||||
if (arg === ScrollView.scrollEvent) {
|
||||
this._scrollChangeCount++;
|
||||
this.attach();
|
||||
}
|
||||
@ -40,7 +40,7 @@ export class ScrollView extends contentView.ContentView implements definition.Sc
|
||||
public removeEventListener(arg: string, callback: any, thisArg?: any) {
|
||||
super.addEventListener(arg, callback, thisArg);
|
||||
|
||||
if (arg === definition.ScrollView.scrollEvent) {
|
||||
if (arg === ScrollView.scrollEvent) {
|
||||
this._scrollChangeCount--;
|
||||
this.dettach();
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ export class ScrollView extends common.ScrollView implements definition.ScrollVi
|
||||
if (rootScrollView && rootScrollView.android) {
|
||||
rootScrollView.notify(<definition.ScrollEventData>{
|
||||
object: rootScrollView,
|
||||
eventName: definition.ScrollView.scrollEvent,
|
||||
eventName: ScrollView.scrollEvent,
|
||||
scrollX: rootScrollView.android.getScrollX() / utils.layout.getDisplayDensity(),
|
||||
scrollY: rootScrollView.android.getScrollY() / utils.layout.getDisplayDensity()
|
||||
});
|
||||
|
@ -80,6 +80,7 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var tabIndex: number;
|
||||
|
||||
if (view.selectedBackgroundColor) {
|
||||
ensureSegmentedBarColorDrawableClass();
|
||||
for (tabIndex = 0; tabIndex < tabHost.getTabWidget().getTabCount(); tabIndex++) {
|
||||
var vg = <android.view.ViewGroup>tabHost.getTabWidget().getChildTabViewAt(tabIndex);
|
||||
|
||||
@ -87,7 +88,7 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
|
||||
var arr = java.lang.reflect.Array.newInstance(java.lang.Integer.class.getField("TYPE").get(null), 1);
|
||||
arr[0] = R_ATTR_STATE_SELECTED;
|
||||
var colorDrawable = new SegmentedBarColorDrawable(view.selectedBackgroundColor.android)
|
||||
var colorDrawable = new SegmentedBarColorDrawableClass(view.selectedBackgroundColor.android)
|
||||
stateDrawable.addState(arr, colorDrawable);
|
||||
stateDrawable.setBounds(0, 15, vg.getRight(), vg.getBottom());
|
||||
|
||||
@ -107,6 +108,12 @@ function onItemsPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
}
|
||||
(<proxy.PropertyMetadata>common.SegmentedBar.itemsProperty.metadata).onSetNativeValue = onItemsPropertyChanged;
|
||||
|
||||
var SegmentedBarColorDrawableClass;
|
||||
function ensureSegmentedBarColorDrawableClass() {
|
||||
if (SegmentedBarColorDrawableClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SegmentedBarColorDrawable extends android.graphics.drawable.ColorDrawable {
|
||||
constructor(arg: any) {
|
||||
super(arg);
|
||||
@ -121,6 +128,7 @@ class SegmentedBarColorDrawable extends android.graphics.drawable.ColorDrawable
|
||||
canvas.drawRect(0, this.getBounds().height() - 15, this.getBounds().width(), this.getBounds().height(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class SegmentedBarItem extends common.SegmentedBarItem {
|
||||
public _update() {
|
||||
@ -136,11 +144,12 @@ export class SegmentedBarItem extends common.SegmentedBarItem {
|
||||
}
|
||||
|
||||
export class SegmentedBar extends common.SegmentedBar {
|
||||
private _android: OurTabHost;
|
||||
private _android;
|
||||
public _listener: android.widget.TabHost.OnTabChangeListener;
|
||||
|
||||
public _createUI() {
|
||||
this._android = new OurTabHost(this._context, null);
|
||||
ensureTabHostClass();
|
||||
this._android = new TabHostClass(this._context, null);
|
||||
if (types.isNumber(this.selectedIndex) && this._android.getCurrentTab() !== this.selectedIndex) {
|
||||
this._android.setCurrentTab(this.selectedIndex);
|
||||
}
|
||||
@ -177,6 +186,12 @@ export class SegmentedBar extends common.SegmentedBar {
|
||||
}
|
||||
}
|
||||
|
||||
var TabHostClass;
|
||||
function ensureTabHostClass() {
|
||||
if (TabHostClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class OurTabHost extends android.widget.TabHost {
|
||||
constructor(context: any, attrs: any) {
|
||||
super(context, attrs);
|
||||
@ -189,6 +204,9 @@ class OurTabHost extends android.widget.TabHost {
|
||||
}
|
||||
}
|
||||
|
||||
TabHostClass = OurTabHost;
|
||||
}
|
||||
|
||||
export class SegmentedBarStyler implements style.Styler {
|
||||
//Text color methods
|
||||
private static setColorProperty(v: view.View, newValue: any) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import imageSource = require("image-source");
|
||||
import colorModule = require("color");
|
||||
import enums = require("ui/enums");
|
||||
import dts = require("ui/styling/background");
|
||||
import definition = require("ui/styling/background");
|
||||
import cssValue = require("css-value");
|
||||
import * as typesModule from "utils/types";
|
||||
|
||||
@ -12,7 +12,7 @@ interface CSSValue {
|
||||
value?: number;
|
||||
}
|
||||
|
||||
export class Background implements dts.Background {
|
||||
export class Background implements definition.Background {
|
||||
public static default = new Background(undefined, undefined, undefined, undefined, undefined);
|
||||
|
||||
color: colorModule.Color;
|
||||
@ -55,12 +55,12 @@ export class Background implements dts.Background {
|
||||
return new Background(this.color, this.image, this.repeat, this.position, value);
|
||||
}
|
||||
|
||||
public getDrawParams(width: number, height: number): dts.BackgroundDrawParams {
|
||||
public getDrawParams(width: number, height: number): definition.BackgroundDrawParams {
|
||||
if (!this.image) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var res: dts.BackgroundDrawParams = {
|
||||
var res: definition.BackgroundDrawParams = {
|
||||
repeatX: true,
|
||||
repeatY: true,
|
||||
posX: 0,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import utils = require("utils/utils");
|
||||
import common = require("./background-common");
|
||||
import dts = require("ui/styling/background");
|
||||
import definition = require("ui/styling/background");
|
||||
import view = require("ui/core/view");
|
||||
import types = require("utils/types");
|
||||
import * as styleModule from "./style";
|
||||
@ -12,7 +12,21 @@ global.moduleMerge(common, exports);
|
||||
|
||||
// We are using "ad" here to avoid namespace collision with the global android object
|
||||
export module ad {
|
||||
export class BorderDrawable extends android.graphics.drawable.ColorDrawable implements dts.ad.BorderDrawable {
|
||||
Object.defineProperty(ad, "BorderDrawable", {
|
||||
get: function () {
|
||||
ensureBorderDrawable();
|
||||
return BorderDrawableClass;
|
||||
},
|
||||
configurable: true
|
||||
});
|
||||
|
||||
var BorderDrawableClass;
|
||||
function ensureBorderDrawable() {
|
||||
if (BorderDrawableClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class BorderDrawable extends android.graphics.drawable.ColorDrawable implements definition.ad.BorderDrawable {
|
||||
private _density = utils.layout.getDisplayDensity();
|
||||
private _borderWidth: number;
|
||||
private _cornerRadius: number;
|
||||
@ -135,7 +149,17 @@ export module ad {
|
||||
}
|
||||
}
|
||||
|
||||
var SDK = android.os.Build.VERSION.SDK_INT;
|
||||
BorderDrawableClass = BorderDrawable;
|
||||
}
|
||||
|
||||
var SDK: number;
|
||||
function getSDK() {
|
||||
if (!SDK) {
|
||||
SDK = android.os.Build.VERSION.SDK_INT;
|
||||
}
|
||||
|
||||
return SDK;
|
||||
}
|
||||
|
||||
var _defaultBackgrounds = new Map<string, android.graphics.drawable.Drawable>();
|
||||
|
||||
@ -164,8 +188,8 @@ export module ad {
|
||||
bkg.backgroundColor = backgroundColor;
|
||||
} else if (v.borderWidth !== 0 || v.borderRadius !== 0 || !backgroundValue.isEmpty()) {
|
||||
|
||||
if (!(bkg instanceof dts.ad.BorderDrawable)) {
|
||||
bkg = new dts.ad.BorderDrawable();
|
||||
if (!(bkg instanceof BorderDrawableClass)) {
|
||||
bkg = new BorderDrawableClass();
|
||||
let viewClass = types.getClass(v);
|
||||
if (!(v instanceof btn.Button) && !_defaultBackgrounds.has(viewClass)) {
|
||||
_defaultBackgrounds.set(viewClass, nativeView.getBackground());
|
||||
@ -179,7 +203,7 @@ export module ad {
|
||||
bkg.borderColor = v.borderColor ? v.borderColor.android : android.graphics.Color.TRANSPARENT;
|
||||
bkg.background = backgroundValue;
|
||||
|
||||
if (SDK < 18) {
|
||||
if (getSDK() < 18) {
|
||||
// Switch to software because of unsupported canvas methods if hardware acceleration is on:
|
||||
// http://developer.android.com/guide/topics/graphics/hardware-accel.html
|
||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_SOFTWARE, null);
|
||||
@ -201,7 +225,7 @@ export module ad {
|
||||
}
|
||||
}
|
||||
|
||||
if (SDK < 18) {
|
||||
if (getSDK() < 18) {
|
||||
// Reset layer type to hardware
|
||||
nativeView.setLayerType(android.view.View.LAYER_TYPE_HARDWARE, null);
|
||||
}
|
||||
|
@ -29,7 +29,13 @@ export class TabViewItem extends common.TabViewItem {
|
||||
}
|
||||
}
|
||||
|
||||
class PagerAdapterClass extends android.support.v4.view.PagerAdapter {
|
||||
var PagerAdapterClass;
|
||||
function ensurePagerAdapterClass() {
|
||||
if (PagerAdapterClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class PagerAdapterClassInner extends android.support.v4.view.PagerAdapter {
|
||||
private owner: TabView;
|
||||
private items: Array<definition.TabViewItem>;
|
||||
|
||||
@ -132,6 +138,15 @@ class PagerAdapterClass extends android.support.v4.view.PagerAdapter {
|
||||
}
|
||||
};
|
||||
|
||||
PagerAdapterClass = PagerAdapterClassInner;
|
||||
}
|
||||
|
||||
var PageChangedListenerClass;
|
||||
function ensurePageChangedListenerClass() {
|
||||
if (PageChangedListenerClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class PageChangedListener extends android.support.v4.view.ViewPager.SimpleOnPageChangeListener {
|
||||
private _owner: TabView;
|
||||
constructor(owner: TabView) {
|
||||
@ -145,6 +160,9 @@ class PageChangedListener extends android.support.v4.view.ViewPager.SimpleOnPage
|
||||
}
|
||||
}
|
||||
|
||||
PageChangedListenerClass = PageChangedListener;
|
||||
}
|
||||
|
||||
function selectedColorPropertyChanged(data: dependencyObservable.PropertyChangeData) {
|
||||
var tabLayout = (<TabView>data.object)._getAndroidTabView();
|
||||
if (tabLayout && data.newValue instanceof color.Color) {
|
||||
@ -168,7 +186,7 @@ export class TabView extends common.TabView {
|
||||
private _pagerAdapter: android.support.v4.view.PagerAdapter;
|
||||
private _androidViewId: number;
|
||||
|
||||
private _pageChagedListener: PageChangedListener;
|
||||
private _pageChagedListener;
|
||||
|
||||
get android(): android.view.View {
|
||||
return this._grid;
|
||||
@ -207,7 +225,8 @@ export class TabView extends common.TabView {
|
||||
}
|
||||
this._grid.setId(this._androidViewId);
|
||||
|
||||
this._pageChagedListener = new PageChangedListener(this);
|
||||
ensurePageChangedListenerClass();
|
||||
this._pageChagedListener = new PageChangedListenerClass(this);
|
||||
(<any>this._viewPager).addOnPageChangeListener(this._pageChagedListener);
|
||||
}
|
||||
|
||||
@ -248,6 +267,7 @@ export class TabView extends common.TabView {
|
||||
tabItems.push(this.createTabItem(item));
|
||||
});
|
||||
|
||||
ensurePagerAdapterClass();
|
||||
this._pagerAdapter = new PagerAdapterClass(this, data.newValue);
|
||||
this._viewPager.setAdapter(this._pagerAdapter);
|
||||
|
||||
|
@ -4,7 +4,13 @@ import * as fileSystemModule from "file-system";
|
||||
|
||||
global.moduleMerge(common, exports);
|
||||
|
||||
export class WebViewClientClass extends android.webkit.WebViewClient {
|
||||
var WebViewClientClass;
|
||||
function ensureWebViewClientClass() {
|
||||
if (WebViewClientClass) {
|
||||
return;
|
||||
}
|
||||
|
||||
class WebViewClientClassInner extends android.webkit.WebViewClient {
|
||||
private _view: common.WebView;
|
||||
|
||||
constructor(view: common.WebView) {
|
||||
@ -67,6 +73,9 @@ export class WebViewClientClass extends android.webkit.WebViewClient {
|
||||
}
|
||||
};
|
||||
|
||||
WebViewClientClass = WebViewClientClassInner;
|
||||
}
|
||||
|
||||
export class WebView extends common.WebView {
|
||||
private _android: android.webkit.WebView;
|
||||
private _webViewClient: android.webkit.WebViewClient;
|
||||
@ -74,6 +83,7 @@ export class WebView extends common.WebView {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
ensureWebViewClientClass();
|
||||
this._webViewClient = new WebViewClientClass(this);
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,13 @@ import { knownFolders } from "file-system"
|
||||
export var debug = true;
|
||||
|
||||
// TODO: Get this from the runtimes...
|
||||
var applicationRootPath = knownFolders.currentApp().path;
|
||||
var applicationRootPath;
|
||||
function ensureAppRootPath() {
|
||||
if (!applicationRootPath) {
|
||||
applicationRootPath = knownFolders.currentApp().path;
|
||||
applicationRootPath = applicationRootPath.substr(0, applicationRootPath.length - "app/".length);
|
||||
}
|
||||
}
|
||||
|
||||
export class Source {
|
||||
private _uri: string;
|
||||
@ -15,6 +20,8 @@ export class Source {
|
||||
private static _appRoot: string;
|
||||
|
||||
constructor(uri: string, line: number, column: number) {
|
||||
ensureAppRootPath();
|
||||
|
||||
if (uri.length > applicationRootPath.length && uri.substr(0, applicationRootPath.length) === applicationRootPath) {
|
||||
this._uri = "file://" + uri.substr(applicationRootPath.length);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user