Fixed the logic of the resizing layout
authorjc47.park <jc47.park@samsung.com>
Thu, 11 Oct 2012 04:25:06 +0000 (13:25 +0900)
committerjc47.park <jc47.park@samsung.com>
Thu, 11 Oct 2012 04:25:06 +0000 (13:25 +0900)
composer/include/email-composer.h
composer/src/email-composer-callback.c
composer/src/email-composer-contents.c
composer/src/email-composer-util.c
composer/src/email-composer.c

index cad530b..e7751eb 100755 (executable)
@@ -35,7 +35,9 @@
 
 #define COMPOSER_ICON_DIR IMGDIR
 
-#define COMPOSER_NAVI_HEIGHT 108
+#define COMPOSER_NAVI_HEIGHT 98 //108
+#define COMPOSER_IME_HEIGHT_V 444
+#define COMPOSER_IME_HEIGHT_H 316
 
 #define COMPOSER_SP_H 10
 #define COMPOSER_EDIT_FIELD_H 80
@@ -231,7 +233,6 @@ struct ug_data {
        Eina_List *popup_list;
 
        COMPOSER_ERROR_TYPE_E eComposerErrorType;
-       int ime_height;
 
        Eina_List *listOfImageUrls;
 
index 6fa5781..b9fc473 100755 (executable)
@@ -106,22 +106,19 @@ void _composer_more_button_cb(void *data, Evas_Object *obj, void *event_info)
 
        debug_log("More Button Clicked");
 
-       if (ugd->option_header_opened) {
-               if (ugd->isRotated == true) {
-                       _composer_resize_body_webview(ugd, 316);
-               } else {
-                       _composer_resize_body_webview(ugd, ugd->ime_height);
-               }
+       ugd->option_header_opened = !ugd->option_header_opened;
+
+       if (!ugd->option_header_opened) {
                elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,close", "");
        } else {
-               if (ugd->isRotated == true) {
-                       _composer_resize_body_webview(ugd, 316 + 122);
-               } else {
-                       _composer_resize_body_webview(ugd, ugd->ime_height + 122);
-               }
                elm_object_item_signal_emit(ugd->navi_item, "elm,state,optionheader,open", "");
        }
-       ugd->option_header_opened = !ugd->option_header_opened;
+       
+       if (ugd->isRotated == true) {
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_H);
+       } else {
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_V);
+       }
 
        elm_layout_sizing_eval(ugd->c_layout);
 
index b8d347e..d98f3b0 100755 (executable)
@@ -46,6 +46,9 @@ static void _composer_webkit_ime_opened_cb(void *data, Evas_Object *obj, void *e
 static void _composer_webkit_resized_cb(void *data, Evas_Object *obj, void *event_info);
 static void _composer_webview_policy_navigation_decide_cb(void *data, Evas_Object *obj, void *event_info);
 static void _composer_webview_contextmenu_customize_cb(void *data, Evas_Object *webview, void *event_info);
+static void _composer_webview_contextmenu_selected_cb(void *data, Evas_Object *webview, void *event_info);
+
+
 
 static void _changed_cb(void *data, Evas_Object *obj, void *event_info) // This callback is for showing(hiding) X marked button.
 {
@@ -323,9 +326,9 @@ void _composer_webkit_loadFinished_cb(void *data, Evas_Object *obj, void *event_
        ewk_setting_editable_link_behavior_set(ewkSetting, EWK_EDITABLE_LINK_BEHAVIOR_NEVER_LIVE);
 
        if (ugd->isRotated == true) {
-               _composer_resize_body_webview(ugd, 316);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_H);
        } else {
-               _composer_resize_body_webview(ugd, ugd->ime_height);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_V);
        }
 
        if (ugd->selected_entry == ugd->body_ewkview) {
@@ -394,7 +397,7 @@ static void _composer_webkit_focused_cb(void *data, Evas *e, Evas_Object *obj, v
        _composer_attachment_contract_items(ugd);
 
 //     ugd->bringin_timer = ecore_timer_add(0.7f, _composer_bringin_cb, ugd);
-
+       elm_layout_sizing_eval(ugd->c_layout);
        if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_SET_FOCUS, _composer_script_executed_cb, 0) == EINA_FALSE)
                debug_log("COMPOSER_JS_SET_FOCUS failed.");
 }
@@ -498,9 +501,9 @@ static void _composer_webkit_ime_opened_cb(void *data, Evas_Object *obj, void *e
 
        EmailComposerUGD *ugd = (EmailComposerUGD *)data;
        if (ugd->isRotated == true) {
-               _composer_resize_body_webview(ugd, 316);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_H);
        } else {
-               _composer_resize_body_webview(ugd, ugd->ime_height);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_V);
        }
 }
 
