FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(typings): Adding Android typings for API levels from 17 to 27 (#… · NativeScript/NativeScript@398c9b3 · GitHub

Commit 398c9b3

Browse files
authored andcommitted
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.
1 parent bcadcbe commit 398c9b3

48 files changed

Lines changed: 1183360 additions & 259921 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎tests/app/ui/button/button-tests-native.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export function getNativeText(button: buttonModule.Button): string {
88
}
99

1010
export function getNativeTextWrap(button: buttonModule.Button): boolean {
11-
return (<android.widget.Button>button.android).isSingleLine();
11+
return ((<android.widget.Button>button.android).getLineCount() === 1);
1212
}
1313

1414
export function getNativeFontSize(button: buttonModule.Button): number {

‎tests/app/ui/layouts/layout-helper.android.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ class NativeButton extends android.widget.Button {
1414
return global.__native(this);
1515
}
1616

17-
protected onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
17+
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
1818
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
1919
this.owner.widthMeasureSpec = widthMeasureSpec;
2020
this.owner.heightMeasureSpec = heightMeasureSpec;
2121
this.owner.measureCount++;
2222
}
2323

24-
protected onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
24+
public onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
2525
super.onLayout(changed, left, top, right, bottom);
2626
this.owner.arrangeCount++;
2727
}
@@ -33,14 +33,14 @@ class NativeStackLayout extends org.nativescript.widgets.StackLayout {
3333
return global.__native(this);
3434
}
3535

36-
protected onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
36+
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
3737
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
3838
this.owner.widthMeasureSpec = widthMeasureSpec;
3939
this.owner.heightMeasureSpec = heightMeasureSpec;
4040
this.owner.measureCount++;
4141
}
4242

43-
protected onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
43+
public onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
4444
super.onLayout(changed, left, top, right, bottom);
4545
this.owner.arrangeCount++;
4646
}
@@ -52,14 +52,14 @@ class NativeGridLayout extends org.nativescript.widgets.GridLayout {
5252
return global.__native(this);
5353
}
5454

55-
protected onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
55+
public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void {
5656
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
5757
this.owner.widthMeasureSpec = widthMeasureSpec;
5858
this.owner.heightMeasureSpec = heightMeasureSpec;
5959
this.owner.measureCount++;
6060
}
6161

62-
protected onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
62+
public onLayout(changed: boolean, left: number, top: number, right: number, bottom: number): void {
6363
super.onLayout(changed, left, top, right, bottom);
6464
this.owner.arrangeCount++;
6565
}

‎tns-core-modules/application-settings/application-settings.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as common from "./application-settings-common";
22
import { getNativeApplication } from "../application";
33

