#define SIG_VISIBLE "visible"
#define SIG_INVISIBLE "invisible"
#define SIG_DISABLE "elm,state,disabled"
+#define SIG_TOGGLE "toggle"
/* Signal Source */
#define SRC_MYAPPS "source.myapps"
#define ACTION_FAV_FOC_PNG "btn_menu_favorite_foc.png"
#define ACTION_FAV_SEL_PNG "btn_menu_favorite_sel.png"
#define ACTION_FAV_DIS_PNG "btn_menu_favorite_dis.png"
+#define ACTION_UNLOCK_NOR_PNG "btn_menu_unlock_nor.png"
+#define ACTION_UNLOCK_FOC_PNG "btn_menu_unlock_foc.png"
#define ACTION_LOCK_NOR_PNG "btn_menu_lock_nor.png"
#define ACTION_LOCK_FOC_PNG "btn_menu_lock_foc.png"
#define ACTION_LOCK_SEL_PNG "btn_menu_lock_sel.png"
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __AIR_APPS_VIEW_H__
+#define __AIR_APPS_VIEW_H__
+
+view_class *view_base_get_vclass(void);
+view_class *view_action_menu_get_vclass(void);
+
+enum update_type {
+ UPDATE_ID = 0,
+ UPDATE_FAVORITE,
+};
+
+#endif /* __AIR_APPS_VIEW_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AIR_APPS_VIEW_BASE_H__
-#define __AIR_APPS_VIEW_BASE_H__
-
-view_class *view_base_get_vclass(void);
-
-#endif /* __AIR_APPS_VIEW_BASE_H__ */
#define STATE_NORMAL 0
#define STATE_SELECTED 1
#define STATE_DISABLE 2
+#define STATE_TOGGLE 3
group {
name, "elm/button/base/style.menu.button";
fixed, 1 1;
min, 60 60;
}
+ description {
+ state, "default.toggle" 0.0;
+ inherit, "default" 0.0;
+ /* It will be fixed to another image later */
+ image.normal, ACTION_FAV_NOR_PNG;
+ }
description {
state, "focused" 0.0;
inherit, "default" 0.0;
image.normal, ACTION_FAV_FOC_PNG;
}
+ description {
+ state, "focused.toggle" 0.0;
+ inherit, "default" 0.0;
+ /* It will be fixed to another image later */
+ image.normal, ACTION_FAV_FOC_PNG;
+ }
description {
state, "selected" 0.0;
inherit, "default" 0.0;
}
programs{
+ program {
+ name, "load";
+ signal, "load";
+ source, "";
+ script {
+ set_int(cur_state, STATE_NORMAL);
+ }
+ }
+
+ program {
+ name, SIG_TOGGLE;
+ signal, SIG_TOGGLE;
+ source, SRC_ACTION_BTN;
+ script {
+ new state;
+ state = get_int(cur_state);
+ if (state == STATE_NORMAL) {
+ set_int(cur_state, STATE_TOGGLE);
+ set_state(PART:"part.icon", "default.toggle", 0.0);
+ }
+ }
+ }
+
program {
name, SIG_FOCUSED;
signal, "elm,action,focus";
script {
new state;
state = get_int(cur_state);
- if (state != STATE_DISABLE) {
- set_int(cur_state, STATE_NORMAL);
+ if (state == STATE_NORMAL) {
+ set_state(PART:"part.icon", "focused", 0.0);
+ run_program(PROGRAM:"focused,anim");
+ } else if (state == STATE_TOGGLE) {
+ set_state(PART:"part.icon", "focused.toggle", 0.0);
run_program(PROGRAM:"focused,anim");
}
}
script {
new state;
state = get_int(cur_state);
- if (state == STATE_SELECTED) {
- set_state(PART:"part.bg", "selected", 0.0);
- set_state(PART:"elm.text", "selected", 0.0);
- set_state(PART:"part.icon", "selected", 0.0);
+ if (state == STATE_NORMAL) {
+ set_state(PART:"part.icon", "default", 0.0);
+ run_program(PROGRAM:"unfocused,anim");
} else if (state != STATE_DISABLE) {
+ set_state(PART:"part.icon", "default.toggle", 0.0);
run_program(PROGRAM:"unfocused,anim");
}
}
action, STATE_SET "focused" 0.0;
target, "part.bg";
target, "elm.text";
- target, "part.icon";
transition, TRANSITION_FOCUS;
}
action, STATE_SET "default" 0.0;
target, "part.bg";
target, "elm.text";
- target, "part.icon";
transition, TRANSITION_FOCUS;
}
script {
new state;
state = get_int(cur_state);
- if (state != STATE_DISABLE) {
- set_int(cur_state, STATE_SELECTED);
- set_state(PART:"part.bg", "selected", 0.0);
- set_state(PART:"elm.text", "selected", 0.0);
- set_state(PART:"part.icon", "selected", 0.0);
+ if (state == STATE_NORMAL) {
+ set_int(cur_state, STATE_TOGGLE);
+ set_state(PART:"part.icon", "focused.toggle", 0.0);
+ } else if (state == STATE_TOGGLE) {
+ set_int(cur_state, STATE_NORMAL);
+ set_state(PART:"part.icon", "focused", 0.0);
}
}
}
inherit, "elm/button/base/style.action.menu.favorite.button";
data.item, "focus_highlight" "on";
images {
+ image, ACTION_UNLOCK_NOR_PNG COMP;
+ image, ACTION_UNLOCK_FOC_PNG COMP;
image, ACTION_LOCK_NOR_PNG COMP;
image, ACTION_LOCK_FOC_PNG COMP;
image, ACTION_LOCK_SEL_PNG COMP;
align, 0.5 0.5;
fixed, 1 1;
min, 60 60;
+ image.normal, ACTION_UNLOCK_NOR_PNG;
+ }
+ description {
+ state, "default.toggle" 0.0;
+ inherit, "default" 0.0;
image.normal, ACTION_LOCK_NOR_PNG;
}
description {
state, "focused" 0.0;
inherit, "default" 0.0;
+ image.normal, ACTION_UNLOCK_FOC_PNG;
+ }
+ description {
+ state, "focused.toggle" 0.0;
+ inherit, "default" 0.0;
image.normal, ACTION_LOCK_FOC_PNG;
}
description {
min, 60 60;
image.normal, ACTION_UNINSTALL_NOR_PNG;
}
+ description {
+ state, "default.toggle" 0.0;
+ inherit, "default" 0.0;
+ image.normal, ACTION_UNINSTALL_NOR_PNG;
+ }
description {
state, "focused" 0.0;
inherit, "default" 0.0;
image.normal, ACTION_UNINSTALL_FOC_PNG;
}
+ description {
+ state, "focused.toggle" 0.0;
+ inherit, "default" 0.0;
+ image.normal, ACTION_UNINSTALL_FOC_PNG;
+ }
description {
state, "selected" 0.0;
inherit, "default" 0.0;
#include "define.h"
#include "utils.h"
-#include "view_base.h"
-#include "view_action_menu.h"
+#include "view.h"
SET_TAG(PACKAGE);
#include <viewmgr.h>
#include <inputmgr.h>
#include <gridmgr.h>
+#include <app_contents.h>
#include <app_debug.h>
#include "define.h"
#include "utils.h"
+#include "view.h"
#include "data/app.h"
#include "grid.h"
};
struct _priv {
+ const char *appid;
Evas_Object *win;
Evas_Object *base;
Evas_Object *grid;
const char *title;
const char *style;
Eina_Bool disable;
+ Eina_Bool toggle;
};
static struct _action_info action_info[] = {
.id = BTN_LOCK,
.title = STR_LOCK,
.style = STYLE_ACTION_MENU_LOCK_BTN,
- .disable = EINA_TRUE
+ .disable = EINA_TRUE,
+ .toggle = EINA_FALSE
},
{
.id = BTN_UNINSTALL,
.title = STR_UNINSTALL,
.style = STYLE_ACTION_MENU_UNINSTALL_BTN,
- .disable = EINA_TRUE
+ .disable = EINA_TRUE,
+ .toggle = EINA_FALSE
}
};
elm_object_focus_set(obj, EINA_TRUE);
}
-static void _favorite_selected(void *data, Evas_Object *obj)
+static void _livetv_selected(void *data, Evas_Object *obj)
{
/* It will be implemented later */
}
-static void _livetv_selected(void *data, Evas_Object *obj)
+static void _favorite_selected(void *data, Evas_Object *obj)
{
- /* It will be implemented later */
+ struct _priv *priv;
+ int r;
+ bool isfavorite;
+
+ if (!data) {
+ _ERR("Invalid argument.");
+ return;
+ }
+ priv = data;
+
+ if (!priv->appid)
+ return;
+
+ r = app_contents_favorite_check(CONTENTS_APP, priv->appid, &isfavorite);
+ if (r != APP_CONTENTS_ERROR_NONE) {
+ _ERR("Favorite check failed.");
+ return;
+ }
+
+ r = app_contents_favorite_set(CONTENTS_APP, priv->appid, !isfavorite);
+ if (r != APP_CONTENTS_ERROR_NONE) {
+ _ERR("Favorite set failed.");
+ return;
+ }
+
+ elm_object_signal_emit(obj, SIG_SELECTED, SRC_ACTION_BTN);
}
static void _clicked_cb(int id, void *data, Evas_Object *obj)
return true;
}
-static bool _draw_menu_area(struct _priv *priv)
+void _set_action_state(int idx, Evas_Object *btn, const char *appid)
+{
+ bool isfavorite;
+
+ if (!btn || !appid) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ if (action_info[idx].disable) {
+ elm_object_disabled_set(btn, EINA_TRUE);
+ return;
+ }
+
+ if (action_info[idx].id == BTN_FAVORITE) {
+ app_contents_favorite_check(CONTENTS_APP, appid, &isfavorite);
+ if (isfavorite)
+ action_info[idx].toggle = EINA_TRUE;
+ else
+ action_info[idx].toggle = EINA_FALSE;
+ }
+
+ if (action_info[idx].toggle)
+ elm_object_signal_emit(btn, SIG_TOGGLE, SRC_ACTION_BTN);
+}
+
+static bool _draw_action_area(struct _priv *priv)
{
Evas_Object *table, *btn;
int i, row = 0, col = 0;
inputmgr_add_callback(btn, action_info[i].id,
&_btn_input_handler, priv);
- if (action_info[i].disable)
- elm_object_disabled_set(btn, EINA_TRUE);
+ _set_action_state(i, btn, priv->appid);
col = i % SIZE_COL_MAX;
row = i / SIZE_COL_MAX;
}
/* 'Favorite' can only be focused now. */
- elm_object_focus_next_object_set(priv->menu_btn[0],
- priv->menu_btn[0], ELM_FOCUS_LEFT);
- elm_object_focus_next_object_set(priv->menu_btn[0],
- priv->menu_btn[0], ELM_FOCUS_RIGHT);
+ elm_object_focus_next_object_set(priv->menu_btn[0], priv->menu_btn[0],
+ ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->menu_btn[0], priv->menu_btn[0],
+ ELM_FOCUS_RIGHT);
elm_object_focus_next_object_set(priv->live_btn, priv->menu_btn[0],
ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(priv->menu_btn[0], priv->grid,
+ ELM_FOCUS_DOWN);
+ elm_object_focus_next_object_set(priv->grid, priv->menu_btn[0],
+ ELM_FOCUS_UP);
return true;
}
priv->fav_list = get_app_favorite_list();
if (!priv->fav_list) {
- //emit no contents signal
+ /* FIXME: No content message will be displayed */
return true;
}
elm_object_part_content_set(priv->base, PART_FAVORITE, priv->grid);
- elm_object_focus_next_object_set(priv->menu_btn[0], priv->grid,
- ELM_FOCUS_DOWN);
- elm_object_focus_next_object_set(priv->grid, priv->menu_btn[0],
- ELM_FOCUS_UP);
- elm_object_focus_next_object_set(priv->grid, priv->grid, ELM_FOCUS_LEFT);
+ elm_object_focus_next_object_set(priv->grid, priv->grid,
+ ELM_FOCUS_LEFT);
return true;
}
return grid;
}
-static void _draw_view_content(struct _priv *priv)
-{
- if (!priv) {
- _ERR("Invalid argument.");
- return;
- }
-
- if (!_draw_livetv_area(priv)) {
- _ERR("Draw livetv area failed.");
- return;
- }
-
- if (!_draw_menu_area(priv)) {
- _ERR("Draw menu area failed.");
- return;
- }
-
- if (!_draw_favorite_area(priv))
- _ERR("Draw favorite area failed.");
-}
-
static Evas_Object *_create(Evas_Object *win, void *data)
{
struct _priv *priv;
goto end;
}
- _draw_view_content(priv);
+ _draw_livetv_area(priv);
+ _draw_favorite_area(priv);
return base;
_ERR("Get data failed.");
return;
}
- priv = (struct _priv *)data;
+ priv = data;
if (priv->base)
evas_object_show(priv->base);
_ERR("Get data failed.");
return;
}
- priv = (struct _priv *)data;
+ priv = data;
if (priv->base)
evas_object_hide(priv->base);
}
+static void _update(void *view_data, int update_type, void *data)
+{
+ struct _priv *priv;
+ struct app_data *adata;
+
+ if (!view_data) {
+ _ERR("Get data failed.");
+ return;
+ }
+ priv = view_data;
+
+ if (update_type == UPDATE_ID) {
+ if (!data)
+ return;
+
+ adata = data;
+ priv->appid = get_app_id(adata);
+
+ _draw_action_area(priv);
+ }
+}
+
static void _destroy(void *data)
{
struct _priv *priv;
_ERR("Get data failed.");
return;
}
- priv = (struct _priv *)data;
+ priv = data;
if (priv->gmgr)
gridmgr_destroy(priv->gmgr);
.create = _create,
.show = _show,
.hide = _hide,
+ .update = _update,
.destroy = _destroy,
};
#include "define.h"
#include "utils.h"
#include "data/app.h"
-#include "view_base.h"
+#include "view.h"
#include "grid.h"
enum menu_type {
Evas_Event_Key_Down *ev)
{
struct _priv *priv;
+ struct app_data *adata;
if (!data || !ev) {
_ERR("Invalid argument.");
priv = data;
if (!strcmp(ev->keyname, KEY_BACK)
- || !strcmp(ev->keyname, KEY_BACK_REMOTE))
+ || !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
elm_object_focus_set(priv->focused_menu, EINA_TRUE);
- /* FIXME: The action menu is blocked temporarily. */
- /*
- else if (!strcmp(ev->keyname, KEY_MENU)
- || !strcmp(ev->keyname, KEY_MENU_REMOTE))
+ } else if (!strcmp(ev->keyname, KEY_MENU)
+ || !strcmp(ev->keyname, KEY_MENU_REMOTE)) {
+ adata = elm_object_item_data_get(priv->focused_item);
+ if (!adata)
+ return;
+
+ viewmgr_update_view(VIEW_ACTION_MENU, UPDATE_ID, adata);
viewmgr_show_view(VIEW_ACTION_MENU);
- */
+ }
}
static input_handler _menu_input_handler = {