@@ -567,25 +570,98 @@ static void _composer_webview_contextmenu_customize_cb(void *data, Evas_Object *
 {
        debug_log("");
        int i = 0, count = 0;
+       Eina_Bool sel = EINA_FALSE, has_content = EINA_FALSE;
        Ewk_Context_Menu* contextmenu = (Ewk_Context_Menu*)event_info;
        Ewk_Context_Menu_Item* menu_item = NULL;
+       Ewk_Context_Menu_Item_Tag menu_item_tag = EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION;
 
        count = ewk_context_menu_item_count(contextmenu);
+       menu_item = ewk_context_menu_nth_item_get(contextmenu, 0);
+       menu_item_tag = ewk_context_menu_item_tag_get(menu_item);
+       debug_log("menu_item_tag : %d", menu_item_tag);
+
+       switch (menu_item_tag) {
+               case EWK_CONTEXT_MENU_ITEM_TAG_CUT: // selection
+               case EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB:
+                       sel = EINA_TRUE;
+               break;
+               case EWK_CONTEXT_MENU_ITEM_TAG_PASTE:   // no selection
+               case EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL:
+                       sel = EINA_FALSE;
+               break;
+               default:
+                       debug_log("No context menu");
+                       return;
+       }
 
        for (i = 0; i < count; i++) {
-               Ewk_Context_Menu_Item_Tag menu_item_tag = EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION;
-               menu_item = ewk_context_menu_nth_item_get(contextmenu, i);
-               if (EWK_CONTEXT_MENU_ITEM_TYPE_ACTION != ewk_context_menu_item_type_get(menu_item))
-                       continue;
-
+               menu_item = ewk_context_menu_nth_item_get(contextmenu, 0);
                menu_item_tag = ewk_context_menu_item_tag_get(menu_item);
-               debug_log("menu_item_tag : %d", menu_item_tag);
+               debug_log("menu_item_tag in for: %d", menu_item_tag);
+               if (menu_item_tag == EWK_CONTEXT_MENU_ITEM_TAG_PASTE) { // has content
+                       has_content = EINA_TRUE;
+               }
+               ewk_context_menu_item_remove(contextmenu, menu_item);
+       }
 
-               if (menu_item_tag == EWK_CONTEXT_MENU_ITEM_TAG_SEARCH_WEB) {
-                       ewk_context_menu_item_remove(contextmenu, menu_item);
+       debug_log("Sel = %d , Content = %d", sel, has_content);
+
+       if (sel == EINA_FALSE) {
+               if (has_content == EINA_FALSE) {
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_WORD, _("IDS_EMAIL_OPT_SELECT"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, _("IDS_EMAIL_OPT_SELECT_ALL"), EINA_TRUE);
+                       //ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, _("IDS_EMAIL_HEADER_SEARCH"), EINA_TRUE); // Smart search
+               } else {
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_WORD, _("IDS_EMAIL_OPT_SELECT"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_SELECT_ALL, _("IDS_EMAIL_OPT_SELECT_ALL"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_PASTE, _("IDS_EMAIL_OPT_PASTE"), EINA_TRUE);
+                       //ewk_context_menu_item_append_as_action(contextmenu, menu_item, menu_name, EINA_TRUE); // for Clipboard
+                       //ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, _("IDS_EMAIL_HEADER_SEARCH"), EINA_TRUE); // Smart search
+               }
+       } else {
+               if (has_content == EINA_FALSE) {
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_COPY, _("IDS_EMAIL_OPT_COPY"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_CUT, _("IDS_EMAIL_OPT_CUT"), EINA_TRUE);
+                       //ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, _("IDS_EMAIL_HEADER_SEARCH"), EINA_TRUE); // Smart search
+               } else {
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_COPY, _("IDS_EMAIL_OPT_COPY"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_CUT, _("IDS_EMAIL_OPT_CUT"), EINA_TRUE);
+                       ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_TAG_PASTE, _("IDS_EMAIL_OPT_PASTE"), EINA_TRUE);
+                       //ewk_context_menu_item_append_as_action(contextmenu, menu_item, menu_name, EINA_TRUE); // for Clipboard
+                       //ewk_context_menu_item_append_as_action(contextmenu, EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG, _("IDS_EMAIL_HEADER_SEARCH"), EINA_TRUE); // Smart search
                }
-               //if (ewk_context_menu_item_append_as_action(contextmenu, 10001/*CUSTOM_CONTEXT_MENU_ITEM_TEST_TAG*/, "test", EINA_TRUE) == EINA_FALSE)
-               //      debug_log("failed");
        }
 }
 
+static void _composer_webview_contextmenu_selected_cb(void *data, Evas_Object *webview, void *event_info)
+{
+       debug_log("");
+
+       EmailComposerUGD *ugd = (EmailComposerUGD *)data;
+
+       Ewk_Context_Menu_Item* menu_item = (Ewk_Context_Menu_Item*)event_info;
+       Ewk_Context_Menu_Item_Tag menu_item_tag = EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION;
+
+       debug_log("menu_item : %d", menu_item);
+       menu_item_tag = ewk_context_menu_item_tag_get(menu_item);
+       debug_log("menu_item_tag : %d", menu_item_tag);
+
+       switch (menu_item_tag) {
+       case EWK_CONTEXT_MENU_ITEM_BASE_APPLICATION_TAG : //Smart search
+       {
+               service_h service = NULL;
+               const char *keyword = NULL;
+               keyword = ewk_view_text_selection_text_get(ugd->body_ewkview);
+               debug_log("keyword : %s", keyword);
+
+               service_create(&service);
+               service_set_operation(service, SERVICE_OPERATION_SEARCH);
+               service_add_extra_data(service, "http://tizen.org/appcontrol/data/keyword", keyword);
+               service_send_launch_request(service, NULL, NULL);
+               service_destroy(service);
+       }
+       break;
+       default:
+               debug_log("Never here!");
+       }
+}
index 750d6bf..8767fb6 100755 (executable)
@@ -3442,10 +3442,16 @@ void _composer_resize_body_webview(EmailComposerUGD *ugd, int ime_height)
        evas_object_geometry_get(ugd->webkit_ly, &x, &y, &w, &h);
        debug_log(" === resize webkit_ly x:%d, y:%d, w:%d, h:%d", x, y, w, h);
 
+       if (ugd->option_header_opened == true) {
+               ime_height += 122;
+       }
+
        if (ugd->isRotated == false) {
-               debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nHeight, COMPOSER_NAVI_HEIGHT, ugd->indicator_height);
+               // Webkit should be resized after showing/hiding IME
+               debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nHeight, COMPOSER_NAVI_HEIGHT, ugd->indicator_height );
                evas_object_size_hint_min_set(ugd->webkit_ly, 0, nHeight - COMPOSER_NAVI_HEIGHT - ugd->indicator_height - ime_height);
        } else {
+               debug_log("nHeight:%d, COMPOSER_NAVI_HEIGHT:%d, indicator_height:%d", nWidth, COMPOSER_NAVI_HEIGHT, ugd->indicator_height);
                evas_object_size_hint_min_set(ugd->webkit_ly, 0, nWidth - COMPOSER_NAVI_HEIGHT - ime_height);
        }
 }
