From db37559e3942e082faf67ca0890c6f734dee1ac4 Mon Sep 17 00:00:00 2001 From: Lukasz Stanislawski Date: Tue, 28 Mar 2017 09:37:42 +0200 Subject: [PATCH] EditAlarmView: fix volume adjustment/alarm type logic When volume is reduced to 0, alarm type should change to 'vibration', alternatively i volume is >0, then alarm type wil change to 'sound'. Additionally when alarm type is changed to 'vibration' manually, the slider will become disabled. Change-Id: I67cf86daa826198f7d2a9aafa6e612c22b3e0ec9 --- clock/inc/View/EditAlarmView.h | 1 + clock/src/View/EditAlarmView.cpp | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/clock/inc/View/EditAlarmView.h b/clock/inc/View/EditAlarmView.h index 4bb99e1..5377406 100644 --- a/clock/inc/View/EditAlarmView.h +++ b/clock/inc/View/EditAlarmView.h @@ -205,6 +205,7 @@ namespace view { void OnWeekFlagsPagePopped(); void UpdateVolumeIcon(bool mute); + void UpdateAlarmType(bool mute); utils::RingtonePicker picker_; void RingtonePathUpdateCallback(); const char *GetTitle(); diff --git a/clock/src/View/EditAlarmView.cpp b/clock/src/View/EditAlarmView.cpp index f964657..dfd8aa0 100644 --- a/clock/src/View/EditAlarmView.cpp +++ b/clock/src/View/EditAlarmView.cpp @@ -249,6 +249,21 @@ void EditAlarmView::DateTimeChangedCallback(void *data, Evas_Object *obj, void * } } +void EditAlarmView::UpdateAlarmType(bool mute) +{ + if (mute) + { + if (data_.type == model::Alarm::Type::SOUND_ONLY) + data_.type = model::Alarm::Type::VIBRATION; + } + else + { + if (data_.type == model::Alarm::Type::VIBRATION) + data_.type = model::Alarm::Type::SOUND_ONLY; + } + elm_genlist_item_update(type_it_); +} + void EditAlarmView::UpdateVolumeIcon(bool mute) { const char *file_path; @@ -291,6 +306,7 @@ void EditAlarmView::SliderChangedCallback(void *data, Evas_Object *obj, void *ev } view->UpdateVolumeIcon(mute); + view->UpdateAlarmType(mute); } void EditAlarmView::CheckChangedCallback(void *data, Evas_Object *obj, void *event) @@ -535,6 +551,19 @@ void EditAlarmView::PopupHide(void *data, Evas_Object *obj, void *event) // refresh type item elm_genlist_item_update(view->type_it_); elm_popup_dismiss(view->type_popup_); + + switch (view->data_.type) + { + case Alarm::Type::VIBRATION: + elm_object_item_disabled_set(view->volume_it_, EINA_TRUE); + elm_object_item_disabled_set(view->tone_it_, EINA_TRUE); + break; + case Alarm::Type::SOUND_ONLY: + case Alarm::Type::VIBRATION_AND_SOUND: + elm_object_item_disabled_set(view->volume_it_, EINA_FALSE); + elm_object_item_disabled_set(view->tone_it_, EINA_FALSE); + break; + } } void EditAlarmView::Del(void *data, Evas_Object *obj, void *event) @@ -553,18 +582,18 @@ void EditAlarmView::ShowSetTypePopup() elm_list_mode_set(list, ELM_LIST_EXPAND); main_radio_ = elm_radio_add(list); - elm_radio_state_value_set(main_radio_, 0); + elm_radio_state_value_set(main_radio_, (int)Alarm::Type::SOUND_ONLY); elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::SOUND_ONLY).c_str(), NULL, main_radio_, EditAlarmView::PopupListItemSelectedCallback, main_radio_); Evas_Object *radio = elm_radio_add(list); - elm_radio_state_value_set(radio, 1); + elm_radio_state_value_set(radio, (int)Alarm::Type::VIBRATION); elm_radio_group_add(radio, main_radio_); elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::VIBRATION).c_str(), NULL, radio, EditAlarmView::PopupListItemSelectedCallback, radio); radio = elm_radio_add(list); - elm_radio_state_value_set(radio, 2); + elm_radio_state_value_set(radio, (int)Alarm::Type::VIBRATION_AND_SOUND); elm_radio_group_add(radio, main_radio_); elm_list_item_append(list, GetLabelForAlarmType(Alarm::Type::VIBRATION_AND_SOUND).c_str(), NULL, radio, EditAlarmView::PopupListItemSelectedCallback, radio); -- 2.7.4