TizenRefApp-6856 [Email] Change composing of new email to not use body (use editable... 13/83013/1
authorIgor Nazarov <i.nazarov@samsung.com>
Mon, 8 Aug 2016 16:48:27 +0000 (19:48 +0300)
committerIgor Nazarov <i.nazarov@samsung.com>
Mon, 8 Aug 2016 16:48:27 +0000 (19:48 +0300)
Change-Id: I9c55e6ea91ac07f8a37a8192013bf61dd073c9d2

modules/composer/inc/email-composer-js.h
modules/composer/src/email-composer-initial-data.c
modules/composer/src/email-composer-webkit.c
res/misc/email-composer.css
res/misc/email-composer.js

index d2e21ad..b275df9 100644 (file)
@@ -57,7 +57,6 @@
 #define EC_TAG_SIGNATURE_DEFAULT EC_TAG_DIV_DIR
 #define EC_TAG_SIGNATURE_TEXT EC_TAG_DIV_DIR""EC_TAG_DIV_DIR""EC_TAG_DIV_DIR"<div dir='auto' style='font-size: 14px; color: rgba(%d, %d, %d, %d);'>%s"EC_TAG_DIV_F
 #define EC_TAG_BODY_CSS_START "<body class='css-body'>\n"
-#define EC_TAG_BODY_ORIGINAL_MESSAGE_START "<body class='css-body-IncludeOriginalMessage'>\n"
 #define EC_TAG_BODY_END "</body>\n"
 #define EC_TAG_HTML_END "</html>\n"
 
        "<div id='"EC_NAME_ORIGINAL_MESSAGE_BAR_CHECKBOX_ICON"' class='checkicon'>" \
        EC_TAG_DIV_F""EC_TAG_DIV_F""EC_TAG_DIV_F""EC_TAG_DIV_F""EC_TAG_DIV_F
 
-#define EC_JS_ENABLE_EDITABLE_BODY     "document.body.contentEditable='true'; void 0;"
-#define EC_JS_ENABLE_EDITABLE_DIVS \
-       "document.getElementById('"EC_NAME_NEW_MESSAGE"').contentEditable=\"true\";" \
+#define EC_JS_ENABLE_EDITABLE_DIV      "document.getElementById('"EC_NAME_NEW_MESSAGE"').contentEditable=\"true\";"
+#define EC_JS_ENABLE_EDITABLE_DIVS EC_JS_ENABLE_EDITABLE_DIV \
        "document.getElementById('"EC_NAME_ORIGINAL_MESSAGE_BAR"').contentEditable=\"false\";" \
        "document.getElementById('"EC_NAME_ORG_MESSAGE"').contentEditable=\"true\"; void 0;"
 
-#define EC_JS_SET_FOCUS                                        "document.body.focus(); void 0;"
-#define EC_JS_SET_UNFOCUS                              "document.body.blur(); void 0;"
 #define EC_JS_SET_FOCUS_NEW_MESSAGE            "document.getElementById('"EC_NAME_NEW_MESSAGE"').focus(); void 0;"
 #define EC_JS_SET_UNFOCUS_NEW_MESSAGE  "document.getElementById('"EC_NAME_NEW_MESSAGE"').blur(); void 0;"
 #define EC_JS_SET_FOCUS_ORG_MESSAGE            "document.getElementById('"EC_NAME_ORG_MESSAGE"').focus(); void 0;"
@@ -95,7 +91,6 @@
 #define EC_JS_UPDATE_TEXT_TO_ORIGINAL_MESSAGE_BAR "UpdateOriginalMessageText(\"%s\");"
 
 #define EC_JS_INSERT_ORIGINAL_MAIL_INFO "InsertOriginalMailInfo(\"%s\");"
-#define EC_JS_INSERT_SIGNATURE "InsertSignature(\"%s\");"
 #define EC_JS_INSERT_SIGNATURE_TO_NEW_MESSAGE "InsertSignatureTo(\""EC_NAME_NEW_MESSAGE"\", \"%s\");"
 
 #define EC_JS_UPDATE_COLOR_OF_ORG_MESSAGE_BAR "UpdateBGColorTo(\""EC_NAME_ORIGINAL_MESSAGE_BAR"\", %d, %d, %d, %d);"
index 71f2c0d..fef2f86 100644 (file)
@@ -728,7 +728,7 @@ static char *_initial_data_get_mail_body(EmailComposerView *view)
 
                        if (body_document) {
                                char *temp_body = body_document;
-                               body_document = g_strconcat(EC_TAG_BODY_CSS_START, temp_body, EC_TAG_BODY_END, NULL);
+                               body_document = g_strconcat(EC_TAG_BODY_CSS_START, EC_TAG_NEW_MSG_START, temp_body, EC_TAG_NEW_MSG_END, EC_TAG_BODY_END, NULL);
                                g_free(temp_body);
                        }
                }
