#define PRT_SET_VALUE_SELECTOR "set-value-selector"
#define PRT_SET_VALUE_RANGE "set-value-range"
#define PRT_SET_VALUE_DESC "set-value-desc"
-#define PRT_SET_VALUE_LIST "set-value-list"
#define PRT_SET_VALUE_ENTRY "set-value-entry"
SetValuePage::SetValuePage(SettingAccessibility *ad, ValueEditorType type, const char *title)
ad->set_value_layout.list_item_options_request_cb_data = data;
}
-void SetValuePage::createUpdateAccessoriesSwitchPage(SettingAccessibility *ad)
-{
- Evas_Object *tb;
- Elm_Object_Item *nf_it;
- tb = elm_toolbar_add(ad->md.getNaviframe()->getObject());
- elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_NONE);
- evas_object_smart_callback_add(tb, "clicked", closeUpdateAccessoriesSwitchPage, ad);
- evas_object_show(tb);
-
- elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND);
- elm_toolbar_transverse_expanded_set(tb, EINA_TRUE);
-
- elm_toolbar_item_append(tb, NULL, _("IDS_ACCS_UNIVERSAL_SWITCH_CANCEL"), NULL, NULL);
- ad->save_object_item = elm_toolbar_item_append(tb, NULL, _("IDS_ACCS_UNIVERSAL_SWITCH_SAVE"), NULL, NULL);
-
- ad->set_value_layout.setLayout(createLayout(ad->md.getNaviframe()->getObject(), GRP_SET_VALUE_UPDATE_ACCESSORIES_SWITCH));
- ad->entry = elm_entry_add(ad->set_value_layout.getLayout());
- elm_entry_entry_set(ad->entry, ad->config_item_to_update.user_name.c_str());
- elm_entry_cursor_end_set(ad->entry);
- evas_object_show(ad->entry);
- elm_object_part_content_set(ad->set_value_layout.getLayout(), PRT_SET_VALUE_ENTRY, ad->entry);
-
- elm_object_part_text_set(ad->set_value_layout.getLayout(), PRT_SET_VALUE_DESC, _("IDS_ACCS_UNIVERSAL_SWITCH_NAME"));
-
- ad->update_accessories_action_genlist = createGenlist(ad->set_value_layout.getLayout(), NULL);
- addActionGendialField(ad);
-
- nf_it = elm_naviframe_item_push(ad->md.getNaviframe()->getObject(), "", NULL, NULL, ad->set_value_layout.getLayout(), "tabbar/notitle");
- elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
- elm_object_item_part_content_set(nf_it, "tabbar", tb);
-}
-
void SetValuePage::syncPageWithVconf(keynode_t *node, void *user_data)
{
retm_if(user_data == NULL, "Data parameter is NULL");
ad->removeSwitchPageCbData_ = data;
}
-void SetValuePage::addActionGendialField(SettingAccessibility *ad)
-{
- createGendialGroupItem(ad->update_accessories_action_genlist, &itc_1text,
- updateSwitchAction, ad,
- SwallowType::INVALID, 0,
- "IDS_ACCS_UNIVERSAL_SWITCH_ACTION",
- setting_accessibility_universal_switch_dbus_config_get_activity_name(&ad->config, ad->config_item_to_update.activity_type),
- NULL);
-}
-
-void SetValuePage::updateSwitchAction(void *data, Evas_Object *obj, void *event_info)
-{
- elm_genlist_item_selected_set((Elm_Genlist_Item *)event_info, 0);
- auto ad = static_cast<SettingAccessibility *>(data);
- retm_if(ad == NULL, "Data argument is NULL");
-
- ad->actionPage_ = std::make_unique<ActionPage>(ad);
- ad->actionPage_->attachCallback(updateSwitchChooseAction, NULL);
-}
-
-void SetValuePage::updateSwitchChooseAction(SettingAccessibility *ad, const std::string &action, void *user_data)
-{
- ad->config_item_to_update.activity_type = action;
- updateGendialActionField(ad);
- elm_naviframe_item_pop(ad->md.getNaviframe()->getObject());
-}
-
-void SetValuePage::updateGendialActionField(SettingAccessibility *ad)
-{
- retm_if(ad == NULL, "Input argument is NULL");
-
- elm_genlist_clear(ad->update_accessories_action_genlist);
- addActionGendialField(ad);
-}
-
-void SetValuePage::closeUpdateAccessoriesSwitchPage(void *data, Evas_Object *obj, void *event_info)
-{
- auto ad = static_cast<SettingAccessibility *>(data);
- retm_if(ad == NULL, "Data argument is NULL");
-
- if (event_info == ad->save_object_item)
- saveAccessoriesSwitchUpdateChanges(ad);
-
- elm_naviframe_item_pop(ad->md.getNaviframe()->getObject());
-}
-
-void SetValuePage::saveAccessoriesSwitchUpdateChanges(SettingAccessibility *ad)
-{
- if (ad->us_configuration.switch_updated_cb) {
- ad->us_configuration.switch_updated_cb(ad, ad->config_item_to_update.switch_id, ad->config_item_to_update.activity_type, elm_entry_entry_get(ad->entry));
- }
-}
-
void SetValuePage::gendialRadioItemSelectedCb(void *data, Evas_Object *obj, void *event_info)
{
retm_if(event_info == NULL, "Invalid argument: event_info is NULL");
static void addRadioItemChangedCb(SettingAccessibility *ad, changeRadioItemCb cb, void *data);
static void addSwitchItemChangedCb(SettingAccessibility *ad, changeSwitchItemCb cb);
static void addListItemOptionsRequestCb(SettingAccessibility *ad, requestListItemOptionsCb cb, void *data);
- static void createUpdateAccessoriesSwitchPage(SettingAccessibility *ad);
static void syncPageWithVconf(keynode_t *node, void *user_data);
static void addRemoveSwitchPageCallback(SettingAccessibility *ad, RemoveSwitchPageCb cb, RemoveSwitchPage *data);
private:
- static void addActionGendialField(SettingAccessibility *ad);
- static void updateSwitchAction(void *data, Evas_Object *obj, void *event_info);
- static void updateSwitchChooseAction(SettingAccessibility *ad, const std::string &action, void *user_data); //TODO rename
- static void updateGendialActionField(SettingAccessibility *ad);
- static void closeUpdateAccessoriesSwitchPage(void *data, Evas_Object *obj, void *event_info);
- static void saveAccessoriesSwitchUpdateChanges(SettingAccessibility *ad); //TODO rename
static void gendialRadioItemSelectedCb(void *data, Evas_Object *obj, void *event_info);
static void gendialRadioChangeCb(void *data, Evas_Object *obj, void *event_info);
static void callRadioItemChangeCbAndPopNaviframe(GenGroupItemData *list_item);
MainData md;
Elm_Genlist_Item_Class itc_1text;
Elm_Genlist_Item_Class itc_multiline_sub;
- Evas_Object *entry;
- Evas_Object *update_accessories_action_genlist;
- Elm_Object_Item *save_object_item;
Elm_Object_Item *naviframe_it;
SetValueLayout set_value_layout;
tts_h tts;
UniversalSwitchDbusConfig config;
- UniversalSwitchConfigurationItem config_item_to_update;
UniversalSwitchConfiguration us_configuration;
int switches_to_remove_counter;
auto config_item = static_cast<UniversalSwitchConfigurationItem *>(list_item->userdata);
auto self = static_cast<SwitchesPage *>(data);
- UpdateSwitchPage::attachActionCallback(self->context_, switchUpdatedCb, self);
self->updateSwitchPage_ = std::make_unique<UpdateSwitchPage>(self->context_, config_item);
+ self->updateSwitchPage_->attachActionCallback(switchUpdatedCb, self);
}
void SwitchesPage::switchUpdatedCb(void *data, const std::string &switch_id, const std::string &switch_action, const std::string &switch_name)
#include "setting-accessibility.h"
+#include <app.h>
+
+#define GRP_SET_VALUE_UPDATE_ACCESSORIES_SWITCH "set-value-update-accessories-switch"
+#define PRT_SET_VALUE_ENTRY "set-value-entry"
+#define PRT_SET_VALUE_DESC "set-value-desc"
+#define EDJ_SET_VALUE "edje/accessibility-settings-set-value.edj"
+#define PRT_SET_VALUE_LIST "set-value-list"
+
UpdateSwitchPage::UpdateSwitchPage(SettingAccessibility *ad, UniversalSwitchConfigurationItem *config_item)
+ : context_(ad)
{
retm_if(ad == NULL, "Input parameter is NULL");
+ config_item_to_update_.activity_type = config_item->activity_type;
+ config_item_to_update_.switch_id = config_item->switch_id;
+ config_item_to_update_.user_name = config_item->user_name;
- if (strlen(config_item->provider_id.c_str()) == strlen(ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER)
- && !strncmp(config_item->provider_id.c_str(), ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER, strlen(ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER)) != 0) {
-
- ad->config_item_to_update.activity_type = config_item->activity_type;
- ad->config_item_to_update.switch_id = config_item->switch_id;
- ad->config_item_to_update.user_name = config_item->user_name;
- SetValuePage::createUpdateAccessoriesSwitchPage(ad);
+ if (config_item->provider_id == ACCESSIBILITY_UNIVERSAL_SWITCH_ACCESSORIES_SWITCH_PROVIDER) {
+ createUpdateAccessoriesSwitchPage();
} else {
- ad->actionPage_ = std::make_unique<ActionPage>(ad);
- ad->actionPage_->attachCallback(onActionUpdate, config_item);
+ actionPage_ = std::make_unique<ActionPage>(context_);
+ actionPage_->attachCallback(onActionUpdate, this);
}
}
-void UpdateSwitchPage::attachActionCallback(SettingAccessibility *ad, UniversalSwitchUpdateCb cb, void *cbData)
+void UpdateSwitchPage::attachActionCallback(UniversalSwitchUpdateCb cb, void *cbData)
{
- retm_if(ad == NULL, "Input parameter is NULL");
-
- ad->us_configuration.switch_updated_cb = cb;
- ad->us_configuration.switch_updated_cb_data = cbData;
+ switch_updated_cb = cb;
+ switch_updated_cb_data = cbData;
}
void UpdateSwitchPage::onActionUpdate(SettingAccessibility *ad, const std::string &action, void *user_data)
{
- if (ad->us_configuration.switch_updated_cb) {
- auto config_item = static_cast<UniversalSwitchConfigurationItem *>(user_data);
- ad->us_configuration.switch_updated_cb(ad->us_configuration.switch_updated_cb_data, config_item->switch_id, action, config_item->user_name);
+ auto self = static_cast<UpdateSwitchPage *>(user_data);
+ if (self->switch_updated_cb) {
+ self->switch_updated_cb(self->switch_updated_cb_data, self->config_item_to_update_.switch_id, action, self->config_item_to_update_.user_name);
+ }
+}
+
+void UpdateSwitchPage::createUpdateAccessoriesSwitchPage()
+{
+ Evas_Object *tb;
+ Elm_Object_Item *nf_it;
+ tb = elm_toolbar_add(context_->md.getNaviframe()->getObject());
+ elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_NONE);
+ evas_object_smart_callback_add(tb, "clicked", closeUpdateAccessoriesSwitchPage, this);
+ evas_object_show(tb);
+
+ elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND);
+ elm_toolbar_transverse_expanded_set(tb, EINA_TRUE);
+
+ elm_toolbar_item_append(tb, NULL, _("IDS_ACCS_UNIVERSAL_SWITCH_CANCEL"), NULL, NULL);
+ save_object_item = elm_toolbar_item_append(tb, NULL, _("IDS_ACCS_UNIVERSAL_SWITCH_SAVE"), NULL, NULL);
+
+ context_->set_value_layout.setLayout(createLayout(context_->md.getNaviframe()->getObject(), GRP_SET_VALUE_UPDATE_ACCESSORIES_SWITCH));
+ entry_ = elm_entry_add(context_->set_value_layout.getLayout());
+ elm_entry_entry_set(entry_, config_item_to_update_.user_name.c_str());
+ elm_entry_cursor_end_set(entry_);
+ evas_object_show(entry_);
+ elm_object_part_content_set(context_->set_value_layout.getLayout(), PRT_SET_VALUE_ENTRY, entry_);
+
+ elm_object_part_text_set(context_->set_value_layout.getLayout(), PRT_SET_VALUE_DESC, _("IDS_ACCS_UNIVERSAL_SWITCH_NAME"));
+
+ update_accessories_action_genlist_ = createGenlist(context_->set_value_layout.getLayout(), NULL);
+ createGendialGroupItem(update_accessories_action_genlist_, &itc_1text,
+ updateSwitchAction, this,
+ SwallowType::INVALID, 0,
+ "IDS_ACCS_UNIVERSAL_SWITCH_ACTION",
+ setting_accessibility_universal_switch_dbus_config_get_activity_name(&context_->config, config_item_to_update_.activity_type),
+ NULL);
+
+ nf_it = elm_naviframe_item_push(context_->md.getNaviframe()->getObject(), "", NULL, NULL, context_->set_value_layout.getLayout(), "tabbar/notitle");
+ elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
+ elm_object_item_part_content_set(nf_it, "tabbar", tb);
+}
+
+void UpdateSwitchPage::closeUpdateAccessoriesSwitchPage(void *data, Evas_Object *obj, void *event_info)
+{
+ auto self = static_cast<UpdateSwitchPage *>(data);
+
+ if (event_info == self->save_object_item) {
+ if (self->switch_updated_cb) {
+ self->switch_updated_cb(self->switch_updated_cb_data, self->config_item_to_update_.switch_id, self->config_item_to_update_.activity_type, elm_entry_entry_get(self->entry_));
+ }
+ }
+
+ elm_naviframe_item_pop(self->context_->md.getNaviframe()->getObject());
+}
+
+Evas_Object *UpdateSwitchPage::createLayout(Evas_Object *parent, const char *layout_grp)
+{
+ Evas_Object *layout;
+ retvm_if(parent == NULL || layout_grp == NULL, NULL, "Input parameter is NULL");
+
+ char *res_path = app_get_resource_path();
+ std::string edj_path;
+ if (res_path) {
+ edj_path = std::string{res_path} + std::string{EDJ_SET_VALUE};
+ free(res_path);
}
+
+ layout = elm_layout_add(parent);
+ elm_layout_file_set(layout, edj_path.c_str(), layout_grp);
+ evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_show(layout);
+
+
+ return layout;
+}
+
+Evas_Object *UpdateSwitchPage::createGenlist(Evas_Object *parent, const char *title)
+{
+ retvm_if(parent == NULL, NULL, "Input parameter is NULL");
+
+ Evas_Object *genlist = elm_genlist_add(parent);
+ elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+ elm_object_style_set(genlist, "dialogue");
+
+ if (title)
+ createGendialTitleItem(genlist, &itc_group_item, title);
+
+ elm_object_part_content_set(parent, PRT_SET_VALUE_LIST, genlist);
+ evas_object_show(genlist);
+
+
+ return genlist;
+}
+
+void UpdateSwitchPage::updateSwitchAction(void *data, Evas_Object *obj, void *event_info)
+{
+ elm_genlist_item_selected_set((Elm_Genlist_Item *)event_info, 0);
+ auto self = static_cast<UpdateSwitchPage *>(data);
+
+ self->actionPage_ = std::make_unique<ActionPage>(self->context_);
+ self->actionPage_->attachCallback(updateSwitchChooseAction, self);
+}
+
+void UpdateSwitchPage::updateSwitchChooseAction(SettingAccessibility *ad, const std::string &action, void *user_data)
+{
+ auto self = static_cast<UpdateSwitchPage *>(user_data);
+
+ self->config_item_to_update_.activity_type = action;
+ elm_genlist_clear(self->update_accessories_action_genlist_);
+ createGendialGroupItem(self->update_accessories_action_genlist_, &itc_1text,
+ updateSwitchAction, self,
+ SwallowType::INVALID, 0,
+ "IDS_ACCS_UNIVERSAL_SWITCH_ACTION",
+ setting_accessibility_universal_switch_dbus_config_get_activity_name(&ad->config, self->config_item_to_update_.activity_type),
+ NULL);
+ elm_naviframe_item_pop(ad->md.getNaviframe()->getObject());
}
#define UPDATE_SWITCH_PAGE_HPP
#include "SettingAccessibility.hpp"
+#include "ActionPage.hpp"
/**
* View allowing to edit existing mapping between switches and activities
{
public:
UpdateSwitchPage(SettingAccessibility *ad, UniversalSwitchConfigurationItem *config_item);
- static void attachActionCallback(SettingAccessibility *ad, UniversalSwitchUpdateCb cb, void *cbData);
+ void attachActionCallback(UniversalSwitchUpdateCb cb, void *cbData);
private:
static void onActionUpdate(SettingAccessibility *ad, const std::string &action, void *user_data);
+ void createUpdateAccessoriesSwitchPage();
+ static void closeUpdateAccessoriesSwitchPage(void *data, Evas_Object *obj, void *event_info);
+ Evas_Object *createLayout(Evas_Object *parent, const char *layout_grp);
+ Evas_Object *createGenlist(Evas_Object *parent, const char *title);
+ static void updateSwitchAction(void *data, Evas_Object *obj, void *event_info);
+ static void updateSwitchChooseAction(SettingAccessibility *ad, const std::string &action, void *user_data);
+
+ SettingAccessibility *context_ = nullptr;
+ UniversalSwitchUpdateCb switch_updated_cb = nullptr;
+ void *switch_updated_cb_data = nullptr;
+ UniversalSwitchConfigurationItem config_item_to_update_;
+ std::unique_ptr<ActionPage> actionPage_;
+ Elm_Object_Item *save_object_item = nullptr;
+ Evas_Object *entry_ = nullptr;
+ Evas_Object *update_accessories_action_genlist_ = nullptr;
};
#endif