1/*
2 * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file Some notification types and content
18 * @kit NotificationKit
19 */
20
21import notification from '../@ohos.notification';
22import image from '../@ohos.multimedia.image';
23import { Resource } from '../global/resource';
24import type notificationManager from '../@ohos.notificationManager';
25
26/**
27 * Describes a normal text notification.
28 *
29 * @typedef NotificationBasicContent
30 * @syscap SystemCapability.Notification.Notification
31 * @since 7
32 */
33/**
34 * Describes a normal text notification.
35 *
36 * @typedef NotificationBasicContent
37 * @syscap SystemCapability.Notification.Notification
38 * @crossplatform
39 * @since 12
40 */
41export interface NotificationBasicContent {
42  /**
43   * Title of the normal text notification.
44   *
45   * @type { string }
46   * @syscap SystemCapability.Notification.Notification
47   * @since 7
48   */
49  /**
50   * Title of the normal text notification.
51   *
52   * @type { string }
53   * @syscap SystemCapability.Notification.Notification
54   * @crossplatform
55   * @since 12
56   */
57  title: string;
58
59  /**
60   * Content of the normal text notification.
61   *
62   * @type { string }
63   * @syscap SystemCapability.Notification.Notification
64   * @since 7
65   */
66  /**
67   * Content of the normal text notification.
68   *
69   * @type { string }
70   * @syscap SystemCapability.Notification.Notification
71   * @crossplatform
72   * @since 12
73   */
74  text: string;
75
76  /**
77   * Additional information of the normal text notification.
78   *
79   * @type { ?string }
80   * @syscap SystemCapability.Notification.Notification
81   * @since 7
82   */
83  additionalText?: string;
84
85  /**
86   * Data image of the lock screen.
87   *
88   * @type { ?image.PixelMap }
89   * @syscap SystemCapability.Notification.Notification
90   * @since 12
91   */
92  lockscreenPicture?: image.PixelMap;
93}
94
95/**
96 * Describes a long text notification.
97 *
98 * @typedef NotificationLongTextContent
99 * @syscap SystemCapability.Notification.Notification
100 * @since 7
101 */
102/**
103 * Describes a long text notification.
104 *
105 * @typedef NotificationLongTextContent
106 * @syscap SystemCapability.Notification.Notification
107 * @crossplatform
108 * @since 12
109 */
110export interface NotificationLongTextContent extends NotificationBasicContent {
111  /**
112   * Long text content of the notification.
113   *
114   * @type { string }
115   * @syscap SystemCapability.Notification.Notification
116   * @since 7
117   */
118  /**
119   * Long text content of the notification.
120   *
121   * @type { string }
122   * @syscap SystemCapability.Notification.Notification
123   * @crossplatform
124   * @since 12
125   */
126  longText: string;
127
128  /**
129   * Brief text of the long text notification.
130   *
131   * @type { string }
132   * @syscap SystemCapability.Notification.Notification
133   * @since 7
134   */
135  /**
136   * Brief text of the long text notification.
137   *
138   * @type { string }
139   * @syscap SystemCapability.Notification.Notification
140   * @crossplatform
141   * @since 12
142   */
143  briefText: string;
144
145  /**
146   * Title that will be displayed for the long text notification when it is expanded.
147   *
148   * @type { string }
149   * @syscap SystemCapability.Notification.Notification
150   * @since 7
151   */
152  /**
153   * Title that will be displayed for the long text notification when it is expanded.
154   *
155   * @type { string }
156   * @syscap SystemCapability.Notification.Notification
157   * @crossplatform
158   * @since 12
159   */
160  expandedTitle: string;
161}
162
163/**
164   * Enum for live view notification option type.
165   *
166   * @enum { number }
167   * @syscap SystemCapability.Security.AccessToken
168   * @systemapi
169   * @since 11
170   */
171export enum LiveViewStatus {
172  /**
173   * Create the live view notification.
174   *
175   * @syscap SystemCapability.Security.AccessToken
176   * @systemapi
177   * @since 11
178   */
179  LIVE_VIEW_CREATE = 0,
180  /**
181   * Batch update the live view notification.
182   *
183   * @syscap SystemCapability.Security.AccessToken
184   * @systemapi
185   * @since 11
186   */
187  LIVE_VIEW_INCREMENTAL_UPDATE = 1,
188  /**
189   * Complete the live view notification.
190   *
191   * @syscap SystemCapability.Security.AccessToken
192   * @systemapi
193   * @since 11
194   */
195  LIVE_VIEW_END = 2,
196  /**
197   * Full update the live view notification.
198   *
199   * @syscap SystemCapability.Security.AccessToken
200   * @systemapi
201   * @since 11
202   */
203  LIVE_VIEW_FULL_UPDATE = 3
204}
205
206/**
207 * Describes a live view notification.
208 *
209 * @typedef NotificationLiveViewContent
210 * @syscap SystemCapability.Notification.Notification
211 * @systemapi
212 * @since 11
213 */
214export interface NotificationLiveViewContent extends NotificationBasicContent {
215  /**
216   * Status of the live view (0: create, 1: batch update, 2: end, 3: full update).
217   *
218   * @type { LiveViewStatus }
219   * @syscap SystemCapability.Notification.Notification
220   * @systemapi
221   * @since 11
222   */
223  status: LiveViewStatus;
224
225  /**
226   * Version of the live view with the same id. (If the version number stored in the database is 0xffffffff,
227   * the version number is not verified at the current operation of update or end. Otherwise, the
228   * version number must be greater than the version number stored in the database.)
229   *
230   * @type { ?number }
231   * @syscap SystemCapability.Notification.Notification
232   * @systemapi
233   * @since 11
234   */
235  version?: number;
236
237  /**
238   * Additional information of the live view notification.
239   *
240   * @type { ?Record<string, Object>}
241   * @syscap SystemCapability.Notification.Notification
242   * @systemapi
243   * @since 11
244   */
245  extraInfo?: Record<string, Object>;
246
247  /**
248   * The picture information list of the live view notification.
249   *
250   * @type { ?Record<string, Array<image.PixelMap>> }
251   * @syscap SystemCapability.Notification.Notification
252   * @systemapi
253   * @since 11
254   */
255  pictureInfo?: Record<string, Array<image.PixelMap>>;
256
257  /**
258   * Whether to update locally.
259   *
260   * @type { ?boolean }
261   * @syscap SystemCapability.Notification.Notification
262   * @systemapi
263   * @since 12
264   */
265  isLocalUpdateOnly?: boolean;
266}
267
268/**
269 * Describes a multi-line text notification.
270 *
271 * @typedef NotificationMultiLineContent
272 * @syscap SystemCapability.Notification.Notification
273 * @since 7
274 */
275/**
276 * Describes a multi-line text notification.
277 *
278 * @typedef NotificationMultiLineContent
279 * @syscap SystemCapability.Notification.Notification
280 * @crossplatform
281 * @since 12
282 */
283export interface NotificationMultiLineContent extends NotificationBasicContent {
284  /**
285   * Brief text of the multi-line text notification.
286   *
287   * @type { string }
288   * @syscap SystemCapability.Notification.Notification
289   * @since 7
290   */
291  /**
292   * Brief text of the multi-line text notification.
293   *
294   * @type { string }
295   * @syscap SystemCapability.Notification.Notification
296   * @crossplatform
297   * @since 12
298   */
299  briefText: string;
300
301  /**
302   * Long title of the multi-line text notification.
303   *
304   * @type { string }
305   * @syscap SystemCapability.Notification.Notification
306   * @since 7
307   */
308  /**
309   * Long title of the multi-line text notification.
310   *
311   * @type { string }
312   * @syscap SystemCapability.Notification.Notification
313   * @crossplatform
314   * @since 12
315   */
316  longTitle: string;
317
318  /**
319   * Multi-line content of the multi-line text notification.
320   *
321   * @type { Array<string> }
322   * @syscap SystemCapability.Notification.Notification
323   * @since 7
324   */
325  /**
326   * Multi-line content of the multi-line text notification.
327   *
328   * @type { Array<string> }
329   * @syscap SystemCapability.Notification.Notification
330   * @crossplatform
331   * @since 12
332   */
333  lines: Array<string>;
334}
335
336/**
337 * Describes a picture-attached notification.
338 *
339 * @typedef NotificationPictureContent
340 * @syscap SystemCapability.Notification.Notification
341 * @since 7
342 */
343export interface NotificationPictureContent extends NotificationBasicContent {
344  /**
345   * Brief text of the multi-line text notification.
346   *
347   * @type { string }
348   * @syscap SystemCapability.Notification.Notification
349   * @since 7
350   */
351  briefText: string;
352
353  /**
354   * Title that will be displayed for the picture-attached notification when it is expanded.
355   *
356   * @type { string }
357   * @syscap SystemCapability.Notification.Notification
358   * @since 7
359   */
360  expandedTitle: string;
361
362  /**
363   * Picture to be included in a notification.
364   *
365   * @type { image.PixelMap }
366   * @syscap SystemCapability.Notification.Notification
367   * @since 7
368   */
369  picture: image.PixelMap;
370}
371
372/**
373 * Describes a system live view notification.
374 *
375 * @typedef NotificationSystemLiveViewContent
376 * @syscap SystemCapability.Notification.Notification
377 * @since 11
378 */
379export interface NotificationSystemLiveViewContent extends NotificationBasicContent {
380  /**
381   * type code of a system live view notification.
382   *
383   * @type { number }
384   * @syscap SystemCapability.Notification.Notification
385   * @since 11
386   */
387  typeCode: number;
388
389  /**
390   * capsule of a system live view notification.
391   *
392   * @type { ?NotificationCapsule }
393   * @syscap SystemCapability.Notification.Notification
394   * @since 11
395   */
396  capsule?: NotificationCapsule;
397
398  /**
399   * button of a system live view notification.
400   *
401   * @type { ?NotificationButton }
402   * @syscap SystemCapability.Notification.Notification
403   * @since 11
404   */
405  button?: NotificationButton;
406
407  /**
408   * type of a system live view notification.
409   *
410   * @type { ?NotificationTime }
411   * @syscap SystemCapability.Notification.Notification
412   * @since 11
413   */
414  time?: NotificationTime;
415
416  /**
417   * progress of a system live view notification.
418   *
419   * @type { ?NotificationProgress }
420   * @syscap SystemCapability.Notification.Notification
421   * @since 11
422   */
423  progress?: NotificationProgress;
424}
425
426/**
427 * Describes a system live view capsule type.
428 *
429 * @typedef NotificationCapsule
430 * @syscap SystemCapability.Notification.Notification
431 * @since 11
432 */
433export interface NotificationCapsule {
434  /**
435   * Title displayed in this capsule.
436   *
437   * @type { ?string }
438   * @syscap SystemCapability.Notification.Notification
439   * @since 11
440   */
441  title?: string;
442
443  /**
444   * Icon displayed in this capsule.
445   *
446   * @type { ?image.PixelMap }
447   * @syscap SystemCapability.Notification.Notification
448   * @since 11
449   */
450  icon?: image.PixelMap;
451
452  /**
453   * Background color of this capsule.
454   *
455   * @type { ?string }
456   * @syscap SystemCapability.Notification.Notification
457   * @since 11
458   */
459  backgroundColor?: string;
460
461  /**
462   * Extended text of this capsule.
463   *
464   * @type { ?string }
465   * @syscap SystemCapability.Notification.Notification
466   * @systemapi
467   * @since 12
468   */
469  content?: string;
470}
471
472/**
473 * Describes a system live view button type.
474 *
475 * @typedef NotificationButton
476 * @syscap SystemCapability.Notification.Notification
477 * @since 11
478 */
479export interface NotificationButton {
480  /**
481   * array of button names.
482   *
483   * @type { ?Array<string> }
484   * @syscap SystemCapability.Notification.Notification
485   * @since 11
486   */
487  names?: Array<string>;
488
489  /**
490   * array of button icons.
491   *
492   * @type { ?Array<image.PixelMap> }
493   * @syscap SystemCapability.Notification.Notification
494   * @since 11
495   */
496  icons?: Array<image.PixelMap>;
497
498  /**
499   * array of button icons resource.
500   *
501   * @type { ?Array<Resource> }
502   * @syscap SystemCapability.Notification.Notification
503   * @since 12
504   */
505  iconsResource?: Array<Resource>;
506}
507
508/**
509 * Describes a system live view time type.
510 *
511 * @typedef NotificationTime
512 * @syscap SystemCapability.Notification.Notification
513 * @since 11
514 */
515export interface NotificationTime {
516  /**
517   * The initial time of this notification.
518   *
519   * @type { ?number }
520   * @syscap SystemCapability.Notification.Notification
521   * @since 11
522   */
523  initialTime?: number;
524
525  /**
526   *
527   * Count down the time.
528   *
529   * @type { ?boolean }
530   * @syscap SystemCapability.Notification.Notification
531   * @since 11
532   */
533  isCountDown?: boolean;
534
535  /**
536   * The time is paused.
537   *
538   * @type { ?boolean }
539   * @syscap SystemCapability.Notification.Notification
540   * @since 11
541   */
542  isPaused?: boolean;
543
544  /**
545   * The time should be displayed in title.
546   *
547   * @type { ?boolean }
548   * @syscap SystemCapability.Notification.Notification
549   * @since 11
550   */
551  isInTitle?: boolean;
552}
553
554/**
555 * Describes a system live view progress type.
556 *
557 * @typedef NotificationProgress
558 * @syscap SystemCapability.Notification.Notification
559 * @since 11
560 */
561export interface NotificationProgress {
562  /**
563   * Max value of this progress.
564   *
565   * @type { ?number }
566   * @syscap SystemCapability.Notification.Notification
567   * @since 11
568   */
569  maxValue?: number;
570
571  /**
572   * Current value of this progress.
573   *
574   * @type { ?number }
575   * @syscap SystemCapability.Notification.Notification
576   * @since 11
577   */
578  currentValue?: number;
579
580  /**
581   * Use percentage mode in this progress.
582   *
583   * @type { ?boolean }
584   * @syscap SystemCapability.Notification.Notification
585   * @since 11
586   */
587  isPercentage?: boolean;
588}
589
590/**
591 * Describes notification types.
592 *
593 * @typedef NotificationContent
594 * @syscap SystemCapability.Notification.Notification
595 * @since 7
596 */
597/**
598 * Describes notification types.
599 *
600 * @typedef NotificationContent
601 * @syscap SystemCapability.Notification.Notification
602 * @crossplatform
603 * @since 12
604 */
605export interface NotificationContent {
606  /**
607   * Notification content type.
608   *
609   * @type { ?notification.ContentType }
610   * @syscap SystemCapability.Notification.Notification
611   * @since 7
612   * @deprecated since 11
613   * @useinstead NotificationContent#notificationContentType
614   */
615  contentType?: notification.ContentType;
616
617  /**
618   * Notification content type.
619   *
620   * @type { ?notificationManager.ContentType }
621   * @syscap SystemCapability.Notification.Notification
622   * @since 11
623   */
624  /**
625   * Notification content type.
626   *
627   * @type { ?notificationManager.ContentType }
628   * @syscap SystemCapability.Notification.Notification
629   * @crossplatform
630   * @since 12
631   */
632  notificationContentType?: notificationManager.ContentType;
633
634  /**
635   * Normal text notification.
636   *
637   * @type { ?NotificationBasicContent }
638   * @syscap SystemCapability.Notification.Notification
639   * @since 7
640   */
641  /**
642   * Normal text notification.
643   *
644   * @type { ?NotificationBasicContent }
645   * @syscap SystemCapability.Notification.Notification
646   * @crossplatform
647   * @since 12
648   */
649  normal?: NotificationBasicContent;
650
651  /**
652   * Long text notification.
653   *
654   * @type { ?NotificationLongTextContent }
655   * @syscap SystemCapability.Notification.Notification
656   * @since 7
657   */
658  /**
659   * Long text notification.
660   *
661   * @type { ?NotificationLongTextContent }
662   * @syscap SystemCapability.Notification.Notification
663   * @crossplatform
664   * @since 12
665   */
666  longText?: NotificationLongTextContent;
667
668  /**
669   * Multi-line text notification.
670   *
671   * @type { ?NotificationMultiLineContent }
672   * @syscap SystemCapability.Notification.Notification
673   * @since 7
674   */
675  /**
676   * Multi-line text notification.
677   *
678   * @type { ?NotificationMultiLineContent }
679   * @syscap SystemCapability.Notification.Notification
680   * @crossplatform
681   * @since 12
682   */
683  multiLine?: NotificationMultiLineContent;
684
685  /**
686   * Picture-attached notification.
687   *
688   * @type { ?NotificationPictureContent }
689   * @syscap SystemCapability.Notification.Notification
690   * @since 7
691   */
692  picture?: NotificationPictureContent;
693
694  /**
695   * System-live-view notification.
696   *
697   * @type { ?NotificationSystemLiveViewContent }
698   * @syscap SystemCapability.Notification.Notification
699   * @since 11
700   */
701  systemLiveView?: NotificationSystemLiveViewContent;
702
703  /**
704   * live-view notification.
705   *
706   * @type { ?NotificationLiveViewContent }
707   * @syscap SystemCapability.Notification.Notification
708   * @systemapi
709   * @since 11
710   */
711  liveView?: NotificationLiveViewContent;
712}
713