Update voice control functionality and added voice control app launching button to... 12/244812/3 submit/tizen/20200924.114723
authoraman.jeph <aman.jeph@samsung.com>
Thu, 24 Sep 2020 09:41:52 +0000 (15:11 +0530)
committeraman.jeph <aman.jeph@samsung.com>
Thu, 24 Sep 2020 11:42:14 +0000 (17:12 +0530)
Change-Id: I9c2da047a739d6b80569d0e9b4ec7aaefb6b2a1c
Signed-off-by: aman.jeph <aman.jeph@samsung.com>
res/edje/quickpanel_noti_section.edc
res/images_icon/icon_voice_control.png [new file with mode: 0755]
src/notifications/noti_section.c
src/settings/modules/voice-control.c

index 82995a8baaf249e9fc1072ea15610e680213e307..72f3a1b08b417c49b320eb835541ef25f6cce2c2 100755 (executable)
                                scale: 1;
                                description {
                                        state: "default" 0.0;
-                                       min: 50 48;
-                                       max: 50 48;
+                                       min: 48 48;
+                                       max: 48 48;
                                        fixed: 1 1;
                                        rel1 {
                                                to: "base";
                                                relative: 0.0 0.0;
                                        }
                                        rel2 {
-                                               relative: 1.0 1.0;
+                                               relative: 0.0 1.0;
                                                to_y: "base";
                                        }
-                                       align: 0.0 0.5;
+                                       align: 0.0 0.0;
                                        color: 0 0 0 0;
                                        visible: 1;
                                }
                                        rel2 { relative: 1.0 1.0; to: "rect.settings"; }
                                }
                        }
