Skip to content

Commit 2a839f7

Browse files
committed
chore: missing impl
1 parent 56dbaba commit 2a839f7

2 files changed

Lines changed: 320 additions & 0 deletions

File tree

packages/widgets/index.android.ts

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,81 @@ export class RemoteViews {
6262
return this._remoteViews;
6363
}
6464

65+
setOnClickPendingIntent(intent: android.app.PendingIntent) {
66+
this.native.setOnClickPendingIntent(intent);
67+
return this;
68+
}
69+
70+
setBackgroundColor(value: number) {
71+
this.native.setBackgroundColor(value);
72+
return this;
73+
}
74+
75+
setBoolean(method: string, value: boolean) {
76+
this.native.setBoolean(method, value);
77+
return this;
78+
}
79+
80+
setByte(method: string, value: number) {
81+
this.native.setByte(method, value);
82+
return this;
83+
}
84+
85+
setShort(method: string, value: number) {
86+
this.native.setShort(method, value);
87+
return this;
88+
}
89+
90+
setInt(method: string, value: number) {
91+
this.native.setInt(method, value);
92+
return this;
93+
}
94+
95+
setLong(method: string, value: number) {
96+
this.native.setLong(method, value);
97+
return this;
98+
}
99+
100+
setFloat(method: string, value: number) {
101+
this.native.setFloat(method, value);
102+
return this;
103+
}
104+
105+
setString(method: string, value: string) {
106+
this.native.setString(method, value);
107+
return this;
108+
}
109+
110+
setSize(width: number, widthUnit: number, height: number, heightUnit: number) {
111+
this.native.setSize(width, widthUnit, height, heightUnit);
112+
return this;
113+
}
114+
115+
setWidth(value: number, unit: number) {
116+
this.native.setWidth(value, unit);
117+
return this;
118+
}
119+
120+
setHeight(value: number, unit: number) {
121+
this.native.setHeight(value, unit);
122+
return this;
123+
}
124+
125+
setVisibility(visibility: number) {
126+
this.native.setVisibility(visibility);
127+
return this;
128+
}
129+
130+
findViewById(id: string) {
131+
const view = this.native.findViewById(id);
132+
return view ? new RemoteViews(view) : null;
133+
}
134+
135+
resolveRemoteResources() {
136+
this.native.resolveRemoteResources();
137+
return this;
138+
}
139+
65140
toAndroidRemoteViews(packageName?: string): AndroidRemoteViews {
66141
return new AndroidRemoteViews(this._remoteViews.build(packageName ?? Utils.android.getApplicationContext().getPackageName()));
67142
}
@@ -71,18 +146,40 @@ export class AdapterViewFlipper extends RemoteViews {
71146
constructor(id?: string) {
72147
super(new org.nativescript.widgets.RemoteViews.AdapterViewFlipper(id ?? null));
73148
}
149+
150+
get native() {
151+
return this._remoteViews as org.nativescript.widgets.RemoteViews.AdapterViewFlipper;
152+
}
74153
}
75154

76155
export class Button extends RemoteViews {
77156
constructor(id?: string) {
78157
super(new org.nativescript.widgets.RemoteViews.Button(id ?? null));
79158
}
159+
160+
get native() {
161+
return this._remoteViews as org.nativescript.widgets.RemoteViews.Button;
162+
}
163+
164+
setText(value: string) {
165+
this.native.setText(value);
166+
return this;
167+
}
168+
169+
setTextColor(value: number) {
170+
this.native.setTextColor(value);
171+
return this;
172+
}
80173
}
81174

82175
export class Chronometer extends RemoteViews {
83176
constructor(id?: string) {
84177
super(new org.nativescript.widgets.RemoteViews.Chronometer(id ?? null));
85178
}
179+
180+
get native() {
181+
return this._remoteViews as org.nativescript.widgets.RemoteViews.Chronometer;
182+
}
86183
}
87184

