2 * Copyright 2018 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.
17 #include "ActionPage.hpp"
19 #include "AccessibilitySettingLog.hpp"
20 #include "Singleton.hpp"
21 #include "setting-accessibility.h"
25 ActionPage::ActionPage(NaviframeItem targetItem)
26 : context_(Singleton<AppContext>::instance())
28 setValuePage_ = std::make_unique<SetValuePage>(ValueEditorType::RADIOS, "IDS_ACCS_UNIVERSAL_SWITCH_SELECT_ACTION", targetItem);
29 setValuePage_->addRadioItemChangedCb([this](auto val) { this->actionChangedCb(val); });
30 for (auto i = 0u; i < context_.config.activity_types.size(); ++i)
31 setValuePage_->addRadioItem(context_.config.activity_types[i]->name, i, false);
34 void ActionPage::actionChangedCb(size_t item_id)
36 if (item_id >= context_.config.activity_types.size()) {
37 DEBUG("Unknown item id");
41 auto activity = context_.config.activity_types[item_id];
42 DEBUG("Selected activity type, id: %s, name: %s, description: %s",
44 activity->name.c_str(),
45 activity->description.c_str());
47 actionCb_(activity->id, actionCbData_);
50 void ActionPage::attachCallback(switch_action_cb cb, void *user_data)
53 actionCbData_ = user_data;