src/view/system/view_sleep_timer.c
src/view/system/view_wakeup_timer.c
src/view/system/view_pincode.c
+ src/view/system/view_language.c
src/view/system/view_location.c
src/view/view_new_network.c
src/common/utils.c
src/data/system/settings_clock.c
src/data/system/settings_wakeup_timer.c
src/data/system/settings_pincode.c
+ src/data/system/settings_language.c
src/data/system/data_wireless.c
src/data/system/data_wired.c
)
--- /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_WAKEUP_TIMER_H__
+#define __AIR_SETTINGS_WAKEUP_TIMER_H__
+
+#include <stdbool.h>
+#include <time.h>
+
+typedef enum _language_type {
+ LANG_TYPE_ENG = 0,
+ LANG_TYPE_KOR,
+ LANG_TYPE_MAX
+} settings_language_type;
+
+/* Sets current language */
+void settings_language_set_language(settings_language_type lang_type);
+/* Gets current language ID */
+settings_language_type settings_language_get_language_id(void);
+/* Gets current locale language string.
+ * Note that the returned string needs to be freed after use. */
+char *settings_language_get_language_locale_str(void);
+/* Gets current display language string. */
+char *settings_language_get_language_display_str(void);
+
+#endif /* __AIR_SETTINGS_WAKEUP_TIMER_H__ */
#define VIEW_NEW_NETWORK "VIEW_NEW_NETWORK"
#define VIEW_WAKEUP_TIMER "VIEW_WAKEUP_TIMER"
#define VIEW_SLEEP_TIMER "VIEW_SLEEP_TIMER"
+#define VIEW_LANGUAGE "VIEW_LANGUAGE"
/* 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"
/* Part for EDC */
#define PART_TOP_TITLE "part.top.title"
/* group */
#define GRP_LAYOUT_SYSTEM "grp.layout.system"
-#define GRP_POPUP_LANGUAGE "grp.popup.language"
/* part */
#define PART_SYSTEM "part.system"
-#define POPUP_SLEEP_TIMER_BTN_COUNT 6
-#define POPUP_LANGUAGE_BTN_COUNT 2
-
#define PART_LOCATION_TEXT "part.location.text"
#define PART_LOCATION_MENU1 "part.location.menu1"
#define PART_LOCATION_MENU2 "part.location.menu2"
--- /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_LANGUAGE_H__
+#define __AIR_SETTINGS_VIEW_LANGUAGE_H__
+
+view_class *view_language_get_vclass(void);
+
+#endif /* __AIR_SETTINGS_VIEW_LANGUAGE_H__ */
}
}
}
-
-
-
-group {
- name, GRP_POPUP_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;
- }
- }
- }
-}
#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_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;
+ }
+ }
+ }
+}
--- /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 <stdlib.h>
+#include <system_settings.h>
+#include <utils_i18n.h>
+#include "app_debug.h"
+#include "data/system/settings_language.h"
+
+#define LANG_LOCALE_STR_L 6
+#define LANG_DISPLAY_STR_L 64
+
+#define LOCALE_UNKNOWN "Unknown"
+
+static char *lang_str[LANG_TYPE_MAX] = { "en_US", "ko_KR" };
+
+void settings_language_set_language(settings_language_type lang_type)
+{
+ int ret = system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, lang_str[lang_type]);
+ if (ret != SYSTEM_SETTINGS_ERROR_NONE)
+ _ERR("Failed to set language: %s", lang_str[lang_type]);
+}
+
+settings_language_type settings_language_get_language_id(void)
+{
+ char *lang = NULL;
+ int r = 0;
+ int i = 0;
+
+ r = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
+ if (r != SYSTEM_SETTINGS_ERROR_NONE)
+ return LANG_TYPE_MAX;
+
+ for (i = 0; i < LANG_TYPE_MAX; i++) {
+ if (!strncmp(lang, lang_str[i], LANG_LOCALE_STR_L)) {
+ free(lang);
+ return i;
+ }
+ }
+
+ free(lang);
+
+ return LANG_TYPE_MAX;
+}
+
+char *settings_language_get_language_locale_str(void)
+{
+ char *lang = NULL;
+
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
+
+ return lang;
+}
+
+char *settings_language_get_language_display_str(void)
+{
+ char *lang = NULL;
+ char name[LANG_DISPLAY_STR_L] = {0, };
+ i18n_uchar res[LANG_DISPLAY_STR_L] = {0, };
+ int r = 0;
+
+ lang = settings_language_get_language_locale_str();
+ if (!lang) {
+ _ERR("Failed to get language.");
+ return strdup(LOCALE_UNKNOWN);
+ }
+
+ r = i18n_ulocale_get_display_language(lang, lang, res, sizeof(res));
+ if (r < 0) {
+ _ERR("Failed to get display language: %s.", get_last_result());
+ free(lang);
+ return strdup(LOCALE_UNKNOWN);
+ }
+
+ i18n_ustring_copy_au_n(name, res, LANG_DISPLAY_STR_L-1);
+
+ free(lang);
+
+ return strdup(name);
+}
#include "view/system/view_clock.h"
#include "view/system/view_location.h"
#include "data/system/settings_clock.h"
+#include "data/system/settings_language.h"
#define PADDING_X 26
#define PADDING_Y 26
#define TIMER_ON "On"
#define LOCALE_UNKNOWN "Unknown"
-#define PART_POPUP_BUTTON_X "part.popup.btn%d"
-
struct _priv {
Evas_Object *base;
Evas_Object *ly;
Evas_Object *table;
layoutmgr *lmgr;
struct menumgr *menu;
-
- Evas_Object *popup;
- Evas_Object *popup_btn[POPUP_SLEEP_TIMER_BTN_COUNT];
};
enum {
MENU_RESET
};
-
-enum object_type {
- EO_BTN_LANG_ENG = 0,
- EO_BTN_LANG_KOR
-};
-
static char *_get_status(void *data, int id);
static char *_get_clock_mode(void *data, int id);
static char *_get_sleep_timer(void *data, int id);
static char *_get_location(void *data, int id);
static void _selected(void *data, int id);
-static void _language_selected(void *data, int id);
static void _location_selected(void *data, int id);
-// popup handler
-static void _remove_popup(struct _priv *priv);
-static void _popup_clicked_cb(int id, void *data, Evas_Object *obj);
-static void _popup_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
-
-static char *language_option[POPUP_LANGUAGE_BTN_COUNT] = { "English", "Korean"};
-
static struct menumgr_info menu_info[] = {
{
.id = MENU_CLOCK,
.style = STYLE_STATUS_BTN,
.disabled = EINA_FALSE,
.status = _get_language,
- .selected = _language_selected,
+ .selected = _selected,
},
{
.id = MENU_SUBTITLE,
static char *_get_language(void *data, int id)
{
- char *lang = NULL;
- char name[64] = {'\0',};
- i18n_uchar res[64] = {0};
- int r;
-
- r = system_settings_get_value_string(
- SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
- if (r != SYSTEM_SETTINGS_ERROR_NONE) {
- _ERR("failed to get language");
- return strdup(LOCALE_UNKNOWN);
- }
-
- r = i18n_ulocale_get_display_language(lang, lang, res, sizeof(res));
- if (r < 0) {
- _ERR("failed to get display language: %s", get_last_result());
- free(lang);
- return strdup(LOCALE_UNKNOWN);
- }
-
- i18n_ustring_copy_au(name, res);
-
- free(lang);
-
- return strdup(name);
+ return settings_language_get_language_display_str();
}
static char *_get_location(void *data, int id)
if (!viewmgr_show_view(VIEW_CHANGE_PINCODE))
_ERR("Push Clock view failed.");
break;
+ case MENU_LANGUAGE:
+ if (!viewmgr_show_view(VIEW_LANGUAGE))
+ _ERR("Push Language view failed.");
+ break;
default:
_ERR("Invalid menu.");
}
}
-static input_handler _popup_input_handler = {
- .mouse_move = NULL,
- .clicked = _popup_clicked_cb,
- .key_down = _popup_key_down_cb
-};
-
-
-static void _remove_popup(struct _priv *priv)
-{
- int i = 0;
-
- if (!priv) {
- _ERR("Invalid popup data !");
- return;
- }
-
- for(i = 0; i < POPUP_SLEEP_TIMER_BTN_COUNT; i++) {
- if (priv->popup_btn[i]) {
- inputmgr_remove_callback(priv->popup_btn[i], &_popup_input_handler);
- evas_object_del(priv->popup_btn[i]);
- priv->popup_btn[i] = NULL;
- }
- }
-
- evas_object_hide(priv->popup);
- evas_object_del(priv->popup);
- priv->popup = NULL;
-}
-
-
-
-static void _popup_clicked_cb(int id, void *data, Evas_Object *obj)
-{
- struct _priv *priv = NULL;
-
- if (!data || !obj) {
- _ERR("Invalid argument.");
- return;
- }
-
- priv = data;
-
- switch (id) {
- case EO_BTN_LANG_ENG:
- system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, "en_US");
- menumgr_update(priv->menu);
-
- _remove_popup(priv);
- break;
-
- case EO_BTN_LANG_KOR:
- system_settings_set_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, "ko_KR");
- menumgr_update(priv->menu);
-
- _remove_popup(priv);
- break;
- default:
- _ERR("Unhandled object type.");
- return;
- }
-}
-
-static void _popup_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
- Evas_Event_Key_Down *ev)
-{
- struct _priv *priv = NULL;
-
- if (!ev || !data) {
- _ERR("Invalid argument.");
- return;
- }
-
- priv = data;
-
- if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_ESC)) {
- _remove_popup(priv);
- }
-}
-
-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 = 0;
-
- for(i = 0; i < btn_count; i++) {
- char part_name[24] = {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, &_popup_input_handler, priv);
- }
-
- return true;
-}
-
-static bool _draw_language_select_popup(struct _priv *priv)
-{
- Evas_Object *popup = NULL;
- Evas_Object *ly = NULL;
-
- popup = utils_add_popup(priv->base, NULL, STR_LANGUAGE, NULL);
- if (!popup) {
- _ERR("Add popup failed");
- return false;
- }
- evas_object_show(popup);
-
- ly = utils_add_layout(popup, GRP_POPUP_LANGUAGE, EINA_FALSE);
- if (!ly) {
- _ERR("Add layout failed.");
- evas_object_del(popup);
- return false;
- }
-
- elm_object_part_text_set(ly, PART_POPUP_NAME, "Select language.");
- evas_object_show(ly);
-
- if (!_fill_popup_btns(priv, ly, POPUP_LANGUAGE_BTN_COUNT, PART_POPUP_BUTTON_X, language_option, EO_BTN_LANG_ENG)) {
- evas_object_del(popup);
- return false;
- }
-
- if (priv->popup)
- evas_object_del(priv->popup);
-
- priv->popup = popup;
-
- elm_object_content_set(popup, ly);
-
- // Set Focus
-
- {
- char *lang;
- int r;
-
- r = system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &lang);
- if (r != SYSTEM_SETTINGS_ERROR_NONE) {
- return false;
- }
-
- if (!strncmp(lang, "en_US",4)) {
- elm_object_focus_set(priv->popup_btn[0], EINA_TRUE);
- }
- else {
- elm_object_focus_set(priv->popup_btn[1], EINA_TRUE);
- }
-
- free(lang);
- }
- return true;
-}
-
-static void _language_selected(void *data, int id)
-{
- SETTING_TRACE_BEGIN;
- struct _priv *priv = (struct _priv *)data;
-
-
- if (!_draw_language_select_popup(priv)) {
- _ERR("Draw language select popup failed.");
- return;
- }
-
-}
-
static void _location_selected(void *data, int id)
{
SETTING_TRACE_BEGIN;
priv->table = NULL;
priv->menu = NULL;
- priv->popup = NULL;
-
- memset(priv->popup_btn, 0, POPUP_SLEEP_TIMER_BTN_COUNT * sizeof(Evas_Object *));
-
priv->lmgr = lmgr;
priv->base = base;
priv->ly = ly;
#include "view/system/view_sleep_timer.h"
#include "view/system/view_wakeup_timer.h"
#include "view/system/view_pincode.h"
-
-#include <system_settings.h>
+#include "view/system/view_language.h"
+#include "data/system/settings_language.h"
struct _appdata {
Evas_Object *win;
return false;
}
- if (!viewmgr_add_view(view_wakeup_timer_get_vclass(), NULL)) {
- _ERR("Add view failed.");
- evas_object_del(win);
- return false;
- }
-
ad->win = win;
return true;
_destroy_system_ui();
- if (!viewmgr_remove_view(VIEW_WAKEUP_TIMER))
- _ERR("Remove view failed.");
-
if (!viewmgr_destroy())
_ERR("Destroy viewmgr failed.");
{
SETTING_TRACE_BEGIN;
- char* localeLanguage = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &localeLanguage);
+ char* localeLanguage = settings_language_get_language_locale_str();
elm_language_set(localeLanguage);
free(localeLanguage);
static void setting_region_changed_cb(app_event_info_h event_info, void *data)
{
SETTING_TRACE_BEGIN;
-#if 0
- char* localeLanguage = NULL;
- system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &localeLanguage);
- elm_language_set(localeLanguage);
- free(localeLanguage);
-
- // add more here
-#endif
}
int main(int argc, char *argv[])
return false;
}
+ if (!viewmgr_add_view(view_wakeup_timer_get_vclass(), NULL)) {
+ _ERR("Add wake up view failed.");
+ return false;
+ }
+
if (!viewmgr_add_view(view_pincode_get_vclass(), NULL)) {
_ERR("Adding change pin view failed.");
return false;
}
+ if (!viewmgr_add_view(view_language_get_vclass(), NULL)) {
+ _ERR("Add language 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_SLEEP_TIMER))
_ERR("Remove sleep timer view failed.");
+ if (!viewmgr_remove_view(VIEW_WAKEUP_TIMER))
+ _ERR("Remove wake up view failed.");
+
if (!viewmgr_remove_view(VIEW_CHANGE_PINCODE))
_ERR("Remove change pin view failed.");
+ if (!viewmgr_remove_view(VIEW_LANGUAGE))
+ _ERR("Remove language view failed.");
+
if (!viewmgr_remove_view(VIEW_LOCATION))
_ERR("Remove location view failed.");
}
--- /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 <system_settings.h>
+#include <utils_i18n.h>
+#include <vconf.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_language.h"
+
+#define STR_LANGUAGE_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 *language_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_LANGUAGE, NULL);
+ if (!priv->base) {
+ _ERR("Add popup failed");
+ free(priv);
+ return NULL;
+ }
+
+ ly = utils_add_layout(priv->base, GRP_VIEW_LANGUAGE, 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_LANGUAGE_DES);
+
+ if (!_fill_popup_btns(priv, ly, LANG_TYPE_MAX, PART_POPUP_BUTTON_X,
+ language_option, EO_BTN_LANG_ENG)) {
+ evas_object_del(priv->base);
+ return NULL;
+ }
+
+ elm_object_content_set(priv->base, ly);
+
+
+ if (!viewmgr_set_view_data(VIEW_LANGUAGE, 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_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_LANGUAGE,
+ .create = _create,
+ .show = _show,
+ .hide = _hide,
+ .destroy = _destroy
+};
+
+view_class *view_language_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_language(LANG_TYPE_ENG);
+ break;
+ case EO_BTN_LANG_KOR:
+ settings_language_set_language(LANG_TYPE_KOR);
+ break;
+ default:
+ _ERR("Unhandled object type.");
+ }
+
+ viewmgr_pop_view();
+}
break;
default:
_ERR("Unhandled object type.");
- return;
}
viewmgr_pop_view();