88185
export class FrameLayout extends RemoteViews {
@@ -143,12 +240,60 @@ export class ImageButton extends RemoteViews {
143240
constructor(id?: string) {
144241
super(new org.nativescript.widgets.RemoteViews.ImageButton(id ?? null));
145242
}
243+
244+
get native() {
245+
return this._remoteViews as org.nativescript.widgets.RemoteViews.ImageButton;
246+
}
247+
248+
setImageUrl(url: string) {
249+
this.native.setImageUrl(url);
250+
return this;
251+
}
252+
253+
setImageResource(value: number) {
254+
this.native.setImageResource(value);
255+
return this;
256+
}
257+
258+
setImageURI(value: android.net.Uri) {
259+
this.native.setImageURI(value);
260+
return this;
261+
}
262+
263+
setImageBitmap(value: android.graphics.Bitmap) {
264+
this.native.setImageBitmap(value);
265+
return this;
266+
}
146267
}
147268

148269
export class ImageView extends RemoteViews {
149270
constructor(id?: string) {
150271
super(new org.nativescript.widgets.RemoteViews.ImageView(id ?? null));
151272
}
273+
274+
get native() {
275+
return this._remoteViews as org.nativescript.widgets.RemoteViews.ImageView;
276+
}
277+
278+
setImageUrl(url: string) {
279+
this.native.setImageUrl(url);
280+
return this;
281+
}
282+
283+
setImageResource(value: number) {
284+
this.native.setImageResource(value);
285+
return this;
286+
}
287+
288+
setImageURI(value: android.net.Uri) {
289+
this.native.setImageURI(value);
290+
return this;
291+
}
292+
293+
setImageBitmap(value: android.graphics.Bitmap) {
294+
this.native.setImageBitmap(value);
295+
return this;
296+
}
152297
}
153298

154299
export class LinearLayout extends RemoteViews {
@@ -173,12 +318,20 @@ export class ListView extends RemoteViews {
173318
constructor(id?: string) {
174319
super(new org.nativescript.widgets.RemoteViews.ListView(id ?? null));
175320
}
321+
322+
get native() {
323+
return this._remoteViews as org.nativescript.widgets.RemoteViews.ListView;
324+
}
176325
}
177326

178327
export class ProgressBar extends RemoteViews {
179328
constructor(id?: string) {
180329
super(new org.nativescript.widgets.RemoteViews.ProgressBar(id ?? null));
181330
}
331+
332+
get native() {
333+
return this._remoteViews as org.nativescript.widgets.RemoteViews.ProgressBar;
334+
}
182335
}
183336

184337
export class RelativeLayout extends RemoteViews {
@@ -221,12 +374,40 @@ export class TextView extends RemoteViews {
221374
constructor(id?: string) {
222375
super(new org.nativescript.widgets.RemoteViews.TextView(id ?? null));
223376
}
377+
378+
get native() {
379+
return this._remoteViews as org.nativescript.widgets.RemoteViews.TextView;
380+
}
381+
382+
setText(value: string) {
383+
this.native.setText(value);
384+
return this;
385+
}
386+
387+
setTextColor(value: number) {
388+
this.native.setTextColor(value);
389+
return this;
390+
}
224391
}
225392

226393
export class TextClock extends RemoteViews {
227394
constructor(id?: string) {
228395
super(new org.nativescript.widgets.RemoteViews.TextClock(id ?? null));
229396
}
397+
398+
get native() {
399+
return this._remoteViews as org.nativescript.widgets.RemoteViews.TextClock;
400+
}
401+
402+
setText(value: string) {
403+
this.native.setText(value);
404+
return this;
405+
}
406+
407+
setTextColor(value: number) {
408+
this.native.setTextColor(value);
409+
return this;
410+
}
230411
}
231412

232413
export function registerWidgetListener(provider: string, listener: IWidgetListener) {

packages/widgets/index.d.ts

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
export declare class AndroidRemoteViews {
2+
private _remoteViews;
3+
constructor(remoteViews: android.widget.RemoteViews);
4+
get native(): android.widget.RemoteViews;
5+
}
6+
7+
export declare class RemoteViews {
8+
protected _remoteViews: org.nativescript.widgets.RemoteViews;
9+
constructor(remoteViews: org.nativescript.widgets.RemoteViews);
10+
get native(): org.nativescript.widgets.RemoteViews;
11+
setOnClickPendingIntent(intent: android.app.PendingIntent): this;
12+
setBackgroundColor(value: number): this;
13+
setBoolean(method: string, value: boolean): this;
14+
setByte(method: string, value: number): this;
15+
setShort(method: string, value: number): this;
16+
setInt(method: string, value: number): this;
17+
setLong(method: string, value: number): this;
18+
setFloat(method: string, value: number): this;
19+
setString(method: string, value: string): this;
20+
setSize(width: number, widthUnit: number, height: number, heightUnit: number): this;
21+
setWidth(value: number, unit: number): this;
22+
setHeight(value: number, unit: number): this;
23+
setVisibility(visibility: number): this;
24+
findViewById(id: string): RemoteViews | null;
25+
resolveRemoteResources(): this;
26+
toAndroidRemoteViews(packageName?: string): AndroidRemoteViews;
27+
}
28+
29+
export declare class AdapterViewFlipper extends RemoteViews {
30+
constructor(id?: string);
31+
get native(): org.nativescript.widgets.RemoteViews.AdapterViewFlipper;
32+
}
33+
34+
export declare class Button extends RemoteViews {
35+
constructor(id?: string);
36+
get native(): org.nativescript.widgets.RemoteViews.Button;
37+
setText(value: string): this;
38+
setTextColor(value: number): this;
39+
}
40+
41+
export declare class Chronometer extends RemoteViews {
42+
constructor(id?: string);
43+
get native(): org.nativescript.widgets.RemoteViews.Chronometer;
44+
}
45+
46+
export declare class FrameLayout extends RemoteViews {
47+
constructor(id?: string);
48+
get native(): org.nativescript.widgets.RemoteViews.FrameLayout;
49+
addView(view: RemoteViews): void;
50+
removeView(view: RemoteViews): void;
51+
}
52+
53+
export declare class GridLayout extends RemoteViews {
54+
constructor(id?: string);
55+
get native(): org.nativescript.widgets.RemoteViews.GridLayout;
56+
addView(view: RemoteViews): void;
57+
removeView(view: RemoteViews): void;
58+
}
59+
60+
export declare class GridView extends RemoteViews {
61+
constructor(id?: string);
62+
get native(): org.nativescript.widgets.RemoteViews.GridView;
63+
addView(view: RemoteViews): void;
64+
removeView(view: RemoteViews): void;
65+
}
66+
67+
export declare class ImageButton extends RemoteViews {
68+
constructor(id?: string);
69+
get native(): org.nativescript.widgets.RemoteViews.ImageButton;
70+
setImageUrl(url: string): this;
71+
setImageResource(value: number): this;
72+
setImageURI(value: android.net.Uri): this;
73+
setImageBitmap(value: android.graphics.Bitmap): this;
74+
}
75+
76+
export declare class ImageView extends RemoteViews {
77+
constructor(id?: string);
78+
get native(): org.nativescript.widgets.RemoteViews.ImageView;
79+
setImageUrl(url: string): this;
80+
setImageResource(value: number): this;
81+
setImageURI(value: android.net.Uri): this;
82+
setImageBitmap(value: android.graphics.Bitmap): this;
83+
}
84+
85+
export declare class LinearLayout extends RemoteViews {
86+
constructor(id?: string);
87+
get native(): org.nativescript.widgets.RemoteViews.LinearLayout;
88+
addView(view: RemoteViews): void;
89+
removeView(view: RemoteViews): void;
90+
}
91+
92+
export declare class ListView extends RemoteViews {
93+
constructor(id?: string);
94+
get native(): org.nativescript.widgets.RemoteViews.ListView;
95+
}
96+
97+
export declare class ProgressBar extends RemoteViews {
98+
constructor(id?: string);
99+
get native(): org.nativescript.widgets.RemoteViews.ProgressBar;
100+
}
101+
102+
export declare class RelativeLayout extends RemoteViews {
103+
constructor(id?: string);
104+
get native(): org.nativescript.widgets.RemoteViews.RelativeLayout;
105+
addView(view: RemoteViews): void;
106+
removeView(view: RemoteViews): void;
107+
}
108+
109+
export declare class StackView extends RemoteViews {
110+
constructor(id?: string);
111+
get native(): org.nativescript.widgets.RemoteViews.StackView;
112+
addView(view: RemoteViews): void;
113+
removeView(view: RemoteViews): void;
114+
}
115+
116+
export declare class TextView extends RemoteViews {
117+
constructor(id?: string);
118+
get native(): org.nativescript.widgets.RemoteViews.TextView;
119+
setText(value: string): this;
120+
setTextColor(value: number): this;
121+
}
122+
123+
export declare class TextClock extends RemoteViews {
124+
constructor(id?: string);
125+
get native(): org.nativescript.widgets.RemoteViews.TextClock;
126+
setText(value: string): this;
127+
setTextColor(value: number): this;
128+
}
129+
130+
interface IWidgetListener {
131+
onEnabled?: (provider: string) => void;
132+
onUpdate?: (event: { provider: string; appWidgetIds: number[]; manager: { native: org.nativescript.widgets.AppWidgetManager }; widgetManager: { native: android.appwidget.AppWidgetManager } }) => void;
133+
onUpdateAsync?: (event: { provider: string; appWidgetIds: number[]; manager: { native: org.nativescript.widgets.AppWidgetManager }; widgetManager: { native: android.appwidget.AppWidgetManager } }) => void;
134+
onDeleted?: (event: { provider: string; appWidgetIds: number[] }) => void;
135+
onDisabled?: (provider: string) => void;
136+
}
137+
138+
export declare function registerWidgetListener(provider: string, listener: IWidgetListener): void;
139+
export declare function unregisterWidgetListener(provider: string): void;

0 commit comments

Comments
 (0)