2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include "notification-ex/entry_item.h"
22 #include "notification-ex/entry_item_implementation.h"
23 #include "notification-ex/factory_manager.h"
29 #define LOG_TAG "NOTIFICATION_EX"
30 #define ENTRY_TEXT_KEY "__ENTRY_TEXT_KEY__"
31 #define ENTRY_LIMIT_KEY "__ENTRY_LIMIT_KEY__"
33 namespace notification {
36 EntryItem::EntryItem(std::string id, std::shared_ptr<AbstractAction> action)
37 : AbstractItem(id, AbstractItem::Type::Entry), impl_(new Impl()) {
40 EntryItem::EntryItem(std::shared_ptr<AbstractAction> action)
41 : AbstractItem(AbstractItem::Type::Entry), impl_(new Impl()) {
44 EntryItem::Impl::Impl() {
45 LOGI("EntryItem created");
48 EntryItem::~EntryItem() = default;
49 EntryItem::Impl::~Impl() = default;
51 Bundle EntryItem::Serialize() {
53 b = AbstractItem::Serialize();
55 if (!impl_->text_.empty())
56 b.Add(ENTRY_TEXT_KEY, impl_->text_);
58 b.Add(ENTRY_LIMIT_KEY, std::to_string(impl_->limit_));
63 void EntryItem::Deserialize(Bundle b) {
64 AbstractItem::Deserialize(b);
65 impl_->text_ = b.GetString(ENTRY_TEXT_KEY);
66 impl_->limit_ = std::stoi(b.GetString(ENTRY_LIMIT_KEY));
69 AbstractItem& EntryItem::FindByID(std::string id) {
72 return FactoryManager::GetInst().GetNullItem();
75 std::string EntryItem::GetText() const {
79 void EntryItem::SetText(std::string text) {
83 int EntryItem::GetTextLimit() const {
88 } // namespace notification