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 16 #ifndef BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_PICTURE_CONTENT_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_PICTURE_CONTENT_H 18 19 #include "notification_basic_content.h" 20 #include "parcel.h" 21 #include "pixel_map.h" 22 23 namespace OHOS { 24 namespace Notification { 25 class NotificationPictureContent : public NotificationBasicContent { 26 public: 27 /** 28 * Default constructor used to create an empty NotificationPictureContent instance. 29 */ 30 NotificationPictureContent() = default; 31 32 /** 33 * Default deconstructor used to deconstruct. 34 */ 35 ~NotificationPictureContent() = default; 36 37 /** 38 * Sets the title to be displayed when this picture-attached notification is expanded. 39 * After this title is set, the title set by setTitle(string) will be displayed only 40 * when this notification is in the collapsed state. 41 * @param exTitle Indicates the title to be displayed when this notification is expanded. 42 */ 43 void SetExpandedTitle(const std::string &exTitle); 44 45 /** 46 * Obtains the title that will be displayed for this picture-attached notification when it is expanded. 47 * @return the title to be displayed when this notification is expanded. 48 */ 49 std::string GetExpandedTitle() const; 50 51 /** 52 * Sets the brief text to be included in a picture-attached notification. 53 * The brief text is a summary of a picture-attached notification and is displayed in the first line of the 54 * notification. Similar to setAdditionalText(string), the font of the brief text is also smaller than the 55 * notification text. The positions where the brief text and additional text will display may conflict. If both 56 * texts are set, only the additional text will be displayed. 57 * @param briefText Indicates the brief text to be included. 58 */ 59 void SetBriefText(const std::string &briefText); 60 61 /** 62 * Obtains the brief text of a picture-attached notification specified by calling the setBriefText(string) method. 63 * @return the brief text of the picture-attached notification. 64 */ 65 std::string GetBriefText() const; 66 67 /** 68 * Sets the picture to be included in a notification. 69 * @param bigPicture Indicates the PixelMap of the picture to be included. 70 */ 71 void SetBigPicture(const std::shared_ptr<Media::PixelMap> &bigPicture); 72 73 /** 74 * Obtains the PixelMap of the picture specified by calling the setBigPicture(PixelMap) method. 75 * @return the PixelMap of the picture included in the notification. 76 */ 77 const std::shared_ptr<Media::PixelMap> GetBigPicture() const; 78 79 /** 80 * Returns a string representation of the object. 81 * @return a string representation of the object. 82 */ 83 std::string Dump() override; 84 85 /** 86 * Converts a NotificationPictureContent object into a Json. 87 * @param jsonObject Indicates the Json object. 88 */ 89 virtual bool ToJson(nlohmann::json &jsonObject) const override; 90 91 /** 92 * Creates a NotificationPictureContent object from a Json. 93 * @param jsonObject Indicates the Json object. 94 * @return the NotificationPictureContent. 95 */ 96 static NotificationPictureContent *FromJson(const nlohmann::json &jsonObject); 97 98 /** 99 * Marshal a object into a Parcel. 100 * @param parcel the object into the parcel 101 */ 102 virtual bool Marshalling(Parcel &parcel) const override; 103 104 /** 105 * Unmarshal object from a Parcel. 106 * @return the NotificationPictureContent 107 */ 108 static NotificationPictureContent *Unmarshalling(Parcel &parcel); 109 110 protected: 111 /** 112 * Read a NotificationPictureContent object from a Parcel. 113 * @param parcel the parcel 114 */ 115 bool ReadFromParcel(Parcel &parcel) override; 116 117 private: 118 std::string expandedTitle_ {}; 119 std::string briefText_ {}; 120 std::shared_ptr<Media::PixelMap> bigPicture_ {}; 121 }; 122 } // namespace Notification 123 } // namespace OHOS 124 125 #endif // BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_PICTURE_CONTENT_H