• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2023 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
16import notification from '../@ohos.notification';
17import image from '../@ohos.multimedia.image';
18import type notificationManager from '../@ohos.notificationManager';
19
20/**
21 * Describes a normal text notification.
22 *
23 * @typedef NotificationBasicContent
24 * @syscap SystemCapability.Notification.Notification
25 * @since 7
26 */
27export interface NotificationBasicContent {
28  /**
29   * Title of the normal text notification.
30   *
31   * @type { string }
32   * @syscap SystemCapability.Notification.Notification
33   * @since 7
34   */
35  title: string;
36
37  /**
38   * Content of the normal text notification.
39   *
40   * @type { string }
41   * @syscap SystemCapability.Notification.Notification
42   * @since 7
43   */
44  text: string;
45
46  /**
47   * Additional information of the normal text notification.
48   *
49   * @type { ?string }
50   * @syscap SystemCapability.Notification.Notification
51   * @since 7
52   */
53  additionalText?: string;
54}
55
56/**
57 * Describes a long text notification.
58 *
59 * @typedef NotificationLongTextContent
60 * @syscap SystemCapability.Notification.Notification
61 * @since 7
62 */
63export interface NotificationLongTextContent extends NotificationBasicContent {
64  /**
65   * Long text content of the notification.
66   *
67   * @type { string }
68   * @syscap SystemCapability.Notification.Notification
69   * @since 7
70   */
71  longText: string;
72
73  /**
74   * Brief text of the long text notification.
75   *
76   * @type { string }
77   * @syscap SystemCapability.Notification.Notification
78   * @since 7
79   */
80  briefText: string;
81
82  /**
83   * Title that will be displayed for the long text notification when it is expanded.
84   *
85   * @type { string }
86   * @syscap SystemCapability.Notification.Notification
87   * @since 7
88   */
89  expandedTitle: string;
90}
91
92/**
93   * Enum for live view notification option type.
94   *
95   * @enum { number }
96   * @syscap SystemCapability.Security.AccessToken
97   * @systemapi
98   * @since 11
99   */
100export enum LiveViewStatus {
101  /**
102   * Create the live view notification.
103   *
104   * @syscap SystemCapability.Security.AccessToken
105   * @systemapi
106   * @since 11
107   */
108  LIVE_VIEW_CREATE = 0,
109  /**
110   * Batch update the live view notification.
111   *
112   * @syscap SystemCapability.Security.AccessToken
113   * @systemapi
114   * @since 11
115   */
116  LIVE_VIEW_INCREMENTAL_UPDATE = 1,
117  /**
118   * Complete the live view notification.
119   *
120   * @syscap SystemCapability.Security.AccessToken
121   * @systemapi
122   * @since 11
123   */
124  LIVE_VIEW_END = 2,
125  /**
126   * Full update the live view notification.
127   *
128   * @syscap SystemCapability.Security.AccessToken
129   * @systemapi
130   * @since 11
131   */
132  LIVE_VIEW_FULL_UPDATE = 3
133}
134
135/**
136 * Describes a live view notification.
137 *
138 * @typedef NotificationLiveViewContent
139 * @syscap SystemCapability.Notification.Notification
140 * @systemapi
141 * @since 11
142 */
143export interface NotificationLiveViewContent extends NotificationBasicContent {
144  /**
145   * Status of the live view (0: create, 1: batch update, 2: end, 3: full update).
146   *
147   * @type { LiveViewStatus }
148   * @syscap SystemCapability.Notification.Notification
149   * @systemapi
150   * @since 11
151   */
152  status: LiveViewStatus;
153
154  /**
155   * Version of the live view with the same id. (If the version number stored in the database is 0xffffffff,
156   * the version number is not verified at the current operation of update or end. Otherwise, the
157   * version number must be greater than the version number stored in the database.)
158   *
159   * @type { ?number }
160   * @syscap SystemCapability.Notification.Notification
161   * @systemapi
162   * @since 11
163   */
164  version?: number;
165
166  /**
167   * Additional information of the live view notification.
168   *
169   * @type { ?Record<string, Object>}
170   * @syscap SystemCapability.Notification.Notification
171   * @systemapi
172   * @since 11
173   */
174  extraInfo?: Record<string, Object>;
175
176  /**
177   * The picture information list of the live view notification.
178   *
179   * @type { ?Record<string, Array<image.PixelMap>> }
180   * @syscap SystemCapability.Notification.Notification
181   * @systemapi
182   * @since 11
183   */
184  pictureInfo?: Record<string, Array<image.PixelMap>>;
185}
186
187/**
188 * Describes a multi-line text notification.
189 *
190 * @typedef NotificationMultiLineContent
191 * @syscap SystemCapability.Notification.Notification
192 * @since 7
193 */
194export interface NotificationMultiLineContent extends NotificationBasicContent {
195  /**
196   * Brief text of the multi-line text notification.
197   *
198   * @type { string }
199   * @syscap SystemCapability.Notification.Notification
200   * @since 7
201   */
202  briefText: string;
203
204  /**
205   * Brief text of the multi-line text notification.
206   *
207   * @type { string }
208   * @syscap SystemCapability.Notification.Notification
209   * @since 7
210   */
211  longTitle: string;
212
213  /**
214   * Multi-line content of the multi-line text notification.
215   *
216   * @type { Array<string> }
217   * @syscap SystemCapability.Notification.Notification
218   * @since 7
219   */
220  lines: Array<string>;
221}
222
223/**
224 * Describes a picture-attached notification.
225 *
226 * @typedef NotificationPictureContent
227 * @syscap SystemCapability.Notification.Notification
228 * @since 7
229 */
230export interface NotificationPictureContent extends NotificationBasicContent {
231  /**
232   * Multi-line content of the multi-line text notification.
233   *
234   * @type { string }
235   * @syscap SystemCapability.Notification.Notification
236   * @since 7
237   */
238  briefText: string;
239
240  /**
241   * Title that will be displayed for the picture-attached notification when it is expanded.
242   *
243   * @type { string }
244   * @syscap SystemCapability.Notification.Notification
245   * @since 7
246   */
247  expandedTitle: string;
248
249  /**
250   * Picture to be included in a notification.
251   *
252   * @type { image.PixelMap }
253   * @syscap SystemCapability.Notification.Notification
254   * @since 7
255   */
256  picture: image.PixelMap;
257}
258
259/**
260 * Describes a system live view notification.
261 *
262 * @typedef NotificationSystemLiveViewContent
263 * @syscap SystemCapability.Notification.Notification
264 * @since 11
265 */
266export interface NotificationSystemLiveViewContent extends NotificationBasicContent {
267  /**
268   * type code of a system live view notification.
269   *
270   * @type { number }
271   * @syscap SystemCapability.Notification.Notification
272   * @since 11
273   */
274  typeCode: number;
275
276  /**
277   * capsule of a system live view notification.
278   *
279   * @type { ?NotificationCapsule }
280   * @syscap SystemCapability.Notification.Notification
281   * @since 11
282   */
283  capsule?: NotificationCapsule;
284
285  /**
286   * button of a system live view notification.
287   *
288   * @type { ?NotificationButton }
289   * @syscap SystemCapability.Notification.Notification
290   * @since 11
291   */
292  button?: NotificationButton;
293
294  /**
295   * type of a system live view notification.
296   *
297   * @type { ?NotificationTime }
298   * @syscap SystemCapability.Notification.Notification
299   * @since 11
300   */
301  time?: NotificationTime;
302
303  /**
304   * progress of a system live view notification.
305   *
306   * @type { ?NotificationProgress }
307   * @syscap SystemCapability.Notification.Notification
308   * @since 11
309   */
310  progress?: NotificationProgress;
311}
312
313/**
314 * Describes a system live view capsule type.
315 *
316 * @typedef NotificationCapsule
317 * @syscap SystemCapability.Notification.Notification
318 * @since 11
319 */
320export interface NotificationCapsule {
321  /**
322   * Title displayed in this capsule.
323   *
324   * @type { ?string }
325   * @syscap SystemCapability.Notification.Notification
326   * @since 11
327   */
328  title?: string;
329
330  /**
331   * Icon displayed in this capsule.
332   *
333   * @type { ?image.PixelMap }
334   * @syscap SystemCapability.Notification.Notification
335   * @since 11
336   */
337  icon?: image.PixelMap;
338
339  /**
340   * Background color of this capsule.
341   *
342   * @type { ?string }
343   * @syscap SystemCapability.Notification.Notification
344   * @since 11
345   */
346  backgroundColor?: string;
347}
348
349/**
350 * Describes a system live view button type.
351 *
352 * @typedef NotificationButton
353 * @syscap SystemCapability.Notification.Notification
354 * @since 11
355 */
356export interface NotificationButton {
357  /**
358   * array of button names.
359   *
360   * @type { ?Array<string> }
361   * @syscap SystemCapability.Notification.Notification
362   * @since 11
363   */
364  names?: Array<string>;
365
366  /**
367   * array of button icons.
368   *
369   * @type { ?Array<image.PixelMap> }
370   * @syscap SystemCapability.Notification.Notification
371   * @since 11
372   */
373  icons?: Array<image.PixelMap>;
374}
375
376/**
377 * Describes a system live view time type.
378 *
379 * @typedef NotificationTime
380 * @syscap SystemCapability.Notification.Notification
381 * @since 11
382 */
383export interface NotificationTime {
384  /**
385   * The initial time of this notification.
386   *
387   * @type { ?number }
388   * @syscap SystemCapability.Notification.Notification
389   * @since 11
390   */
391  initialTime?: number;
392
393  /**
394   *
395   * Count down the time.
396   *
397   * @type { ?boolean }
398   * @syscap SystemCapability.Notification.Notification
399   * @since 11
400   */
401  isCountDown?: boolean;
402
403  /**
404   * The time is paused.
405   *
406   * @type { ?boolean }
407   * @syscap SystemCapability.Notification.Notification
408   * @since 11
409   */
410  isPaused?: boolean;
411
412  /**
413   * The time should be displayed in title.
414   *
415   * @type { ?boolean }
416   * @syscap SystemCapability.Notification.Notification
417   * @since 11
418   */
419  isInTitle?: boolean;
420}
421
422/**
423 * Describes a system live view progress type.
424 *
425 * @typedef NotificationProgress
426 * @syscap SystemCapability.Notification.Notification
427 * @since 11
428 */
429export interface NotificationProgress {
430  /**
431   * Max value of this progress.
432   *
433   * @type { ?number }
434   * @syscap SystemCapability.Notification.Notification
435   * @since 11
436   */
437  maxValue?: number;
438
439  /**
440   * Current value of this progress.
441   *
442   * @type { ?number }
443   * @syscap SystemCapability.Notification.Notification
444   * @since 11
445   */
446  currentValue?: number;
447
448  /**
449   * Use percentage mode in this progress.
450   *
451   * @type { ?boolean }
452   * @syscap SystemCapability.Notification.Notification
453   * @since 11
454   */
455  isPercentage?: boolean;
456}
457
458/**
459 * Describes notification types.
460 *
461 * @typedef NotificationContent
462 * @syscap SystemCapability.Notification.Notification
463 * @since 7
464 */
465export interface NotificationContent {
466  /**
467   * Notification content type.
468   *
469   * @type { ?notification.ContentType }
470   * @syscap SystemCapability.Notification.Notification
471   * @since 7
472   * @deprecated since 11
473   * @useinstead NotificationContent#notificationContentType
474   */
475  contentType?: notification.ContentType;
476
477  /**
478   * Notification content type.
479   *
480   * @type { ?notificationManager.ContentType }
481   * @syscap SystemCapability.Notification.Notification
482   * @since 11
483   */
484  notificationContentType?: notificationManager.ContentType;
485
486  /**
487   * Normal text notification.
488   *
489   * @type { ?NotificationBasicContent }
490   * @syscap SystemCapability.Notification.Notification
491   * @since 7
492   */
493  normal?: NotificationBasicContent;
494
495  /**
496   * Long text notification.
497   *
498   * @type { ?NotificationLongTextContent }
499   * @syscap SystemCapability.Notification.Notification
500   * @since 7
501   */
502  longText?: NotificationLongTextContent;
503
504  /**
505   * Multi-line text notification.
506   *
507   * @type { ?NotificationMultiLineContent }
508   * @syscap SystemCapability.Notification.Notification
509   * @since 7
510   */
511  multiLine?: NotificationMultiLineContent;
512
513  /**
514   * Picture-attached notification.
515   *
516   * @type { ?NotificationPictureContent }
517   * @syscap SystemCapability.Notification.Notification
518   * @since 7
519   */
520  picture?: NotificationPictureContent;
521
522  /**
523   * System-live-view notification.
524   *
525   * @type { ?NotificationSystemLiveViewContent }
526   * @syscap SystemCapability.Notification.Notification
527   * @since 11
528   */
529  systemLiveView?: NotificationSystemLiveViewContent;
530
531  /**
532   * live-view notification.
533   *
534   * @type { ?NotificationLiveViewContent }
535   * @syscap SystemCapability.Notification.Notification
536   * @systemapi
537   * @since 11
538   */
539  liveView?: NotificationLiveViewContent;
540}
541