Refactoring code for emoticon list 97/250597/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Sat, 26 Dec 2020 10:45:49 +0000 (19:45 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 31 Dec 2020 01:42:37 +0000 (01:42 +0000)
Change-Id: If362efe277b46e5553b6667e1d113082e4ae66d7
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
src/include/ise-emoticon-group.h [new file with mode: 0644]
src/include/ise-emoticon-list.h [new file with mode: 0644]
src/include/ise-emoticon-mode.h
src/ise-emoticon-list.cpp
src/ise-emoticon-mode.cpp
src/ise.cpp

diff --git a/src/include/ise-emoticon-group.h b/src/include/ise-emoticon-group.h
new file mode 100644 (file)
index 0000000..fe0b2b8
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef ISE_EMOTICON_GROUP_H_
+#define ISE_EMOTICON_GROUP_H_
+
+#ifdef SUPPORTS_EMOTICONS
+
+#ifdef _WEARABLE
+#define EMOTICON_GROUP_RECENTLY_USED_NUM 9
+#define EMOTICON_GROUP_1_NUM 9
+#define EMOTICON_GROUP_2_NUM 9
+#define EMOTICON_GROUP_3_NUM 9
+#define EMOTICON_GROUP_4_NUM 0
+#define EMOTICON_GROUP_5_NUM 0
+
+enum emoticon_group_t
+{
+    EMOTICON_GROUP_DESTROY = -1,
+    EMOTICON_GROUP_RECENTLY_USED,
+    EMOTICON_GROUP_1,
+    EMOTICON_GROUP_2,
+    EMOTICON_GROUP_3,
+    MAX_EMOTICON_GROUP,
+};
+
+#else
+#define EMOTICON_GROUP_RECENTLY_USED_NUM 28
+#define EMOTICON_GROUP_1_NUM 77
+#define EMOTICON_GROUP_2_NUM 157
+#define EMOTICON_GROUP_3_NUM 178
+#define EMOTICON_GROUP_4_NUM 114
+#define EMOTICON_GROUP_5_NUM 207
+
+enum emoticon_group_t
+{
+    EMOTICON_GROUP_DESTROY = -1,
+    EMOTICON_GROUP_RECENTLY_USED,
+    EMOTICON_GROUP_1,
+    EMOTICON_GROUP_2,
+    EMOTICON_GROUP_3,
+    EMOTICON_GROUP_4,
+    EMOTICON_GROUP_5,
+    MAX_EMOTICON_GROUP,
+};
+#endif
+
+#endif /* SUPPORTS_EMOTICONS */
+#endif /* ISE_EMOTICON_GROUP_H_ */
diff --git a/src/include/ise-emoticon-list.h b/src/include/ise-emoticon-list.h
new file mode 100644 (file)
index 0000000..9cb00be
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef ISE_EMOTICON_LIST_H_
+#define ISE_EMOTICON_LIST_H_
+
+#ifdef SUPPORTS_EMOTICONS
+
+#include "ise-emoticon-group.h"
+
+void ise_emoticon_init_list(void);
+
+emoticon_group_t ise_emoticon_get_group_id(const char *group_name);
+const char *ise_emoticon_get_group_name(int id);
+int ise_emoticon_get_code(unsigned int group, unsigned int index);
+
+#endif /* SUPPORTS_EMOTICONS */
+#endif /* ISE_EMOTICON_LIST_H_ */
index b897f1f..1dcfb3b 100644 (file)
 #ifndef ISE_EMOTICON_MODE_H_
 #define ISE_EMOTICON_MODE_H_
 
-#include "ise-floating-mode.h"
-#include <stdlib.h>
-
 #ifdef SUPPORTS_EMOTICONS
 
-#ifdef _WEARABLE
-#define EMOTICON_GROUP_RECENTLY_USED_NUM 9
-#define EMOTICON_GROUP_1_NUM 9
-#define EMOTICON_GROUP_2_NUM 9
-#define EMOTICON_GROUP_3_NUM 9
-#define EMOTICON_GROUP_4_NUM 0
-#define EMOTICON_GROUP_5_NUM 0
-
-enum emoticon_group_t
-{
-    EMOTICON_GROUP_DESTROY = -1,
-    EMOTICON_GROUP_RECENTLY_USED,
-    EMOTICON_GROUP_1,
-    EMOTICON_GROUP_2,
-    EMOTICON_GROUP_3,
-    MAX_EMOTICON_GROUP,
-};
-
-#else
-#define EMOTICON_GROUP_RECENTLY_USED_NUM 28
-#define EMOTICON_GROUP_1_NUM 77
-#define EMOTICON_GROUP_2_NUM 157
-#define EMOTICON_GROUP_3_NUM 178
-#define EMOTICON_GROUP_4_NUM 114
-#define EMOTICON_GROUP_5_NUM 207
-
-enum emoticon_group_t
-{
-    EMOTICON_GROUP_DESTROY = -1,
-    EMOTICON_GROUP_RECENTLY_USED,
-    EMOTICON_GROUP_1,
-    EMOTICON_GROUP_2,
-    EMOTICON_GROUP_3,
-    EMOTICON_GROUP_4,
-    EMOTICON_GROUP_5,
-    MAX_EMOTICON_GROUP,
-};
-#endif
+#include <stdlib.h>
+#include "ise-emoticon-group.h"
 
-void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window);
-void ise_change_emoticon_mode(emoticon_group_t emoticon_group);
-void ise_destroy_emoticon_layout(void);
-void ise_init_emoticon_list(void);
-bool is_emoticon_show(void);
-emoticon_group_t ise_get_emoticon_group_id(const char *group_name);
-const char *ise_get_emoticon_group_name(int id);
-void ise_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group);
-size_t get_emoticon_list_recent_size();
+void ise_emoticon_show_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window);
+void ise_emoticon_change_mode(emoticon_group_t emoticon_group);
+void ise_emoticon_destroy_layout(void);
+bool ise_emoticon_is_show(void);
+void ise_emoticon_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group);
+size_t ise_emoticon_get_recent_list_size();
 
