Commit bb51030b authored by Ludovic Fauvet's avatar Ludovic Fauvet

Replace the notification by a minicontrol

The aspect ratio of this widget (window?) is weird, looks like a Tizen
issue.
parent f593d8d3
......@@ -71,6 +71,7 @@
#define AUDIOPLAYERMINI_EDJ get_resource_path( EDJPATH "/audio_player_mini.edj")
#define AUDIOPLAYER_EDJ get_resource_path( EDJPATH "/audio_player.edj")
#define AUDIOPLAYERSPEED_EDJ get_resource_path( EDJPATH "/audio_player_speed.edj")
#define QUICKPANELCONTROLS_EDJ get_resource_path( EDJPATH "/quick_panel_controls.edj")
#define ABOUT_EDJ get_resource_path( EDJPATH "/about.edj")
#define THEME_EDJ get_resource_path( EDJPATH "/theme.edj")
......
/*****************************************************************************
* Copyright © 2015-2016 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
collections {
base_scale: 1.8;
group {
name: "quick_panel_controls";
parts {
part{
name: "hub_background";
type: RECT;
description{
state: "default" 0.0;
color: 245 245 245 255; // grey
aspect: 6.0 1.0;
aspect_preference: HORIZONTAL;
min: 0 120;
max: 9999 120;
}
}
part {
name: "swallow.cover";
type: SWALLOW;
description {
aspect: 1.0 1.0;
color: 255 0 0 255;
aspect: 1.0 1.0;
rel1 {
relative: 0.17 0.05;
to: "hub_background";
}
rel2 {
relative: 0.0 0.95;
to: "hub_background";
}
}
}
part {
name: "swallow.title";
type: TEXT;
description {
color: 0 0 0 255; // black
visible: 1;
rel1 {
relative: 1.1 0.0;
to: "swallow.cover";
}
rel2 {
relative: 1.0 1.0;
to: "hub_background";
}
text {
text: "";
size: 30;
ellipsis: 0;
align: 0 0;
}
}
}
part {
name: "swallow.progress";
type: SWALLOW;
description {
aspect_preference: VERTICAL;
color: 255 0 0 255;
rel1 {
relative: 1.0 0.4;
to: "swallow.cover";
}
rel2 {
relative: 0.99 0.5;
to: "hub_background";
}
}
}
part {
name: "swallow.previous";
type: SWALLOW;
description {
aspect: 0.9 0.9;
aspect_preference: VERTICAL;
color: 255 0 0 255; // transparent grey
aspect: 1.0 1.0;
rel1 {
relative: -3.0 0.0;
to: "swallow.play";
}
rel2 {
relative: 1.0 1.0;
to: "swallow.play";
}
}
}
part {
name: "swallow.play";
type: SWALLOW;
description {
aspect: 0.9 0.9;
aspect_preference: VERTICAL;
color: 255 0 0 255; // transparent grey
aspect: 1.0 1.0;
rel1 {
relative: 1.0 0.45;
to: "swallow.cover";
}
rel2 {
relative: 1.0 1.0;
to: "hub_background";
}
}
}
part {
name: "swallow.next";
type: SWALLOW;
description {
aspect: 0.9 0.9;
aspect_preference: VERTICAL;
color: 255 0 0 255; // transparent grey
align: 0.5 0.5;
aspect: 1.0 1.0;
rel1 {
relative: 3.0 0.0;
to: "swallow.play";
}
rel2 {
relative: 1.0 1.0;
to: "swallow.play";
}
}
}
} //parts
}
}
......@@ -40,6 +40,7 @@
#include "preferences/preferences.h"
#include "ui/interface.h"
#include "ui/views/minicontrol_view.h"
#define PLAYLIST_CONTEXT_COUNT (PLAYLIST_CONTEXT_OTHERS)
......@@ -81,9 +82,8 @@ struct playback_service
bool b_auto_exit;
bool b_restart_emotion;
notification_h p_notification;
minicontrol *p_minicontrol;
double i_last_notification_pos;
app_control_h p_app_control;
ps_on_emotion_restart emotion_restart_cb;
void *emotion_restart_cb_data;
......@@ -111,8 +111,6 @@ struct playback_service
} \
} while(0)
static int playback_service_stop_notify(playback_service *, bool);
void
ps_register_on_emotion_restart_cb(playback_service *p_ps, ps_on_emotion_restart func, void *data)
{
......@@ -123,24 +121,7 @@ ps_register_on_emotion_restart_cb(playback_service *p_ps, ps_on_emotion_restart
static void
ps_notification_create(playback_service *p_ps)
{
notification_h previous = notification_load_by_tag("vlc_ps");
if (previous)
{
notification_delete(previous);
notification_free(previous);
}
if ((p_ps->p_notification = notification_create(NOTIFICATION_TYPE_ONGOING)) == NULL)
LOGE("Failed to create the notification");
// Note: notification_* are noop if p_notification is NULL
notification_set_tag(p_ps->p_notification, "vlc_ps");
notification_set_display_applist(p_ps->p_notification, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
notification_set_image(p_ps->p_notification, NOTIFICATION_IMAGE_TYPE_ICON, ICON_DIR"cone.png");
app_control_create(&p_ps->p_app_control);
app_control_set_app_id(p_ps->p_app_control, PACKAGE);
notification_set_launch_option(p_ps->p_notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)p_ps->p_app_control);
p_ps->p_minicontrol = mini_control_view_create(p_ps);
}
static void
......@@ -150,23 +131,11 @@ ps_notification_update_meta(playback_service *p_ps, media_item *p_mi)
const char *psz_meta_artist = media_item_artist(p_mi);
if (psz_meta_title)
notification_set_text(p_ps->p_notification, NOTIFICATION_TEXT_TYPE_TITLE, psz_meta_title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
mini_control_title_set(p_ps->p_minicontrol, psz_meta_title);
else if (psz_meta_artist)
notification_set_text(p_ps->p_notification, NOTIFICATION_TEXT_TYPE_TITLE, psz_meta_artist, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
else
notification_set_text(p_ps->p_notification, NOTIFICATION_TEXT_TYPE_TITLE, media_item_get_filename(p_mi), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
if (psz_meta_title && psz_meta_artist)
notification_set_text(p_ps->p_notification, NOTIFICATION_TEXT_TYPE_CONTENT, psz_meta_artist, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
else
notification_set_text(p_ps->p_notification, NOTIFICATION_TEXT_TYPE_CONTENT, "", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
mini_control_title_set(p_ps->p_minicontrol, psz_meta_artist);
if (p_mi->psz_snapshot)
notification_set_image(p_ps->p_notification, NOTIFICATION_IMAGE_TYPE_ICON, p_mi->psz_snapshot);
else
notification_set_image(p_ps->p_notification, NOTIFICATION_IMAGE_TYPE_ICON, ICON_DIR"cone.png");
notification_update(p_ps->p_notification);
mini_control_cover_set(p_ps->p_minicontrol, p_mi->psz_snapshot);
}
static void
......@@ -198,9 +167,8 @@ ps_emotion_position_update_cb(void *data, Evas_Object *obj, void *event)
if (p_ps->i_ctx != PLAYLIST_CONTEXT_VIDEO
&& fabs(p_ps->i_last_notification_pos - i_pos) > 0.01f)
{
notification_set_progress(p_ps->p_notification, i_pos);
notification_update(p_ps->p_notification);
p_ps->i_last_notification_pos = i_pos;
mini_control_progress_set(p_ps->p_minicontrol, i_pos);
}
PS_SEND_CALLBACK(pf_on_new_time, i_time, i_pos);
......@@ -223,13 +191,20 @@ ps_emotion_play_started_cb(void *data, Evas_Object *obj, void *event)
PS_SEND_CALLBACK(pf_on_started, p_mi);
mini_control_playing_set(p_ps->p_minicontrol, EINA_TRUE);
if (p_ps->i_ctx != PLAYLIST_CONTEXT_VIDEO)
{
p_ps->i_last_notification_pos = 0.0001f;
notification_post(p_ps->p_notification);
notification_set_progress(p_ps->p_notification, p_ps->i_last_notification_pos);
ps_notification_update_meta(p_ps, p_mi);
mini_control_visibility_set(p_ps->p_minicontrol, EINA_TRUE);
mini_control_progress_set(p_ps->p_minicontrol, 0);
}
else
{
mini_control_visibility_set(p_ps->p_minicontrol, EINA_FALSE);
}
}
......@@ -423,8 +398,7 @@ playback_service_destroy(playback_service *p_ps)
if (p_ps->p_ev)
ps_emotion_destroy(p_ps, p_ps->p_ev);
app_control_destroy(p_ps->p_app_control);
notification_free(p_ps->p_notification);
mini_control_destroy(p_ps->p_minicontrol);
free(p_ps);
}
......@@ -687,7 +661,7 @@ playback_service_start(playback_service *p_ps, double i_time)
return playback_service_play(p_ps);
}
static int
int
playback_service_stop_notify(playback_service *p_ps, bool b_notify)
{
if (!p_ps->b_started)
......@@ -706,7 +680,8 @@ playback_service_stop_notify(playback_service *p_ps, bool b_notify)
if (b_notify)
PS_SEND_VOID_CALLBACK(pf_on_stopped);
notification_delete(p_ps->p_notification);
mini_control_playing_set(p_ps->p_minicontrol, EINA_FALSE);
mini_control_visibility_set(p_ps->p_minicontrol, EINA_FALSE);
if (p_ps->b_auto_exit)
ui_app_exit();
......@@ -734,6 +709,7 @@ playback_service_play(playback_service *p_ps)
emotion_object_play_set(p_ps->p_e, true);
PS_SEND_CALLBACK(pf_on_playpause, true);
mini_control_playing_set(p_ps->p_minicontrol, EINA_TRUE);
return 0;
}
......@@ -745,6 +721,7 @@ playback_service_pause(playback_service *p_ps)
emotion_object_play_set(p_ps->p_e, false);
PS_SEND_CALLBACK(pf_on_playpause, false);
mini_control_playing_set(p_ps->p_minicontrol, EINA_FALSE);
return 0;
}
......@@ -758,6 +735,7 @@ playback_service_toggle_play_pause(playback_service *p_ps)
b_new_state = !emotion_object_play_get(p_ps->p_e);
emotion_object_play_set(p_ps->p_e, b_new_state);
PS_SEND_CALLBACK(pf_on_playpause, b_new_state);
mini_control_playing_set(p_ps->p_minicontrol, b_new_state);
return b_new_state;
}
......
......@@ -88,6 +88,9 @@ playback_service_start(playback_service *p_ps, double i_time);
int
playback_service_stop(playback_service *p_ps);
int
playback_service_stop_notify(playback_service *p_ps, bool b_notify);
bool
playback_service_is_started(playback_service *p_ps);
......
/*****************************************************************************
* Copyright © 2015-2016 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Ludovic Fauvet <etix@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#include "common.h"
#include "minicontrol_view.h"
#include "playback_service.h"
#include "ui/utils.h"
#include <minicontrol-provider.h>
struct minicontrol
{
playback_service *p_ps;
Evas_Object *win;
Evas_Object *layout;
Evas_Object *play_button;
Evas_Object *next_button;
Evas_Object *prev_button;
Evas_Object *cover;
Evas_Object *progress;
};
void
mini_control_visibility_set(minicontrol *mc, Eina_Bool visible)
{
visible ? evas_object_show(mc->win) : evas_object_hide(mc->win);
}
void
mini_control_playing_set(minicontrol *mc, Eina_Bool playing)
{
elm_image_file_set(mc->play_button, playing ? ICON_DIR "ic_pause_circle_normal_o.png" : ICON_DIR "ic_play_circle_normal_o.png", NULL);
}
void
mini_control_title_set(minicontrol *mc, const char* title)
{
elm_object_part_text_set(mc->layout, "swallow.title", title);
}
void
mini_control_progress_set(minicontrol *mc, double progress)
{
elm_slider_value_set(mc->progress, progress);
}
void
mini_control_cover_set(minicontrol *mc, const char* path)
{
if (!path)
elm_object_part_content_set(mc->layout, "swallow.cover", create_icon(mc->layout, "background_cone.png"));
else
elm_object_part_content_set(mc->layout, "swallow.cover", create_image(mc->layout, path));
}
static void
mini_control_play_pause_toggle_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
minicontrol *mc = data;
playback_service_toggle_play_pause(mc->p_ps);
}
static void
mini_control_next_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
minicontrol *mc = data;
playback_service_list_set_next(mc->p_ps);
}
static void
mini_control_prev_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
{
minicontrol *mc = data;
playback_service_list_set_prev(mc->p_ps);
}
// mini_control_event_cb doesn't provide an embedded opaque object...
static playback_service* ps = NULL;
static void
mini_control_event_cb(minicontrol_viewer_event_e event_type, bundle *event_arg)
{
if (event_type == MINICONTROL_VIEWER_EVENT_HIDE || event_type == MINICONTROL_EVENT_REQUEST_HIDE)
playback_service_stop_notify(ps, true);
}
minicontrol*
mini_control_view_create(playback_service *p_ps)
{
minicontrol *mc = calloc(1, sizeof(*mc));
mc->p_ps = p_ps;
ps = p_ps;
const Evas_Coord width = 720;
const Evas_Coord height = 120;
/* main widget */
mc->win = minicontrol_create_window("quickpanel", MINICONTROL_TARGET_VIEWER_QUICK_PANEL, mini_control_event_cb);
evas_object_resize(mc->win, width, height);
evas_object_hide(mc->win);
/* Create layout and set the theme */
Evas_Object *wlayout = elm_layout_add(mc->win);
evas_object_resize(wlayout, width, height);
//elm_win_resize_object_add(mc->win, layout);
elm_layout_theme_set(wlayout, "layout", "application", "default");
evas_object_show(wlayout);
/* Create the background */
Evas_Object *bg = elm_bg_add(wlayout);
elm_bg_color_set(bg, 255, 255, 255);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(bg);
/* Set the background to the theme */
elm_object_part_content_set(wlayout, "elm.swallow.bg", bg);
/* */
Evas_Object *layout = mc->layout = elm_layout_add(mc->win);
elm_object_part_content_set(wlayout, "elm.swallow.content", layout);
/* */
elm_layout_file_set(layout, QUICKPANELCONTROLS_EDJ, "quick_panel_controls");
evas_object_show(layout);
mc->play_button = create_icon(layout, "ic_play_circle_normal_o.png");
mc->next_button = create_icon(layout, "ic_widget_next_normal.png");
mc->prev_button = create_icon(layout, "ic_widget_previous_normal.png");
mc->cover = create_icon(layout, "background_cone.png");
elm_object_part_content_set(layout, "swallow.play", mc->play_button);
elm_object_part_content_set(layout, "swallow.cover", mc->cover);
elm_object_part_content_set(layout, "swallow.previous", mc->prev_button);
elm_object_part_content_set(layout, "swallow.next", mc->next_button);
evas_object_smart_callback_add(mc->play_button, "clicked", mini_control_play_pause_toggle_cb, mc);
evas_object_smart_callback_add(mc->next_button, "clicked", mini_control_next_cb, mc);
evas_object_smart_callback_add(mc->prev_button, "clicked", mini_control_prev_cb, mc);
/* */
Evas_Object *progress = mc->progress = elm_slider_add(layout);
elm_slider_horizontal_set(progress, EINA_TRUE);
elm_object_disabled_set(progress, EINA_TRUE);
elm_object_part_content_set(layout, "swallow.progress", progress);
return mc;
}
void
mini_control_destroy(minicontrol *mc)
{
evas_object_del(mc->win);
free(mc);
}
/*****************************************************************************
* Copyright © 2015-2016 VideoLAN, VideoLabs SAS
*****************************************************************************
*
* Authors: Ludovic Fauvet <etix@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
* By committing to this project, you allow VideoLAN and VideoLabs to relicense
* the code to a different OSI approved license, in case it is required for
* compatibility with the Store
*****************************************************************************/
#ifndef MINICONTROL_VIEW_H_
#define MINICONTROL_VIEW_H_
#include "ui/interface.h"
struct minicontrol;
typedef struct minicontrol minicontrol;
minicontrol*
mini_control_view_create();
void
mini_control_destroy(minicontrol *mc);
void
mini_control_visibility_set(minicontrol *mc, Eina_Bool visible);
void
mini_control_playing_set(minicontrol *mc, Eina_Bool playing);
void
mini_control_title_set(minicontrol *mc, const char* title);
void
mini_control_progress_set(minicontrol *mc, double progress);
void
mini_control_cover_set(minicontrol *mc, const char* path);
#endif /* MINICONTROL_VIEW_H_ */
......@@ -10,6 +10,7 @@ VLC media player supports many audio and video compression methods and file form
<icon>VLC.png</icon>
</ui-application>
<privileges>
<privilege>http://tizen.org/privilege/minicontrol.provider</privilege>
<privilege>http://tizen.org/privilege/mediastorage</privilege>
<privilege>http://tizen.org/privilege/internet</privilege>
<privilege>http://tizen.org/privilege/notification</privilege>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment