From f5f7743c5d43c9c05f60eff04353c33833450686 Mon Sep 17 00:00:00 2001 From: junkyu Han Date: Fri, 8 Apr 2016 17:16:01 +0900 Subject: [PATCH] Create max volume function for call Change-Id: I1569530d7ebfe95c278cb38f994d35bd638b5d54 --- include/view.h | 6 +++++- src/bt.c | 2 +- src/control.c | 11 ++++++++++- src/view.c | 37 ++++++++++++++++++++++++++++++++++--- 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/include/view.h b/include/view.h index 07b2f82..2d14fec 100755 --- a/include/view.h +++ b/include/view.h @@ -19,6 +19,9 @@ #ifndef __VOLUME_VIEW_H__ #define __VOLUME_VIEW_H__ +extern sound_type_e volume_view_pre_sound_type_get(void); +extern volume_error_e volume_change_slider_max_value(sound_type_e type); + extern Evas_Object *volume_view_win_get(void); extern tzsh_h volume_view_tzsh_get(void); extern tzsh_volume_service_h volume_view_service_get(void); @@ -37,7 +40,7 @@ extern void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int extern void volume_view_setting_icon_set(const char *file); extern void volume_view_setting_icon_callback_del(void); -extern volume_error_e volume_view_window_show(void); +extern volume_error_e volume_view_window_show(sound_type_e type); extern volume_error_e volume_view_window_hide(void); extern volume_error_e volume_view_layout_create(Evas_Object *win); @@ -46,4 +49,5 @@ extern Evas_Object *volume_view_window_create(void); extern Evas_Object* show_lockscreen_splash(const char *bg_path); extern volume_error_e hide_lockscreen_splash(void); + #endif /* __VOLUME_VIEW_H__ */ diff --git a/src/bt.c b/src/bt.c index 4bf22b9..7f99354 100644 --- a/src/bt.c +++ b/src/bt.c @@ -73,7 +73,7 @@ void bt_deinit_sco(void) static void _bt_display_bt_volume_view(sound_type_e sound_type, int sound, int vibration, bool bt_opened) { - if (VOLUME_ERROR_OK != volume_view_window_show()) + if (VOLUME_ERROR_OK != volume_view_window_show(sound_type)) _E("Failed to show volume window"); volume_view_volume_icon_set(sound_type, sound, vibration, bt_opened); diff --git a/src/control.c b/src/control.c index b7c94d0..38bc890 100755 --- a/src/control.c +++ b/src/control.c @@ -286,6 +286,7 @@ Eina_Bool volume_control_show_view(int status, sound_type_e sound_type, int soun Evas_Object *win = NULL; int volume = 0; int vibration = 0; + sound_type_e pre_sound_type; retv_if(control_info.is_deleting, EINA_FALSE); @@ -294,6 +295,8 @@ Eina_Bool volume_control_show_view(int status, sound_type_e sound_type, int soun win = volume_view_win_get(); retv_if(!win, EINA_FALSE); + pre_sound_type = volume_view_pre_sound_type_get(); + if(status == LOCK_AND_NOT_MEDIA) { _D("Lock and Not Media"); @@ -314,8 +317,14 @@ Eina_Bool volume_control_show_view(int status, sound_type_e sound_type, int soun _D("UNLOCK or LOCK_AND_MEDIA"); control_info.sound_type_at_show = sound_type; + if (sound_type != pre_sound_type) { + if (VOLUME_ERROR_OK != volume_change_slider_max_value(sound_type)) { + _E("Failed to changed max volume"); + } + } + if(status == UNLOCK_STATUS) { - if(VOLUME_ERROR_OK != volume_view_window_show()) { + if(VOLUME_ERROR_OK != volume_view_window_show(sound_type)) { _E("Failed to show volume window"); } } diff --git a/src/view.c b/src/view.c index 43af8b5..2b8525a 100755 --- a/src/view.c +++ b/src/view.c @@ -46,6 +46,7 @@ struct _view_s_info { Eina_Bool is_registered_callback; Eina_Bool is_slider_touching; Eina_Bool is_warning_displayed; + sound_type_e pre_sound_type; }; static struct _view_s_info view_info = { .win = NULL, @@ -63,7 +64,8 @@ static struct _view_s_info view_info = { .is_registered_callback = EINA_FALSE, .is_slider_touching = EINA_FALSE, - .is_warning_displayed = EINA_FALSE + .is_warning_displayed = EINA_FALSE, + .pre_sound_type = SOUND_TYPE_RINGTONE }; static void _button_cb(void *data, Evas_Object *obj, void *event_info); @@ -127,6 +129,11 @@ Eina_Bool volume_view_is_slider_touching_get(void) return view_info.is_slider_touching; } +sound_type_e volume_view_pre_sound_type_get(void) +{ + return view_info.pre_sound_type; +} + volume_error_e volume_view_set_default_slider(){ Evas_Object *slider = volume_view_slider_get(); elm_object_style_set(slider, "default"); @@ -184,6 +191,26 @@ int volume_mute_toggle_set() } } +volume_error_e volume_change_slider_max_value(sound_type_e type) +{ + _D("Slider max change for state: %d", type); + int ret = 0; + int step = 0; + + ret = sound_manager_get_max_volume(type, &step); + if (ret < 0) { + _E("Failed to get max volume for sound_type: %d", type); + return VOLUME_ERROR_FAIL; + } + _D("Sound type: %d, max: %d", type, step); + + elm_slider_min_max_set(view_info.slider, 0, step); + + view_info.pre_sound_type = type; + + return VOLUME_ERROR_OK; +} + volume_error_e volume_view_slider_value_set(int val) { _D("Slider value set : %d", val); @@ -306,11 +333,15 @@ Evas_Object *add_slider(Evas_Object *parent, int min, int max, int val) return slider; } -volume_error_e volume_view_window_show(void) +volume_error_e volume_view_window_show(sound_type_e type) { _D("Volume view window SHOW is [%p]", view_info.win); elm_win_iconified_set(view_info.win, EINA_FALSE); - volume_view_setting_icon_callback_add(); + if (type == SOUND_TYPE_CALL) { + _D("Sound type is Call"); + } else { + volume_view_setting_icon_callback_add(); + } return VOLUME_ERROR_OK; } -- 2.7.4