src/view/system/view_wakeup_timer.c
src/view/system/view_pincode.c
src/view/system/view_language.c
+ src/view/system/view_subtitle.c
src/view/system/view_location.c
src/view/view_new_network.c
src/common/utils.c
/* Gets current display language string. */
char *settings_language_get_language_display_str(void);
+/* Sets current subtitle language */
+void settings_language_set_subtitle_language(settings_language_type lang_type);
+/* Gets current subtitle language ID */
+settings_language_type settings_language_get_subtitle_language_id(void);
+/* Gets current display subtitlelanguage string. */
+char *settings_language_get_subtitle_language_display_str(void);
+
#endif /* __AIR_SETTINGS_WAKEUP_TIMER_H__ */
#define VIEW_WAKEUP_TIMER "VIEW_WAKEUP_TIMER"
#define VIEW_SLEEP_TIMER "VIEW_SLEEP_TIMER"
#define VIEW_LANGUAGE "VIEW_LANGUAGE"
+#define VIEW_SUBTITLE "VIEW_SUBTITLE"
/* Layout ID */
#define LAYOUT_ID_PICTURE "LAYOUT_ID_PICTURE"
#define GRP_VIEW_NEW_NETWORK "grp.view.new_network"
#define GRP_VIEW_WAKEUP_TIMER "grp.view.wakeup_timer"
#define GRP_VIEW_SLEEP_TIMER "grp.view.sleep_timer"
-#define GRP_VIEW_LANGUAGE "grp.view.language"
+
+#define GRP_VIEW_POPUP_2BTNS "grp.view.popup_2btns"
/* Part for EDC */
#define PART_TOP_TITLE "part.top.title"
#define STR_LANGUAGE "Language"
#define STR_LOCATION "Location"
#define STR_SLEEP_TIMER "Sleep timer"
+#define STR_SUBTITLE "Subtitle"
/* Size */
#define SIZE_STR 1024
--- /dev/null
+/*
+ * Copyright (c) 2016 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_SETTINGS_VIEW_SUBTITLE_H__
+#define __AIR_SETTINGS_VIEW_SUBTITLE_H__
+
+view_class *view_subtitle_get_vclass(void);
+
+#endif /* __AIR_SETTINGS_VIEW_SUBTITLE_H__ */
collections {
base_scale: APP_BASE_SCALE;
#include "view/base.edc"
+ #include "view/common/popup_2btns.edc"
#include "view/system/clock.edc"
#include "view/system/sleep_timer.edc"
#include "view/system/wakeup_timer.edc"
#include "view/system/pin.edc"
- #include "view/system/language.edc"
#include "view/system/location.edc"
#include "layout/picture.edc"
#include "layout/channel.edc"
--- /dev/null
+group {
+ name, GRP_VIEW_POPUP_2BTNS;
+ parts {
+ part {
+ name, "area";
+ type, RECT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ visible, 0;
+ }
+ }
+
+ part {
+ name, "padding.title";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 24;
+ rel1.to, "area";
+ rel2 { to, "area"; relative, 1.0 0.0; }
+ align, 0.5 0.0;
+ fixed, 0 1;
+ }
+ }
+
+ part {
+ name, PART_POPUP_NAME;
+ type, TEXT;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 32;
+ rel1 { to, "padding.title"; relative, 0.0 1.0; }
+ rel2.to, "padding.title";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ color, COLOR_TEXT_POPUP;
+ text {
+ font, FONT_LIGHT;
+ size, 32;
+ }
+ }
+ }
+
+ part {
+ name, "padding.lang1";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 32;
+ rel1 { to, PART_POPUP_NAME; relative, 0.0 1.0; }
+ rel2.to, PART_POPUP_NAME;
+ align, 0.5 0.0;
+ fixed, 0 1;
+ }
+ }
+
+ part {
+ name, PART_POPUP_BUTTON1;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 488 68;
+ rel1 { to, "padding.lang1"; relative, 0.5 1.0; }
+ rel2 { to, "padding.lang1"; relative, 0.5 1.0; }
+ align, 0.5 0.0;
+ fixed, 0 1;
+ color, 0 0 0 255;
+ }
+ }
+
+ part {
+ name, "padding.lang2";
+ type, SPACER;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 0 32;
+ rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
+ rel2.to, PART_POPUP_BUTTON1;
+ align, 0.5 0.0;
+ fixed, 0 1;
+ }
+ }
+
+ part {
+ name, PART_POPUP_BUTTON2;
+ type, SWALLOW;
+ scale, 1;
+ description {
+ state, "default" 0.0;
+ min, 488 68;
+ rel1 { to, "padding.lang2"; relative, 0.0 1.0; }
+ rel2.to, "padding.lang2";
+ align, 0.5 0.0;
+ fixed, 0 1;
+ color, 0 0 0 255;
+ }
+ }
+ }
+}
+++ /dev/null
-group {
- name, GRP_VIEW_LANGUAGE;
- parts {
- part {
- name, "area";
- type, RECT;
- scale, 1;
- description {
- state, "default" 0.0;
- visible, 0;
- }
- }
-
- part {
- name, "padding.title";
- type, SPACER;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 0 24;
- rel1.to, "area";
- rel2 { to, "area"; relative, 1.0 0.0; }
- align, 0.5 0.0;
- fixed, 0 1;
- }
- }
-
- part {
- name, PART_POPUP_NAME;
- type, TEXT;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 0 32;
- rel1 { to, "padding.title"; relative, 0.0 1.0; }
- rel2.to, "padding.title";
- align, 0.5 0.0;
- fixed, 0 1;
- color, COLOR_TEXT_POPUP;
- text {
- font, FONT_LIGHT;
- size, 32;
- }
- }
- }
-
- part {
- name, "padding.lang1";
- type, SPACER;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 0 32;
- rel1 { to, PART_POPUP_NAME; relative, 0.0 1.0; }
- rel2.to, PART_POPUP_NAME;
- align, 0.5 0.0;
- fixed, 0 1;
- }
- }
-
- part {
- name, PART_POPUP_BUTTON1;
- type, SWALLOW;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 488 68;
- rel1 { to, "padding.lang1"; relative, 0.5 1.0; }
- rel2 { to, "padding.lang1"; relative, 0.5 1.0; }
- align, 0.5 0.0;
- fixed, 0 1;
- color, 0 0 0 255;
- }
- }
-
- part {
- name, "padding.lang2";
- type, SPACER;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 0 32;
- rel1 { to, PART_POPUP_BUTTON1; relative, 0.0 1.0; }
- rel2.to, PART_POPUP_BUTTON1;
- align, 0.5 0.0;
- fixed, 0 1;
- }
- }
-
- part {
- name, PART_POPUP_BUTTON2;
- type, SWALLOW;
- scale, 1;
- description {
- state, "default" 0.0;
- min, 488 68;
- rel1 { to, "padding.lang2"; relative, 0.0 1.0; }
- rel2.to, "padding.lang2";
- align, 0.5 0.0;
- fixed, 0 1;
- color, 0 0 0 255;
- }
- }
- }
-}
return strdup(name);
}
+
+void settings_language_set_subtitle_language(settings_language_type lang_type)
+{
+ //@TODO: set subtitle language
+}
+
+settings_language_type settings_language_get_subtitle_language_id(void)
+{
+ //@TODO: get subtitle language
+ return LANG_TYPE_ENG;
+}
+
+char *settings_language_get_subtitle_language_display_str(void)
+{
+ //@TODO: get subtitle language and corresponding display string
+ return strdup("English");
+}
static char *_get_clock_mode(void *data, int id);
static char *_get_sleep_timer(void *data, int id);
static char *_get_language(void *data, int id);
+static char *_get_subtitle(void *data, int id);
static char *_get_location(void *data, int id);
static void _selected(void *data, int id);
},
{
.id = MENU_SUBTITLE,
- .title = "Subtitile",
+ .title = STR_SUBTITLE,
.style = STYLE_STATUS_BTN,
.disabled = EINA_FALSE,
- .status = _get_status,
+ .status = _get_subtitle,
.selected = _selected,
},
{
return settings_language_get_language_display_str();
}
+static char *_get_subtitle(void *data, int id)
+{
+ return settings_language_get_subtitle_language_display_str();
+}
+
static char *_get_location(void *data, int id)
{
char *country = NULL;
if (!viewmgr_show_view(VIEW_LANGUAGE))
_ERR("Push Language view failed.");
break;
+ case MENU_SUBTITLE:
+ if (!viewmgr_show_view(VIEW_SUBTITLE))
+ _ERR("Push Language view failed.");
+ break;
default:
_ERR("Invalid menu.");
}
#include "view/system/view_wakeup_timer.h"
#include "view/system/view_pincode.h"
#include "view/system/view_language.h"
+#include "view/system/view_subtitle.h"
#include "data/system/settings_language.h"
struct _appdata {
return false;
}
+ if (!viewmgr_add_view(view_subtitle_get_vclass(), NULL)) {
+ _ERR("Add view failed.");
+ return false;
+ }
+
if (!viewmgr_add_view(view_location_get_vclass(), NULL)) {
_ERR("Adding location view failed.");
return false;
if (!viewmgr_remove_view(VIEW_LANGUAGE))
_ERR("Remove language view failed.");
+ if (!viewmgr_remove_view(VIEW_SUBTITLE))
+ _ERR("Remove view failed.");
+
if (!viewmgr_remove_view(VIEW_LOCATION))
_ERR("Remove location view failed.");
}
#include <app.h>
#include <Elementary.h>
-#include <system_settings.h>
-#include <utils_i18n.h>
-#include <vconf.h>
#include "app_debug.h"
#include "define.h"
return NULL;
}
- ly = utils_add_layout(priv->base, GRP_VIEW_LANGUAGE, EINA_FALSE);
+ ly = utils_add_layout(priv->base, GRP_VIEW_POPUP_2BTNS, EINA_FALSE);
if (!ly) {
_ERR("Add layout failed.");
evas_object_del(priv->base);
if (!_fill_popup_btns(priv, ly, LANG_TYPE_MAX, PART_POPUP_BUTTON_X,
language_option, EO_BTN_LANG_ENG)) {
evas_object_del(priv->base);
+ free(priv);
return NULL;
}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.
+ */
+
+#include <app.h>
+#include <Elementary.h>
+
+#include "app_debug.h"
+#include "define.h"
+#include "common/viewmgr.h"
+#include "common/inputmgr.h"
+#include "common/utils.h"
+#include "data/system/settings_language.h"
+#include "view/system/view_subtitle.h"
+
+#define STR_SUBTITLE_DES "Select language."
+#define PART_POPUP_BUTTON_X "part.popup.btn%d"
+#define PART_POPUP_BUTTON_MAX_L 24
+
+struct _priv {
+ Evas_Object *base;
+ Evas_Object *popup_btn[LANG_TYPE_MAX];
+};
+
+enum language_eo_type {
+ EO_BTN_LANG_ENG = 0,
+ EO_BTN_LANG_KOR
+};
+
+static void _clicked_cb(int id, void *data, Evas_Object *obj);
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev);
+
+static char *subtitle_option[LANG_TYPE_MAX] = { "English", "Korean"};
+
+static input_handler handler = {
+ .key_down = _key_down_cb,
+ .clicked = _clicked_cb
+};
+
+static bool _fill_popup_btns(struct _priv *priv, Evas_Object *layout,
+ int btn_count, char *btn_part_x, char **btn_text, int first_btn_eo)
+{
+ Evas_Object *btn = NULL;
+ int i;
+
+ for(i = 0; i < btn_count; i++) {
+ char part_name[PART_POPUP_BUTTON_MAX_L] = {0, };
+ snprintf(part_name, sizeof(part_name), btn_part_x, i+1);
+
+ btn = utils_add_button(layout, part_name, NULL, btn_text[i]);
+ if (!btn) {
+ _ERR("Add button failed.");
+ return false;
+ }
+
+ priv->popup_btn[i] = btn;
+
+ inputmgr_add_callback(btn, first_btn_eo+i, &handler, priv);
+ }
+
+ return true;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+ struct _priv *priv = NULL;
+ Evas_Object *ly = NULL;
+
+ if (!win) {
+ _ERR("Get window object failed.");
+ return NULL;
+ }
+
+ priv = calloc(1, sizeof(struct _priv *));
+ if (!priv) {
+ _ERR("Calloc failed.");
+ return NULL;
+ }
+
+ priv->base = utils_add_popup(win, NULL, STR_SUBTITLE, NULL);
+ if (!priv->base) {
+ _ERR("Add popup failed");
+ free(priv);
+ return NULL;
+ }
+
+ ly = utils_add_layout(priv->base, GRP_VIEW_POPUP_2BTNS, EINA_FALSE);
+ if (!ly) {
+ _ERR("Add layout failed.");
+ evas_object_del(priv->base);
+ free(priv);
+ return NULL;
+ }
+
+ elm_object_part_text_set(ly, PART_POPUP_NAME, STR_SUBTITLE_DES);
+
+ if (!_fill_popup_btns(priv, ly, LANG_TYPE_MAX, PART_POPUP_BUTTON_X,
+ subtitle_option, EO_BTN_LANG_ENG)) {
+ evas_object_del(priv->base);
+ free(priv);
+ return NULL;
+ }
+
+ elm_object_content_set(priv->base, ly);
+
+ if (!viewmgr_set_view_data(VIEW_SUBTITLE, priv)) {
+ _ERR("Set view data failed.");
+ evas_object_del(priv->base);
+ free(priv);
+ return NULL;
+ }
+
+ return priv->base;
+}
+
+static void _show(void *data)
+{
+ struct _priv *priv = (struct _priv *)data;
+ int lang_id = 0;
+
+ if (!priv) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ evas_object_show(priv->base);
+
+ /* Set Focus */
+ lang_id = settings_language_get_subtitle_language_id();
+
+ if(lang_id != LANG_TYPE_MAX)
+ elm_object_focus_set(priv->popup_btn[lang_id], EINA_TRUE);
+}
+
+static void _hide(void *data)
+{
+ struct _priv *priv = (struct _priv *)data;
+
+ if (!priv) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ evas_object_hide(priv->base);
+}
+
+static void _destroy(void *data)
+{
+ struct _priv *priv = (struct _priv *)data;
+
+ if (!priv) {
+ _ERR("Invalid parameter.");
+ return;
+ }
+
+ evas_object_del(priv->base);
+
+ free(priv);
+}
+
+static view_class _vclass = {
+ .view_id = VIEW_SUBTITLE,
+ .create = _create,
+ .show = _show,
+ .hide = _hide,
+ .destroy = _destroy
+};
+
+view_class *view_subtitle_get_vclass(void)
+{
+ return &_vclass;
+}
+
+static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
+ Evas_Event_Key_Down *ev)
+{
+ struct _priv *priv = (struct _priv *)data;
+
+ if (!ev || !priv) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ if (!strcmp(ev->keyname, KEY_BACK))
+ viewmgr_pop_view();
+}
+
+static void _clicked_cb(int id, void *data, Evas_Object *obj)
+{
+ struct _priv *priv = (struct _priv *)data;
+
+ if (!priv || !obj) {
+ _ERR("Invalid argument.");
+ return;
+ }
+
+ switch (id) {
+ case EO_BTN_LANG_ENG:
+ settings_language_set_subtitle_language(LANG_TYPE_ENG);
+ break;
+ case EO_BTN_LANG_KOR:
+ settings_language_set_subtitle_language(LANG_TYPE_KOR);
+ break;
+ default:
+ _ERR("Unhandled object type.");
+ }
+
+ viewmgr_pop_view();
+}