54 Commits

Author SHA1 Message Date
4f39fb728b chore: update tslint rules (#7391) 2019-06-26 15:13:48 +03:00
c5db112b8d feat(android): androidX support (#7039)
* feat: migrate support library namespaces to androidX

* feat(tns-platform-declarations): update to androidX typings

* chore(tests): migrate test apps to AndroidX

* chore(tns-platform-declarations): update tsconfig to include androidx dts files

* update package.json to androidx

* chore(androidx): migrate forgotten support library namspaces

* feat(tns-core-modules-widgets): migrate to AndroidX namespaces

* chore(utils): update androidx namspace for getPaletteColor method

* chore(apps): update tns-platform-declarations package

* Update package.json
2019-06-10 09:21:41 +03:00
46705ee332 refactor(core-modules): implement createNativeView and initNativeView for all components
refactor(core-modules): implement createNativeView and initNativeView for all components
2018-09-26 13:59:12 +03:00
cf034dd04d feat(android): migrate to support library apis (#6129)
Switch Activity / Fragment / FragmentManager implementation from native framework to support library APIs

BREAKING CHANGE:


NativeScript core framework now extends support library APIs versus native framework classes as per Google's latest guidelines:
- NativeScript activities now extend `android.support.v7.app.AppCompatActivity` (vs android.app.Activity)
- NativeScript fragments now extend `android.support.v4.app.Fragment` (vs android.app.Fragment)
- NativeScript now works internally with `android.support.v4.app.FragmentManager` (vs android.app.FragmentManager) 

The implications of these changes should be mostly transparent to the developer except for the fact that the support library Fragment / FragmentManager work with Animation APIs versus Animator APIs.

For Android API Levels lower than 28 the new Fragment API uses a different fragment enter animation by default. You can customise the transition per navigation entry or globally via the [navigation transitions API](https://docs.nativescript.org/core-concepts/navigation#navigation-transitions)
Before:
Default fragment enter animation was fade animation

After:
Default fragment enter animation for API levels lower than 28 is now a fast "push fade" animation; default fragment enter animation for API levels equal to or greater than 28 remains fade animation

Before:
AndroidFragmentCallbacks interface exposed the following `onCreateAnimator(...)` method
``` ts
export interface AndroidFragmentCallbacks {
    onCreateAnimator(fragment: any, transit: number, enter: boolean, nextAnim: number, superFunc: Function): any;
    // ...
}
```

After:
AndroidFragmentCallbacks interface now exposes the following `onCreateAnimation(...)` method instead (and `onCreateAnimator(...)` is now removed)
``` ts
export interface AndroidFragmentCallbacks {
    onCreateAnimation(fragment: any, transit: number, enter: boolean, nextAnim: number, superFunc: Function): any;
    // ...
}
```

Before:
Transition class exposed the following abstract `createAndroidAnimator(...)` method
``` ts
export class Transition {
    public createAndroidAnimator(transitionType: string): any;
    // ...
}
```

After:
Transition class now exposes the following abstract `createAndroidAnimation(...)` method instead (and `createAndroidAnimation(...) is now removed)
``` ts
export class Transition {
    public createAndroidAnimation(transitionType: string): any;
    // ...
}
```

To migrate the code of your custom transitions follow the example below:

Before:
``` ts
import * as transition from "tns-core-modules/ui/transition";

export class CustomTransition extends transition.Transition {
    constructor(duration: number, curve: any) {
        super(duration, curve);
    }

    public createAndroidAnimator(transitionType: string): android.animation.Animator {
        var scaleValues = Array.create("float", 2);
        switch (transitionType) {
            case transition.AndroidTransitionType.enter:
            case transition.AndroidTransitionType.popEnter:
                scaleValues[0] = 0;
                scaleValues[1] = 1;
                break;
            case transition.AndroidTransitionType.exit:
            case transition.AndroidTransitionType.popExit:
                scaleValues[0] = 1;
                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();
        if (duration !== undefined) {
            animatorSet.setDuration(duration);
        }
        animatorSet.setInterpolator(this.getCurve());

        return animatorSet;
    }
}
```

After:
``` ts
import * as transition from "tns-core-modules/ui/transition";

export class CustomTransition extends transition.Transition {
    constructor(duration: number, curve: any) {
        super(duration, curve);
    }

    public createAndroidAnimation(transitionType: string): android.view.animation.Animation {
        const scaleValues = [];

        switch (transitionType) {
            case transition.AndroidTransitionType.enter:
            case transition.AndroidTransitionType.popEnter:
                scaleValues[0] = 0;
                scaleValues[1] = 1;
                break;
            case transition.AndroidTransitionType.exit:
            case transition.AndroidTransitionType.popExit:
                scaleValues[0] = 1;
                scaleValues[1] = 0;
                break;
        }
            
        const animationSet = new android.view.animation.AnimationSet(false);
        const duration = this.getDuration();
        if (duration !== undefined) {
            animationSet.setDuration(duration);
        }

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

        return animationSet;
    }
}
```
2018-07-31 18:48:34 +03:00
398c9b3f33 feat(typings): Adding Android typings for API levels from 17 to 27 (#5890)
Adding android typings for API levels from 17 to 27

BREAKING CHANGES:
There is no longer added `I` prefix in the names of the interfaces. For example `android.view.IMenuItem` is now `android.view.MenuItem`. This matches the original name of the interface in the android framework.
2018-07-05 18:36:23 +03:00
ca444aa8ed fix(android-textfield): returnPress fired twice for GO/SEARCH/SEND (#5727) 2018-05-16 15:13:09 +03:00
7cd8e7ef54 fix(text): Allow -1 to be a valid binding value for text views (#5563)
* fix(android/text ios/text): allow -1 to be a valid binding value

Instead of using -1 as special value, use Symbol(-1)
so that it can't be reset accidentally

Closes issue #5559

* renamed the symbol
2018-03-21 11:37:30 +01:00
1e690a7b83 Add more typings to methods 2018-01-11 13:37:30 +02:00
18fe9392d6 Fix memory leak in edit-text.android
Fix fromObjectRecursive to doesn't override source object
2018-01-11 13:25:03 +02:00
82f081d603 fix android keyboard 2018-01-10 17:45:08 +02:00
8df8d754ab Fix Enter key not moving caret on next line in TextView for android
Fixes #5121
2017-12-20 10:31:39 +02:00
725475f860 Click next moves the focus to next focusable textfield (#5047)
* Click next moves the focus to next focusable textfield

Fixes https://github.com/NativeScript/NativeScript/issues/5033
When clicking next arrow on the virtual keyboard we were returning true which means we handled the event so the OS doesn't move the focus to the next item. This PR delete the `return true` when the action is `IME_ACTION_NEXT` so that next focusable item is automatically focued

* Fix IME_ACTION_PREVIOUS to raise returnPress event.
Added unit-test that IME_ACTION_PREVIOUS to raise returnPress event.
Refactored text-field-tests
2017-11-10 16:34:47 +02:00
b0577728be Return true if user has consumed the action (#4859)
Based on this: https://developer.android.com/reference/android/widget/TextView.OnEditorActionListener.html
And assuming that the developer will run dismissSoftInput in the owner.dismissSoftInput() only if they need to.
Returning False will close the keyboard regardless.
2017-09-25 15:46:01 +03:00
f00ec1a966 Add a 'focus' even to text input fields (#4730) 2017-08-25 11:22:47 +03:00
0f14101238 recycling now happens only if nativeView and android properties are not accessed. (#4627)
recycleNativeView filed now accepts: "always" | "never" | "auto". Always will recycle the nativeView no matter if its nativeView or android proprties are accessed. Never will disable recycling. Auto will recycle it only if nativeView and android properties are not accessed.
2017-08-01 15:04:16 +03:00
23757e5dfc Enable recycling of nativeView 2 (#4467)
* enable recycling of nativeView

* backgroundInternal is reset if setting new value leads to background.isEmpty() == true.

* android background.getDefault always return copy of the background. Now all controls that mutate the background can be reset to initial state (e.g. Button & ActionBar)
passing resources to copied background so it respect density.
fix properties initNativeView

* reset padding when backgroundInternal is reset.

* Fix text reset
Fix padding reset

* fix tsc errors

* fix ugly text rendering.

* Add unit tests for recycling native views
Fix several issues that came from the above tests
Fix maxLength property missing a converter callback
Remove old files

* Remove old files

* Revert backgroundInternal setter

* change the order of tests so that appium can work again

* Remove suggestion on every TextView & TextField init (strangely it is enabled after view is recycled....)

* Fix function to get parent layout if specified

* Button stateListAnimator restored when button is recycled
zIndex defaultValue is now undefined instead of NaN

* revert zIndex.setNative to always clear stateListAnimator because it was breaking one UI test (setting value=0 was returning the previous stateListAnimator)

* fix search-bar backgound-color recycling

* Fix alignments setters

* Fix imageView recycling
Fix button recycling
Fix edit-text recycling
resetNativeView is called only if recycleNativeView flag is true

* Fix incorrect merge

* Fix text-view & text-field textTransform

* Fix EditText text reset

* Fix runtime crash on ARM emulator API 21

* Fix text-base minHeight. maxHeight reset
Fix reset of isUserInteractionEnabled
2017-06-29 18:01:22 +03:00
eda57d2c35 #3614 Feature request: TextField maxLength property support.
- Implemented @PanayotCankov's Android 'view recycle' remark.
2017-06-01 11:57:24 +03:00
0997d537d0 Feature request #3614: TextField maxLength property support. 2017-06-01 11:57:24 +03:00
b67213120e Change onReturnPress from abstract to non abstract so that TextView doesn’t throw exception when Return is pressed (#4208)
Fix https://github.com/NativeScript/NativeScript/issues/4123
2017-05-17 09:47:05 +03:00
34aec12c3b fix https://github.com/NativeScript/NativeScript/issues/4135 (#4192) 2017-05-16 11:02:24 +03:00
9437f49aed #3889 Add a 'blur' event to text input fields (#3896) 2017-04-20 17:57:03 +03:00
4b98db0643 Property values should be lowercased to pass validation. 2017-04-13 11:22:45 +03:00
5f14fc6a23 text-decoration won’t be applied to edit-text (#3932)
* text-decoration won’t be applied to edit-text

* stop printing slow tests

* remove console line

* fix failing tests

* fix wrong checks
2017-04-04 13:50:34 +03:00
b2c6cf2d01 Merge pull request #3861 from DickSmith/master
fix(ui) updateTextTrigger="focusLost" for Android
2017-04-03 10:33:39 +03:00
e6250e718a Disable recycling of native views
createNativeView will set iOS nativeView if it is null/undefined
2017-03-28 18:08:59 +03:00
84e726e6b9 Resolving comments 2017-03-28 18:08:59 +03:00
c18a76c93a rename:
_createNativeView to createNativeView;
_initNativeView to initNativeView
_disposeNativeView to disposeNativeView
_resetNativeView to resetNativeView
2017-03-28 18:08:59 +03:00
f2898f84d5 NativeView recycled for android 2017-03-28 18:08:59 +03:00
73ead078fc Fix #3860 2017-03-23 15:42:49 -04:00
2b28730011 Split get/set native to getDefault setNative 2017-03-22 16:37:52 +02:00
a64bba62aa whiteSpace default value change to undefined (#3782)
TKUnit default message change to empty string
isSet method is now instance method of Property classes
fix detaching from parent bindingContext - were using oldParent.parent instead of parent
editable-text-base.android - onTextChanged implementation commented. Does nothing.
frame - onCreateView wrapped in try/catch and shows label with exception message if any
text-base.android - should support reset of nativeView. TransformationMethod won’t be set if TextField is secure
Change some types to their string couterparts
TextField.android won’t support multilines anymore in order to work as iOS
In android when page is removed from native backstack we won’t call tearDownUI again a second time
2017-03-14 10:26:45 +02:00
629eb6e683 Use relative imports in tns-core-modules.
Use tns-core-modules/* imports in outside code (apps, tests, etc)
2017-03-13 14:37:59 +02:00
1d49f5f3c3 fix padding on text-view & text-field (#3758)
* fix padding on text-view & text-field
text-base is now snapshotable
view.android is now snapshotable

* createNativeView returns the nativeView for android
Fix image tests
Implement test for image loaded from res://
EffectivePaddings updated when nativeView have some from its native theme
2017-03-09 16:09:53 +02:00
33aa48bdfd Add support for snapshot
Fix Layout class getMeasuredWidth & getMeasuredHeight
Move some classes to widgets
Fix API17 tests
2017-03-06 14:05:55 +02:00
86481cce4a Make typings compatible with @types/node.
Fixes name clashes and uses Node-compatible typings where possible.

Changes:
 - setTimout et al now return NodeJS.Timer instead of number
 - No "console" module anymore. Everyone uses it through global.console
 anyway.
 - We have a typed "global" instance with exposed properties now. Any
 "freeform" accesses must go through a `(<any>global).blah` cast.
 - remove tns-core-modules.{base,es6,es2015}.d.ts. Those were needed
 as workarounds for the ES6/DOM/Node type clashes.
2017-02-15 13:01:10 +02:00
309ea148e1 Fix setting text property to number. (#3449)
Fix setting JS property from native.
2017-01-09 18:13:31 +02:00
421810c293 TextView tests. 2017-01-05 16:09:13 +02:00
c30be0d606 View lifecycle methods 2017-01-04 17:18:45 +02:00
7931ecd4f8 Fix tslint errors 2016-12-21 17:42:31 +02:00
2aebdd800c Fix apps runtime crashes 2016-12-20 14:09:28 +02:00
b20fd7fd4c Fix nativeView issues
Fix Listeners base class
2016-12-15 10:46:20 +02:00
19ee47ba24 got to layouts 2016-12-13 15:51:18 +02:00
07e2102c5d restore properties deleted with merge 2016-12-13 15:51:18 +02:00
befb494a50 up to segmented-bar.ios 2016-12-13 15:51:18 +02:00
1202cb7288 almost all without layouts 2016-12-13 15:51:18 +02:00
645f428f59 alpha1 2016-12-13 15:51:18 +02:00
bb2c7aa60a partial state 2016-12-13 15:51:18 +02:00
e4c21258a3 More files migrated. 2016-12-13 15:51:18 +02:00
fee1dd9a59 Do not dismiss keyboard on android, when text-field has return key type set to 'next' (#3239) 2016-12-05 14:07:00 +02:00
6ac1417578 Fix: TextView new line closes virtual keyboard on Android
Resolves #3111
2016-11-28 15:13:19 +02:00