@@ -737,7 +737,7 @@ static char *_initial_data_get_mail_body(EmailComposerView *view)
                        if (view->new_mail_info->mail_data->file_path_plain) {
                                current_content = (char *)email_get_parse_plain_text(view->new_mail_info->mail_data->file_path_plain, STR_LEN(view->new_mail_info->mail_data->file_path_plain));
                                if (current_content) {
-                                       body_document = g_strconcat(EC_TAG_BODY_CSS_START, current_content, EC_TAG_BODY_END, NULL);
+                                       body_document = g_strconcat(EC_TAG_BODY_CSS_START, EC_TAG_NEW_MSG_START, current_content, EC_TAG_NEW_MSG_END, EC_TAG_BODY_END, NULL);
                                }
                                free(view->new_mail_info->mail_data->file_path_plain);
                                view->new_mail_info->mail_data->file_path_plain = NULL;
@@ -748,14 +748,14 @@ static char *_initial_data_get_mail_body(EmailComposerView *view)
                        original_message_bar = _initial_data_body_get_original_message_bar_tags(view);
 
                        if (parent_content) {
-                               body_document = g_strconcat(EC_TAG_BODY_ORIGINAL_MESSAGE_START, EC_TAG_NEW_MSG_START, EC_TAG_NEW_MSG_END, original_message_bar, EC_TAG_ORG_MSG_START, parent_content, EC_TAG_ORG_MSG_END, EC_TAG_BODY_END, NULL);
+                               body_document = g_strconcat(EC_TAG_BODY_CSS_START, EC_TAG_NEW_MSG_START, EC_TAG_NEW_MSG_END, original_message_bar, EC_TAG_ORG_MSG_START, parent_content, EC_TAG_ORG_MSG_END, EC_TAG_BODY_END, NULL);
                        }
                }
        }
 
        if (!body_document) {
                /* html_document will be freed on the place that this functions returned. */
-               body_document = g_strconcat(EC_TAG_BODY_CSS_START, EC_TAG_BODY_END, NULL);
+               body_document = g_strconcat(EC_TAG_BODY_CSS_START, EC_TAG_NEW_MSG_START, EC_TAG_NEW_MSG_END, EC_TAG_BODY_END, NULL);
        }
 
        char html_meta_info[EC_HTML_META_INFO_SIZE];
