From: Oskar Chodowicz Date: Wed, 26 Jun 2019 08:44:21 +0000 (+0200) Subject: Add possibility to update switch for camera & screen providers X-Git-Tag: accepted/tizen/unified/20190705.110821~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1ce530276cf2ed12c3f4239d056144e456eb835;p=profile%2Fmobile%2Fapps%2Fnative%2Faccessibility-setting.git Add possibility to update switch for camera & screen providers Change-Id: I206051f003c9480d711ffaaad14f6585e33fd1a7 --- diff --git a/src/presenter/SelectActionPagePresenter.cpp b/src/presenter/SelectActionPagePresenter.cpp index 9fe29eb..46747c4 100644 --- a/src/presenter/SelectActionPagePresenter.cpp +++ b/src/presenter/SelectActionPagePresenter.cpp @@ -27,7 +27,7 @@ void SelectActionPagePresenter::addOrUpdateSwitchConfigurationItem(const std::st model_.addSwitch({switchId_, userName_, activityType}); break; case ChangeType::UPDATE: - model_.addSwitch({switchId_, userName_, activityType}); + model_.updateSwitch({switchId_, userName_, activityType}); break; default: ASSERT(0, "Unhandled change type"); diff --git a/src/presenter/SwitchesPagePresenter.cpp b/src/presenter/SwitchesPagePresenter.cpp index 22a082c..528d3d8 100644 --- a/src/presenter/SwitchesPagePresenter.cpp +++ b/src/presenter/SwitchesPagePresenter.cpp @@ -3,6 +3,7 @@ #include "AddSwitchPagePresenter.hpp" #include "AppContext.hpp" #include "RemoveSwitchesPagePresenter.hpp" +#include "SelectActionPagePresenter.hpp" #include "UniversalSwitchConstants.hpp" SwitchesPagePresenter::SwitchesPagePresenter() @@ -27,12 +28,12 @@ void SwitchesPagePresenter::addItemsToList() { auto &items = groups_.back().items_; auto switches = model_.getAllSwitchConfigurationItems(); - for (auto oneSwitch : switches) { + for (auto &oneSwitch : switches) { items.push_back(std::make_unique( oneSwitch.userName, model_.getActivityName(oneSwitch.activityType), - [this](auto item) { - //UpdateSwitchPage should be added here + [this, oneSwitch](auto item) { + this->createUpdatePage(oneSwitch.switchId); })); } items.push_back(std::make_unique( @@ -47,3 +48,19 @@ void SwitchesPagePresenter::addItemsToList() true, ACCESSIBILITY_UNIVERSAL_SWITCH_PLUS_ICON)); } + +void SwitchesPagePresenter::createUpdatePage(const std::string &switchId) +{ + auto providerName = utils::stringSplitByDelimiter(switchId, '_')[0]; + if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN_SWITCH_PROVIDER) { + Singleton::instance().push(std::make_unique(switchId, ACCESSIBILITY_UNIVERSAL_SWITCH_SCREEN, ChangeType::UPDATE, 0)); + return; + } + if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER) { + return; + } + if (providerName == ACCESSIBILITY_UNIVERSAL_SWITCH_CAMERA_SWITCH_PROVIDER) { + Singleton::instance().push(std::make_unique(switchId, ACCESSIBILITY_UNIVERSAL_SWITCH_CAMERA_SWITCH_PROVIDER, ChangeType::UPDATE, 0)); + return; + } +} \ No newline at end of file diff --git a/src/presenter/SwitchesPagePresenter.hpp b/src/presenter/SwitchesPagePresenter.hpp index dabc2f2..74b27c9 100644 --- a/src/presenter/SwitchesPagePresenter.hpp +++ b/src/presenter/SwitchesPagePresenter.hpp @@ -12,6 +12,7 @@ class SwitchesPagePresenter : public ListPresenter private: SwitchesPageModel model_; void addItemsToList(); + void createUpdatePage(const std::string &switchId); }; #endif diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index 0c9ca9f..835f899 100644 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -20,6 +20,7 @@ #include "Elementary.h" #include +#include using SettingCallback = void (*)(void *, Evas_Object *, void *); @@ -76,6 +77,17 @@ namespace utils return out.str(); } + + inline std::vector stringSplitByDelimiter(const std::string &s, char delimiter) + { + std::vector tokens; + std::string token; + std::istringstream tokenStream(s); + while (std::getline(tokenStream, token, delimiter)) { + tokens.push_back(token); + } + return tokens; + } } // namespace utils #endif