-emoticon_group_t get_current_emoticon_group();
-void set_current_emoticon_group(emoticon_group_t emoticon_group);
-int get_emoticon_code(unsigned int group, unsigned int index);
+void ise_emoticon_set_current_group(emoticon_group_t emoticon_group);
+emoticon_group_t ise_emoticon_get_current_group();
 
 #endif /* SUPPORTS_EMOTICONS */
 #endif /* ISE_EMOTICON_MODE_H_ */
index 2aaf04a..d44b92d 100644 (file)
@@ -838,7 +838,7 @@ const char *emoticon_group_name[] =
 
 extern void ise_read_recent_emoticon_list_from_scim(void);
 
-void ise_init_emoticon_list(void)
+void ise_emoticon_init_list(void)
 {
     static bool is_emoticon_list_initialised = false;
     if (!is_emoticon_list_initialised) {
@@ -847,7 +847,7 @@ void ise_init_emoticon_list(void)
     }
 }
 
-emoticon_group_t ise_get_emoticon_group_id(const char *group_name)
+emoticon_group_t ise_emoticon_get_group_id(const char *group_name)
 {
     int i = 0;
     for (; i < MAX_EMOTICON_GROUP; ++i) {
@@ -857,7 +857,7 @@ emoticon_group_t ise_get_emoticon_group_id(const char *group_name)
     return (emoticon_group_t)0;
 }
 
-const char *ise_get_emoticon_group_name(int id)
+const char *ise_emoticon_get_group_name(int id)
 {
     if (id >= 0 && id < MAX_EMOTICON_GROUP)
         return emoticon_group_name[id];
@@ -865,7 +865,7 @@ const char *ise_get_emoticon_group_name(int id)
         return NULL;
 }
 
-int get_emoticon_code(unsigned int group, unsigned int index)
+int ise_emoticon_get_code(unsigned int group, unsigned int index)
 {
     return emoticon_list[group][index];
 }
index 59d4146..8691aa7 100644 (file)
@@ -28,6 +28,7 @@
 #include <sclfeedback.h>
 
 #include "ise-emoticon-mode.h"
+#include "ise-emoticon-list.h"
 #include "ise.h"
 #include "config.h"
 #include "candidate-factory.h"
@@ -112,17 +113,17 @@ static bool is_emoticon_mode = false;
 static emoticon_group_t current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
 static std::vector <int> emoticon_list_recent;
 
-size_t get_emoticon_list_recent_size()
+size_t ise_emoticon_get_recent_list_size()
 {
     return emoticon_list_recent.size();
 }
 
-emoticon_group_t get_current_emoticon_group()
+emoticon_group_t ise_emoticon_get_current_group()
 {
     return current_emoticon_group;
 }
 
-void set_current_emoticon_group(emoticon_group_t emoticon_group)
+void ise_emoticon_set_current_group(emoticon_group_t emoticon_group)
 {
     current_emoticon_group = emoticon_group;
 }
@@ -248,7 +249,7 @@ void ise_write_recent_emoticon_list_to_scim(void)
     }
 }
 