index 8164e53..e00bc2d 100644 (file)
@@ -352,8 +352,8 @@ static void _webkit_js_execute_get_initial_html_content_cb(Evas_Object *obj, con
                        debug_error("EC_JS_ENABLE_EDITABLE_DIVS failed!");
                }
        } else {
-               if (!ewk_view_script_execute(ewk_view, EC_JS_ENABLE_EDITABLE_BODY, _webkit_js_execute_set_focus_cb, (void *)view)) {
-                       debug_error("EC_JS_ENABLE_EDITABLE_BODY failed!");
+               if (!ewk_view_script_execute(ewk_view, EC_JS_ENABLE_EDITABLE_DIV, _webkit_js_execute_set_focus_cb, (void *)view)) {
+                       debug_error("EC_JS_ENABLE_EDITABLE_DIV failed!");
                }
        }
 
@@ -462,12 +462,7 @@ static void _ewk_view_load_nonemptylayout_finished_cb(void *data, Evas_Object *o
                char *to_be_inserted_signature = NULL;
                char *signature = composer_initial_data_body_make_signature_markup(view);
 
-               if (((view->composer_type == RUN_COMPOSER_REPLY || view->composer_type == RUN_COMPOSER_REPLY_ALL) && view->account_info->original_account->options.reply_with_body) ||
-                       (view->composer_type == RUN_COMPOSER_FORWARD) || (view->composer_type == RUN_COMPOSER_FORWARD_ALL)) {
-                       to_be_inserted_signature = g_strdup_printf(EC_JS_INSERT_SIGNATURE_TO_NEW_MESSAGE, signature);
-               } else {
-                       to_be_inserted_signature = g_strdup_printf(EC_JS_INSERT_SIGNATURE, signature);
-               }
+               to_be_inserted_signature = g_strdup_printf(EC_JS_INSERT_SIGNATURE_TO_NEW_MESSAGE, signature);
 
                if (!ewk_view_script_execute(obj, to_be_inserted_signature, _webkit_js_execute_insert_signature_cb, (void *)view)) {
                        debug_warning("EC_JS_INSERT_SIGNATURE failed.");
@@ -538,11 +533,8 @@ static void _ewk_view_handle_user_event(EmailComposerView *view, const char *eve
                        if (!ewk_view_script_execute(view->ewk_view, buf, NULL, (void *)view)) {
                                debug_error("EC_JS_UPDATE_COLOR_OF_CHECKBOX failed.");
                        }
-                       /* Not to move the focus to new meesage div when focused ui is enabled. */
-                       if (!elm_win_focus_highlight_enabled_get(view->base.module->win) && !view->is_focus_on_new_message_div) {
-                               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_NEW_MESSAGE, NULL, view) == EINA_FALSE) {
-                                       debug_error("EC_JS_SET_FOCUS_NEW_MESSAGE is failed!");
-                               }
+                       if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_NEW_MESSAGE, NULL, view) == EINA_FALSE) {
+                               debug_error("EC_JS_SET_FOCUS_NEW_MESSAGE is failed!");
                        }
                        edje_object_signal_emit(_EDJ(view->composer_layout), "ec,action,clicked,layout", "");
                } else if (g_str_has_prefix(event, COMPOSER_EVENT_NEW_MESSAGE_DIV_FOCUSED)) {
@@ -821,19 +813,13 @@ void composer_webkit_blur_webkit_focus(void *data)
 
        EmailComposerView *view = (EmailComposerView *)data;
 
-       if (view->with_original_message) {
-               if (view->is_focus_on_new_message_div) {
-                       if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_UNFOCUS_NEW_MESSAGE, NULL, view) == EINA_FALSE) {
-                               debug_error("EC_JS_SET_UNFOCUS_NEW_MESSAGE is failed!");
-                       }
-               } else {
-                       if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_UNFOCUS_ORG_MESSAGE, NULL, view) == EINA_FALSE) {
-                               debug_error("EC_JS_SET_UNFOCUS_ORG_MESSAGE is failed!");
-                       }
+       if (view->is_focus_on_new_message_div) {
+               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_UNFOCUS_NEW_MESSAGE, NULL, view) == EINA_FALSE) {
+                       debug_error("EC_JS_SET_UNFOCUS_NEW_MESSAGE is failed!");
                }
        } else {
-               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_UNFOCUS, NULL, view) == EINA_FALSE) {
-                       debug_error("EC_JS_SET_UNFOCUS is failed!");
+               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_UNFOCUS_ORG_MESSAGE, NULL, view) == EINA_FALSE) {
+                       debug_error("EC_JS_SET_UNFOCUS_ORG_MESSAGE is failed!");
                }
        }
 
@@ -893,19 +879,13 @@ void composer_webkit_set_focus_to_webview_with_js(void *data)
 
        EmailComposerView *view = (EmailComposerView *)data;
 
-       if (view->with_original_message) {
-               if (view->is_focus_on_new_message_div) {
-                       if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_NEW_MESSAGE, NULL, NULL) == EINA_FALSE) {
-                               debug_error("EC_JS_SET_FOCUS_NEW_MESSAGE is failed!");
-                       }
-               } else {
-                       if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_ORG_MESSAGE, NULL, NULL) == EINA_FALSE) {
-                               debug_error("EC_JS_SET_FOCUS_ORG_MESSAGE is failed!");
-                       }
+       if (view->is_focus_on_new_message_div) {
+               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_NEW_MESSAGE, NULL, NULL) == EINA_FALSE) {
+                       debug_error("EC_JS_SET_FOCUS_NEW_MESSAGE is failed!");
                }
        } else {
-               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS, NULL, NULL) == EINA_FALSE) {
-                       debug_error("EC_JS_SET_FOCUS is failed!");
+               if (ewk_view_script_execute(view->ewk_view, EC_JS_SET_FOCUS_ORG_MESSAGE, NULL, NULL) == EINA_FALSE) {
+                       debug_error("EC_JS_SET_FOCUS_ORG_MESSAGE is failed!");
                }
        }
 
index 908aaf4..9430258 100644 (file)
@@ -24,23 +24,6 @@ html {
 }
 
 .css-body {
-       margin-top:8px !important;
-       margin-bottom:8px !important;
-       margin-left:10px !important;
-       margin-right:10px !important;
-       width: auto !important;
-       height: auto !important;
-       font-size: 16px !important; /* 16px is default font-size in webkit */
-       font-family:Tizen !important;
-       font-weight: 400 !important;
-       text-align: initial !important; /* initial: For LTR, left. For RTL, right */
-       background-color:#ffffff !important;
-       overflow-x: auto;
-       overflow-y: hidden;
-       word-wrap: break-word;
-}
-
-.css-body-IncludeOriginalMessage {
        margin-top:0px !important;
        margin-bottom:0px !important;
        margin-left:0px !important;
index 9de15a8..c1f0440 100644 (file)
@@ -373,7 +373,6 @@ function ImageLayer() {
        function initialize() {
                element_ = document.createElement("DIV");
                element_.style.cssText = "position: absolute; pointer-events: none; display: none;";
-               element_.className = "email-composer-image-layer";
                document.body.appendChild(element_);
 
                var overlay = document.createElement("DIV");
@@ -689,23 +688,20 @@ function InitializeEmailComposer(elmScaleSize, resDirUri) {
                if (originalMessageBarCheckbox) {
                        originalMessageBarCheckbox.addEventListener('keydown', function () { OnkeyDown_Checkbox(this, event); }, false);
                }
+       }
 
-               var newMessage = document.getElementById(G_NAME_NEW_MESSAGE);
-               if (newMessage) {
-                       newMessage.addEventListener('focus', function () { OnFocus_NewMessageDIV(event); }, false);
-                       newMessage.addEventListener('paste', function () { OnPaste(this, event); }, false);
-                       newMessage.addEventListener('keydown', function () { OnKeyDown(this, event); }, false);
-               }
+       var newMessage = document.getElementById(G_NAME_NEW_MESSAGE);
+       if (newMessage) {
+               newMessage.addEventListener('focus', function () { OnFocus_NewMessageDIV(event); }, false);
+               newMessage.addEventListener('paste', function () { OnPaste(this, event); }, false);
+               newMessage.addEventListener('keydown', function () { OnKeyDown(this, event); }, false);
+       }
 
-               var originalMessage = document.getElementById(G_NAME_ORG_MESSAGE);
-               if (originalMessage) {
-                       originalMessage.addEventListener('focus', function () { OnFocus_OrgMessageDIV(event); }, false);
-                       originalMessage.addEventListener('paste', function () { OnPaste(this, event); }, false);
-                       originalMessage.addEventListener('keydown', function () { OnKeyDown(this, event); }, false);
-               }
-       } else {
-               document.body.addEventListener('paste', function () { OnPaste(this, event); }, false);
-               document.body.addEventListener('keydown', function () { OnKeyDown(this, event); }, false);
+       var originalMessage = document.getElementById(G_NAME_ORG_MESSAGE);
+       if (originalMessage) {
+               originalMessage.addEventListener('focus', function () { OnFocus_OrgMessageDIV(event); }, false);
+               originalMessage.addEventListener('paste', function () { OnPaste(this, event); }, false);
+               originalMessage.addEventListener('keydown', function () { OnKeyDown(this, event); }, false);
        }
 
        g_imageLayer = new ImageLayer();
@@ -885,13 +881,6 @@ function InsertOriginalMailInfo(mail_info) {
        orgMessageDiv.insertBefore(mailInfoDiv, orgMessageDiv.firstChild);
 }
 
-function InsertSignature(signature) {
-       utils.log(arguments.callee.name + "()");
-       var signatureDiv = document.createElement("div");
-       signatureDiv.innerHTML = signature;
-       document.body.appendChild(signatureDiv);
-}
-
 function InsertSignatureTo(div_id, signature) {
        utils.log(arguments.callee.name + "()");
        var signatureDiv = document.createElement("div");
@@ -967,7 +956,11 @@ function GetComposedHtmlContents(inlineImageSrcs) {
        utils.log(arguments.callee.name + "()");
 
        var srcNewMsg = document.getElementById(G_NAME_NEW_MESSAGE);
-       var srcOrgMsg = srcNewMsg && document.getElementById(G_NAME_ORG_MESSAGE);
+       if (!srcNewMsg) {
+               return "";
+       }
+
+       var srcOrgMsg = document.getElementById(G_NAME_ORG_MESSAGE);
 
        var dstContent = document.createElement("html");
 
@@ -975,18 +968,9 @@ function GetComposedHtmlContents(inlineImageSrcs) {
        var dstBody;
 
        if (!srcOrgMsg || (IsCheckboxChecked() != "true")) {
-               if (!srcNewMsg) {
-                       dstBody = document.body.cloneNode(true);
-                       // TODO Temp code. Remove when replace body with DIV.
-                       var imgLayers = dstBody.getElementsByClassName("email-composer-image-layer");
-                       if (imgLayers.length > 0) {
-                               imgLayers[0].parentElement.removeChild(imgLayers[0]);
-                       }
-               } else {
-                       dstBody = srcNewMsg.cloneNode(true);
-                       dstBody.removeAttribute("id");
-                       dstBody.removeAttribute("class");
-               }
+               dstBody = srcNewMsg.cloneNode(true);
+               dstBody.removeAttribute("id");
+               dstBody.removeAttribute("class");
                dstBody.removeAttribute("contenteditable");
        } else {
                dstBody = document.createElement("body");