@@ -3472,7 +3478,6 @@ void _composer_input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx,
                                break;
 
                        case ECORE_IMF_INPUT_PANEL_STATE_SHOW: /* :0 */
-                               ugd->ime_height = h;
                                _composer_resize_body_webview(ugd, h);
                                break;
 
index f78eab3..786aaeb 100755 (executable)
@@ -423,7 +423,7 @@ static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *
                }
                ugd->isRotated = false;
                win_main_angle = 0;
-               _composer_resize_body_webview(ugd, ugd->ime_height);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_V);
                break;
        case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
                elm_layout_theme_set(ugd->main_layout, "layout", "application", "default");
@@ -433,8 +433,7 @@ static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *
                        ugd->option_header_opened = FALSE;
                }
                ugd->isRotated = false;
-               win_main_angle = 180;
-               _composer_resize_body_webview(ugd, ugd->ime_height);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_V);
                break;
        case UG_EVENT_ROTATE_LANDSCAPE:
                elm_layout_theme_set(ugd->main_layout, "layout", "application", "noindicator");
@@ -445,7 +444,7 @@ static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *
                }
                ugd->isRotated = true;
                win_main_angle = 270;
-               _composer_resize_body_webview(ugd, 316);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_H);
                break;
        case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
                elm_layout_theme_set(ugd->main_layout, "layout", "application", "noindicator");
@@ -455,8 +454,7 @@ static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *
                        ugd->option_header_opened = FALSE;
                }
                ugd->isRotated = true;
-               win_main_angle = 90;
-               _composer_resize_body_webview(ugd, 316);
+               _composer_resize_body_webview(ugd, COMPOSER_IME_HEIGHT_H);
                break;
        case UG_EVENT_REGION_CHANGE:
                break;
@@ -503,8 +501,6 @@ static void on_event(ui_gadget_h ug, enum ug_event event, service_h data, void *
                elm_win_rotation_with_resize_set(ugd->popup_win, win_main_angle);
        }
 
-       elm_win_rotation_with_resize_set(ugd->win_main, win_main_angle);
-
 //     ugd->bringin_timer = ecore_timer_add(0.1f, _composer_bringin_cb, ugd);
 }
 
@@ -1014,7 +1010,6 @@ static void _composer_init_data(void *data)
        ugd->account_info = (EmailComposerAccount *) calloc(1, sizeof(EmailComposerAccount));
        memset(ugd->account_info, 0x00, sizeof(EmailComposerMail));
 
-       ugd->ime_height = 444;
        ugd->priority_option = EMAIL_MAIL_PRIORITY_NORMAL;
 }