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