EditAlarmView: fix volume adjustment/alarm type logic 48/121548/3
authorLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 28 Mar 2017 07:37:42 +0000 (09:37 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Tue, 28 Mar 2017 08:14:44 +0000 (10:14 +0200)
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
clock/src/View/EditAlarmView.cpp

index 4bb99e1e905c800bfe936f560d9065de0133b260..5377406004024afc7b887e74c1152d3c301c1e49 100644 (file)
@@ -205,6 +205,7 @@ namespace view {
                        void OnWeekFlagsPagePopped();
 
                        void UpdateVolumeIcon(bool mute);
+                       void UpdateAlarmType(bool mute);
                        utils::RingtonePicker picker_;
                        void RingtonePathUpdateCallback();
                        const char *GetTitle();
index f964657fe5998d7a06109ad6714570d6f6b60e9c..dfd8aa05a67bb9afa7f5b1fff6b5903e008b1494 100644 (file)
@@ -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);