From a6359674ed75ebaa63cb97a347b17d893037bf60 Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Mon, 12 Jun 2017 10:00:23 +0300 Subject: [PATCH] TizenRefApp-8698 [Call UI] Fix issue with sliding label duration Change-Id: I4e04879a12cbde06d6bcf8008ef4634748ef45bd --- inc/presenters/CallInfoPresenter.h | 1 + inc/presenters/MoreOptionsPresenter.h | 11 +- src/main.cpp | 6 +- src/presenters/CallInfoPresenter.cpp | 158 +++++++++++++----------- src/presenters/MoreOptionsPresenter.cpp | 12 +- src/view/Slider.cpp | 14 --- src/view/VolumeControl.cpp | 5 - 7 files changed, 105 insertions(+), 102 deletions(-) diff --git a/inc/presenters/CallInfoPresenter.h b/inc/presenters/CallInfoPresenter.h index eb9a9f3..9bdacc9 100644 --- a/inc/presenters/CallInfoPresenter.h +++ b/inc/presenters/CallInfoPresenter.h @@ -59,6 +59,7 @@ namespace callui { ucl::Result createWidget(ucl::ElmWidget &parent); ucl::Result createLabel(const std::string &text); + ucl::Result createCallerIdImage(const std::string &imagePath); ucl::Result createCallStatus(); ucl::Result update(); diff --git a/inc/presenters/MoreOptionsPresenter.h b/inc/presenters/MoreOptionsPresenter.h index b82aaba..b574a31 100644 --- a/inc/presenters/MoreOptionsPresenter.h +++ b/inc/presenters/MoreOptionsPresenter.h @@ -84,8 +84,12 @@ namespace callui { 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); + void onPanelActivate(Evas_Object *obj, + const char *emission, + const char *source); + void onPanelInactivate(Evas_Object *obj, + const char *emission, + const char *source); ucl::Result startCallDurationTimer(); void stopCallDurationTimer(); @@ -96,7 +100,8 @@ namespace callui { void onAudioStateChanged(AudioStateType state); void unsetPanelContent(const ucl::EdjePart &part); - void setPanelContent(ucl::StyledWidgetSRef &widget, const ucl::EdjePart &part); + void setPanelContent(ucl::StyledWidgetSRef &widget, + const ucl::EdjePart &part); void onPageExitRequest(Page &page); diff --git a/src/main.cpp b/src/main.cpp index b00dae0..31ba842 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,8 +25,12 @@ using namespace callui; int main(int argc, char *argv[]) { + ILOG("MAIN START"); + InstanceManager mgr; const int ret = UIApp(mgr).run(argc, argv); - ILOG("ret: %d", ret); + + ILOG("MAIN END. ret[%d]", ret); + return ret; } diff --git a/src/presenters/CallInfoPresenter.cpp b/src/presenters/CallInfoPresenter.cpp index 58cef09..ca5632c 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 = 20; + constexpr int SLIDE_LABEL_DURATION_KOEFF = 8; constexpr LayoutTheme LAYOUT_CALLER_INFO_WIDGET {"layout", "callui", "call_info"}; @@ -70,13 +70,16 @@ namespace callui { namespace { namespace impl { constexpr EdjePart PART_SWL_CALLER_ID {"caller_id"}; constexpr EdjePart PART_SWL_2LINE {"text_2line"}; - const TString STR_LABEL_CALLER_ID_ENABLE{ + const TString STR_LABEL_CID_ENABLE{ "%s"}; - const TString STR_LABEL_CALLER_ID_DISABLE{ + const TString STR_LABEL_CID_DISABLE{ "%s"}; int getTextBlockActualWidth(const Evas_Object *obj) { + if (!obj) { + LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, 0, "Evas object is NULL"); + } int resWidth = 0; evas_object_textblock_size_native_get(obj, &resWidth, NULL); return resWidth; @@ -205,8 +208,7 @@ namespace callui { } } - Result CallInfoPresenter::update(CallMode mode, - const ICallManagerSRef &cm) + Result CallInfoPresenter::update(CallMode mode, const ICallManagerSRef &cm) { m_needModifyCallStatus = false; if (mode != m_mode || mode == CallMode::DURING) { @@ -257,7 +259,7 @@ namespace callui { } if (m_incomCallInfo->isVoiceMailNumber() || - m_incomCallInfo->isEmergency()){ + m_incomCallInfo->isEmergency()) { return ""; } @@ -267,7 +269,8 @@ namespace callui { std::string CallInfoPresenter::getDuringCallSubText() const { if (m_activeCallInfo) { - auto confMemberCount = m_activeCallInfo->getConferenceMemberCount(); + auto confMemberCount = + m_activeCallInfo->getConferenceMemberCount(); if (m_heldCallInfo) { return STR_CALL_ON_HOLD.translate(); } else if (confMemberCount > 1) { @@ -275,7 +278,8 @@ namespace callui { format(confMemberCount); } } else if (m_heldCallInfo) { - auto confMemberCount = m_heldCallInfo->getConferenceMemberCount(); + auto confMemberCount = + m_heldCallInfo->getConferenceMemberCount(); if (confMemberCount > 1) { return TString{STR_WITH_PD_PEOPLE.translate()}. format(confMemberCount); @@ -293,7 +297,8 @@ namespace callui { FAIL_RETURN_VALUE(RES_FAIL, "", "end is NULL!"); } - auto confMemberCount = m_endCallInfo->getConferenceMemberCount(); + auto confMemberCount = + m_endCallInfo->getConferenceMemberCount(); if (confMemberCount > 1) { return TString{STR_WITH_PD_PEOPLE.translate()}. format(confMemberCount); @@ -304,31 +309,53 @@ namespace callui { Result CallInfoPresenter::createLabel(const std::string &text) { - TString tmp; - 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()); - } + auto *eo = elm_label_add(*m_widget); + if (!eo) { + LOG_RETURN(RES_FAIL, "elm_label_add() failed!"); + } + m_label = makeShared(eo, true); + m_label->setStyle(impl::STYLE_SLIDING_LABEL); + m_label->setText((m_callerId) ? + impl::STR_LABEL_CID_ENABLE.format(text.c_str()) : + impl::STR_LABEL_CID_DISABLE.format(text.c_str())); + + elm_label_slide_mode_set(*m_label, + ELM_LABEL_SLIDE_MODE_AUTO); + elm_label_wrap_width_set(*m_label, + ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH)); + double duration = (static_cast(text.size())) / impl::SLIDE_LABEL_DURATION_KOEFF; + elm_label_slide_duration_set(*m_label, duration); + elm_label_slide_go(*m_label); + + m_widget->setContent(*m_label, impl::PART_SWL_2LINE); - auto label = makeShared(elm_label_add(*m_widget), true); - if (!label) { - LOG_RETURN(RES_FAIL, "Create label failed!"); + return RES_OK; + } + + Result CallInfoPresenter::createCallerIdImage(const std::string &imagePath) + { + auto *eo = elm_image_add(*m_widget); + if (!eo) { + LOG_RETURN(RES_FAIL, "elm_image_add() failed"); } - label->setStyle(impl::STYLE_SLIDING_LABEL); - label->setText(tmp); + auto callerId = makeShared(eo, true); + elm_image_file_set(*callerId, imagePath.c_str(), NULL); + elm_image_aspect_fixed_set(*callerId, EINA_TRUE); + elm_image_fill_outside_set(*callerId, EINA_TRUE); - elm_label_slide_mode_set(*label, ELM_LABEL_SLIDE_MODE_AUTO); - elm_label_wrap_width_set(*label, - ELM_SCALE_SIZE(impl::SUB_TXT_WIDTH)); - elm_label_slide_duration_set(*label, duration); - elm_label_slide_go(*label); + auto window = callerId->getWindow(); + if (!window) { + LOG_RETURN(RES_FAIL, "Window is NULL!"); + } + int w = 0, h = 0; + window->getScreenSize(&w, &h); + evas_object_size_hint_min_set(*callerId, w, h); - m_widget->setContent(*label, impl::PART_SWL_2LINE); + m_widget->setContent(*callerId, impl::PART_SWL_CALLER_ID); - m_label = label; + m_callerId = callerId; return RES_OK; } @@ -336,7 +363,7 @@ namespace callui { Result CallInfoPresenter::updateCallerId() { m_callerId.reset(); - m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, impl::SRC_CALLER_ID); + m_widget->emit(impl::SIGN_CALLER_ID_DISABLE,impl::SRC_CALLER_ID); if (m_mode == CallMode::INCOMING) { @@ -346,41 +373,18 @@ namespace callui { auto contactInfo = m_incomCallInfo->getContactInfo(); if (!contactInfo) { - ILOG("No contact info"); - return RES_OK; + LOG_RETURN(RES_OK, "No contact info"); } auto callerIdPath = contactInfo->getImagePath(); if (callerIdPath.empty()) { - ILOG("No caller id content to set"); - return RES_OK; - } - - auto callerId = makeShared( - elm_image_add(*m_widget), true); - if (!callerId) { - LOG_RETURN(RES_FAIL, "Create callerId failed!"); - } - - elm_image_file_set(*callerId, callerIdPath.c_str(), NULL); - elm_image_aspect_fixed_set(*callerId, EINA_TRUE); - elm_image_fill_outside_set(*callerId, EINA_TRUE); - - auto window = callerId->getWindow(); - if (!window) { - LOG_RETURN(RES_FAIL, "Window is NULL!"); + LOG_RETURN(RES_OK, "No caller id content to set"); } - int w = 0, h = 0; - window->getScreenSize(&w, &h); - ILOG("size w[%d] h[%d]", w, h); - evas_object_size_hint_min_set(*callerId, w, h); - m_widget->setContent(*callerId, - impl::PART_SWL_CALLER_ID); + FAIL_RETURN(createCallerIdImage(callerIdPath), + "createCallerIdImage() failed"); m_widget->emit(impl::SIGN_CALLER_ID_ENABLE, impl::SRC_CALLER_ID); - - m_callerId = callerId; } return RES_OK; @@ -414,14 +418,7 @@ namespace callui { if (!subTxt.empty()) { m_isSubTxtEnable = true; - - TString tmp; - 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()); - } - FAIL_RETURN(createLabel(tmp), "createLabel() failed"); + FAIL_RETURN(createLabel(subTxt), "createLabel() failed"); } return RES_OK; @@ -472,40 +469,51 @@ namespace callui { if (tempEo) { int lineWidth = m_incomCallInfo ? - impl::MAIN_TXT_WIDTH_INCOM : impl::MAIN_TXT_WIDTH_SIMPLE; + impl::MAIN_TXT_WIDTH_INCOM : + impl::MAIN_TXT_WIDTH_SIMPLE; bool isMainTxtSingleLine = (impl::getTextBlockActualWidth(tempEo) <= lineWidth); - m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, impl::SRC_TXT_1LINE); + m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, + impl::SRC_TXT_1LINE); if (info->isEmergency()) { - m_widget->emit(impl::SIGN_EMERGENCY_MODE, impl::SRC_TXT_1LINE); + m_widget->emit(impl::SIGN_EMERGENCY_MODE, + impl::SRC_TXT_1LINE); } if (m_mode == CallMode::INCOMING) { if (m_callerId) { - m_widget->emit(impl::SIGN_CALLER_ID_ENABLE, impl::SRC_TXT_1LINE); + 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); + m_widget->emit(impl::SIGN_CALLER_ID_DISABLE, + impl::SRC_TXT_1LINE); } if (isMainTxtSingleLine) { - m_widget->emit(impl::SIGN_INCOM_1LINE, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_INCOM_1LINE, + impl::SRC_TOP_PAD); } else { - m_widget->emit(impl::SIGN_INCOM_2LINE, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_INCOM_2LINE, + impl::SRC_TOP_PAD); } } else { if (isMainTxtSingleLine) { if (m_isSubTxtEnable) { - m_widget->emit(impl::SIGN_1LINE_2TXT, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_1LINE_2TXT, + impl::SRC_TOP_PAD); } else { - m_widget->emit(impl::SIGN_1LINE, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_1LINE, + impl::SRC_TOP_PAD); } } else { if (m_isSubTxtEnable) { - m_widget->emit(impl::SIGN_2LINE_2TXT, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_2LINE_2TXT, + impl::SRC_TOP_PAD); } else { - m_widget->emit(impl::SIGN_2LINE, impl::SRC_TOP_PAD); + m_widget->emit(impl::SIGN_2LINE, + impl::SRC_TOP_PAD); } } } @@ -591,7 +599,7 @@ namespace callui { build(); if (!m_callStatus) { - LOG_RETURN(RES_FAIL, "CallStatus::Builder()::build() failed!"); + LOG_RETURN(RES_FAIL, "CallStatus::build() failed!"); } return RES_OK; diff --git a/src/presenters/MoreOptionsPresenter.cpp b/src/presenters/MoreOptionsPresenter.cpp index e14d91b..00ac111 100644 --- a/src/presenters/MoreOptionsPresenter.cpp +++ b/src/presenters/MoreOptionsPresenter.cpp @@ -198,10 +198,10 @@ namespace callui { elm_panel_toggle(*m_panel); elm_layout_signal_callback_add(*m_panel, "elm,state,active,finished", - "elm", CALLBACK_A(MoreOptionsPresenter::onActivate), this); + "elm", CALLBACK_A(MoreOptionsPresenter::onPanelActivate), this); elm_layout_signal_callback_add(*m_panel, "elm,state,inactive,finished", - "elm", CALLBACK_A(MoreOptionsPresenter::onInactivate), this); + "elm", CALLBACK_A(MoreOptionsPresenter::onPanelInactivate), this); return RES_OK; } @@ -419,7 +419,9 @@ namespace callui { updateStatusText(); } - void MoreOptionsPresenter::onActivate(Evas_Object *obj, const char *emission, const char *source) + void MoreOptionsPresenter::onPanelActivate(Evas_Object *obj, + const char *emission, + const char *source) { eext_object_event_callback_add(*m_widget, EEXT_CALLBACK_BACK, CALLBACK_A(MoreOptionsPresenter::onBackKey), this); @@ -429,7 +431,9 @@ namespace callui { activateBy(m_widget.get()); } - void MoreOptionsPresenter::onInactivate(Evas_Object *obj, const char *emission, const char *source) + void MoreOptionsPresenter::onPanelInactivate(Evas_Object *obj, + const char *emission, + const char *source) { eext_object_event_callback_del(*m_widget, EEXT_CALLBACK_BACK, CALLBACK_A(MoreOptionsPresenter::onBackKey)); diff --git a/src/view/Slider.cpp b/src/view/Slider.cpp index 7d3219f..5fb0f8e 100644 --- a/src/view/Slider.cpp +++ b/src/view/Slider.cpp @@ -25,20 +25,7 @@ namespace callui { namespace { namespace impl { 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 { @@ -118,7 +105,6 @@ namespace callui { 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) diff --git a/src/view/VolumeControl.cpp b/src/view/VolumeControl.cpp index 16ea0ef..e4e2c76 100644 --- a/src/view/VolumeControl.cpp +++ b/src/view/VolumeControl.cpp @@ -28,17 +28,12 @@ namespace callui { namespace { namespace impl { 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 { -- 2.34.1