diff options
author | anirudha_r.c <anirudha_r.c@samsung.com> | 2016-12-26 17:40:55 +0530 |
---|---|---|
committer | anirudha_r.c <anirudha_r.c@samsung.com> | 2016-12-26 17:40:55 +0530 |
commit | ec82eedad300a27d4ebdeafba575b96b2961113e (patch) | |
tree | b4c0288dd6c8f93d6a7ea9d748e0a10ede01fc04 | |
parent | 7de99d9e0f21b77d62af0a48b85f7e2460f98ed8 (diff) | |
download | alarm-ec82eedad300a27d4ebdeafba575b96b2961113e.tar.gz alarm-ec82eedad300a27d4ebdeafba575b96b2961113e.tar.bz2 alarm-ec82eedad300a27d4ebdeafba575b96b2961113e.zip |
[Alarm-widget] Fix for - App widget auto open when long tap on
Change-Id: I4c767e4e9622a1fb578a9322b0b1d59458e893e3
-rwxr-xr-x | alarm_widget/res/edje/widget.edc | 20 | ||||
-rwxr-xr-x | alarm_widget/src/main.c | 74 |
2 files changed, 55 insertions, 39 deletions
diff --git a/alarm_widget/res/edje/widget.edc b/alarm_widget/res/edje/widget.edc index 9e93d08..c7f7a49 100755 --- a/alarm_widget/res/edje/widget.edc +++ b/alarm_widget/res/edje/widget.edc @@ -494,7 +494,7 @@ group { name: "alarm_widget"; parts { part { name: "base"; type: RECT; - mouse_events: 0; + mouse_events: 1; scale: 1; description { state: "default" 0.0; min : 360 360; @@ -867,8 +867,8 @@ group { name: "alarm_widget"; part { name: "elm.swallow.content.bg"; type: IMAGE; scale: 1; - mouse_events: 1; - repeat_events: 0; + mouse_events: 0; + //repeat_events: 1; description { state: "default" 0.0; min : 94 94; rel1 { @@ -931,8 +931,8 @@ group { name: "alarm_widget"; part { name: "text_clicked_rect"; type: RECT; - mouse_events: 1; - repeat_events: 0; + mouse_events: 0; + //repeat_events: 0; description { state: "default" 0.0; rel1 { relative : 0.0 0.0; to: "base";} @@ -979,7 +979,7 @@ group { name: "alarm_widget"; target: "ampm.12.3"; target: "ampm.12.4"; } - + /* program { source: "elm.swallow.content.bg"; signal: "mouse,down,*"; @@ -1007,7 +1007,7 @@ group { name: "alarm_widget"; set_int(press_flag, 0); } } - + */ /* program { source: "elm.swallow.content.bg"; @@ -1020,7 +1020,7 @@ group { name: "alarm_widget"; } } */ - + /* program { source: "text_clicked_rect"; signal: "mouse,down,*"; @@ -1036,18 +1036,20 @@ group { name: "alarm_widget"; set_int(press_flag_text_field, get_int(press_flag_text_field)+1); } } + */ program { source: "text_clicked_rect"; signal: "mouse,up,*"; script { if (get_int(press_flag_text_field) < 8 ) { - emit("edit_clicked", "*"); + // emit("edit_clicked", "*"); } set_int(press_flag_text_field, 0); } } + /* program { diff --git a/alarm_widget/src/main.c b/alarm_widget/src/main.c index 9ee7d1e..8fac8d1 100755 --- a/alarm_widget/src/main.c +++ b/alarm_widget/src/main.c @@ -54,9 +54,10 @@ static void _reply_from_alarm(app_control_h request, app_control_h reply, app_co static void switch_to_layout_with_alarm(widget_instance_data_s *wid); static void switch_to_layout_with_no_alarm(widget_instance_data_s *wid); int update_widget_content_to_whome(widget_instance_data_s* wid); - - - +static void __alm_widget_new_alarm_mouse_down_cb(void *data, Evas * e, Evas_Object * obj, void *event_info); +//static void _alarm_widget_edit_alarm_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _alarm_widget_edit_alarm_up_cb(void *data); +static void __alm_widget_new_alarm_mouse_move_cb(void *data, Evas * e, Evas_Object * obj, void *event_info); static void _reply_from_alarm(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { @@ -94,6 +95,12 @@ static void _reply_from_alarm(app_control_h request, app_control_h reply, app_co static void __alm_widget_new_alarm_mouse_up_cb(void *data, Evas * e, Evas_Object * obj, void *event_info) { + Evas_Event_Mouse_Up *ev = (Evas_Event_Mouse_Up *)event_info; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) { + _D("EVAS_EVENT_FLAG_ON_HOLD - Need to ignore this event"); + return; + } + _D("__alm_widget_new_alarm_mouse_up_cb new_alarm_move:%d", new_alarm_move); widget_instance_data_s *wid = (widget_instance_data_s *)data; ret_if(!wid); @@ -105,23 +112,33 @@ static void __alm_widget_new_alarm_mouse_up_cb(void *data, Evas * e, Evas_Object } new_alarm_move = 0; - elm_object_signal_emit(wid->layout, "clipper.no_alarm.default", "*"); - app_control_h app_control; + if(wid->db_id == 0) { + elm_object_signal_emit(wid->layout, "clipper.no_alarm.default", "*"); + app_control_h app_control; - app_control_create(&app_control); - app_control_set_operation(app_control, APP_CONTROL_OPERATION_ALARM_WIDGET_NEWALARM); - app_control_set_app_id(app_control, ALARM_APP_ID); - if (app_control_send_launch_request(app_control, _reply_from_alarm, wid) == APP_CONTROL_ERROR_NONE) { - _D("Succeeded to launch a alarm for new alarm"); + app_control_create(&app_control); + app_control_set_operation(app_control, APP_CONTROL_OPERATION_ALARM_WIDGET_NEWALARM); + app_control_set_app_id(app_control, ALARM_APP_ID); + if (app_control_send_launch_request(app_control, _reply_from_alarm, wid) == APP_CONTROL_ERROR_NONE) { + _D("Succeeded to launch a alarm for new alarm"); + } else { + Evas_Object *popup = NULL; + char *popup_text = NULL; + _E("Failed to launch a alarm"); + popup_text = data_get_popup_text(); + popup = view_create_text_popup(wid->layout, POPUP_DURATION, popup_text); + free(popup_text); + } + app_control_destroy(app_control); } else { - Evas_Object *popup = NULL; - char *popup_text = NULL; - _E("Failed to launch a alarm"); - popup_text = data_get_popup_text(); - popup = view_create_text_popup(wid->layout, POPUP_DURATION, popup_text); - free(popup_text); + //retrieve x, y position from ev + //based on x and y positon , if time text is there then emit edit_clicked , if icon part is there the emit on_off_clicked + if(ev->canvas.y <= 250 ) { + _alarm_widget_edit_alarm_up_cb(wid); + } else if(ev->canvas.x > 132 && ev->canvas.x < 228 && ev->canvas.y > 267 && ev->canvas.x < 363) { + elm_layout_signal_emit(wid->layout, "on_off_clicked", "*"); + } } - app_control_destroy(app_control); } static void __alm_widget_new_alarm_mouse_move_cb(void *data, Evas * e, Evas_Object * obj, void *event_info) @@ -145,7 +162,8 @@ static void __alm_widget_new_alarm_mouse_down_cb(void *data, Evas * e, Evas_Obje elm_object_signal_emit(wid->layout, "clipper.no_alarm.pressed", "*"); } -static void _alarm_widget_edit_alarm_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +//static void _alarm_widget_edit_alarm_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source) +static void _alarm_widget_edit_alarm_up_cb(void *data) { _ALM_WIDGET_ENTER_; widget_instance_data_s *wid = (widget_instance_data_s *)data; @@ -180,11 +198,6 @@ static void switch_to_layout_with_alarm(widget_instance_data_s *wid) { _ALM_WIDGET_ENTER_; ret_if(!wid); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_DOWN, __alm_widget_new_alarm_mouse_down_cb); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_UP, __alm_widget_new_alarm_mouse_up_cb); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_MOVE, __alm_widget_new_alarm_mouse_move_cb); - elm_layout_signal_callback_del(wid->layout, "edit_clicked", "*", _alarm_widget_edit_alarm_up_cb); - elm_layout_signal_callback_add(wid->layout, "edit_clicked", "*", _alarm_widget_edit_alarm_up_cb, wid); view_alarm_update_no_allarmlist_layout_with_alarmlist(wid); @@ -194,13 +207,6 @@ static void switch_to_layout_with_no_alarm(widget_instance_data_s *wid) { _ALM_WIDGET_ENTER_; ret_if(!wid); - elm_layout_signal_callback_del(wid->layout, "edit_clicked", "*", _alarm_widget_edit_alarm_up_cb); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_DOWN, __alm_widget_new_alarm_mouse_down_cb); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_UP, __alm_widget_new_alarm_mouse_up_cb); - evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_MOVE, __alm_widget_new_alarm_mouse_move_cb); - evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_DOWN, __alm_widget_new_alarm_mouse_down_cb, wid); - evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_UP, __alm_widget_new_alarm_mouse_up_cb, wid); - evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_MOVE, __alm_widget_new_alarm_mouse_move_cb, wid); view_alarm_update_alarm_layout(wid); view_set_text(wid->layout, "no_alarm_text", "Add alarm"); @@ -264,6 +270,9 @@ static int widget_instance_create(widget_context_h context, bundle *content, int * Create GUI for alarm widget */ view_alarm_widget_create(context, file_path); + evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_DOWN, __alm_widget_new_alarm_mouse_down_cb, wid); + evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_UP, __alm_widget_new_alarm_mouse_up_cb, wid); + evas_object_event_callback_add(wid->layout, EVAS_CALLBACK_MOUSE_MOVE, __alm_widget_new_alarm_mouse_move_cb, wid); if (wid->db_id > 0) { ret = read_alarm_details(wid->db_id, &wid->alm_details); if (ret == 0) { @@ -300,6 +309,11 @@ static int widget_instance_destroy(widget_context_h context, widget_app_destroy_ /* Get the data structure using the tag */ widget_app_context_get_tag(context, (void**) &wid); retv_if(!wid, WIDGET_ERROR_NONE); + + evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_DOWN, __alm_widget_new_alarm_mouse_down_cb); + evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_UP, __alm_widget_new_alarm_mouse_up_cb); + evas_object_event_callback_del(wid->layout, EVAS_CALLBACK_MOUSE_MOVE, __alm_widget_new_alarm_mouse_move_cb); + /* Destroy all views */ view_widget_destroy(wid); if (wid->content) { |