4-
var sharedPreferences: android.content.ISharedPreferences;
4+
var sharedPreferences: android.content.SharedPreferences;
55
function ensureSharedPreferences() {
66
if (!sharedPreferences) {
77
sharedPreferences = (<android.app.Application>getNativeApplication()).getApplicationContext().getSharedPreferences("prefs.db", 0);

‎tns-core-modules/ui/action-bar/action-bar.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function initializeMenuItemClickListener(): void {
3838
return global.__native(this);
3939
}
4040

41-
onMenuItemClick(item: android.view.IMenuItem): boolean {
41+
onMenuItemClick(item: android.view.MenuItem): boolean {
4242
let itemId = item.getItemId();
4343
return this.owner._onAndroidItemSelected(itemId);
4444
}

‎tns-core-modules/ui/core/view/view.android.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ function initializeDialogFragment() {
145145

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

148-
// do not override alignment unless fullscreen modal will be shown;
148+
// do not override alignment unless fullscreen modal will be shown;
149149
// otherwise we might break component-level layout:
150-
// https://github.com/NativeScript/NativeScript/issues/5392
150+
// https://github.com/NativeScript/NativeScript/issues/5392
151151
if (!this._fullscreen && !this._stretched) {
152152
this.owner.horizontalAlignment = "center";
153153
this.owner.verticalAlignment = "middle";
@@ -185,7 +185,7 @@ function initializeDialogFragment() {
185185
this._shownCallback();
186186
}
187187

188-
public onDismiss(dialog: android.content.IDialogInterface): void {
188+
public onDismiss(dialog: android.content.DialogInterface): void {
189189
super.onDismiss(dialog);
190190
const manager = this.getFragmentManager();
191191
if (manager) {

‎tns-core-modules/ui/editable-text-base/editable-text-base.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function initializeEditTextListeners(): void {
7171
// owner.android.setSelection(selectionStart);
7272
}
7373

74-
public afterTextChanged(editable: android.text.IEditable): void {
74+
public afterTextChanged(editable: android.text.Editable): void {
7575
const owner = this.owner;
7676
if (!owner || owner._changeFromCode) {
7777
return;

‎tns-core-modules/ui/frame/activity.android.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class NativeScriptActivity extends android.app.Activity {
1616
return global.__native(this);
1717
}
1818

19-
protected onCreate(savedInstanceState: android.os.Bundle): void {
19+
public onCreate(savedInstanceState: android.os.Bundle): void {
2020
appModule.android.init(this.getApplication());
21-
21+
2222
// Set isNativeScriptActivity in onCreate.
2323
// The JS constructor might not be called because the activity is created from Android.
2424
this.isNativeScriptActivity = true;
@@ -29,24 +29,24 @@ class NativeScriptActivity extends android.app.Activity {
2929
this._callbacks.onCreate(this, savedInstanceState, super.onCreate);
3030
}
3131

32-
protected onNewIntent(intent: android.content.Intent): void {
32+
public onNewIntent(intent: android.content.Intent): void {
3333
super.onNewIntent(intent);
3434
super.setIntent(intent);
3535
}
3636

37-
protected onSaveInstanceState(outState: android.os.Bundle): void {
37+
public onSaveInstanceState(outState: android.os.Bundle): void {
3838
this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState);
3939
}
4040

41-
protected onStart(): void {
41+
public onStart(): void {
4242
this._callbacks.onStart(this, super.onStart);
4343
}
4444

45-
protected onStop(): void {
45+
public onStop(): void {
4646
this._callbacks.onStop(this, super.onStop);
4747
}
4848

49-
protected onDestroy(): void {
49+
public onDestroy(): void {
5050
this._callbacks.onDestroy(this, super.onDestroy);
5151
}
5252

@@ -58,7 +58,7 @@ class NativeScriptActivity extends android.app.Activity {
5858
this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/);
5959
}
6060

61-
protected onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
61+
public onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void {
6262
this._callbacks.onActivityResult(this, requestCode, resultCode, data, super.onActivityResult);
6363
}
6464
}

‎tns-core-modules/ui/frame/fragment.transitions.android.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/// <reference path="transition-definitions.android.d.ts"/>
2+
13
// Definitions.
24
import { NavigationTransition, BackstackEntry } from "../frame";
35
import { AnimationType } from "./fragment.transitions";
@@ -332,7 +334,7 @@ function getTransitionListener(entry: ExpandedEntry, transition: android.transit
332334
return new TransitionListener(entry, transition);
333335
}
334336

335-
function getAnimationListener(): android.animation.Animator.IAnimatorListener {
337+
function getAnimationListener(): android.animation.Animator.AnimatorListener {
336338
if (!AnimationListener) {
337339
@Interfaces([android.animation.Animator.AnimatorListener])
338340
class AnimationListnerImpl extends java.lang.Object implements android.animation.Animator.AnimatorListener {
@@ -375,7 +377,7 @@ function getAnimationListener(): android.animation.Animator.IAnimatorListener {
375377

376378
return AnimationListener;
377379
}
378-
380+
379381
function addToWaitingQueue(entry: ExpandedEntry): void {
380382
const frameId = entry.frameId;
381383
let entries = waitingQueue.get(frameId);
@@ -387,7 +389,7 @@ function addToWaitingQueue(entry: ExpandedEntry): void {
387389
entries.add(entry);
388390
}
389391

390-
function clearAnimationListener(animator: ExpandedAnimator, listener: android.animation.Animator.IAnimatorListener): void {
392+
function clearAnimationListener(animator: ExpandedAnimator, listener: android.animation.Animator.AnimatorListener): void {
391393
if (!animator) {
392394
return;
393395
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* @private
3+
*/ /** */
4+
5+
// Definitions for Android API lvl 21 transitions
6+
declare module android {
7+
export module transition {
8+
export abstract class Transition extends java.lang.Object {
9+
addListener(transition: Transition.TransitionListener): Transition;
10+
removeListener(transition: Transition.TransitionListener): Transition;
11+
setDuration(duration: number): Transition;
12+
setInterpolator(interpolator: android.animation.TimeInterpolator): Transition;
13+
}
14+
15+
export abstract class Visibility extends android.transition.Transition {
16+
constructor();
17+
}
18+
19+
export class Slide extends Visibility {
20+
constructor(slideEdge: number);
21+
}
22+
23+
export class Fade extends Visibility {
24+
constructor(fadingMode: number);
25+
static IN: number;
26+
static OUT: number;
27+
}
28+
29+
export class Explode extends Visibility {
30+
constructor();
31+
}
32+
33+
export module Transition {
34+
export interface TransitionListener {
35+
onTransitionStart(transition: android.transition.Transition): void;
36+
onTransitionEnd(transition: android.transition.Transition): void;
37+
onTransitionResume(transition: android.transition.Transition): void;
38+
onTransitionPause(transition: android.transition.Transition): void;
39+
onTransitionCancel(transition: android.transition.Transition): void;
40+
}
41+
}
42+
}
43+
44+
export module app {
45+
export interface Fragment {
46+
getEnterTransition(): android.transition.Transition;
47+
getExitTransition(): android.transition.Transition;
48+
getReenterTransition(): android.transition.Transition;
49+
getReturnTransition(): android.transition.Transition;
50+
setEnterTransition(transition: android.transition.Transition): void;
51+
setExitTransition(transition: android.transition.Transition): void;
52+
setReenterTransition(transition: android.transition.Transition): void;
53+
setReturnTransition(transition: android.transition.Transition): void;
54+
setAllowEnterTransitionOverlap(allow: boolean): void;
55+
setAllowReturnTransitionOverlap(allow: boolean): void;
56+
}
57+
}
58+
}

‎tns-core-modules/ui/image-cache/image-cache.android.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function ensureLruBitmapCacheClass() {
1212
return global.__native(this);
1313
}
1414

15-
protected sizeOf(key: string, bitmap: android.graphics.Bitmap): number {
15+
public sizeOf(key: string, bitmap: android.graphics.Bitmap): number {
1616
// The cache size will be measured in kilobytes rather than
1717
// number of items.
1818
var result = Math.round(bitmap.getByteCount() / 1024);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL