Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions tests/app/navigation/custom-transition.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export class CustomTransition extends transition.Transition {
super(duration, curve);
}

public createAndroidAnimator(transitionType: string): android.animation.Animator {
var scaleValues = Array.create("float", 2);
public createAndroidAnimation(transitionType: string): android.view.animation.Animation {
const scaleValues = [];

switch (transitionType) {
case transition.AndroidTransitionType.enter:
case transition.AndroidTransitionType.popEnter:
Expand All @@ -19,18 +20,22 @@ export class CustomTransition extends transition.Transition {
scaleValues[1] = 0;
break;
}
var objectAnimators = Array.create(android.animation.Animator, 2);
objectAnimators[0] = android.animation.ObjectAnimator.ofFloat(null, "scaleX", scaleValues);
objectAnimators[1] = android.animation.ObjectAnimator.ofFloat(null, "scaleY", scaleValues);
var animatorSet = new android.animation.AnimatorSet();
animatorSet.playTogether(objectAnimators);

var duration = this.getDuration();

const animationSet = new android.view.animation.AnimationSet(false);
const duration = this.getDuration();
if (duration !== undefined) {
animatorSet.setDuration(duration);
animationSet.setDuration(duration);
}
animatorSet.setInterpolator(this.getCurve());

return animatorSet;
animationSet.setInterpolator(this.getCurve());
animationSet.addAnimation(
new android.view.animation.ScaleAnimation(
scaleValues[0],
scaleValues[1],
scaleValues[0],
scaleValues[1]
));

return animationSet;
}
}
24 changes: 12 additions & 12 deletions tns-core-modules/application/application.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ export class AndroidApplication extends Observable implements AndroidApplication
public paused: boolean;
public nativeApp: android.app.Application;
public context: android.content.Context;
public foregroundActivity: android.app.Activity;
public startActivity: android.app.Activity;
public foregroundActivity: android.support.v7.app.AppCompatActivity;
public startActivity: android.support.v7.app.AppCompatActivity;
public packageName: string;
// we are using these property to store the callbacks to avoid early GC collection which would trigger MarkReachableObjects
private callbacks: any = {};
Expand Down Expand Up @@ -221,7 +221,7 @@ global.__onLiveSync = function () {
};

function initLifecycleCallbacks() {
const setThemeOnLaunch = profile("setThemeOnLaunch", (activity: android.app.Activity) => {
const setThemeOnLaunch = profile("setThemeOnLaunch", (activity: android.support.v7.app.AppCompatActivity) => {
// Set app theme after launch screen was used during startup
const activityInfo = activity.getPackageManager().getActivityInfo(activity.getComponentName(), android.content.pm.PackageManager.GET_META_DATA);
if (activityInfo.metaData) {
Expand All @@ -232,11 +232,11 @@ function initLifecycleCallbacks() {
}
});

const notifyActivityCreated = profile("notifyActivityCreated", function (activity: android.app.Activity, savedInstanceState: android.os.Bundle) {
const notifyActivityCreated = profile("notifyActivityCreated", function (activity: android.support.v7.app.AppCompatActivity, savedInstanceState: android.os.Bundle) {
androidApp.notify(<AndroidActivityBundleEventData>{ eventName: ActivityCreated, object: androidApp, activity, bundle: savedInstanceState });
});

const subscribeForGlobalLayout = profile("subscribeForGlobalLayout", function (activity: android.app.Activity) {
const subscribeForGlobalLayout = profile("subscribeForGlobalLayout", function (activity: android.support.v7.app.AppCompatActivity) {
const rootView = activity.getWindow().getDecorView().getRootView();
// store the listener not to trigger GC collection before collecting the method
this.onGlobalLayoutListener = new android.view.ViewTreeObserver.OnGlobalLayoutListener({
Expand All @@ -250,7 +250,7 @@ function initLifecycleCallbacks() {
});

const lifecycleCallbacks = new android.app.Application.ActivityLifecycleCallbacks({
onActivityCreated: profile("onActivityCreated", function (activity: android.app.Activity, savedInstanceState: android.os.Bundle) {
onActivityCreated: profile("onActivityCreated", function (activity: android.support.v7.app.AppCompatActivity, savedInstanceState: android.os.Bundle) {
setThemeOnLaunch(activity);

if (!androidApp.startActivity) {
Expand All @@ -264,7 +264,7 @@ function initLifecycleCallbacks() {
}
}),

onActivityDestroyed: profile("onActivityDestroyed", function (activity: android.app.Activity) {
onActivityDestroyed: profile("onActivityDestroyed", function (activity: android.support.v7.app.AppCompatActivity) {
if (activity === androidApp.foregroundActivity) {
androidApp.foregroundActivity = undefined;
}
Expand All @@ -278,7 +278,7 @@ function initLifecycleCallbacks() {
gc();
}),

onActivityPaused: profile("onActivityPaused", function (activity: android.app.Activity) {
onActivityPaused: profile("onActivityPaused", function (activity: android.support.v7.app.AppCompatActivity) {
if ((<any>activity).isNativeScriptActivity) {
androidApp.paused = true;
notify(<ApplicationEventData>{ eventName: suspendEvent, object: androidApp, android: activity });
Expand All @@ -287,7 +287,7 @@ function initLifecycleCallbacks() {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityPaused, object: androidApp, activity: activity });
}),

onActivityResumed: profile("onActivityResumed", function (activity: android.app.Activity) {
onActivityResumed: profile("onActivityResumed", function (activity: android.support.v7.app.AppCompatActivity) {
androidApp.foregroundActivity = activity;

if ((<any>activity).isNativeScriptActivity) {
Expand All @@ -298,15 +298,15 @@ function initLifecycleCallbacks() {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityResumed, object: androidApp, activity: activity });
}),

onActivitySaveInstanceState: profile("onActivityResumed", function (activity: android.app.Activity, outState: android.os.Bundle) {
onActivitySaveInstanceState: profile("onActivityResumed", function (activity: android.support.v7.app.AppCompatActivity, outState: android.os.Bundle) {
androidApp.notify(<AndroidActivityBundleEventData>{ eventName: SaveActivityState, object: androidApp, activity: activity, bundle: outState });
}),

onActivityStarted: profile("onActivityStarted", function (activity: android.app.Activity) {
onActivityStarted: profile("onActivityStarted", function (activity: android.support.v7.app.AppCompatActivity) {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityStarted, object: androidApp, activity: activity });
}),

onActivityStopped: profile("onActivityStopped", function (activity: android.app.Activity) {
onActivityStopped: profile("onActivityStopped", function (activity: android.support.v7.app.AppCompatActivity) {
androidApp.notify(<AndroidActivityEventData>{ eventName: ActivityStopped, object: androidApp, activity: activity });
})
});
Expand Down
6 changes: 3 additions & 3 deletions tns-core-modules/application/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export interface AndroidActivityEventData {
/**
* The activity.
*/
activity: any /* android.app.Activity */;
activity: any /* android.support.v7.app.AppCompatActivity */;

/**
* The name of the event.
Expand Down Expand Up @@ -378,7 +378,7 @@ export class AndroidApplication extends Observable {
/**
* The currently active (loaded) [android Activity](http://developer.android.com/reference/android/app/Activity.html). This property is automatically updated upon Activity events.
*/
foregroundActivity: any /* android.app.Activity */;
foregroundActivity: any /* android.support.v7.app.AppCompatActivity */;

/**
* Deprecated. Please use startActivity, foregroundActivity or context property.
Expand All @@ -388,7 +388,7 @@ export class AndroidApplication extends Observable {
/**
* The main (start) Activity for the application.
*/
startActivity: any /* android.app.Activity */;
startActivity: any /* android.support.v7.app.AppCompatActivity */;

/**
* The name of the application package.
Expand Down
14 changes: 7 additions & 7 deletions tns-core-modules/ui/core/view/view.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface TouchListener {
}

interface DialogFragment {
new(): android.app.DialogFragment;
new(): android.support.v4.app.DialogFragment;
}

function initializeDisabledListener(): void {
Expand Down Expand Up @@ -120,7 +120,7 @@ function initializeDialogFragment() {
}
}

class DialogFragmentImpl extends android.app.DialogFragment {
class DialogFragmentImpl extends android.support.v4.app.DialogFragment {
public owner: View;
private _fullscreen: boolean;
private _stretched: boolean;
Expand All @@ -141,7 +141,7 @@ function initializeDialogFragment() {
this._dismissCallback = options.dismissCallback;
this._shownCallback = options.shownCallback;
this.owner._dialogFragment = this;
this.setStyle(android.app.DialogFragment.STYLE_NO_TITLE, 0);
this.setStyle(android.support.v4.app.DialogFragment.STYLE_NO_TITLE, 0);

const dialog = new DialogImpl(this, this.getActivity(), this.getTheme());

Expand Down Expand Up @@ -225,13 +225,13 @@ function getModalOptions(domId: number): DialogOptions {
export class View extends ViewCommon {
public static androidBackPressedEvent = androidBackPressedEvent;

public _dialogFragment: android.app.DialogFragment;
public _dialogFragment: android.support.v4.app.DialogFragment;
private _isClickable: boolean;
private touchListenerIsSet: boolean;
private touchListener: android.view.View.OnTouchListener;
private layoutChangeListenerIsSet: boolean;
private layoutChangeListener: android.view.View.OnLayoutChangeListener;
private _manager: android.app.FragmentManager;
private _manager: android.support.v4.app.FragmentManager;

nativeViewProtected: android.view.View;

Expand Down Expand Up @@ -263,7 +263,7 @@ export class View extends ViewCommon {
}
}

public _getFragmentManager(): android.app.FragmentManager {
public _getFragmentManager(): android.support.v4.app.FragmentManager {
let manager = this._manager;
if (!manager) {
let view: View = this;
Expand All @@ -280,7 +280,7 @@ export class View extends ViewCommon {
}

if (!manager && this._context) {
manager = (<android.app.Activity>this._context).getFragmentManager();
manager = (<android.support.v7.app.AppCompatActivity>this._context).getSupportFragmentManager();
}

this._manager = manager;
Expand Down
2 changes: 1 addition & 1 deletion tns-core-modules/ui/core/view/view.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ export abstract class View extends ViewBase {
/**
* @private
*/
_getFragmentManager(): any; /* android.app.FragmentManager */
_getFragmentManager(): any; /* android.support.v4.app.FragmentManager */

/**
* Updates styleScope or create new styleScope.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function dismissSoftInput(owner: EditableTextBase): void {
if (!dismissKeyboardTimeoutId) {
dismissKeyboardTimeoutId = setTimeout(() => {
const owner = dismissKeyboardOwner && dismissKeyboardOwner.get();
const activity = (owner && owner._context) as android.app.Activity;
const activity = (owner && owner._context) as android.support.v7.app.AppCompatActivity;
const nativeView = owner && owner.nativeViewProtected;
dismissKeyboardTimeoutId = null;
dismissKeyboardOwner = null;
Expand Down
4 changes: 2 additions & 2 deletions tns-core-modules/ui/frame/activity.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if ((<any>global).__snapshot || (<any>global).__snapshotEnabled) {

//@ts-ignore
@JavaProxy("com.tns.NativeScriptActivity")
class NativeScriptActivity extends android.app.Activity {
class NativeScriptActivity extends android.support.v7.app.AppCompatActivity {
private _callbacks: AndroidActivityCallbacks;
public isNativeScriptActivity;
constructor() {
Expand Down Expand Up @@ -54,7 +54,7 @@ class NativeScriptActivity extends android.app.Activity {
this._callbacks.onBackPressed(this, super.onBackPressed);
}

public onRequestPermissionsResult(requestCode: number, permissions: Array<String>, grantResults: Array<number>): void {
public onRequestPermissionsResult(requestCode: number, permissions: Array<string>, grantResults: Array<number>): void {
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
}

Expand Down
7 changes: 3 additions & 4 deletions tns-core-modules/ui/frame/fragment.android.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AndroidFragmentCallbacks, setFragmentCallbacks, setFragmentClass } from "./frame";

@JavaProxy("com.tns.FragmentClass")
class FragmentClass extends android.app.Fragment {
class FragmentClass extends android.support.v4.app.Fragment {
// This field is updated in the frame module upon `new` (although hacky this eases the Fragment->callbacks association a lot)
private _callbacks: AndroidFragmentCallbacks;

Expand All @@ -14,9 +14,8 @@ class FragmentClass extends android.app.Fragment {
this._callbacks.onHiddenChanged(this, hidden, super.onHiddenChanged);
}

public onCreateAnimator(transit: number, enter: boolean, nextAnim: number): android.animation.Animator {
let result = this._callbacks.onCreateAnimator(this, transit, enter, nextAnim, super.onCreateAnimator);
return result;
public onCreateAnimation(transit: number, enter: boolean, nextAnim: number): android.view.animation.Animation {
return this._callbacks.onCreateAnimation(this, transit, enter, nextAnim, super.onCreateAnimation);
}

public onStop(): void {
Expand Down
Loading