-void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window)
+void ise_emoticon_show_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window)
 {
     CSCLUI *ui = get_ui();
     if (!ui) return;
@@ -259,8 +260,8 @@ void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_
     return;
 #endif
     //xt9_send_flush(0);
-    ise_init_emoticon_list();
-    ise_set_private_key_for_emoticon_mode(emoticon_group);
+    ise_emoticon_init_list();
+    ise_emoticon_set_private_key_for_emoticon_mode(emoticon_group);
 
     if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
         //ise_read_recent_emoticon_list_from_scim();
@@ -270,7 +271,7 @@ void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_
         }
     }
 
-    ise_destroy_emoticon_layout();
+    ise_emoticon_destroy_layout();
 
     layout = elm_layout_add((Evas_Object *)main_window);
     evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -374,7 +375,7 @@ void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_
     current_emoticon_group = emoticon_group;
 }
 
-void ise_destroy_emoticon_layout(void)
+void ise_emoticon_destroy_layout(void)
 {
     /* According to UI FW team, when the a parent is deleted, all its child content will
      * also be deleted. So no need to delete gengrid explicitly. Just setting the gendrid
@@ -401,7 +402,7 @@ void ise_destroy_emoticon_layout(void)
     }
 }
 
-void ise_change_emoticon_mode(emoticon_group_t emoticon_group)
+void ise_emoticon_change_mode(emoticon_group_t emoticon_group)
 {
     if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
         //ise_read_recent_emoticon_list_from_scim();
@@ -533,11 +534,11 @@ static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_gro
             items = emoticon_group_items[emoticon_group];
         }
         for (int i = 0; i < items; i++) {
-            snprintf(img_name, 10, "%x", get_emoticon_code(emoticon_group-1, i));
+            snprintf(img_name, 10, "%x", ise_emoticon_get_code(emoticon_group-1, i));
             file_path = (std::string)EMOTICON_DIR + (std::string)"u" + (std::string)img_name + (std::string)".png";
             if (ise_util_does_file_exists(file_path)) {
-                emoticon_items[i].code = get_emoticon_code(emoticon_group-1, i);
-                emoticon_items[i].keyevent = get_emoticon_code(emoticon_group-1, i);
+                emoticon_items[i].code = ise_emoticon_get_code(emoticon_group-1, i);
+                emoticon_items[i].keyevent = ise_emoticon_get_code(emoticon_group-1, i);
                 emoticon_items[i].path = file_path;
                 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
 //              PRINTFUNC(SECURE_DEBUG,"file_path = %s\n",file_path.c_str());
@@ -620,9 +621,9 @@ static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_gro
             items = emoticon_group_items[emoticon_group];
         }
         for (int i = 0; i < items; i++) {
-            snprintf(img_name, 10, "%x", get_emoticon_code(emoticon_group-1, i));
+            snprintf(img_name, 10, "%x", ise_emoticon_get_code(emoticon_group-1, i));
             file_path = (std::string)img_name;
-            emoticon_items[i].keyevent = get_emoticon_code(emoticon_group-1, i);
+            emoticon_items[i].keyevent = ise_emoticon_get_code(emoticon_group-1, i);
             emoticon_items[i].path = file_path;
             emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
         }
@@ -726,23 +727,23 @@ static void _item_selected(void *data, Evas_Object *obj, void *event_info)
     //PRINTFUNC(DLOG_DEBUG,"_item_selected() ends");
 }
 
-bool is_emoticon_show(void)
+bool ise_emoticon_is_show(void)
 {
     return is_emoticon_mode;
 }
 
-void ise_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group)
+void ise_emoticon_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group)
 {
     CSCLUI *ui = get_ui();
     if (ui) {
         const char *group_name = NULL;
         for (int id = EMOTICON_GROUP_RECENTLY_USED; id < MAX_EMOTICON_GROUP; id++) {
-            group_name = ise_get_emoticon_group_name(id);
+            group_name = ise_emoticon_get_group_name(id);
             if (group_name)
                 ui->unset_private_key(group_name);
         }
 
-        group_name = ise_get_emoticon_group_name(emoticon_group);
+        group_name = ise_emoticon_get_group_name(emoticon_group);
         if (group_name) {
 #ifndef _WEARABLE
             sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
index 540f0e6..da70453 100644 (file)
@@ -41,6 +41,7 @@
 #include "languages.h"
 #include "candidate-factory.h"
 #include "ise-emoticon-mode.h"
+#include "ise-emoticon-list.h"
 #include "ise-stt-mode.h"
 #include "ise-stt-option.h"
 #include "ise-language-change.h"
@@ -686,22 +687,22 @@ on_input_mode_changed(const sclchar *key_value, sclulong key_event, sclint key_t
                 }
             }
         }
-        if (is_emoticon_show()) {
-            ise_destroy_emoticon_layout();
+        if (ise_emoticon_is_show()) {
+            ise_emoticon_destroy_layout();
         }
         if (key_value) {
             if (!strcmp(key_value, USER_KEYSTRING_EMOTICON)) {
-                ise_init_emoticon_list();
+                ise_emoticon_init_list();
 #ifdef _WEARABLE
-                    set_current_emoticon_group(EMOTICON_GROUP_1);
+                    ise_emoticon_set_current_group(EMOTICON_GROUP_1);
 #else
-                if (get_emoticon_list_recent_size() == 0)
-                    set_current_emoticon_group(EMOTICON_GROUP_1);
+                if (ise_emoticon_get_recent_list_size() == 0)
+                    ise_emoticon_set_current_group(EMOTICON_GROUP_1);
                 else
-                    set_current_emoticon_group(EMOTICON_GROUP_RECENTLY_USED);
+                    ise_emoticon_set_current_group(EMOTICON_GROUP_RECENTLY_USED);
 #endif
                 SCLRotation rotation = ui->get_rotation();
-                ise_show_emoticon_layout(get_current_emoticon_group(), ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
+                ise_emoticon_show_layout(ise_emoticon_get_current_group(), ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
             }
         }
     }
@@ -1354,21 +1355,21 @@ SCLEventReturnType CUIEventCallback::on_event_key_clicked(SclUIEventDesc event_d
             }  else {
                 const sclchar *input_mode = ui->get_input_mode();
                 if ((NULL != input_mode) && (!strcmp(input_mode, "EMOTICON_LAYOUT"))) {
-                    if (is_emoticon_show()) {
-                        ise_destroy_emoticon_layout();
+                    if (ise_emoticon_is_show()) {
+                        ise_emoticon_destroy_layout();
                     }
 #ifdef _WEARABLE
                     emoticon_group_t group_id = EMOTICON_GROUP_1;
-                    if (get_current_emoticon_group() < EMOTICON_GROUP_3)
-                        group_id = (emoticon_group_t)(get_current_emoticon_group() + 1);
+                    if (ise_emoticon_get_current_group() < EMOTICON_GROUP_3)
+                        group_id = (emoticon_group_t)(ise_emoticon_get_current_group() + 1);
 
                     ise_set_emoticon_label(group_id);
 #else
-                    emoticon_group_t group_id = ise_get_emoticon_group_id(event_desc.key_value);
+                    emoticon_group_t group_id = ise_emoticon_get_group_id(event_desc.key_value);
 #endif
                     if ((group_id >= 0) && (group_id < MAX_EMOTICON_GROUP)) {
                         SCLRotation rotation = ui->get_rotation();
-                        ise_show_emoticon_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
+                        ise_emoticon_show_layout(group_id, ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
                     }
                 }
             }
@@ -1667,23 +1668,23 @@ ise_show(int ic)
                     }
                 }
                 ui->set_cur_sublayout(g_ise_default_values[layout_index].sublayout_name);
-                if (is_emoticon_show()) {
-                    ise_destroy_emoticon_layout();
+                if (ise_emoticon_is_show()) {
+                    ise_emoticon_destroy_layout();
                 }
 
                 if (keyboard_state->layout == ISE_LAYOUT_STYLE_EMOTICON) {
-                    ise_init_emoticon_list();
+                    ise_emoticon_init_list();
 #ifdef _WEARABLE
-                    set_current_emoticon_group(EMOTICON_GROUP_1);
+                    ise_emoticon_set_current_group(EMOTICON_GROUP_1);
                     ise_set_emoticon_label(1);
 #else
-                    if (get_emoticon_list_recent_size() == 0)
-                        set_current_emoticon_group(EMOTICON_GROUP_1);
+                    if (ise_emoticon_get_recent_list_size() == 0)
+                        ise_emoticon_set_current_group(EMOTICON_GROUP_1);
                     else
-                        set_current_emoticon_group(EMOTICON_GROUP_RECENTLY_USED);
+                        ise_emoticon_set_current_group(EMOTICON_GROUP_RECENTLY_USED);
 #endif
                     SCLRotation rotation = ui->get_rotation();
-                    ise_show_emoticon_layout(get_current_emoticon_group(), ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
+                    ise_emoticon_show_layout(ise_emoticon_get_current_group(), ROTATION_TO_DEGREE(rotation), false, ime_get_main_window());
                 }
             }
         }
@@ -2764,9 +2765,13 @@ static void ime_app_show_cb(int ic, ime_context_h ime_ctx, void *user_data)
 
     ise_reset_context(); // reset ISE
 
-    /*if (context.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
-        ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
-    }*/
+    // if (iseContext.language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
+    //     LOGD("alphabet");
+    //     ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
+    // }
+    // else {
+    //     LOGD("non-alphabet");
+    // }
 
     _context_layout = iseContext.layout;
     _context_layout_variation = iseContext.layout_variation;
@@ -2816,6 +2821,10 @@ static void ime_app_return_key_state_set_cb(bool disabled, void *user_data)
 static void ime_app_language_set_cb(Ecore_IMF_Input_Panel_Lang language, void *user_data)
 {
     LOGD("language : %d\n", language);
+
+    // if (language == ECORE_IMF_INPUT_PANEL_LANG_ALPHABET) {
+    //     ise_explictly_set_language(PRIMARY_LATIN_LANGUAGE_INDEX);
+    // }
 }
 
 static void ime_app_input_context_reset_cb(void *user_data)
@@ -2928,19 +2937,19 @@ static void ime_app_rotation_degree_changed_cb(int degree, void *user_data)
         ise_show_move_handler(handler_width, FLOATING_TITLE_BAR_HEIGHT);
     }
 #endif
-    if (is_emoticon_show()) {
-        ise_destroy_emoticon_layout();
+    if (ise_emoticon_is_show()) {
+        ise_emoticon_destroy_layout();
     }
     if (keyboard_state->layout == ISE_LAYOUT_STYLE_VOICE) {
         ise_hide_stt_mode();
     }
     if (keyboard_state->layout == ISE_LAYOUT_STYLE_EMOTICON) {
-        ise_show_emoticon_layout(get_current_emoticon_group(), degree, false, ime_get_main_window());
+        ise_emoticon_show_layout(ise_emoticon_get_current_group(), degree, false, ime_get_main_window());
     } else if (ui) {
         const sclchar *input_mode = ui->get_input_mode();
         if (input_mode) {
             if (!(strcmp(input_mode, "EMOTICON_LAYOUT")))
-                ise_show_emoticon_layout(get_current_emoticon_group(), degree, false, ime_get_main_window());
+                ise_emoticon_show_layout(ise_emoticon_get_current_group(), degree, false, ime_get_main_window());
             else if (!(strcmp(input_mode, "STT_3X4")))
                 ise_show_stt_mode(NATIVE_WINDOW_CAST(ime_get_main_window()));
         }