• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_PICTURE_CONTENT_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_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     NotificationPictureContent() = default;
28 
29     ~NotificationPictureContent() = default;
30 
31     /**
32      * @brief Sets the title to be displayed when this picture-attached notification is expanded.
33      * After this title is set, the title set by setTitle(string) will be displayed only
34      * when this notification is in the collapsed state.
35      *
36      * @param exTitle Indicates the title to be displayed when this notification is expanded.
37      */
38     void SetExpandedTitle(const std::string &exTitle);
39 
40     /**
41      * @brief Obtains the title that will be displayed for this picture-attached notification when it is expanded.
42      *
43      * @return Returns the title to be displayed when this notification is expanded.
44      */
45     std::string GetExpandedTitle() const;
46 
47     /**
48      * @brief Sets the brief text to be included in a picture-attached notification.
49      * The brief text is a summary of a picture-attached notification and is displayed in the first line of the
50      * notification. Similar to setAdditionalText(string), the font of the brief text is also smaller than the
51      * notification text. The positions where the brief text and additional text will display may conflict. If both
52      * texts are set, only the additional text will be displayed.
53      *
54      * @param briefText Indicates the brief text to be included.
55      */
56     void SetBriefText(const std::string &briefText);
57 
58     /**
59      * @brief Obtains the brief text of a picture-attached notification specified by calling the setBriefText(string)
60      * method.
61      *
62      * @return Returns the brief text of the picture-attached notification.
63      */
64     std::string GetBriefText() const;
65 
66     /**
67      * @brief Sets the picture to be included in a notification.
68      *
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      * @brief Obtains the PixelMap of the picture specified by calling the setBigPicture(PixelMap) method.
75      *
76      * @return Returns the PixelMap of the picture included in the notification.
77      */
78     const std::shared_ptr<Media::PixelMap> GetBigPicture() const;
79 
80     /**
81      * @brief Returns a string representation of the object.
82      *
83      * @return Returns a string representation of the object.
84      */
85     std::string Dump() override;
86 
87     /**
88      * @brief Converts a NotificationPictureContent object into a Json.
89      *
90      * @param jsonObject Indicates the Json object.
91      * @return Returns true if succeed; returns false otherwise.
92      */
93     virtual bool ToJson(nlohmann::json &jsonObject) const override;
94 
95     /**
96      * @brief Creates a NotificationPictureContent object from a Json.
97      *
98      * @param jsonObject Indicates the Json object.
99      * @return Returns the NotificationPictureContent object.
100      */
101     static NotificationPictureContent *FromJson(const nlohmann::json &jsonObject);
102 
103     /**
104      * @brief Marshal a object into a Parcel.
105      *
106      * @param parcel the object into the parcel.
107      * @return Returns true if succeed; returns false otherwise.
108      */
109     virtual bool Marshalling(Parcel &parcel) const override;
110 
111     /**
112      * @brief Unmarshal object from a Parcel.
113      *
114      * @param parcel Indicates the parcel object.
115      * @return Returns the NotificationPictureContent object.
116      */
117     static NotificationPictureContent *Unmarshalling(Parcel &parcel);
118 
119 protected:
120     /**
121      * @brief Read a NotificationPictureContent object from a Parcel.
122      *
123      * @param parcel Indicates the parcel object.
124      * @return Returns true if succeed; returns false otherwise.
125      */
126     bool ReadFromParcel(Parcel &parcel) override;
127 
128 private:
129     std::string expandedTitle_ {};
130     std::string briefText_ {};
131     std::shared_ptr<Media::PixelMap> bigPicture_ {};
132 };
133 }  // namespace Notification
134 }  // namespace OHOS
135 
136 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_PICTURE_CONTENT_H