/*
* Declaration for static functions
*/
-#define RECIPIENT_PADDING_MIN_MAX_WIDTH 15
static void _recipient_entry_layout_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
static void _recipient_notify_invalid_recipient(EmailComposerView *view, MBE_VALIDATION_ERROR err);
static MBE_VALIDATION_ERROR _recipient_mbe_validate_email_address(EmailComposerView *view, Evas_Object *obj, char *email_address);
-static void _recipient_from_button_update_text(EmailComposerView *view, email_account_t *account);
-static void _recipient_from_ctxpopup_move_list(EmailComposerView *view);
-static void _recipient_from_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info);
-static Eina_Bool _recipient_from_ctxpopup_show(void *data);
-static void _recipient_from_ctxpopup_resized_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _recipient_from_ctxpopup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void _recipient_from_ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info);
-static void _recipient_from_button_clicked_cb(void *data, Evas_Object *obj, void *event_info);
+static void _recipient_from_hoversel_update_selected_address(EmailComposerView *view, email_account_t *account);
+static void _recipient_from_hoversel_expanded_cb(void *data, Evas_Object *obj, void *event_info);
+static void _recipient_from_hoversel_dismissed_cb(void *data, Evas_Object *obj, void *event_info);
+static void _recipient_from_hoversel_back_cb(void *data, Evas_Object *obj, void *event_info);
+static void _recipient_from_hoversel_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
+static void _recipient_from_hoversel_item_select_cb(void *data, Evas_Object *obj, void *event_info);
static void _recipient_account_change_size_exceeded_cb(void *data, Evas_Object *obj, void *event_info);
+static void _recipient_create_from_hoversel(EmailComposerView *view);
static Evas_Object *_recipient_create_contact_button(EmailComposerView *view, Evas_Object *parent);
static Evas_Object *_recipient_create_mbe(Evas_Object *parent, COMPOSER_RECIPIENT_TYPE_E recp_type, EmailComposerView *view);
static void _recipient_create_editfield(Evas_Object *parent, EmailComposerView *view, Eina_Bool is_editable, email_editfield_t *editfield);
static Evas_Object *_recipient_create_entry_label(Evas_Object *parent, COMPOSER_RECIPIENT_TYPE_E recp_type, EmailComposerView *view);
static Evas_Object *_recipient_create_layout(Evas_Object *parent, const char *group);
-static void _recipient_ctxpopup_back_cb(void *data, Evas_Object *obj, void *event_info);
static Eina_Bool _recipient_timer_duplicate_toast_cb(void *data);
static Evas_Object *_recipient_get_mbe_with_entry(void *data, Evas_Object *entry);
return ret;
}
+static void _recipient_create_from_hoversel(EmailComposerView *view)
+{
+ debug_enter();
+
+ Evas_Object *box = composer_util_create_box(view->recp_from_layout);
+ elm_box_horizontal_set(box, EINA_TRUE);
+
+ Evas_Object *from_label = _recipient_create_entry_label(box, COMPOSER_RECIPIENT_TYPE_FROM, view);
+
+ Evas_Object *hoversel_layout = elm_layout_add(box);
+ elm_layout_file_set(hoversel_layout, email_get_composer_theme_path(), "ec/recipient/layout/from");
+ evas_object_size_hint_weight_set(hoversel_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(hoversel_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ evas_object_show(hoversel_layout);
+
+ Evas_Object *hoversel = elm_hoversel_add(hoversel_layout);
+ elm_hoversel_horizontal_set(hoversel, EINA_FALSE);
+ elm_hoversel_hover_parent_set(hoversel, view->base.module->win);
+ elm_object_part_content_set(hoversel_layout, "ec.swallow.content", hoversel);
-static void _recipient_from_button_update_text(EmailComposerView *view, email_account_t *account)
+ elm_box_pack_end(box, from_label);
+ elm_box_pack_end(box, hoversel_layout);
+ elm_object_part_content_set(view->recp_from_layout, "ec.swallow.content", box);
+
+ view->recp_from_label = from_label;
+ view->recp_from_hoversel = hoversel;
+
+ evas_object_smart_callback_add(hoversel, "expanded", _recipient_from_hoversel_expanded_cb, view);
+ evas_object_smart_callback_add(hoversel, "dismissed", _recipient_from_hoversel_dismissed_cb, view);
+ evas_object_event_callback_add(hoversel, EVAS_CALLBACK_DEL, _recipient_from_hoversel_del_cb, view);
+
+ debug_leave();
+}
+
+static void _recipient_from_hoversel_update_selected_address(EmailComposerView *view, email_account_t *account)
{
debug_enter();
retm_if(!view, "Invalid parameter: data is NULL!");
retm_if(!account, "account is NULL!");
- char from_display_name[EMAIL_BUFF_SIZE_1K] = { 0, };
- if (account->account_name && (g_strcmp0(account->account_name, account->user_email_address) != 0)) {
- snprintf(from_display_name, sizeof(from_display_name), "%s <%s>", account->account_name, account->user_email_address);
- } else {
- snprintf(from_display_name, sizeof(from_display_name), "%s", account->user_email_address);
+ char *markup_name = elm_entry_utf8_to_markup(account->user_email_address);
+ elm_object_text_set(view->recp_from_hoversel, markup_name);
+ FREE(markup_name);
+
+ debug_leave();
+}
+
+static void _resipient_from_hoversel_clear_address_list(EmailComposerView *view)
+{
+ debug_enter();
+
+ if (elm_hoversel_expanded_get(view->recp_from_hoversel)) {
+ elm_hoversel_hover_end(view->recp_from_hoversel);
}
- EmailRecpInfo *ri = composer_util_recp_make_recipient_info_with_display_name(account->user_email_address, from_display_name);
- if (ri) {
- char *markup_name = elm_entry_utf8_to_markup(ri->display_name);
- elm_object_part_text_set(view->recp_from_btn, "elm.text", markup_name);
- FREE(markup_name);
+ fromListItemData *item_data = NULL;
+ Eina_List *items_list = (Eina_List *)elm_hoversel_items_get(view->recp_from_hoversel);
+ Eina_List *list = NULL;
- EmailAddressInfo *ai = NULL;
- EINA_LIST_FREE(ri->email_list, ai) {
- FREE(ai);
- }
- g_free(ri->display_name);
- free(ri);
+ EINA_LIST_FOREACH(items_list, list, item_data) {
+ FREE(item_data);
}
+ elm_hoversel_clear(view->recp_from_hoversel);
debug_leave();
}
-static void _recipient_from_ctxpopup_move_list(EmailComposerView *view)
+static void _resipient_from_hoversel_fill_address_list(EmailComposerView *view)
{
debug_enter();
- int pos = -1;
- Evas_Coord x = 0, y = 0, w = 0, h = 0;
- Evas_Coord root_win_width = 0, root_win_height = 0;
-
- pos = elm_win_rotation_get(view->base.module->win);
- evas_object_geometry_get(view->recp_from_btn, &x, &y, &w, &h);
- elm_win_screen_size_get(view->base.module->win, NULL, NULL, &root_win_width, &root_win_height);
+ int index;
+ for (index = 0; index < view->account_info->account_count; index++) {
+ fromListItemData *it = (fromListItemData *)malloc(sizeof(fromListItemData));
- switch (pos) {
- case 0:
- case 180:
- w = root_win_width - x;
- evas_object_move(view->recp_from_ctxpopup, (x / 2) + (w / 2), y + h);
- break;
- case 90:
- case 270:
- w = root_win_height - x;
- evas_object_move(view->recp_from_ctxpopup, x + (w / 2), y + h);
- break;
- default:
+ if (!it) {
+ debug_error("it is NULL - allocation memory failed");
break;
+ }
+
+ it->index = index;
+ it->view = view;
+ it->item = elm_hoversel_item_add(view->recp_from_hoversel,
+ view->account_info->account_list[index].user_email_address,
+ NULL,
+ ELM_ICON_NONE,
+ _recipient_from_hoversel_item_select_cb,
+ it);
}
- DELETE_IDLER_OBJECT(view->idler_show_ctx_popup);
- view->idler_show_ctx_popup = ecore_idler_add(_recipient_from_ctxpopup_show, view);
debug_leave();
}
-static Eina_Bool _recipient_from_ctxpopup_show(void *data)
+static void _recipient_from_hoversel_expanded_cb(void *data, Evas_Object *obj, void *event_info)
{
-
debug_enter();
- EmailComposerView *view = (EmailComposerView *)data;
-
- view->idler_show_ctx_popup = NULL;
+ retm_if(!data, "Invalid parameter: data is NULL!");
- evas_object_show(view->recp_from_ctxpopup);
+ EmailComposerView *view = (EmailComposerView *)data;
+ eext_object_event_callback_add(view->recp_from_hoversel, EEXT_CALLBACK_BACK, _recipient_from_hoversel_back_cb, view);
debug_leave();
- return ECORE_CALLBACK_CANCEL;
}
-static void _recipient_from_ctxpopup_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
+static void _recipient_from_hoversel_dismissed_cb(void *data, Evas_Object *obj, void *event_info)
{
debug_enter();
-
retm_if(!data, "Invalid parameter: data is NULL!");
EmailComposerView *view = (EmailComposerView *)data;
-
- evas_object_del(view->recp_from_ctxpopup);
- view->recp_from_ctxpopup = NULL;
- composer_recipient_from_ctxpopup_item_delete(view);
+ eext_object_event_callback_del(view->recp_from_hoversel, EEXT_CALLBACK_BACK, _recipient_from_hoversel_back_cb);
composer_util_focus_set_focus_with_idler(view, view->selected_widget);
debug_leave();
}
-static void _recipient_from_ctxpopup_resized_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void _recipient_from_hoversel_back_cb(void *data, Evas_Object *obj, void *event_info)
{
debug_enter();
+ retm_if(!data, "Invalid parameter: data is NULL!");
EmailComposerView *view = (EmailComposerView *)data;
-
- _recipient_from_ctxpopup_move_list(view);
+ elm_hoversel_hover_end(view->recp_from_hoversel);
debug_leave();
}
-static void _recipient_from_ctxpopup_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
+static void _recipient_from_hoversel_del_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
debug_enter();
+ retm_if(!data, "Invalid parameter: data is NULL!");
EmailComposerView *view = (EmailComposerView *)data;
-
- /* XXX; check this. deletion for dismissed can be deleted. */
- evas_object_smart_callback_del(view->recp_from_ctxpopup, "dismissed", _recipient_from_ctxpopup_dismissed_cb);
- evas_object_event_callback_del_full(view->base.module->win, EVAS_CALLBACK_RESIZE, _recipient_from_ctxpopup_resized_cb, view);
-
+ _resipient_from_hoversel_clear_address_list(view);
+ view->recp_from_hoversel = NULL;
debug_leave();
}
-static void _recipient_from_ctxpopup_item_select_cb(void *data, Evas_Object *obj, void *event_info)
+static void _recipient_from_hoversel_item_select_cb(void *data, Evas_Object *obj, void *event_info)
{
debug_enter();
+ retm_if(!data, "Invalid parameter: data is NULL!");
fromListItemData *it = (fromListItemData *)data;
retm_if(!it, "Invalid parameter: item data is NULL!");
EmailComposerView *view = (EmailComposerView *)it->view;
- Eina_Bool is_popup_displayed = EINA_FALSE;
if (view->account_info->selected_account->account_id != view->account_info->account_list[it->index].account_id) {
char *previously_selected_email = view->account_info->selected_account->user_email_address;
/* Only display notification popup to user and allowing the account switch and disabling send button */
if (composer_util_is_max_sending_size_exceeded(view)) {
composer_attachment_launch_attachment_error_popup(COMPOSER_ERROR_ATTACHMENT_MAX_SIZE_EXCEEDED, _recipient_account_change_size_exceeded_cb, view);
- is_popup_displayed = EINA_TRUE;
}
composer_util_modify_send_button(view);
#endif
/* Change from text */
- _recipient_from_button_update_text(view, view->account_info->selected_account);
+ _recipient_from_hoversel_update_selected_address(view, view->account_info->selected_account);
composer_attachment_ui_group_update_text(view);
} else {
debug_log("No need to change from address! selected account is the same as previous one!");
}
- if (!is_popup_displayed)
- _recipient_from_ctxpopup_dismissed_cb(view, NULL, NULL);
-
debug_leave();
}
EmailComposerView *view = (EmailComposerView *)data;
- _recipient_from_ctxpopup_dismissed_cb(view, NULL, NULL);
+ _recipient_from_hoversel_dismissed_cb(view, NULL, NULL);
composer_util_popup_response_cb(view, NULL, NULL);
debug_leave();
}
-static void _recipient_ctxpopup_back_cb(void *data, Evas_Object *obj, void *event_info)
-{
- if (obj) {
- elm_ctxpopup_dismiss(obj);
- }
-}
-
-static void _recipient_from_button_clicked_cb(void *data, Evas_Object *obj, void *event_info)
-{
- debug_enter();
-
- retm_if(!data, "Invalid parameter: data is NULL!");
-
- EmailComposerView *view = (EmailComposerView *)data;
-
- if (view->recp_from_ctxpopup) {
- _recipient_from_ctxpopup_dismissed_cb(view, NULL, NULL);
- return;
- }
-
- Evas_Object *ctxpopup = elm_ctxpopup_add(view->base.module->navi);
- // TODO: Remove comment when "dropdown/list" style will be available
- //elm_object_style_set(ctxpopup, "dropdown/list");
- elm_ctxpopup_auto_hide_disabled_set(ctxpopup, EINA_TRUE);
- elm_ctxpopup_direction_priority_set(ctxpopup, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN, ELM_CTXPOPUP_DIRECTION_UNKNOWN);
-
- Eina_List *item_list = NULL;
- int index;
- for (index = 0; index < view->account_info->account_count; index++) {
- fromListItemData *it = (fromListItemData *)malloc(sizeof(fromListItemData));
- if (!it) {
- DELETE_EVAS_OBJECT(ctxpopup);
- debug_error("it is NULL - allocation memory failed");
- return;
- }
- it->index = index;
- it->view = view;
- it->item = elm_ctxpopup_item_append(ctxpopup, view->account_info->account_list[index].user_email_address, NULL, _recipient_from_ctxpopup_item_select_cb, it);
- item_list = eina_list_append(item_list, it);
- }
-
- evas_object_smart_callback_add(ctxpopup, "dismissed", _recipient_from_ctxpopup_dismissed_cb, view);
- evas_object_event_callback_add(ctxpopup, EVAS_CALLBACK_DEL, _recipient_from_ctxpopup_del_cb, view);
- eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_BACK, _recipient_ctxpopup_back_cb, NULL);
- eext_object_event_callback_add(ctxpopup, EEXT_CALLBACK_MORE, _recipient_ctxpopup_back_cb, NULL);
- evas_object_event_callback_add(view->base.module->win, EVAS_CALLBACK_RESIZE, _recipient_from_ctxpopup_resized_cb, view);
-
- view->recp_from_item_list = item_list;
- view->recp_from_ctxpopup = ctxpopup;
-
- _recipient_from_ctxpopup_move_list(view);
-
- debug_leave();
-}
-
static Evas_Object *_recipient_create_contact_button(EmailComposerView *view, Evas_Object *parent)
{
email_profiling_begin(_recipient_create_contact_button);
email_profiling_end(composer_recipient_update_bcc_detail);
}
-void composer_recipient_update_from_detail(void *data, Evas_Object *parent)
+void composer_recipient_update_from_detail(EmailComposerView *view)
{
email_profiling_begin(composer_recipient_update_from_detail);
debug_enter();
- EmailComposerView *view = (EmailComposerView *)data;
-
- Evas_Object *box = composer_util_create_box(parent);
- Evas_Object *label = _recipient_create_entry_label(box, COMPOSER_RECIPIENT_TYPE_FROM, view);
-
- Evas_Object *layout = elm_layout_add(box);
- elm_layout_file_set(layout, email_get_composer_theme_path(), "ec/recipient/layout/from");
- evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(layout);
-
- Evas_Object *btn = elm_button_add(layout);
- elm_object_style_set(btn, "dropdown");
- evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(btn, "clicked", _recipient_from_button_clicked_cb, view);
- evas_object_show(btn);
-
- elm_object_part_content_set(layout, "ec.swallow.content", btn);
-
- elm_box_horizontal_set(box, EINA_TRUE);
- elm_box_pack_end(box, label);
- elm_box_pack_end(box, layout);
- elm_object_part_content_set(parent, "ec.swallow.content", box);
-
- view->recp_from_btn = btn;
- view->recp_from_label = label;
+ if (!view->recp_from_hoversel) {
+ _recipient_create_from_hoversel(view);
+ } else {
+ _resipient_from_hoversel_clear_address_list(view);
+ }
- _recipient_from_button_update_text(view, view->account_info->original_account);
+ _resipient_from_hoversel_fill_address_list(view);
+ _recipient_from_hoversel_update_selected_address(view, view->account_info->original_account);
debug_leave();
email_profiling_end(composer_recipient_update_from_detail);
}
-void composer_recipient_from_ctxpopup_item_delete(EmailComposerView *view)
-{
- debug_enter();
-
- Eina_List *list = view->recp_from_item_list;
- fromListItemData *item_data = NULL;
-
- EINA_LIST_FREE(list, item_data) {
- FREE(item_data);
- }
- view->recp_from_item_list = NULL;
-
- debug_leave();
-}
-
void composer_recipient_show_hide_cc_field(EmailComposerView *view, Eina_Bool to_be_showed)
{
debug_enter();