+                       part { name: "voice_control_swallow";
+                               type: SWALLOW;
+                               scale: 1;
+                               description { state: "default" 0.0;
+                                       min: 48 48;
+                                       max: 48 48;
+                                       fixed: 1 1;
+                                       align: 0.0 0.0;
+                                       rel1 { to_x: "rect.settings"; to_y: "base"; relative: 1.0 0.0; }
+                                       rel2 {  to_x: "rect.settings"; to_y: "base"; relative: 1.0 1.0; }
+                               }
+                       }
                        part {
                                name: "spacer_settings";
                                type: SPACER;
                                scale: 1;
                                description {
                                        state: "default" 0.0;
-                                       min: 738 5;
-                                       max: 738 5;
+                                       min: 692 48;
+                                       max: 692 48;
                                        fixed: 1 1;
                                        rel1 {
-                                               to: "rect.settings";
+                                               to: "voice_control_swallow";
                                                relative: 1.0 0.0;
                                        }
                                        rel2 {
diff --git a/res/images_icon/icon_voice_control.png b/res/images_icon/icon_voice_control.png
new file mode 100755 (executable)
index 0000000..b3195b1
Binary files /dev/null and b/res/images_icon/icon_voice_control.png differ
index c1d4d3e4c4528b9535e309cac6e81fd3a02a9622..6e3b9e15dd92659f0bfce452a0b092c495bdbeb5 100755 (executable)
@@ -24,6 +24,8 @@
 #include <tzsh_quickpanel_service.h>
 #include <system_settings.h>
 #include <notification_setting_internal.h>
+#include <voice_control_setting.h>
+#include <voice_control_common.h>
 #include <app.h>
 
 #include "quickpanel-ui.h"
 
 #define NOTI_CLEAR_ALL_SECTION "quickpanel/notisection/clear_all"
 #define NOTI_DEFAULT_SECTION "quickpanel/notisection/default"
+#define VOICE_CONTROL_PKG "org.tizen.voice-control-panel"
 
-#define NOTI_SECTION_WIDTH 393
+
+#define NOTI_SECTION_WIDTH 1200
 #define NOTI_SECTION_HEIGHT 48
-#define NOTI_SECTION_X 847
+#define NOTI_SECTION_X 40
 #define NOTI_SECTION_Y 0
 
 static struct  _noti_section{
@@ -78,6 +82,25 @@ static void _noti_section_set_text(Evas_Object *noti_section, int count)
        elm_object_part_text_set(noti_section, "text.button.clear_all", _("IDS_LCKSCN_ACBUTTON_CLEAR_ALL"));
 }
 
+// To Do : define this function in appropriate file
+static void quickpanel_voice_control_clicked(void *data, Evas_Object *obj, void *event_info)
+{
+       int ret = 0;
+       bool status = false;
+       if ((VC_ERROR_NONE == vc_setting_get_enabled(&status)) && status ) {
+               ret = quickpanel_common_send_message_to_app(VOICE_CONTROL_PKG, NULL, NULL, NULL);
+               quickpanel_common_inform_launch_app_result(VOICE_CONTROL_PKG, ret);
+               if(ret != APP_CONTROL_ERROR_NONE)
+               {
+                       ERR("failed to launch voice control app");
+                       return;
+               }
+               quickpanel_uic_close_quickpanel(true, 1);
+       } else {
+               DBG("voice control service is not enable or failed to get status of voice control service.");
+       }
+}
+
 HAPI void quickpanel_noti_section_create(Evas_Object *parent)
 {
        Evas_Object *section;
@@ -102,8 +125,6 @@ HAPI void quickpanel_noti_section_create(Evas_Object *parent)
 
        evas_object_size_hint_weight_set(section, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(section, EVAS_HINT_FILL, EVAS_HINT_FILL);
-       //quickpanel_uic_initial_resize(section, QP_THEME_LIST_ITEM_NOTI_SECTION_HEIGHT);
-       evas_object_resize(section, NOTI_SECTION_WIDTH, NOTI_SECTION_HEIGHT);
        evas_object_show(section);
 
        focus_clear = quickpanel_accessibility_ui_get_focus_object(section);
@@ -120,6 +141,7 @@ HAPI void quickpanel_noti_section_create(Evas_Object *parent)
        }
 
        Evas_Object *setting_button = elm_button_add(section);
+       evas_object_size_hint_weight_set(setting_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        if(setting_button == NULL) {
                ERR("Failed to add button");
                return ;
@@ -134,20 +156,38 @@ HAPI void quickpanel_noti_section_create(Evas_Object *parent)
        DBG("Image path = %s",path);
        snprintf(buffer, 1024, "%s%s%s", path, "images_icon/", "icon_settings.png");
        elm_image_file_set(img, buffer, NULL);
-       evas_object_size_hint_min_set(img, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48));
-       evas_object_size_hint_max_set(img, ELM_SCALE_SIZE(48), ELM_SCALE_SIZE(48));
+       evas_object_size_hint_min_set(img, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
+       evas_object_size_hint_max_set(img, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
+       evas_object_size_hint_align_set(img, 0.0, 0.5);
        elm_object_part_content_set(setting_button, "icon", img);
        elm_object_style_set(setting_button, "focus");
        elm_object_part_content_set(section, "settings_button_swallow", setting_button);
        evas_object_smart_callback_add(setting_button, "clicked", quickpanel_setting_clicked, NULL);
        evas_object_show(setting_button);
+
+       Evas_Object *vc_button = elm_button_add(section);
+       elm_object_style_set(vc_button, "focus");
+       evas_object_size_hint_weight_set(vc_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+
+       snprintf(buffer, 1024, "%s%s%s", path, "images_icon/", "icon_voice_control.png");
+       Evas_Object *icon = elm_image_add(vc_button);
+       elm_image_file_set(icon, buffer, NULL);
+       evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
+       evas_object_size_hint_max_set(icon, ELM_SCALE_SIZE(40), ELM_SCALE_SIZE(40));
+       evas_object_size_hint_align_set(icon, 1.0, 0.5);
+
+       elm_object_part_content_set(vc_button, "icon", icon);
+
+       elm_object_part_content_set(section, "voice_control_swallow", vc_button);
+       evas_object_smart_callback_add(vc_button, "clicked", quickpanel_voice_control_clicked, NULL);
+       evas_object_show(vc_button);
        free(path);
 
        elm_object_part_content_set(section, "focus", focus_clear);
        evas_object_smart_callback_add(focus_clear, "clicked", quickpanel_noti_on_clear_all_clicked, NULL);
        elm_object_part_content_set(section, "focus.setting", focus_setting);
        evas_object_smart_callback_add(focus_setting, "clicked", quickpanel_noti_on_noti_setting_clicked, NULL);
-       elm_grid_pack(parent, section, 32, NOTI_SECTION_Y, 1200, NOTI_SECTION_HEIGHT);
+       elm_grid_pack(parent, section, NOTI_SECTION_X, NOTI_SECTION_Y, NOTI_SECTION_WIDTH, NOTI_SECTION_HEIGHT);
 
        noti_section_data.layout = section;
        noti_section_data.clear_btn = focus_clear;
index 439b6bac9dd8bd04d9ca57fc2ef81d8904c60e65..e62528ddec550fa54ef838795a41619de7692209 100755 (executable)
@@ -51,28 +51,6 @@ static const char *_label_get(void)
        return BUTTON_LABEL;
 }
 
-static int _check_dead_signal(int pid, void *data)
-{
-       DBG("Process %d is terminated", pid);
-       if (pid < 0) {
-               ERR("pid : %d", pid);
-               return 0;
-       }
-       if(pid == vcpid) {
-               DBG("pid = %d and vcpid = %d",pid,vcpid);
-               QP_Module_Setting *module = (QP_Module_Setting *)data;
-               if(module == NULL) {
-                       ERR("module is NULL");
-                       return 0;
-               }
-               DBG("name of module = %s",module->name);
-               DBG(" check_dead_signal, setting the module icon state to 0");
-               quickpanel_setting_module_icon_state_set(module, 0);
-               quickpanel_setting_module_icon_view_update(module ,0,FLAG_VALUE_VOID);
-       }
-       return 0;
-}
-
 static const char *_icon_get(qp_setting_icon_image_type type)
 {
        if (type == QP_SETTING_ICON_NORMAL) {
@@ -193,42 +171,37 @@ static void _mouse_clicked_cb(void *data, Evas_Object *obj, const char *emission
                quickpanel_setting_module_icon_state_set(module, 1);
                quickpanel_setting_module_icon_view_update(module ,1,FLAG_VALUE_VOID);
 
-               int ret = 0;
-               ret = quickpanel_common_send_message_to_app(VOICE_CONTROL_PKG, NULL, NULL, NULL);
-               quickpanel_common_inform_launch_app_result(VOICE_CONTROL_PKG, ret);
-
-               app_context_h app_context_handle = NULL;
-               ret = app_manager_get_app_context(VOICE_CONTROL_PKG, &app_context_handle);
-               if (ret != APP_MANAGER_ERROR_NONE) {
-                       ERR("Failed to get app context");
-                       return ;
-               }
-
-               ret = app_context_get_pid(app_context_handle, &vcpid);
-               if (ret != APP_MANAGER_ERROR_NONE) {
-                       ERR("Failed to get pid");
-                       return ;
-               }
+       }
+}
 
-               ret = aul_listen_app_dead_signal(_check_dead_signal, module);
-               if (ret < 0) {
-                       ERR("aul_listen_app_dead_signal failed");
-                       return ;
-               }
-               DBG(" pid of voice_control is = %d ",vcpid);
-               quickpanel_uic_close_quickpanel(true, 1);
+static void _vc_enabled_changed_cb(bool enabled, void* user_data)
+{
+       QP_Module_Setting *module = (QP_Module_Setting *)user_data;
+       if(enabled) {
+               quickpanel_setting_module_icon_state_set(module, 1);
+               quickpanel_setting_module_icon_view_update(module ,1,FLAG_VALUE_VOID);
+       } else {
+               quickpanel_setting_module_icon_state_set(module, 0);
+               quickpanel_setting_module_icon_view_update(module ,0,FLAG_VALUE_VOID);
        }
 }
 
+
 static int _register_module_event_handler(void *data)
 {
-       int ret = 0;
+       if (0 != vc_setting_set_enabled_changed_cb(_vc_enabled_changed_cb, data)) {
+               ERR("Fail to set enabled cb");
+               return QP_FAIL;
+       }
        return QP_OK;
 }
 
 static int _unregister_module_event_handler(void *data)
 {
-       int ret = 0;
+       if (0 !=  vc_setting_unset_enabled_changed_cb()) {
+               ERR("Fail to unset enabled cb");
+               return QP_FAIL;
+       }
        return QP_OK;
 }