From c8440309ae90682a6809b24e88d527b376f61c3e Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Tue, 10 Jul 2012 19:11:19 -0300 Subject: [PATCH] callscreen: volume, mute, speaker and contacts. volume was implemented using hardware keys, no visual feedback. mute was implemented as a toggle action. speaker and contacts were marked as placeholders. --- data/themes/default.edc | 200 +++++++++++++++++++++++++++++++++++++++++++++++- dialer/callscreen.c | 72 +++++++++++++++++ dialer/gui.c | 6 ++ dialer/keypad.c | 1 + 4 files changed, 276 insertions(+), 3 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 59d3016..ece6d11 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -364,7 +364,6 @@ collections { part { \ name: "button.over."##id; \ type: IMAGE; \ - mouse_events: 1; \ description { \ state: "default" 0.0; \ color: 255 255 255 0; \ @@ -708,7 +707,144 @@ collections { name: "button.over."##id; \ type: IMAGE; \ clip_to: "clipper."##id; \ + mouse_events: 0; \ + description { \ + state: "default" 0.0; \ + color: 255 255 255 0; \ + visible: 0; \ + color_class: "action"; \ + rel1.to: "button."##id; \ + rel2.to: "button."##id; \ + image.normal: "bt_"##img"_pressed.png"; \ + } \ + description { \ + state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + color: 255 255 255 255; \ + visible: 1; \ + } \ + } \ + part { \ + name: "blocker."##id; \ + type: RECT; \ mouse_events: 1; \ + clip_to: "clipper."##id; \ + description { \ + state: "default" 0.0; \ + color: 0 0 0 0; \ + visible: 0; \ + } \ + description { \ + state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } \ + programs { \ + program { \ + signal: "mouse,up,1"; \ + source: "button."##id; \ + action: SIGNAL_EMIT "released,"##id "call"; \ + after: "show_up_"##id; \ + } \ + program { \ + name: "show_up_"##id; \ + action: STATE_SET "default" 0.0; \ + transition: DECELERATE 0.1; \ + target: "button."##id; \ + target: "button.over."##id; \ + } \ + program { \ + signal: "mouse,down,1"; \ + source: "button."##id; \ + after: "show_down_"##id; \ + action: SIGNAL_EMIT "pressed,"##id "call"; \ + } \ + program { \ + name: "show_down_"##id; \ + action: STATE_SET "pressed" 0.0; \ + transition: ACCELERATE 0.1; \ + target: "button."##id; \ + target: "button.over."##id; \ + } \ + program { \ + signal: "mouse,clicked,1"; \ + source: "button."##id; \ + action: SIGNAL_EMIT "clicked,"##id "call"; \ + } \ + program { \ + signal: "disable,"##id; \ + source: "call"; \ + action: STATE_SET "disabled" 0.0; \ + target: "blocker."##id; \ + target: "clipper."##id; \ + } \ + program { \ + signal: "enable,"##id; \ + source: "call"; \ + action: STATE_SET "default" 0.0; \ + target: "blocker."##id; \ + target: "clipper."##id; \ + } \ + } + +#define ACTION_TOGGLE(id, img, r1, r2) \ + part { \ + name: "clipper."##id; \ + type: RECT; \ + clip_to: "clipper.actions"; \ + description { \ + state: "default" 0.0; \ + color: 255 255 255 255; \ + rel1.to: "button."##id; \ + rel2.to: "button."##id; \ + } \ + description { \ + state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color_class: "disabled"; \ + } \ + description { \ + state: "hidden" 0.0; \ + inherit: "default" 0.0; \ + color: 255 255 255 0; \ + visible: 0; \ + } \ + } \ + part { \ + name: "button."##id; \ + type: IMAGE; \ + mouse_events: 1; \ + clip_to: "clipper.toggle."##id; \ + description { \ + state: "default" 0.0; \ + color: 255 255 255 255; \ + color_class: "action"; \ + min: 240 170; \ + max: 240 170; \ + fixed: 1 1; \ + rel1 { \ + to: "bg.actions"; \ + relative: r1; \ + } \ + rel2 { \ + to: "bg.actions"; \ + relative: r2; \ + offset: -1 -1; \ + } \ + image.normal: "bt_"##img"_released.png"; \ + } \ + description { \ + state: "pressed" 0.0; \ + inherit: "default" 0.0; \ + color: 255 255 255 0; \ + visible: 0; \ + } \ + } \ + part { \ + name: "button.over."##id; \ + type: IMAGE; \ + clip_to: "clipper."##id; \ description { \ state: "default" 0.0; \ color: 255 255 255 0; \ @@ -726,6 +862,44 @@ collections { } \ } \ part { \ + name: "clipper.toggle."##id; \ + type: RECT; \ + clip_to: "clipper."##id; \ + mouse_events: 0; \ + description { \ + state: "default" 0.0; \ + color: 255 255 255 255; \ + visible: 1; \ + } \ + description { \ + state: "on" 0.0; \ + inherit: "default" 0.0; \ + color: 255 255 255 0; \ + visible: 0; \ + } \ + } \ + part { \ + name: "button.toggle."##id; \ + type: IMAGE; \ + clip_to: "clipper."##id; \ + mouse_events: 1; \ + description { \ + state: "default" 0.0; \ + color: 255 255 255 0; \ + visible: 0; \ + color_class: "action"; \ + rel1.to: "button."##id; \ + rel2.to: "button."##id; \ + image.normal: "bt_"##img"_pressed.png"; \ + } \ + description { \ + state: "on" 0.0; \ + inherit: "default" 0.0; \ + color: 255 255 255 255; \ + visible: 1; \ + } \ + } \ + part { \ name: "blocker."##id; \ type: RECT; \ mouse_events: 1; \ @@ -774,6 +948,11 @@ collections { action: SIGNAL_EMIT "clicked,"##id "call"; \ } \ program { \ + signal: "mouse,clicked,1"; \ + source: "button.toggle."##id; \ + action: SIGNAL_EMIT "clicked,"##id "call"; \ + } \ + program { \ signal: "disable,"##id; \ source: "call"; \ action: STATE_SET "disabled" 0.0; \ @@ -787,16 +966,31 @@ collections { target: "blocker."##id; \ target: "clipper."##id; \ } \ + program { \ + signal: "toggle,on,"##id; \ + source: "call"; \ + action: STATE_SET "on" 0.0; \ + target: "clipper.toggle."##id; \ + target: "button.toggle."##id; \ + } \ + program { \ + signal: "toggle,off,"##id; \ + source: "call"; \ + action: STATE_SET "default" 0.0; \ + target: "clipper.toggle."##id; \ + target: "button.toggle."##id; \ + } \ } - ACTION_BUTTON("mute", "mute", 0.000000000 0.0, 0.333333333 0.5); + ACTION_TOGGLE("mute", "mute", 0.000000000 0.0, 0.333333333 0.5); ACTION_BUTTON("keypad", "keypad", 0.333333333 0.0, 0.666666666 0.5); - ACTION_BUTTON("speaker", "speaker", 0.666666666 0.0, 1.000000000 0.5); + ACTION_TOGGLE("speaker", "speaker", 0.666666666 0.0, 1.000000000 0.5); ACTION_BUTTON("merge", "merge", 0.000000000 0.5, 0.333333333 1.0); ACTION_BUTTON("swap", "swap", 0.333333333 0.5, 0.666666666 1.0); ACTION_BUTTON("contacts", "contacts",0.666666666 0.5, 1.000000000 1.0); #undef ACTION_BUTTON +#undef ACTION_TOGGLE SEPARATOR("answer", "clipper.answer", 0.0, -8, "button.answer"); SEPARATOR("hangup", "", 0.0, -8, "button.hangup"); diff --git a/dialer/callscreen.c b/dialer/callscreen.c index d41e08c..eb131b2 100644 --- a/dialer/callscreen.c +++ b/dialer/callscreen.c @@ -218,9 +218,73 @@ static void _on_clicked(void *data, Evas_Object *obj __UNUSED__, } else if (strcmp(emission, "answer") == 0) { if (ctx->in_use) ofono_call_answer(ctx->in_use, NULL, NULL); + } else if (strcmp(emission, "mute") == 0) { + Eina_Bool val = !ofono_mute_get(); + ofono_mute_set(val, NULL, NULL); + } else if (strcmp(emission, "speaker") == 0) { + ERR("TODO - implement platform loudspeaker code"); + } else if (strcmp(emission, "contacts") == 0) { + ERR("TODO - implement access to contacts"); } } +static void _on_key_down(void *data, Evas *e __UNUSED__, + Evas_Object *o __UNUSED__, + void *event_info) +{ + Callscreen *ctx = data; + Evas_Event_Key_Down *ev = event_info; + DBG("ctx=%p, key=%s (%s, %s)", ctx, ev->keyname, ev->key, ev->string); + + if ((strcmp(ev->key, "minus") == 0) || + (strcmp(ev->key, "KP_Subtract") == 0) || + (strcmp(ev->key, "XF86AudioLowerVolume") == 0)) { + unsigned char last, cur; + + last = cur = ofono_volume_speaker_get(); + if (cur < 10) + cur = 0; + else + cur -= 10; + + if (last != cur) + ofono_volume_speaker_set(cur, NULL, NULL); + } else if ((strcmp(ev->key, "plus") == 0) || + (strcmp(ev->key, "KP_Add") == 0) || + (strcmp(ev->key, "XF86AudioRaiseVolume") == 0)) { + unsigned char last, cur; + + last = cur = ofono_volume_speaker_get(); + if (cur > 90) + cur = 100; + else + cur += 10; + + if (last != cur) + ofono_volume_speaker_set(cur, NULL, NULL); + } +} + +static void _ofono_changed(void *data) +{ + Callscreen *ctx = data; + Edje_Message_Float msgf; + Evas_Object *ed; + const char *sig; + + sig = ofono_mute_get() ? "toggle,on,mute" : "toggle,off,mute"; + elm_object_signal_emit(ctx->self, sig, "call"); + + ed = elm_layout_edje_get(ctx->self); + + msgf.val = (ofono_volume_speaker_get() / 100.0); + edje_object_message_send(ed, EDJE_MESSAGE_FLOAT, 1, &msgf); + + msgf.val = (ofono_volume_microphone_get() / 100.0); + edje_object_message_send(ed, EDJE_MESSAGE_FLOAT, 2, &msgf); +} + + static void _call_added(void *data, OFono_Call *c) { Callscreen *ctx = data; @@ -324,6 +388,8 @@ static void _call_changed(void *data, OFono_Call *c) if (state == OFONO_CALL_STATE_DISCONNECTED) _call_disconnected_show(ctx, c, "local"); + + _ofono_changed(ctx); } static void _call_disconnected(void *data, OFono_Call *c, const char *reason) @@ -345,6 +411,7 @@ static void _on_del(void *data, Evas *e __UNUSED__, ofono_call_removed_cb_set(NULL, NULL); ofono_call_changed_cb_set(NULL, NULL); ofono_call_disconnected_cb_set(NULL, NULL); + ofono_changed_cb_set(NULL, NULL); eina_strbuf_free(ctx->tones.todo); if (ctx->tones.pending) @@ -376,6 +443,10 @@ Evas_Object *callscreen_add(Evas_Object *parent) { elm_object_signal_callback_add(obj, "clicked,*", "call", _on_clicked, ctx); + elm_object_focus_allow_set(obj, EINA_TRUE); + evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, + _on_key_down, ctx); + elm_object_part_text_set(obj, "elm.text.name", ""); elm_object_part_text_set(obj, "elm.text.status", ""); @@ -383,6 +454,7 @@ Evas_Object *callscreen_add(Evas_Object *parent) { ofono_call_removed_cb_set(_call_removed, ctx); ofono_call_changed_cb_set(_call_changed, ctx); ofono_call_disconnected_cb_set(_call_disconnected, ctx); + ofono_changed_cb_set(_ofono_changed, ctx); return obj; } diff --git a/dialer/gui.c b/dialer/gui.c index 82b8a2a..47d0dca 100644 --- a/dialer/gui.c +++ b/dialer/gui.c @@ -74,6 +74,7 @@ void gui_call_enter(void) return; in_flip_anim = EINA_TRUE; elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS); + elm_object_focus_set(cs, EINA_TRUE); } void gui_call_exit(void) @@ -85,6 +86,7 @@ void gui_call_exit(void) return; in_flip_anim = EINA_TRUE; elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS); + elm_object_focus_set(kp, EINA_TRUE); } static void _gui_call_sync(void *data __UNUSED__, Evas_Object *o __UNUSED__, @@ -95,6 +97,10 @@ static void _gui_call_sync(void *data __UNUSED__, Evas_Object *o __UNUSED__, if (showing_call ^ in_call) { DBG("Flip back to sync"); elm_flip_go(flip, ELM_FLIP_ROTATE_Y_CENTER_AXIS); + if (in_call) + elm_object_focus_set(cs, EINA_TRUE); + else + elm_object_focus_set(kp, EINA_TRUE); } in_flip_anim = EINA_FALSE; } diff --git a/dialer/keypad.c b/dialer/keypad.c index 245fe2b..c9792a9 100644 --- a/dialer/keypad.c +++ b/dialer/keypad.c @@ -454,6 +454,7 @@ Evas_Object *keypad_add(Evas_Object *parent) { _on_clicked, ctx); elm_object_part_text_set(obj, "elm.text.display", ""); + elm_object_focus_allow_set(obj, EINA_TRUE); return obj; } -- 2.7.4