1/* 2 * Copyright (c) 2021 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 { MessageUser } from './notificationMessageUser'; 19 20/** 21 * Describes a normal text notification. 22 * 23 * @name NotificationBasicContent 24 * @since 7 25 * @syscap SystemCapability.Notification.Notification 26 * @permission N/A 27 */ 28export interface NotificationBasicContent { 29 /** 30 * Title of the normal text notification. 31 */ 32 title: string; 33 34 /** 35 * Content of the normal text notification. 36 */ 37 text: string; 38 39 /** 40 * Additional information of the normal text notification. 41 */ 42 additionalText?: string; 43} 44 45/** 46 * Describes a long text notification. 47 * 48 * @name NotificationLongTextContent 49 * @since 7 50 * @syscap SystemCapability.Notification.Notification 51 * @permission N/A 52 */ 53export interface NotificationLongTextContent extends NotificationBasicContent { 54 /** 55 * Long text content of the notification. 56 */ 57 longText: string; 58 59 /** 60 * Brief text of the long text notification. 61 */ 62 briefText: string; 63 64 /** 65 * Title that will be displayed for the long text notification when it is expanded. 66 */ 67 expandedTitle: string; 68} 69 70/** 71 * Describes a multi-line text notification. 72 * 73 * @name NotificationMultiLineContent 74 * @since 7 75 * @syscap SystemCapability.Notification.Notification 76 * @permission N/A 77 */ 78export interface NotificationMultiLineContent extends NotificationBasicContent { 79 /** 80 * Brief text of the multi-line text notification. 81 */ 82 briefText: string; 83 84 /** 85 * Brief text of the multi-line text notification. 86 */ 87 longTitle: string; 88 89 /** 90 * Multi-line content of the multi-line text notification. 91 */ 92 lines: Array<string>; 93} 94 95/** 96 * Describes a picture-attached notification. 97 * 98 * @name NotificationPictureContent 99 * @since 7 100 * @syscap SystemCapability.Notification.Notification 101 * @permission N/A 102 */ 103export interface NotificationPictureContent extends NotificationBasicContent { 104 /** 105 * Multi-line content of the multi-line text notification. 106 */ 107 briefText: string; 108 109 /** 110 * Title that will be displayed for the picture-attached notification when it is expanded. 111 */ 112 expandedTitle: string; 113 114 /** 115 * Picture to be included in a notification. 116 */ 117 picture: image.PixelMap; 118} 119 120/** 121 * Constructs a conversation-like notification that includes message communication among multiple users. 122 * 123 * @since 8 124 */ 125export interface NotificationConversationalContent extends NotificationBasicContent { 126 /** 127 * Indicates the {@code MessageUser} who sends all objects in this conversation-like notification. 128 * This parameter cannot be null. 129 */ 130 user: MessageUser; 131 132 /** 133 * Obtains all messages included in this conversation-like notification. 134 */ 135 messages: Array<ConversationalMessage>; 136 137 /** 138 * Checks whether this notification represents a group conversation. 139 */ 140 conversationGroup?: boolean; 141 142 /** 143 * Obtains the title to be displayed for the conversation. 144 */ 145 conversationTitle?: string; 146} 147 148/** 149 * Provides methods for defining a conversational message that is used in notifications created with 150 * {@link NotificationConversationalContent}. Each message contains the message content, timestamp, and 151 * sender; and the message content and sender information will be displayed in the notification bar. 152 * 153 * @since 8 154 */ 155export interface ConversationalMessage { 156 /** 157 * Obtains the text to be displayed as the content of this message. 158 */ 159 text: string; 160 161 /** 162 * Obtains the time when this message arrived. 163 */ 164 timestamp: number; 165 166 /** 167 * Obtains the sender of this message. 168 */ 169 sender: MessageUser; 170 171 /** 172 * Obtains the MIME type of this message. 173 */ 174 mimeType?: string; 175 176 /** 177 * Obtains the URI of this message. 178 */ 179 uri?: string; 180} 181 182/** 183 * Describes notification types. 184 * 185 * @name NotificationContent 186 * @since 7 187 * @syscap SystemCapability.Notification.Notification 188 * @permission N/A 189 */ 190export interface NotificationContent { 191 /** 192 * Notification content type. 193 */ 194 contentType: notification.ContentType; 195 196 /** 197 * Normal text notification. 198 */ 199 normal?: NotificationBasicContent; 200 201 /** 202 * Long text notification. 203 */ 204 longText?: NotificationLongTextContent; 205 206 /** 207 * Multi-line text notification. 208 */ 209 multiLine?: NotificationMultiLineContent; 210 211 /** 212 * Picture-attached notification. 213 */ 214 picture?: NotificationPictureContent; 215 216 /** 217 * Constructs a conversation-like notification that includes message communication among multiple users. 218 * 219 * @since 8 220 */ 221 conversation?: NotificationConversationalContent; 222} 223