From: Igor Olshevskyi Date: Tue, 30 May 2017 11:40:21 +0000 (+0300) Subject: TizenRefApp-8618 [Call UI] Prepare base implementation of MoreOptionPresenter X-Git-Tag: submit/tizen/20170703.150902^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a80183298771d1639bd4ad9d58ef3e441b148171;p=profile%2Fwearable%2Fapps%2Fnative%2Fcall-ui.git TizenRefApp-8618 [Call UI] Prepare base implementation of MoreOptionPresenter Change-Id: I5aa45ca5d3a89ae39795b64304bb818a37e765a2 --- diff --git a/edc/buttons.edc b/edc/buttons.edc index 066ce88..54b7a18 100644 --- a/edc/buttons.edc +++ b/edc/buttons.edc @@ -33,6 +33,8 @@ #define CU_BTN_ACCESSORY_EFF_PRESSED_SIZE 144 144 #define CU_BTN_ACCESSORY_ICON_SIZE 50 50 +#define CU_BTN_MORE_OPT_TXT_SIZE 100 32 + #define CU_BTN_INCOM_CALL(_name, _icon, _bg_cc, _effect_cc, _icon_norm_cc, _icon_pressed_cc) \ group { "elm/button/base/"_name; \ script { \ @@ -407,7 +409,7 @@ group { "elm/button/base/"_name; \ } \ program { "disable_event_pass"; \ signal: "elm,event,pass,disabled"; \ - source:"elm"; \ + source: "elm"; \ script { \ set_mouse_events(PART:"event", 1); \ } \ @@ -421,7 +423,7 @@ group { "elm/button/base/"_name; \ } \ program { "disable_event_repeat"; \ signal: "elm,event,repeat,disabled"; \ - source:"elm"; \ + source: "elm"; \ script { \ set_repeat_events(PART:"event", 0); \ } \ @@ -728,6 +730,224 @@ group { "elm/button/base/"_name; \ } \ } +styles { + style { "more_btn_norm"; + base: "font=Tizen font_weight=Regular font_width=Condensed font_size=24 align=center valign=center color=#FFFFFF ellipsis=1.0"; + } + style { "more_btn_dim"; + base: "font=Tizen font_weight=Regular font_width=Condensed font_size=24 align=center valign=center color=#4D4D4D ellipsis=1.0"; + } +} + +#define CU_BTN_MORE_OPTION(_name, _icon) \ + group { "elm/button/base/"_name; \ + images { \ + image: "w_more_circle_bg.png" COMP; \ + image: _icon COMP; \ + } \ + parts { \ + image { "icon.bg"; \ + scale; \ + desc { "default"; \ + aspect: 1 1; \ + aspect_preference: BOTH; \ + align: 0.5 0.0; \ + image.normal: "w_more_circle_bg.png"; \ + color_class: "AO0110"; \ + } \ + desc { "pressed"; \ + inherit: "default"; \ + color_class: "AO0110P"; \ + } \ + desc { "disabled"; \ + inherit: "default"; \ + color_class: "AO0110D"; \ + } \ + } \ + image { "icon"; \ + scale; \ + desc { "default"; \ + aspect: 1 1; \ + aspect_preference: BOTH; \ + align: 0.5 0.0; \ + image.normal: _icon; \ + color_class: "AO0181"; \ + } \ + desc { "pressed"; \ + inherit: "default"; \ + color_class: "AO0181P"; \ + } \ + desc { "disabled"; \ + inherit: "default"; \ + color_class: "AO0181D"; \ + } \ + } \ + textblock { "elm.text"; \ + scale; \ + desc { "default"; \ + min: CU_BTN_MORE_OPT_TXT_SIZE; \ + max: CU_BTN_MORE_OPT_TXT_SIZE; \ + align: 0.5 1.0; \ + text.style: "more_btn_norm"; \ + } \ + desc { "pressed"; \ + inherit: "default"; \ + } \ + desc { "disabled"; \ + inherit: "default"; \ + text.style: "more_btn_dim"; \ + } \ + } \ + rect { "event"; \ + mouse; \ + desc { "default"; \ + color: 0 0 0 0; \ + } \ + desc { "disabled"; \ + inherit: "default"; \ + hid; \ + } \ + } \ + } \ + script { \ + public mouse_down = 0; \ + public multi_down = 0; \ + public disabled = 0; \ + } \ + programs { \ + program { "pressed"; \ + signal: "mouse,down,1*"; \ + source: "event"; \ + action: SIGNAL_EMIT "elm,action,press" ""; \ + after: "on_pressed"; \ + } \ + program { "unpressed"; \ + signal: "mouse,up,1*"; \ + source: "event"; \ + action: SIGNAL_EMIT "elm,action,unpress" ""; \ + after: "on_unpressed"; \ + } \ + program { "clicked"; \ + signal: "mouse,clicked,1"; \ + source: "event"; \ + action: SIGNAL_EMIT "elm,action,click" ""; \ + after: "on_clicked"; \ + } \ + program { "enabled"; \ + signal: "elm,state,enabled"; \ + source: "elm"; \ + action: STATE_SET "default"; \ + target: "event"; \ + after: "on_enabled"; \ + } \ + program { "disabled"; \ + signal: "elm,state,disabled"; \ + source: "elm"; \ + action: STATE_SET "disabled"; \ + target: "event"; \ + after: "on_disabled"; \ + } \ + program { "enable_event_pass"; \ + signal: "elm,event,pass,enabled"; \ + source: "elm"; \ + script { \ + set_mouse_events(PART:"event", 0); \ + } \ + } \ + program { "disable_event_pass"; \ + signal: "elm,event,pass,disabled"; \ + source: "elm"; \ + script { \ + set_mouse_events(PART:"event", 1); \ + } \ + } \ + program { "enable_event_repeat"; \ + signal: "elm,event,repeat,enabled"; \ + source: "elm"; \ + script { \ + set_repeat_events(PART:"event", 1); \ + } \ + } \ + program { "disable_event_repeat"; \ + signal: "elm,event,repeat,disabled"; \ + source: "elm"; \ + script { \ + set_repeat_events(PART:"event", 0); \ + } \ + } \ + program { "on_pressed"; \ + script { \ + if ((get_int(multi_down) == 0) && (get_int(mouse_down) == 0)) { \ + set_int(mouse_down, 1); \ + if (!get_int(disabled)) { \ + set_state(PART:"icon.bg", "pressed", 0.0); \ + set_state(PART:"icon", "pressed", 0.0); \ + set_state(PART:"elm.text", "pressed", 0.0); \ + } \ + } \ + } \ + } \ + program { "on_unpressed"; \ + script { \ + if (get_int(mouse_down) == 1) { \ + set_int(mouse_down, 0); \ + if (!get_int(disabled)) { \ + set_state(PART:"icon.bg", "default", 0.0); \ + set_state(PART:"icon", "default", 0.0); \ + set_state(PART:"elm.text", "default", 0.0); \ + } \ + } \ + } \ + } \ + program { "on_clicked"; \ + script { \ + if (get_int(multi_down) == 0) { \ + if (!get_int(disabled)) { \ + run_program(PROGRAM:"play_sample"); \ + } \ + } \ + } \ + } \ + program { \ + name: "play_sample"; \ + action: RUN_PLUGIN "touch_sound"; \ + } \ + program { "on_disabled"; \ + script { \ + set_int(disabled, 1); \ + set_state(PART:"icon.bg", "disabled", 0.0); \ + set_state(PART:"icon", "disabled", 0.0); \ + set_state(PART:"elm.text", "disabled", 0.0); \ + set_state(PART:"event", "disabled", 0.0); \ + } \ + } \ + program { "on_enabled"; \ + script { \ + set_int(disabled, 0); \ + set_state(PART:"icon.bg", "default", 0.0); \ + set_state(PART:"icon", "default", 0.0); \ + set_state(PART:"elm.text", "default", 0.0); \ + set_state(PART:"event", "default", 0.0); \ + } \ + } \ + program { "multi_down"; \ + signal: "elm,action,multi,down"; \ + source: "elm"; \ + script { \ + set_int(multi_down, 1); \ + } \ + } \ + program { "multi_up"; \ + signal: "elm,action,multi,up"; \ + source: "elm"; \ + script { \ + set_int(multi_down, 0); \ + } \ + } \ + } \ + } + + CU_BTN_INCOM_CALL("callui/accept", "w_call_incoming_icon_accept.png", "AO01131", "AO01132", "AO0113", "AO0113P") CU_BTN_INCOM_CALL("callui/reject", "w_call_incoming_icon_reject.png", "AO01151", "AO01152", "AO0115", "AO0115P") @@ -738,4 +958,11 @@ CU_BTN_VOLUME_CONTROL("callui/minus", "b_slider_icon_minus.png") CU_BTN_VOLUME_CONTROL("callui/plus", "b_slider_icon_plus.png") CU_BTN_ACCESSORY("callui/volume", "w_outgoing_icon_volume.png", 1.0, 1.0) -CU_BTN_ACCESSORY("callui/mute", "w_outgoing_icon_mute.png", 0.0, 0.0) \ No newline at end of file +CU_BTN_ACCESSORY("callui/mute", "w_outgoing_icon_mute.png", 0.0, 0.0) + +CU_BTN_MORE_OPTION("callui/swap", "w_call_option_icon_volume_swap.png") +CU_BTN_MORE_OPTION("callui/unhold", "w_call_option_icon_volume_unhold.png") +CU_BTN_MORE_OPTION("callui/headset", "w_call_option_icon_headset.png") +CU_BTN_MORE_OPTION("callui/phone", "w_call_option_icon_device.png") +CU_BTN_MORE_OPTION("callui/keypad", "w_call_option_icon_keypad.png") +CU_BTN_MORE_OPTION("callui/gear", "w_call_option_icon_volume_towatch.png") diff --git a/edc/call_info.edc b/edc/call_info.edc index 7330124..2186773 100644 --- a/edc/call_info.edc +++ b/edc/call_info.edc @@ -219,6 +219,7 @@ group { "elm/layout/callui/call_info"; desc { "default"; rel1 { relative: 0.5 0.0; to: "zone.text_info"; } rel2 { relative: 0.5 1.0; to: "zone.text_info"; } + max: 208 32; text { style: "call_status"; min: 1 0; @@ -506,6 +507,7 @@ group { "elm/layout/callui/call_info"; set_state(PART:"top.pad", "default", 0.0); set_state(PART:"zone.text_1line", "default", 0.0); set_state(PART:"text_1line", "default", 0.0); + set_int(b_set_photo, 0); } } program { @@ -597,7 +599,6 @@ group { "elm/layout/callui/call_info"; signal: "caller_id_enable"; source: "text_1line"; script { - set_int(b_set_photo, 1); set_state(PART:"text_1line", "photo", 0.0); set_state(PART:"text_info", "photo", 0.0); } @@ -606,7 +607,6 @@ group { "elm/layout/callui/call_info"; signal: "caller_id_disable"; source: "text_1line"; script { - set_int(b_set_photo, 0); set_state(PART:"text_1line", "default", 0.0); set_state(PART:"text_info", "default", 0.0); } @@ -623,6 +623,7 @@ group { "elm/layout/callui/call_info"; signal: "caller_id_enable"; source: "caller_id"; script { + set_int(b_set_photo, 1); set_state(PART:"caller_id.mask", "incoming", 0.0); } } @@ -630,6 +631,7 @@ group { "elm/layout/callui/call_info"; signal: "caller_id_disable"; source: "caller_id"; script { + set_int(b_set_photo, 0); set_state(PART:"caller_id.mask", "default", 0.0); } } diff --git a/edc/color_classes.edc b/edc/color_classes.edc index d9622e4..308a4de 100644 --- a/edc/color_classes.edc +++ b/edc/color_classes.edc @@ -113,4 +113,23 @@ color_classes { color_class { name: "AO012D"; color: 255 255 255 77; } + // More options + color_class { name: "AO0110"; + color: 250 250 250 255; + } + color_class { name: "AO0110P"; + color: 191 191 191 255; + } + color_class { name: "AO0110D"; + color: 77 77 77 255; + } + color_class { name: "AO0181"; + color: 20 20 20 255; + } + color_class { name: "AO0181P"; + color: 50 156 209 255; + } + color_class { name: "AO0181D"; + color: 51 51 51 255; + } } diff --git a/edc/main_ly.edc b/edc/main_ly.edc index 04c6c23..1dc2391 100644 --- a/edc/main_ly.edc +++ b/edc/main_ly.edc @@ -50,6 +50,11 @@ group { "elm/layout/callui/main"; desc { "default"; } } + swallow { "swl.more_option"; + scale; + desc { "default"; + } + } } } diff --git a/edc/more_option.edc b/edc/more_option.edc new file mode 100644 index 0000000..bf1d7ca --- /dev/null +++ b/edc/more_option.edc @@ -0,0 +1,147 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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. + */ + +#define CU_MORE_OPT_TXT_TOP_PAD 161 + +#define CU_MORE_OPT_TXT_SMALL_W 112 +#define CU_MORE_OPT_TXT_SMALL_H 36 + +#define CU_MORE_OPT_TXT_BIG_W 100 +#define CU_MORE_OPT_TXT_BIG_H 39 + +#define CU_MORE_OPT_BTN_TOP_X 130 +#define CU_MORE_OPT_BTN_TOP_Y 21 + +#define CU_MORE_OPT_BTN_LEFT_X 21 +#define CU_MORE_OPT_BTN_LEFT_Y 130 + +#define CU_MORE_OPT_BTN_RIGHT_X 239 +#define CU_MORE_OPT_BTN_RIGHT_Y 130 + +#define CU_MORE_OPT_BTN_BOTTOM_X 130 +#define CU_MORE_OPT_BTN_BOTTOM_Y 219 + +#define CU_MORE_OPT_BTN_W 100 +#define CU_MORE_OPT_BTN_H 135 + +#define CU_MORE_OPT_BTN_TOP_REL1 CU_REL_W(CU_MORE_OPT_BTN_TOP_X) CU_REL_H(CU_MORE_OPT_BTN_TOP_Y) +#define CU_MORE_OPT_BTN_TOP_REL2 CU_REL_W((CU_MORE_OPT_BTN_TOP_X + CU_MORE_OPT_BTN_W)) CU_REL_H((CU_MORE_OPT_BTN_TOP_Y + CU_MORE_OPT_BTN_H)) + +#define CU_MORE_OPT_BTN_LEFT_REL1 CU_REL_W(CU_MORE_OPT_BTN_LEFT_X) CU_REL_H(CU_MORE_OPT_BTN_LEFT_Y) +#define CU_MORE_OPT_BTN_LEFT_REL2 CU_REL_W((CU_MORE_OPT_BTN_LEFT_X + CU_MORE_OPT_BTN_W)) CU_REL_H((CU_MORE_OPT_BTN_LEFT_Y + CU_MORE_OPT_BTN_H)) + +#define CU_MORE_OPT_BTN_RIGHT_REL1 CU_REL_W(CU_MORE_OPT_BTN_RIGHT_X) CU_REL_H(CU_MORE_OPT_BTN_RIGHT_Y) +#define CU_MORE_OPT_BTN_RIGHT_REL2 CU_REL_W((CU_MORE_OPT_BTN_RIGHT_X+CU_MORE_OPT_BTN_W)) CU_REL_H((CU_MORE_OPT_BTN_RIGHT_Y + CU_MORE_OPT_BTN_H)) + +#define CU_MORE_OPT_BTN_BOTTOM_REL1 CU_REL_W(CU_MORE_OPT_BTN_BOTTOM_X) CU_REL_H(CU_MORE_OPT_BTN_BOTTOM_Y) +#define CU_MORE_OPT_BTN_BOTTOM_REL2 CU_REL_W((CU_MORE_OPT_BTN_BOTTOM_X + CU_MORE_OPT_BTN_W)) CU_REL_H((CU_MORE_OPT_BTN_BOTTOM_Y + CU_MORE_OPT_BTN_H)) + +styles { + style { "more_opt_status_big"; + base: "font=Tizen font_weight=Regular font_width=Condensed font_size=30 align=center valign=center color=#4DCFFF ellipsis=1.0"; + } + style { "more_opt_status_small"; + base: "font=Tizen font_weight=Regular font_width=Condensed font_size=27 align=center valign=center color=#4DCFFF ellipsis=1.0"; + } +} + +group { "elm/layout/callui/more_option"; + parts { + rect { "bg"; + scale; + desc { "default"; + min: CU_WIN_W CU_WIN_H; + max: CU_WIN_W CU_WIN_H; + fixed: 1 1; + color: 0 0 0 255; + } + } + spacer { "txt.pad.top"; + scale; + desc { "default"; + min: 0 CU_MORE_OPT_TXT_TOP_PAD; + fixed: 0 1; + rel1 { relative: 0.0 0.0; to: "bg"; } + rel2 { relative: 1.0 0.0; to: "bg"; } + align: 0.0 0.0; + } + } + textblock { "txt.status"; + scale; + desc { "default"; + min: CU_MORE_OPT_TXT_BIG_W CU_MORE_OPT_TXT_BIG_H; + max: CU_MORE_OPT_TXT_BIG_W CU_MORE_OPT_TXT_BIG_H; + fixed: 1 1; + align: 0.5 0.0; + rel1 { relative: 0.0 1.0; to_y: "txt.pad.top"; } + rel2 { relative: 1.0 1.0; to_y: "txt.pad.top"; } + text.style: "more_opt_status_big"; + } + desc { "small"; + inherit: "default"; + min: CU_MORE_OPT_TXT_SMALL_W CU_MORE_OPT_TXT_SMALL_H; + max: CU_MORE_OPT_TXT_SMALL_W CU_MORE_OPT_TXT_SMALL_H; + text.style: "more_opt_status_small"; + } + } + swallow { "swl.top"; + scale; + desc { "default"; + fixed: 1 1; + rel1 { relative: CU_MORE_OPT_BTN_TOP_REL1; to: "bg";} + rel2 { relative: CU_MORE_OPT_BTN_TOP_REL2; to: "bg";} + } + } + swallow { "swl.left"; + scale; + desc { "default"; + fixed: 1 1; + rel1 { relative: CU_MORE_OPT_BTN_LEFT_REL1; to: "bg";} + rel2 { relative: CU_MORE_OPT_BTN_LEFT_REL2; to: "bg";} + } + } + swallow { "swl.right"; + scale; + desc { "default"; + fixed: 1 1; + rel1 { relative: CU_MORE_OPT_BTN_RIGHT_REL1; to: "bg";} + rel2 { relative: CU_MORE_OPT_BTN_RIGHT_REL2; to: "bg";} + } + } + swallow { "swl.bottom"; + scale; + desc { "default"; + fixed: 1 1; + rel1 { relative: CU_MORE_OPT_BTN_BOTTOM_REL1; to: "bg";} + rel2 { relative: CU_MORE_OPT_BTN_BOTTOM_REL2; to: "bg";} + } + } + } + programs { + program { + signal: "status_txt_big"; + source: ""; + action: STATE_SET "default"; + target: "txt.status"; + } + program { + signal: "status_txt_small"; + source: ""; + action: STATE_SET "small"; + target: "txt.status"; + } + } +} diff --git a/edc/volume_control.edc b/edc/volume_control.edc index 25ce08d..e0ab578 100644 --- a/edc/volume_control.edc +++ b/edc/volume_control.edc @@ -33,18 +33,22 @@ styles { } } +group { "elm/layout/callui/slider"; + parts { + swallow { "swl.slider"; + scale; + desc { "default"; + } + } + } +} + group { "elm/layout/callui/volume_control"; images { image: "b_slider_btn_bg.png" COMP; image: "w_call_opt_volume.png" COMP; } parts { - spacer { "sizer" - scale; - desc { "default"; - min: 360 360; - } - } rect { "bg"; scale; desc { "default"; @@ -57,8 +61,6 @@ group { "elm/layout/callui/volume_control"; swallow { "swl.slider"; scale; desc { "default"; - rel1.to: "sizer"; - rel2.to: "sizer"; } } spacer { "pad.top"; @@ -66,8 +68,8 @@ group { "elm/layout/callui/volume_control"; desc { "default"; min: CU_VOLUME_PAD_TOP_MIN; fixed: 0 1; - rel1 { relative: 0.0 0.0; to: "sizer"; } - rel2 { relative: 1.0 0.0; to: "sizer"; } + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 0.0; } align: 0.0 0.0; } } @@ -76,8 +78,8 @@ group { "elm/layout/callui/volume_control"; desc { "default"; min: CU_VOLUME_PAD_BOTTOM_MIN; fixed: 0 1; - rel1 { relative: 0.0 1.0; to: "sizer"; } - rel2 { relative: 1.0 1.0; to: "sizer"; } + rel1 { relative: 0.0 1.0; } + rel2 { relative: 1.0 1.0; } align: 0.0 1.0; } } @@ -172,8 +174,6 @@ group { "elm/layout/callui/volume_control"; desc { "default"; min: CU_VOLUME_ICON_SIZE; max: CU_VOLUME_ICON_SIZE; - rel1.to: "sizer"; - rel2.to: "sizer"; image.normal: "b_slider_btn_bg.png"; } desc { "hide"; @@ -185,8 +185,6 @@ group { "elm/layout/callui/volume_control"; desc { "default"; min: CU_VOLUME_ICON_SIZE; max: CU_VOLUME_ICON_SIZE; - rel1.to: "sizer"; - rel2.to: "sizer"; image.normal: "w_call_opt_volume.png"; color: 0 0 0 255; } diff --git a/inc/presenters/AccessoryPresenter.h b/inc/presenters/AccessoryPresenter.h index e5a1881..92f0f8e 100644 --- a/inc/presenters/AccessoryPresenter.h +++ b/inc/presenters/AccessoryPresenter.h @@ -55,6 +55,7 @@ namespace callui { ucl::Result prepare(ucl::ElmWidget &parent, bool isMuteControlDisabled = false); ucl::Result createWidget(ucl::ElmWidget &parent); + ucl::Result createSlider(); ucl::Result createVolumeControl(); ucl::Result createVolumeBtn(); ucl::Result createMuteBtn(); @@ -85,6 +86,7 @@ namespace callui { ucl::LayoutSRef m_widget; ucl::StyledWidgetSRef m_volumeBtn; ucl::StyledWidgetSRef m_muteBtn; + SliderSRef m_slider; VolumeControlSRef m_vc; ISoundManagerSRef m_sm; Ecore_Timer *m_vcTimer; diff --git a/inc/presenters/CallInfoPresenter.h b/inc/presenters/CallInfoPresenter.h index 53b6a60..eb86978 100644 --- a/inc/presenters/CallInfoPresenter.h +++ b/inc/presenters/CallInfoPresenter.h @@ -87,7 +87,6 @@ namespace callui { ICallInfoSCRef m_heldCallInfo; ICallInfoSCRef m_endCallInfo; CallStatusSRef m_callStatus; - bool m_isCallerIdEnable; bool m_isEmergency; bool m_isSubTxtEnable; bool m_needModifyCallStatus; diff --git a/inc/presenters/MainPage.h b/inc/presenters/MainPage.h index 090b5e3..6f49868 100644 --- a/inc/presenters/MainPage.h +++ b/inc/presenters/MainPage.h @@ -62,8 +62,8 @@ namespace callui { void RejectMsgSelectCb(const IRejectMsgSRef &rm); ucl::Result createCallInfoPresenter(CallMode mode); - ucl::Result createAccessoryPresenter(); + ucl::Result createMoreOptionsPresenter(); ucl::Result createBottomBtn(const ucl::ElmStyle &style); void onBottomBtnClicked(ucl::Widget &widget, void *eventInfo); @@ -102,6 +102,7 @@ namespace callui { AcceptRejectPresenterSRef m_acceptRejectPrs; RejectMsgPresenterSRef m_rmPrs; AccessoryPresenterSRef m_accessoryPrs; + MoreOptionsPresenterSRef m_moreOptions; CallMode m_mode; Ecore_Timer *m_ecTimer; bool m_ecTimerBtnReq; diff --git a/inc/presenters/MoreOptionsPresenter.h b/inc/presenters/MoreOptionsPresenter.h new file mode 100644 index 0000000..c3b748f --- /dev/null +++ b/inc/presenters/MoreOptionsPresenter.h @@ -0,0 +1,104 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__ +#define __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__ + +#include "Presenter.h" + +#include "ucl/gui/Layout.h" +#include "ucl/gui/StyledWidget.h" + +#include "types.h" + +namespace callui { + + class MoreOptionsPresenter final : public Presenter { + public: + class Builder { + public: + Builder(); + ~Builder(); + Builder &setCallManager(const ICallManagerSRef &cm); + MoreOptionsPresenterSRef build(ucl::ElmWidget &parent) const; + private: + ICallManagerSRef m_cm; + }; + + public: + ucl::Widget &getWidget(); + ucl::Result update(); + + private: + friend class ucl::RefCountObj; + MoreOptionsPresenter(ucl::RefCountObjBase &rc, const ICallManagerSRef &cm); + virtual ~MoreOptionsPresenter(); + + ucl::Result prepare(ucl::ElmWidget &parent); + + ucl::Result createWidget(ucl::ElmWidget &parent); + ucl::Result createPanel(); + ucl::Result createPanelLayout(); + ucl::Result createButtons(); + ucl::StyledWidgetSRef createButton(const ucl::ElmStyle &style, + const ucl::TString &txt, + const ucl::WidgetEventHandler &handler); + + ucl::Result updateSlots(); + ucl::Result updateTopSlot(); + ucl::Result updateLeftSlot(); + ucl::Result updateRightSlot(); + ucl::Result updateBottomSlot(); + + ucl::Result updateStatusText(); + void updateStatusFontSize(); + + void onSwapBtnClick(ucl::Widget &sender, void *eventInfo); + void onUnholdBtnClick(ucl::Widget &sender, void *eventInfo); + void onHeadsetBtnClick(ucl::Widget &sender, void *eventInfo); + void onPhoneBtnClick(ucl::Widget &sender, void *eventInfo); + void onKeypadBtnClick(ucl::Widget &sender, void *eventInfo); + void onGearBtnClick(ucl::Widget &sender, void *eventInfo); + + void onBackKey(Evas_Object *obj, void *eventInfo); + + void onActivate(Evas_Object *obj, const char *emission, const char *source); + void onInactivate(Evas_Object *obj, const char *emission, const char *source); + + ucl::Result startCallDurationTimer(); + void stopCallDurationTimer(); + Eina_Bool onCallDurationTimerCb(); + + private: + ucl::LayoutSRef m_widget; + ucl::StyledWidgetSRef m_panel; + ucl::LayoutSRef m_panelLy; + ucl::StyledWidgetSRef m_btnSwap; + ucl::StyledWidgetSRef m_btnUnhold; + ucl::StyledWidgetSRef m_btnHeadset; + ucl::StyledWidgetSRef m_btnPhone; + ucl::StyledWidgetSRef m_btnKeypad; + ucl::StyledWidgetSRef m_btnGear; + + ICallManagerSRef m_cm; + ICallInfoWCRef m_info; + + Ecore_Timer *m_timer; + struct tm m_duration; + }; +} + +#endif // __CALLUI_PRESENTERS_MORE_OPTIONS_PRESENTER_H__ diff --git a/inc/presenters/types.h b/inc/presenters/types.h index e2a558d..fc5fe6c 100644 --- a/inc/presenters/types.h +++ b/inc/presenters/types.h @@ -57,6 +57,7 @@ namespace callui { UCL_DECLARE_REF_ALIASES(RejectMsgPresenter); UCL_DECLARE_REF_ALIASES(AccessoryPresenter); + UCL_DECLARE_REF_ALIASES(MoreOptionsPresenter); using AcceptDialogHandler = ucl::WeakDelegate; using RejectMsgStateHandler = ucl::WeakDelegate; diff --git a/inc/resources.h b/inc/resources.h index 4c24744..9fe4910 100644 --- a/inc/resources.h +++ b/inc/resources.h @@ -44,6 +44,15 @@ namespace callui { extern const ucl::TString STR_DECLINE_MESSAGES; extern const ucl::TString STR_VOLUME; + + extern const ucl::TString STR_MORE_SWAP; + extern const ucl::TString STR_MORE_HEADSET; + extern const ucl::TString STR_MORE_PHONE; + extern const ucl::TString STR_MORE_KEYPAD; + extern const ucl::TString STR_MORE_HOLD; + extern const ucl::TString STR_MORE_UNHOLD; + extern const ucl::TString STR_MORE_TRANSFER; + extern const ucl::TString STR_MORE_GEAR; } #endif // __CALLUI_RESOURCES_H__ diff --git a/inc/view/Slider.h b/inc/view/Slider.h new file mode 100644 index 0000000..ce63711 --- /dev/null +++ b/inc/view/Slider.h @@ -0,0 +1,64 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 __CALLUI_VIEW_SLIDER_H__ +#define __CALLUI_VIEW_SLIDER_H__ + +#include "ucl/gui/Layout.h" + +#include "types.h" + +namespace callui { + + class Slider : public ucl::ElmWidget { + public: + class Builder { + public: + Builder(); + Builder &setMaxValue(int maxValue); + Builder &setValue(int curValue); + SliderSRef build(ucl::ElmWidget &parent) const; + + private: + int m_maxValue; + int m_curValue; + }; + + public: + virtual void setValue(int value); + virtual void setMaxValue(int maxValue); + + protected: + friend class ucl::RefCountObj; + Slider(ucl::RefCountObjBase &rc, + const ucl::LayoutSRef &layout, + int maxValue, + int curValue); + virtual ~Slider(); + + private: + void prepare(int maxValue, int curValue); + + protected: + ucl::LayoutWRef m_layout; + ucl::Layout m_circleLy; + Eext_Circle_Surface *m_circleSurf; + ucl::ElmWidget m_slider; + }; + +} + +#endif // __CALLUI_VIEW_SLIDER_H__ diff --git a/inc/view/VolumeControl.h b/inc/view/VolumeControl.h index 4fcb55b..52dd350 100644 --- a/inc/view/VolumeControl.h +++ b/inc/view/VolumeControl.h @@ -17,6 +17,7 @@ #ifndef __CALLUI_VIEW_VOLUME_CONTROL_H__ #define __CALLUI_VIEW_VOLUME_CONTROL_H__ +#include #include "ucl/gui/StyledWidget.h" #include "ucl/gui/Layout.h" @@ -24,15 +25,14 @@ namespace callui { - class VolumeControl final : public ucl::ElmWidget { + class VolumeControl final : public Slider { public: class Builder { public: Builder(); Builder &setInfoText(const ucl::TString &info); - Builder &setMaxSliderValue(int maxValue); - Builder &setSliderValue(int curValue); - Builder &setShowControls(bool isShown); + Builder &setMaxValue(int maxValue); + Builder &setValue(int curValue); Builder &setEventHandler(const VolumeControlEventHandler &handler); VolumeControlSRef build(ucl::ElmWidget &parent) const; @@ -40,21 +40,19 @@ namespace callui { ucl::TString m_info; int m_maxValue; int m_curValue; - bool m_showControls; VolumeControlEventHandler m_handler; }; public: - void showControls(); - void hideControls(); - bool getControlsVisibilityState(); void setInfoText(const ucl::TString &info); - void setSliderValue(int value); - void setMaxSliderValue(int maxValue); void setDecreaseBtnEnable(bool isEnable); void setIncreaseBtnEnable(bool isEnable); void setEventHandler(const VolumeControlEventHandler &handler); + // Slider + + virtual void setValue(int value) override final; + private: friend class ucl::RefCountObj; VolumeControl(ucl::RefCountObjBase &rc, @@ -62,25 +60,19 @@ namespace callui { const ucl::TString &info, int maxValue, int curValue, - bool showControls, const VolumeControlEventHandler &handler); + virtual ~VolumeControl(); - void prepare(const ucl::TString &info, - int maxValue, - int curValue, - bool showControls); + void prepare(const ucl::TString &info, int curValue); void onDecreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo); void onIncreaseBtnClickedCb(ucl::Widget &widget, void *eventInfo); private: - ucl::LayoutWRef m_layout; - ucl::ElmWidget m_slider; ucl::StyledWidget m_decreaseBtn; ucl::StyledWidget m_increaseBtn; VolumeControlEventHandler m_handler; - bool m_isControlsShown; }; } diff --git a/inc/view/types.h b/inc/view/types.h index 4a38550..eace9d0 100644 --- a/inc/view/types.h +++ b/inc/view/types.h @@ -30,6 +30,7 @@ namespace callui { DECREASE }; + UCL_DECLARE_REF_ALIASES(Slider); UCL_DECLARE_REF_ALIASES(VolumeControl); using VolumeControlEventHandler = ucl::WeakDelegate; diff --git a/res/edje/theme.edc b/res/edje/theme.edc index 2425601..e178e73 100644 --- a/res/edje/theme.edc +++ b/res/edje/theme.edc @@ -45,5 +45,6 @@ collections { #include "../../edc/reject_msg.edc" #include "../../edc/volume_control.edc" #include "../../edc/accessory.edc" + #include "../../edc/more_option.edc" } diff --git a/src/presenters/AccessoryPresenter.cpp b/src/presenters/AccessoryPresenter.cpp index 8920903..af7afef 100644 --- a/src/presenters/AccessoryPresenter.cpp +++ b/src/presenters/AccessoryPresenter.cpp @@ -18,6 +18,7 @@ #include "model/ISoundManager.h" #include "view/VolumeControl.h" + #include "resources.h" #include "common.h" @@ -31,7 +32,7 @@ namespace callui { namespace { namespace impl { constexpr LayoutTheme LAYOUT_ACCESSORY_WIDGET {"layout", "callui", "accessory"}; - constexpr EdjePart PART_SWL_VOLUME_CONTROL {"swl.volume_control"}; + constexpr EdjePart PART_SWL_VOLUME_SLIDER {"swl.volume_control"}; constexpr EdjePart PART_SWL_SOUND {"swl.sound"}; constexpr EdjePart PART_SWL_MUTE {"swl.mute"}; @@ -96,6 +97,8 @@ namespace callui { FAIL_RETURN(createWidget(parent), "createWidget() failed"); + FAIL_RETURN(createSlider(), "createSlider() failed"); + FAIL_RETURN(createVolumeControl(), "createVolumeControl() failed"); FAIL_RETURN(createVolumeBtn(), "createVolumeBtn() failed"); @@ -104,6 +107,8 @@ namespace callui { registerCallbacks(); + updateVolume(m_sm->getVolume()); + setMuteControlDisabled(isMuteControlDisabled); return RES_OK; @@ -117,7 +122,7 @@ namespace callui { void AccessoryPresenter::hideVolumeControls() { stopVCTimer(); - m_vc->hideControls(); + hide(*m_vc); } void AccessoryPresenter::setMuteControlDisabled(bool isDisabled) @@ -143,22 +148,43 @@ namespace callui { return RES_OK; } + Result AccessoryPresenter::createSlider() + { + m_slider = Slider::Builder(). + setMaxValue(m_sm->getMaxVolume()). + build(*m_widget); + if (!m_slider) { + LOG_RETURN(RES_FAIL, "Slider::build() failed"); + } + + m_widget->setContent(*m_slider, impl::PART_SWL_VOLUME_SLIDER); + + return RES_OK; + } + Result AccessoryPresenter::createVolumeControl() { m_vc = VolumeControl::Builder(). setInfoText(STR_VOLUME). - setMaxSliderValue(m_sm->getMaxVolume()). - setShowControls(false). + setMaxValue(m_sm->getMaxVolume()). setEventHandler(WEAK_DELEGATE( - AccessoryPresenter::onVolumeControlEventCb, - asWeak(*this))). + AccessoryPresenter::onVolumeControlEventCb, + asWeak(*this))). build(*m_widget); if (!m_vc) { LOG_RETURN(RES_FAIL, "VolumeControl::build() failed"); } - updateVolume(m_sm->getVolume()); - m_widget->setContent(*m_vc, impl::PART_SWL_VOLUME_CONTROL); + auto window = m_vc->getWindow(); + if (!window) { + LOG_RETURN(RES_FAIL, "Window is NULL!"); + } + int w = 0, h = 0; + window->getScreenSize(&w, &h); + + m_vc->move(0, 0); + m_vc->resize(w, h); + hide(*m_vc); return RES_OK; } @@ -201,7 +227,7 @@ namespace callui { void AccessoryPresenter::onVolumeBtnClicked(Widget &widget, void *eventInfo) { - m_vc->showControls(); + show(*m_vc); startVCTimer(); } @@ -242,7 +268,7 @@ namespace callui { Eina_Bool AccessoryPresenter::onVCTimerCb() { - m_vc->hideControls(); + hide(*m_vc); m_vcTimer = nullptr; return ECORE_CALLBACK_CANCEL; @@ -274,10 +300,14 @@ namespace callui { Eina_Bool AccessoryPresenter::onRotaryEvent(Eext_Rotary_Event_Info *info) { + if (!isActive()) { + LOG_RETURN_VALUE(RES_OK, EINA_TRUE, "Presenter is not active. Ignore"); + } + if (m_vcTimer) { restartVCTimer(); } else { - m_vc->showControls(); + show(*m_vc); startVCTimer(); } @@ -332,15 +362,22 @@ namespace callui { (m_audioState == AudioStateType::BT && state != AudioStateType::BT)) { m_audioState = state; - m_vc->setSliderValue(0); - m_vc->setMaxSliderValue(m_sm->getMaxVolume()); + + m_vc->setValue(0); + m_slider->setValue(0); + + auto maxVol = m_sm->getMaxVolume(); + m_vc->setMaxValue(maxVol); + m_slider->setMaxValue(maxVol); + updateVolume(m_sm->getVolume()); } } void AccessoryPresenter::updateVolume(int value) { - m_vc->setSliderValue(value); + m_vc->setValue(value); + m_slider->setValue(value); auto max = m_sm->getMaxVolume(); auto cur = m_sm->getVolume(); diff --git a/src/presenters/CallInfoPresenter.cpp b/src/presenters/CallInfoPresenter.cpp index d7dd99d..17ac196 100644 --- a/src/presenters/CallInfoPresenter.cpp +++ b/src/presenters/CallInfoPresenter.cpp @@ -38,7 +38,7 @@ namespace callui { namespace { namespace impl { constexpr int SUB_TXT_WIDTH = 208; constexpr int MAIN_TXT_WIDTH_SIMPLE = 208; constexpr int MAIN_TXT_WIDTH_INCOM = 190; - constexpr int SLIDE_LABEL_DURATION_KOEFF = 8; + constexpr int SLIDE_LABEL_DURATION_KOEFF = 20; constexpr LayoutTheme LAYOUT_CALLER_INFO_WIDGET {"layout", "callui", "call_info"}; @@ -126,7 +126,6 @@ namespace callui { CallMode mode): Presenter(rc), m_mode(mode), - m_isCallerIdEnable(false), m_isEmergency(false), m_isSubTxtEnable(false), m_needModifyCallStatus(false) @@ -216,7 +215,6 @@ namespace callui { m_mode = mode; initCallInfos(cm); - m_isCallerIdEnable = false; m_isEmergency = false; m_isSubTxtEnable = false; @@ -298,12 +296,13 @@ namespace callui { Result CallInfoPresenter::createLabel(const std::string &text) { TString tmp; - if (m_isCallerIdEnable) { + if (m_callerId) { tmp = impl::STR_LABEL_CALLER_ID_ENABLE.format(text.c_str()); } else { tmp = impl::STR_LABEL_CALLER_ID_DISABLE.format(text.c_str()); } - int duration = text.size() / impl::SLIDE_LABEL_DURATION_KOEFF; + double duration = (static_cast(text.size())) / + impl::SLIDE_LABEL_DURATION_KOEFF; auto label = makeShared(elm_label_add(*m_widget), true); if (!label) { @@ -326,8 +325,6 @@ namespace callui { Result CallInfoPresenter::updateCallerId() { - m_isCallerIdEnable = false; - m_callerId.reset(); m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, impl::SRC_CALLER_ID); @@ -374,8 +371,6 @@ namespace callui { m_widget->emit(impl::SIGN_CALLER_ID_ENABLE, impl::SRC_CALLER_ID); m_callerId = callerId; - - m_isCallerIdEnable = true; } return RES_OK; @@ -411,7 +406,7 @@ namespace callui { m_isSubTxtEnable = true; TString tmp; - if (m_isCallerIdEnable) { + if (m_callerId) { tmp = impl::STR_LABEL_CALLER_ID_ENABLE.format(subTxt.c_str()); } else { tmp = impl::STR_LABEL_CALLER_ID_DISABLE.format(subTxt.c_str()); @@ -473,7 +468,7 @@ namespace callui { } if (m_mode == CallMode::INCOMING) { - if (m_isCallerIdEnable) { + if (m_callerId) { m_widget->emit(impl::SIGN_CALLER_ID_ENABLE, impl::SRC_TXT_1LINE); } else { m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, impl::SRC_TXT_1LINE); diff --git a/src/presenters/CallStatus.cpp b/src/presenters/CallStatus.cpp index 9629208..a0f7bef 100644 --- a/src/presenters/CallStatus.cpp +++ b/src/presenters/CallStatus.cpp @@ -37,34 +37,6 @@ namespace callui { namespace { namespace impl { constexpr EdjeSignalSrc SIGN_SRC_DOT{"dot"}; - const TString STR_HH_MM_SS_TIME{"%02d:%02d:%02d"}; - const TString STR_MM_SS_TIME{"%02d:%02d"}; - - void setCallDuration(const struct tm &time, - EdjeWidget &widget, - const EdjePart &part) - { - TString tmp; - if (time.tm_hour > 0) { - tmp = STR_HH_MM_SS_TIME.format(time.tm_hour, time.tm_min, time.tm_sec); - } else { - tmp = STR_MM_SS_TIME.format(time.tm_min, time.tm_sec); - } - widget.setText(tmp, part); - } - - void tryUpdateCallDurationTime( - struct tm &curTime, - struct tm &compTime, - EdjeWidget &widget, - const EdjePart &part) - { - if ((compTime.tm_sec - curTime.tm_sec) != 0) { - curTime = compTime; - setCallDuration(curTime, widget, part); - } - } - }}} namespace callui { @@ -193,7 +165,7 @@ namespace callui { } struct tm tmp = m_info->getDuration(); - impl::tryUpdateCallDurationTime( + tryUpdateCallDurationTime( m_duration, tmp, *m_ly, @@ -209,7 +181,7 @@ namespace callui { m_ly->setText(STR_ON_HOLD, impl::PART_TXT_TEXT_INFO); } else { m_duration = m_info->getDuration(); - impl::setCallDuration(m_duration, *m_ly, impl::PART_TXT_TEXT_INFO); + setCallDuration(m_duration, *m_ly, impl::PART_TXT_TEXT_INFO); if (m_timer) { ecore_timer_del(m_timer); @@ -230,7 +202,7 @@ namespace callui { Eina_Bool CallStatus::onBlinkingTimerCb() { if ((m_blinkCount % 2) == 0) { - impl::setCallDuration(m_duration, *m_ly, impl::PART_TXT_TEXT_INFO); + setCallDuration(m_duration, *m_ly, impl::PART_TXT_TEXT_INFO); } else if ((m_blinkCount % 2) == 1) { m_ly->setText("", impl::PART_TXT_TEXT_INFO); } diff --git a/src/presenters/MainPage.cpp b/src/presenters/MainPage.cpp index 84ea49a..85262b5 100644 --- a/src/presenters/MainPage.cpp +++ b/src/presenters/MainPage.cpp @@ -35,6 +35,7 @@ #include "presenters/CallInfoPresenter.h" #include "presenters/RejectMsgPresenter.h" #include "presenters/AccessoryPresenter.h" +#include "presenters/MoreOptionsPresenter.h" #include "resources.h" #include "common.h" @@ -58,6 +59,7 @@ namespace callui { namespace { namespace impl { constexpr EdjePart PART_SWL_REJECT_MSG {"swl.rm"}; constexpr EdjePart PART_SWL_BOTTOM_BTN {"swl.bottom_btn"}; constexpr EdjePart PART_SWL_OVERLAY {"swl.overlay"}; + constexpr EdjePart PART_SWL_MORE_OPTION {"swl.more_option"}; constexpr EdjePart PART_TXT_REJECT_MSG {"reject_msg_text"}; @@ -176,28 +178,40 @@ namespace callui { void MainPage::onActivateBy(const DeactivatorInfo &info) { - if (info.deactivator == &getNaviframe()) { - if (m_rmPrs) { - m_rmPrs->activateBy(info.deactivator); - } + if (info.isBroadcast) { + return; + } + + if (m_rmPrs) { + m_rmPrs->activateBy(info.deactivator); } if (m_acceptRejectPrs) { m_acceptRejectPrs->activateBy(info.deactivator); } + + if (m_accessoryPrs) { + m_accessoryPrs->activateBy(info.deactivator); + } } void MainPage::onDeactivateBy(const DeactivatorInfo &info) { - if (info.deactivator == &getNaviframe()) { - if (m_rmPrs) { - m_rmPrs->deactivateBy(info.deactivator); - } + if (info.isBroadcast) { + return; + } + + if (m_rmPrs) { + m_rmPrs->deactivateBy(info.deactivator); } if (m_acceptRejectPrs) { m_acceptRejectPrs->deactivateBy(info.deactivator); } + + if (m_accessoryPrs) { + m_accessoryPrs->deactivateBy(info.deactivator); + } } void MainPage::processKeyPress() @@ -409,6 +423,8 @@ namespace callui { if (m_mode == CallMode::INCOMING) { m_accessoryPrs.reset(); + m_moreOptions.reset(); + FAIL_RETURN_VOID(processIncomingCall(), "processIncomingCall() failed!"); } else { @@ -418,10 +434,13 @@ namespace callui { if (m_mode == CallMode::END) { m_accessoryPrs.reset(); + m_moreOptions.reset(); startEndCallTimer(); } else { FAIL_RETURN_VOID(createAccessoryPresenter(), "createAccessoryPresenter() failed"); + FAIL_RETURN_VOID(createMoreOptionsPresenter(), + "createMoreOptionsPresenter() failed"); FAIL_RETURN_VOID(createBottomBtn(impl::STYLE_BB_END_CALL), "createBottomBtn() failed"); @@ -449,7 +468,7 @@ namespace callui { Result MainPage::createAccessoryPresenter() { if (m_accessoryPrs) { - ILOG("Already exists. No need to create new one"); + ILOG("Already exists. No need to create new one. Just update."); m_accessoryPrs->setMuteControlDisabled( detectMuteControlDisableState()); return RES_OK; @@ -465,12 +484,35 @@ namespace callui { "AccessoryPresenter::build() failed!"); } - m_widget->setContent(m_accessoryPrs->getWidget().getEo(), + m_widget->setContent(m_accessoryPrs->getWidget(), impl::PART_SWL_OVERLAY); return RES_OK; } + Result MainPage::createMoreOptionsPresenter() + { + if (m_moreOptions) { + ILOG("Already exists. No need to create new one. Just update."); + return m_moreOptions->update(); + } + + m_moreOptions = MoreOptionsPresenter::Builder(). + setCallManager(m_cm). + build(*m_widget); + + if (!m_moreOptions) { + LOG_RETURN(RES_FAIL, + "MoreOptionsPresenter::build() failed!"); + } + + m_widget->setContent(m_moreOptions->getWidget(), + impl::PART_SWL_MORE_OPTION); + addDeactivatorSource(m_moreOptions->getWidget()); + + return RES_OK; + } + Result MainPage::createAcceptRejectPresenter() { if (m_acceptRejectPrs) { diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp new file mode 100644 index 0000000..556433b --- /dev/null +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -0,0 +1,497 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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. + */ + +#include "presenters/MoreOptionsPresenter.h" + +#include "ucl/gui/Layout.h" + +#include "model/ICallManager.h" +#include "model/IHeldCall.h" +#include "model/IActiveCall.h" +#include "model/ICallInfo.h" + +#include "resources.h" +#include "common.h" + +namespace callui { namespace { namespace impl { + + using namespace ucl; + + constexpr auto CALL_DURATION_TIMER_INTERVAL = 0.1; + + constexpr LayoutTheme LAYOUT_DRAWER_PANEL + {"layout", "drawer", "panel"}; + + constexpr LayoutTheme LAYOUT_MORE_OPTION_WIDGET + {"layout", "callui", "more_option"}; + + constexpr EdjePart PART_SWL_RIGHT {"elm.swallow.right"}; + + constexpr ElmStyle STYLE_BTN_SWAP {"callui/swap"}; + constexpr ElmStyle STYLE_BTN_UNHOLD {"callui/unhold"}; + constexpr ElmStyle STYLE_BTN_HEADSET {"callui/headset"}; + constexpr ElmStyle STYLE_BTN_PHONE {"callui/phone"}; + constexpr ElmStyle STYLE_BTN_KEYPAD {"callui/keypad"}; + constexpr ElmStyle STYLE_BTN_GEAR {"callui/gear"}; + + constexpr EdjePart PART_SWL_PANEL_LY_TOP {"swl.top"}; + constexpr EdjePart PART_SWL_PANEL_LY_LEFT {"swl.left"}; + constexpr EdjePart PART_SWL_PANEL_LY_RIGHT {"swl.right"}; + constexpr EdjePart PART_SWL_PANEL_LY_BOTTOM {"swl.bottom"}; + + constexpr EdjePart PART_TXT_STATUS {"txt.status"}; + + constexpr EdjeSignal SIGNAL_STATUS_TXT_BIG {"status_txt_big"}; + constexpr EdjeSignal SIGNAL_STATUS_TXT_SMALL {"status_txt_small"}; + +}}} + +namespace callui { + + using namespace ucl; + + // MoreOptionsPresenter::Builder + + MoreOptionsPresenter::Builder::Builder() + { + } + + MoreOptionsPresenter::Builder::~Builder() + { + } + + MoreOptionsPresenter::Builder &MoreOptionsPresenter::Builder::setCallManager(const ICallManagerSRef &cm) + { + m_cm = cm; + return *this; + } + + MoreOptionsPresenterSRef MoreOptionsPresenter::Builder::build(ElmWidget &parent) const + { + if (!m_cm) { + LOG_RETURN_VALUE(RES_FAIL, {}, "Call Manager is not set"); + } + + auto result = makeShared(m_cm); + FAIL_RETURN_VALUE(result->prepare(parent), {}, + "result->prepare() failed!"); + + return result; + } + + // MoreOptionsPresenter + + MoreOptionsPresenter::MoreOptionsPresenter(RefCountObjBase &rc, const ICallManagerSRef &cm): + Presenter(rc), + m_cm(cm), + m_timer(nullptr) + { + } + + MoreOptionsPresenter::~MoreOptionsPresenter() + { + stopCallDurationTimer(); + + if (m_widget) { + eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK, + CALLBACK_A(MoreOptionsPresenter::onBackKey)); + + sendActivateBy(*m_widget, this); + } + } + + Result MoreOptionsPresenter::prepare(ElmWidget &parent) + { + FAIL_RETURN(Presenter::prepare(parent), "Presenter::prepare() failed!"); + + FAIL_RETURN(createWidget(parent), "createWidget() failed!"); + + FAIL_RETURN(createPanel(), "createPanel() failed!"); + + FAIL_RETURN(createPanelLayout(), "createPanelContent() failed!"); + + FAIL_RETURN(createButtons(), "createButtons() failed!"); + + FAIL_RETURN(update(), "update() failed!"); + + addDeactivatorException(this); + + return RES_OK; + } + + Result MoreOptionsPresenter::createWidget(ElmWidget &parent) + { + m_widget = Layout::Builder(). + setTheme(impl::LAYOUT_DRAWER_PANEL). + setIsOwner(true). + build(parent); + + if (!m_widget) { + LOG_RETURN(RES_FAIL, "Layout::build() failed!"); + } + + return RES_OK; + } + + Result MoreOptionsPresenter::createPanel() + { + auto *eo = elm_panel_add(*m_widget); + if (!eo) { + LOG_RETURN(RES_FAIL, "elm_panel_add() failed!"); + } + m_panel = makeShared(eo, true); + elm_panel_orient_set(*m_panel, ELM_PANEL_ORIENT_RIGHT); + show(*m_panel); + + m_widget->setContent(*m_panel, impl::PART_SWL_RIGHT); + + elm_panel_toggle(*m_panel); + + elm_layout_signal_callback_add(*m_panel, "elm,state,active,finished", + "elm", CALLBACK_A(MoreOptionsPresenter::onActivate), this); + + elm_layout_signal_callback_add(*m_panel, "elm,state,inactive,finished", + "elm", CALLBACK_A(MoreOptionsPresenter::onInactivate), this); + + return RES_OK; + } + + Result MoreOptionsPresenter::createPanelLayout() + { + m_panelLy = Layout::Builder(). + setTheme(impl::LAYOUT_MORE_OPTION_WIDGET). + build(*m_panel); + if (!m_panelLy) { + LOG_RETURN(RES_FAIL, "Layout::build() failed!"); + } + show(*m_panelLy); + m_panel->setContent(*m_panelLy); + + return RES_OK; + } + + Result MoreOptionsPresenter::updateSlots() + { + FAIL_RETURN(updateTopSlot(), "updateTopSlot() failed"); + FAIL_RETURN(updateLeftSlot(), "updateLeftSlot() failed"); + FAIL_RETURN(updateRightSlot(), "updateRightSlot() failed"); + FAIL_RETURN(updateBottomSlot(), "updateBottomSlot() failed"); + + return RES_OK; + } + + Result MoreOptionsPresenter::updateTopSlot() + { + auto active = m_cm->getActiveCall(); + auto held = m_cm->getHeldCall(); + + auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_TOP); + if (eo) { + hide(*asWidget(eo)); + } + + if (active) { + if (held) { + m_panelLy->setContent(*m_btnSwap, impl::PART_SWL_PANEL_LY_TOP); + show(*m_btnSwap); + } + } else if (held) { + m_panelLy->setContent(*m_btnUnhold, impl::PART_SWL_PANEL_LY_TOP); + show(*m_btnUnhold); + } else { + LOG_RETURN(RES_FAIL, "Undefined state"); + } + + return RES_OK; + } + + Result MoreOptionsPresenter::updateLeftSlot() + { + auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_LEFT); + if (eo) { + hide(*asWidget(eo)); + } + + m_panelLy->setContent(*m_btnHeadset, impl::PART_SWL_PANEL_LY_LEFT); + show(*m_btnHeadset); + disable(*m_btnHeadset); + + return RES_OK; + } + + Result MoreOptionsPresenter::updateRightSlot() + { + auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_RIGHT); + if (eo) { + hide(*asWidget(eo)); + } + + m_panelLy->setContent(*m_btnPhone, impl::PART_SWL_PANEL_LY_RIGHT); + show(*m_btnPhone); + disable(*m_btnPhone); + + return RES_OK; + } + + Result MoreOptionsPresenter::updateBottomSlot() + { + auto *eo = m_panelLy->unsetContent(impl::PART_SWL_PANEL_LY_BOTTOM); + if (eo) { + hide(*asWidget(eo)); + } + + m_panelLy->setContent(*m_btnKeypad, impl::PART_SWL_PANEL_LY_BOTTOM); + show(*m_btnKeypad); + disable(*m_btnKeypad); + + return RES_OK; + } + + Result MoreOptionsPresenter::createButtons() + { + // Swap + m_btnSwap = createButton(impl::STYLE_BTN_SWAP, STR_MORE_SWAP, + WEAK_DELEGATE(MoreOptionsPresenter::onSwapBtnClick, + asWeak(*this))); + if (!m_btnSwap) { + LOG_RETURN(RES_FAIL, "Create Swap button failed!"); + } + + // Unhold + m_btnUnhold = createButton(impl::STYLE_BTN_UNHOLD, STR_MORE_UNHOLD, + WEAK_DELEGATE(MoreOptionsPresenter::onUnholdBtnClick, + asWeak(*this))); + if (!m_btnUnhold) { + LOG_RETURN(RES_FAIL, "Create Unhold button failed!"); + } + + // Headset + m_btnHeadset = createButton(impl::STYLE_BTN_HEADSET, STR_MORE_HEADSET, + WEAK_DELEGATE(MoreOptionsPresenter::onHeadsetBtnClick, + asWeak(*this))); + if (!m_btnHeadset) { + LOG_RETURN(RES_FAIL, "Create Headset button failed!"); + } + + // Phone + m_btnPhone = createButton(impl::STYLE_BTN_PHONE, STR_MORE_PHONE, + WEAK_DELEGATE(MoreOptionsPresenter::onPhoneBtnClick, + asWeak(*this))); + if (!m_btnPhone) { + LOG_RETURN(RES_FAIL, "Create Phone button failed!"); + } + + // Keypad + m_btnKeypad = createButton(impl::STYLE_BTN_KEYPAD, STR_MORE_KEYPAD, + WEAK_DELEGATE(MoreOptionsPresenter::onKeypadBtnClick, + asWeak(*this))); + if (!m_btnKeypad) { + LOG_RETURN(RES_FAIL, "Create Keypad button failed!"); + } + + // Gear + m_btnGear = createButton(impl::STYLE_BTN_GEAR, STR_MORE_GEAR, + WEAK_DELEGATE(MoreOptionsPresenter::onGearBtnClick, + asWeak(*this))); + if (!m_btnGear) { + LOG_RETURN(RES_FAIL, "Create Gear button failed!"); + } + + return RES_OK; + } + + void MoreOptionsPresenter::onSwapBtnClick(Widget &sender, void *eventInfo) + { + auto held = m_cm->getHeldCall(); + if (!held) { + LOG_RETURN_VOID(RES_FAIL, "Held call is NULL"); + } + FAIL_RETURN_VOID(held->swapWithActive(), "swapWithActive() failed"); + } + + void MoreOptionsPresenter::onUnholdBtnClick(Widget &sender, void *eventInfo) + { + auto held = m_cm->getHeldCall(); + if (!held) { + LOG_RETURN_VOID(RES_FAIL, "Held call is NULL"); + } + FAIL_RETURN_VOID(held->unhold(), "unhold() failed"); + } + + void MoreOptionsPresenter::onHeadsetBtnClick(Widget &sender, void *eventInfo) + { + ELOG("Not implemented"); + } + + void MoreOptionsPresenter::onPhoneBtnClick(Widget &sender, void *eventInfo) + { + ELOG("Not implemented"); + } + + void MoreOptionsPresenter::onKeypadBtnClick(Widget &sender, void *eventInfo) + { + ELOG("Not implemented"); + } + + void MoreOptionsPresenter::onGearBtnClick(Widget &sender, void *eventInfo) + { + ELOG("Not implemented"); + } + + StyledWidgetSRef MoreOptionsPresenter::createButton( + const ElmStyle &style, + const TString &txt, + const WidgetEventHandler &handler) + { + auto *eo = elm_button_add(*m_panelLy); + if (!eo) { + LOG_RETURN_VALUE(RES_FAIL, {}, "elm_button_add() failed!"); + } + auto btn = makeShared(eo, true); + btn->setStyle(style); + btn->setText(txt); + btn->addEventHandler(BTN_CLICKED, handler); + hide(*btn); + + btn->bindToEo(); + + return btn; + } + + Widget &MoreOptionsPresenter::getWidget() + { + return *m_widget; + } + + Result MoreOptionsPresenter::update() + { + FAIL_RETURN(updateSlots(), "updateSlots() failed!"); + + FAIL_RETURN(updateStatusText(), "updateStatusText() failed!"); + + return RES_OK; + } + + void MoreOptionsPresenter::onActivate(Evas_Object *obj, const char *emission, const char *source) + { + eext_object_event_callback_add(*m_widget, EEXT_CALLBACK_BACK, + CALLBACK_A(MoreOptionsPresenter::onBackKey), this); + + const auto keepAliver = asShared(*this); + sendDeactivateBy(*m_widget, this); + activateBy(m_widget.get()); + } + + void MoreOptionsPresenter::onInactivate(Evas_Object *obj, const char *emission, const char *source) + { + eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK, + CALLBACK_A(MoreOptionsPresenter::onBackKey)); + + const auto keepAliver = asShared(*this); + deactivateBy(m_widget.get()); + sendActivateBy(*m_widget, this); + } + + void MoreOptionsPresenter::onBackKey(Evas_Object *obj, void *eventInfo) + { + if (isActive() && !elm_panel_hidden_get(*m_panel)) { + elm_panel_toggle(*m_panel); + } + } + + Result MoreOptionsPresenter::updateStatusText() + { + m_panelLy->setText("", impl::PART_TXT_STATUS); + + auto active = m_cm->getActiveCall(); + auto held = m_cm->getHeldCall(); + + if (held && !active) { + m_panelLy->setText(STR_ON_HOLD, impl::PART_TXT_STATUS); + m_panelLy->emit(impl::SIGNAL_STATUS_TXT_BIG); + } else if (active) { + if (active->isDialingMode()) { + m_panelLy->setText(STR_DIALING_CALL, impl::PART_TXT_STATUS); + m_panelLy->emit(impl::SIGNAL_STATUS_TXT_BIG); + return RES_OK; + } + m_info = active->getInfo(); + if (!m_info) { + LOG_RETURN(RES_FAIL, "Call Info is NULL"); + } + m_duration = m_info->getDuration(); + setCallDuration(m_duration, *m_panelLy, impl::PART_TXT_STATUS); + updateStatusFontSize(); + + FAIL_RETURN(startCallDurationTimer(), "startTimer() failed!"); + + } else { + LOG_RETURN(RES_FAIL, "Undefined state"); + } + + return RES_OK; + } + + void MoreOptionsPresenter::updateStatusFontSize() + { + if (m_duration.tm_hour > 0) { + m_panelLy->emit(impl::SIGNAL_STATUS_TXT_SMALL); + } else { + m_panelLy->emit(impl::SIGNAL_STATUS_TXT_BIG); + } + } + + Eina_Bool MoreOptionsPresenter::onCallDurationTimerCb() + { + if (!m_info) { + m_timer = nullptr; + LOG_RETURN_VALUE(RES_FAIL, ECORE_CALLBACK_CANCEL, "m_info is NULL"); + } + + struct tm tmp = m_info->getDuration(); + tryUpdateCallDurationTime( + m_duration, + tmp, + *m_panelLy, + impl::PART_TXT_STATUS); + updateStatusFontSize(); + + return ECORE_CALLBACK_RENEW; + } + + Result MoreOptionsPresenter::startCallDurationTimer() + { + stopCallDurationTimer(); + + m_timer = ecore_timer_add(impl::CALL_DURATION_TIMER_INTERVAL, + CALLBACK_B(MoreOptionsPresenter::onCallDurationTimerCb), + this); + + if (!m_timer) { + LOG_RETURN(RES_FAIL, "m_timer is NULL"); + } + + return RES_OK; + } + + void MoreOptionsPresenter::stopCallDurationTimer() + { + if (m_timer) { + ecore_timer_del(m_timer); + m_timer = nullptr; + } + } +} diff --git a/src/presenters/RejectMsgPresenter.cpp b/src/presenters/RejectMsgPresenter.cpp index 3911e08..63e224a 100644 --- a/src/presenters/RejectMsgPresenter.cpp +++ b/src/presenters/RejectMsgPresenter.cpp @@ -19,7 +19,6 @@ #include "model/IRejectMsgProvider.h" #include "model/IRejectMsg.h" -#include "helpers.h" #include "resources.h" #include "common.h" @@ -167,6 +166,8 @@ namespace callui { FAIL_RETURN(createGenlist(), "createGenlist() failed!"); + addDeactivatorException(this); + deactivateBy(m_widget.get()); return RES_OK; diff --git a/src/presenters/common.h b/src/presenters/common.h index 18bd36f..879c2c1 100644 --- a/src/presenters/common.h +++ b/src/presenters/common.h @@ -21,6 +21,8 @@ #include "view/helpers.h" +#include "helpers.h" + #include "../common.h" #include "../view/common.h" diff --git a/src/presenters/helpers.cpp b/src/presenters/helpers.cpp index 5e35a14..ef4ea02 100644 --- a/src/presenters/helpers.cpp +++ b/src/presenters/helpers.cpp @@ -14,10 +14,15 @@ * limitations under the License. */ -#include "helpers.h" - #include "common.h" +namespace callui { namespace { namespace himpl { + + const TString STR_HH_MM_SS_TIME{"%02d:%02d:%02d"}; + const TString STR_MM_SS_TIME{"%02d:%02d"}; + +}}} + namespace callui { using namespace ucl; @@ -36,4 +41,29 @@ namespace callui { } } + void setCallDuration(const struct tm &time, + EdjeWidget &widget, + const EdjePart &part) + { + TString tmp; + if (time.tm_hour > 0) { + tmp = himpl::STR_HH_MM_SS_TIME.format(time.tm_hour, time.tm_min, time.tm_sec); + } else { + tmp = himpl::STR_MM_SS_TIME.format(time.tm_min, time.tm_sec); + } + widget.setText(tmp, part); + } + + void tryUpdateCallDurationTime( + struct tm &curTime, + struct tm &compTime, + EdjeWidget &widget, + const EdjePart &part) + { + if ((compTime.tm_sec - curTime.tm_sec) != 0) { + curTime = compTime; + setCallDuration(curTime, widget, part); + } + } + } diff --git a/src/presenters/helpers.h b/src/presenters/helpers.h index 1986073..0504407 100644 --- a/src/presenters/helpers.h +++ b/src/presenters/helpers.h @@ -18,11 +18,22 @@ #define __CALLUI_PRESENTERS_HELPERS_H__ #include +#include + +#include "ucl/gui/EdjeWidget.h" +#include "ucl/gui/types.h" namespace callui { void replaceSubstringInString(std::string &str, const std::string &from, const std::string &to); + + void setCallDuration(const struct tm &time, + ucl::EdjeWidget &widget, const ucl::EdjePart &part); + + void tryUpdateCallDurationTime( + struct tm &curTime, struct tm &compTime, + ucl::EdjeWidget &widget, const ucl::EdjePart &part); } #endif // __CALLUI_PRESENTERS_HELPERS_H__ diff --git a/src/resources.cpp b/src/resources.cpp index 6b666d9..fdd8f18 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -39,4 +39,12 @@ namespace callui { const ucl::TString STR_DECLINE_MESSAGES {"Decline messages"}; const ucl::TString STR_VOLUME {"Volume"}; + + const ucl::TString STR_MORE_SWAP {"Swap"}; + const ucl::TString STR_MORE_HEADSET {"Headset"}; + const ucl::TString STR_MORE_PHONE {"Phone"}; + const ucl::TString STR_MORE_KEYPAD {"Keypad"}; + const ucl::TString STR_MORE_HOLD {"Hold"}; + const ucl::TString STR_MORE_UNHOLD {"Unhold"}; + const ucl::TString STR_MORE_GEAR {"Gear"}; } diff --git a/src/view/Slider.cpp b/src/view/Slider.cpp new file mode 100644 index 0000000..34a4011 --- /dev/null +++ b/src/view/Slider.cpp @@ -0,0 +1,129 @@ +/* + * Copyright 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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. + */ + +#include + +#include "common.h" + +namespace callui { namespace { namespace impl { + + using namespace ucl; + + constexpr LayoutTheme LAYOUT_SLIDER + {"layout", "callui", "slider"}; + + constexpr ElmStyle STYLE_BTN_MINUS {"callui/minus"}; + constexpr ElmStyle STYLE_BTN_PLUS {"callui/plus"}; + + constexpr EdjePart PART_SWL_SLIDER {"swl.slider"}; + constexpr EdjePart PART_SWL_MINUS {"swl.minus"}; + constexpr EdjePart PART_SWL_PLUS {"swl.plus"}; + + constexpr EdjePart PART_TXT_INFO {"txt.info"}; + constexpr EdjePart PART_TXT_VALUE {"txt.value"}; + + constexpr EdjeSignal SIGNAL_SHOW_CONTROLS {"show_controls"}; + constexpr EdjeSignal SIGNAL_HIDE_CONTROLS {"hide_controls"}; + + constexpr EdjeSignalSrc SIGNAL_SRC_VOICE_CONTROL {"volume_control"}; +}}} + +namespace callui { + + using namespace ucl; + + Slider::Builder::Builder(): + m_maxValue(0), + m_curValue(0) + { + } + + Slider::Builder &Slider::Builder::setMaxValue(int maxValue) + { + m_maxValue = maxValue; + return *this; + } + + Slider::Builder &Slider::Builder::setValue(int curValue) + { + m_curValue = curValue; + return *this; + } + + SliderSRef Slider::Builder::build(ElmWidget &parent) const + { + auto layout = Layout::Builder(). + setTheme(impl::LAYOUT_SLIDER). + setIsOwner(true). + build(parent); + if (!layout) { + LOG_RETURN_VALUE(RES_FAIL, {}, "Layout::build() failed!"); + } + + auto result = makeShared(layout, m_maxValue, m_curValue); + + result->bindToEo(); + + return result; + } + + Slider::Slider(RefCountObjBase &rc, + const LayoutSRef &layout, + int maxValue, + int curValue): + ElmWidget(&rc, *layout, true), + m_layout(layout), + m_circleLy(elm_layout_add(*m_layout)), + m_circleSurf(eext_circle_surface_layout_add(m_circleLy)), + m_slider(eext_circle_object_slider_add(*m_layout, m_circleSurf)) + { + prepare(maxValue, curValue); + } + + Slider::~Slider() + { + } + + void Slider::prepare(int maxValue, int curValue) + { + m_layout->setIsOwner(false); + + evas_object_size_hint_align_set(m_slider, + EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(m_slider, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + m_circleLy.setContent(m_slider); + m_layout->setContent(m_circleLy, impl::PART_SWL_SLIDER); + show(m_circleLy); + show(m_slider); + show(*m_layout); + + setMaxValue(maxValue); + setValue(curValue); + } + + void Slider::setValue(int value) + { + eext_circle_object_value_set(m_slider, static_cast(value)); + m_layout->setText(std::to_string(value), impl::PART_TXT_VALUE); + } + + void Slider::setMaxValue(int maxValue) + { + eext_circle_object_value_min_max_set(m_slider, 0, maxValue); + } +} diff --git a/src/view/VolumeControl.cpp b/src/view/VolumeControl.cpp index dea42cb..16ea0ef 100644 --- a/src/view/VolumeControl.cpp +++ b/src/view/VolumeControl.cpp @@ -47,8 +47,7 @@ namespace callui { VolumeControl::Builder::Builder(): m_maxValue(0), - m_curValue(0), - m_showControls(true) + m_curValue(0) { } @@ -58,24 +57,18 @@ namespace callui { return *this; } - VolumeControl::Builder &VolumeControl::Builder::setMaxSliderValue(int maxValue) + VolumeControl::Builder &VolumeControl::Builder::setMaxValue(int maxValue) { m_maxValue = maxValue; return *this; } - VolumeControl::Builder &VolumeControl::Builder::setSliderValue(int curValue) + VolumeControl::Builder &VolumeControl::Builder::setValue(int curValue) { m_curValue = curValue; return *this; } - VolumeControl::Builder &VolumeControl::Builder::setShowControls(bool isShown) - { - m_showControls = isShown; - return *this; - } - VolumeControl::Builder &VolumeControl::Builder::setEventHandler( const VolumeControlEventHandler &handler) { @@ -97,7 +90,6 @@ namespace callui { m_info, m_maxValue, m_curValue, - m_showControls, m_handler); result->bindToEo(); @@ -110,38 +102,21 @@ namespace callui { const TString &info, int maxValue, int curValue, - bool showControls, const VolumeControlEventHandler &handler): - ElmWidget(&rc, *layout, true), - m_layout(layout), - m_slider(eext_circle_object_slider_add(*m_layout, - getCircleSurface(*m_layout))), + Slider(rc, layout, maxValue, curValue), m_decreaseBtn(elm_button_add(*m_layout)), m_increaseBtn(elm_button_add(*m_layout)), - m_handler(handler), - m_isControlsShown(true) + m_handler(handler) { - prepare(info, maxValue, curValue, showControls); + prepare(info, curValue); } VolumeControl::~VolumeControl() { } - void VolumeControl::prepare(const TString &info, - int maxValue, - int curValue, - bool showControls) + void VolumeControl::prepare(const ucl::TString &info, int curValue) { - m_layout->setIsOwner(false); - - evas_object_size_hint_align_set(m_slider, - EVAS_HINT_FILL, 0.5); - evas_object_size_hint_weight_set(m_slider, - EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - m_layout->setContent(m_slider, impl::PART_SWL_SLIDER); - show(*m_layout); - m_decreaseBtn.setStyle(impl::STYLE_BTN_MINUS); m_decreaseBtn.addEventHandler(BTN_CLICKED, WEAK_DELEGATE( VolumeControl::onDecreaseBtnClickedCb, asWeak(*this))); @@ -155,35 +130,7 @@ namespace callui { show(m_increaseBtn); setInfoText(info); - setMaxSliderValue(maxValue); - setSliderValue(curValue); - - if (!showControls) { - hideControls(); - } - } - - void VolumeControl::showControls() - { - if (!m_isControlsShown) { - m_layout->emit(impl::SIGNAL_SHOW_CONTROLS, - impl::SIGNAL_SRC_VOICE_CONTROL); - m_isControlsShown = true; - } - } - - void VolumeControl::hideControls() - { - if (m_isControlsShown) { - m_layout->emit(impl::SIGNAL_HIDE_CONTROLS, - impl::SIGNAL_SRC_VOICE_CONTROL); - m_isControlsShown = false; - } - } - - bool VolumeControl::getControlsVisibilityState() - { - return m_isControlsShown; + setValue(curValue); } void VolumeControl::setInfoText(const TString &info) @@ -191,18 +138,12 @@ namespace callui { m_layout->setText(info.translate(), impl::PART_TXT_INFO); } - void VolumeControl::setSliderValue(int value) + void VolumeControl::setValue(int value) { eext_circle_object_value_set(m_slider, static_cast(value)); m_layout->setText(std::to_string(value), impl::PART_TXT_VALUE); } - void VolumeControl::setMaxSliderValue(int maxValue) - { - eext_circle_object_value_min_max_set(m_slider, - 0, maxValue); - } - void VolumeControl::setIncreaseBtnEnable(bool isEnable) { isEnable ? enable(m_increaseBtn) : disable(m_increaseBtn); @@ -221,10 +162,6 @@ namespace callui { void VolumeControl::onDecreaseBtnClickedCb(Widget &widget, void *eventInfo) { - if (m_isControlsShown) { - ILOG("Ignored as callback called after control was hidden"); - } - if (m_handler) { m_handler(VolumeControlEvent::DECREASE); } @@ -232,10 +169,6 @@ namespace callui { void VolumeControl::onIncreaseBtnClickedCb(Widget &widget, void *eventInfo) { - if (m_isControlsShown) { - ILOG("Ignored as callback called after control was hidden"); - } - if (m_handler) { m_handler(VolumeControlEvent::INCREASE); } diff --git a/src/view/helpers.cpp b/src/view/helpers.cpp index 4b72176..03fb991 100644 --- a/src/view/helpers.cpp +++ b/src/view/helpers.cpp @@ -43,7 +43,7 @@ namespace callui { LOG_RETURN(RES_ILLEGAL_STATE, "Circle Surface data already set!"); } - const auto sfc = eext_circle_surface_naviframe_add(navi); + const auto sfc = eext_circle_surface_conformant_add(win->getConformant()); if (!sfc) { LOG_RETURN(RES_FAIL, "eext_circle_surface_conformant_add() failed!");