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.
19 #include "notification-ex/checkbox_item.h"
20 #include "notification-ex/checkbox_item_implementation.h"
21 #include "notification-ex/factory_manager.h"
22 #include "notification-ex/exception.h"
28 #define LOG_TAG "NOTIFICATION_EX"
29 #define CHECKBOX_TITLE_KEY "__CHECKBOX_TITLE_KEY__"
30 #define CHECKBOX_CHECKED_KEY "__CHECKBOX_CHECKED_KEY__"
32 using namespace tizen_base;
34 namespace notification {
37 CheckBoxItem::CheckBoxItem(std::string id, std::string title, bool checked,
38 std::shared_ptr<AbstractAction> action)
39 : AbstractItem(id, action), impl_(new Impl(this, title, checked)) {
42 CheckBoxItem::Impl::Impl(CheckBoxItem* parent, std::string title, bool checked)
43 : parent_(parent), title_(title), checked_(checked) {
44 LOGI("CheckBoxItem impl created");
47 int CheckBoxItem::GetType() const {
48 return AbstractItem::CheckBox;
51 Bundle CheckBoxItem::Serialize() const {
54 b = AbstractItem::Serialize();
55 b.Add(CHECKBOX_TITLE_KEY, impl_->title_);
56 b.Add(CHECKBOX_CHECKED_KEY, std::to_string(impl_->checked_));
61 void CheckBoxItem::Deserialize(Bundle b) {
62 AbstractItem::Deserialize(b);
64 impl_->title_ = b.GetString(CHECKBOX_TITLE_KEY);
65 impl_->checked_ = std::stoi(b.GetString(CHECKBOX_CHECKED_KEY));
68 bool CheckBoxItem::IsItemTypeExist(int type) {
69 if (GetType() == type)
74 std::string CheckBoxItem::GetTitle(void) const {
78 bool CheckBoxItem::IsChecked(void) const {
79 return impl_->checked_;
82 void CheckBoxItem::SetChecked(bool checked) {
83 impl_->checked_ = checked;
86 CheckBoxItem::~CheckBoxItem() = default;
87 CheckBoxItem::Impl::~Impl() = default;
90 } // namespace notification