system: add system layout 62/49062/1
authorMinkyu Kang <mk7.kang@samsung.com>
Tue, 6 Oct 2015 05:23:22 +0000 (14:23 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Tue, 6 Oct 2015 05:23:22 +0000 (14:23 +0900)
Change-Id: I65d4671c03a98a9e4b0dbf20c844eb2906db80e1
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
CMakeLists.txt
include/define.h
include/layout/system.h [new file with mode: 0644]
org.tizen.settings.xml.in
packaging/org.tizen.settings.spec
res/layout/system.edc [new file with mode: 0644]
res/settings.edc
src/layout/layout_system.c
src/view/view_base.c

index 210d12e..43cd5a3 100644 (file)
@@ -23,6 +23,8 @@ pkg_check_modules(PKGS REQUIRED
                capi-appfw-application
                capi-system-info
                capi-system-device
+               capi-system-system-settings
+               capi-base-utils-i18n
                app-utils
                tv-service
                )
index e7d264c..b959c48 100644 (file)
@@ -21,6 +21,7 @@
 #include "layout/support.h"
 #include "layout/network.h"
 #include "layout/picture.h"
+#include "layout/system.h"
 
 /* View ID */
 #define VIEW_BASE "VIEW_BASE"
diff --git a/include/layout/system.h b/include/layout/system.h
new file mode 100644 (file)
index 0000000..997712c
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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_SETTINGS_LAYOUT_SYSTEM_H__
+#define __AIR_SETTINGS_LAYOUT_SYSTEM_H__
+
+/* group */
+#define GRP_LAYOUT_SYSTEM "grp.layout.system"
+
+/* part */
+#define PART_SYSTEM "part.system"
+
+#endif
index 7e21e9b..5f7b96c 100644 (file)
@@ -15,5 +15,6 @@
                <privilege>http://tizen.org/privilege/network.profile</privilege>
                <privilege>http://tizen.org/privilege/internal/dbus</privilege>
                <privilege>http://tizen.org/privilege/display</privilege>
+               <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
        </privileges>
 </manifest>
index 361b5fa..e2f8bf8 100644 (file)
@@ -12,6 +12,8 @@ BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(capi-system-info)
 BuildRequires: pkgconfig(capi-system-device)
+BuildRequires: pkgconfig(capi-system-system-settings)
+BuildRequires: pkgconfig(capi-base-utils-i18n)
 BuildRequires: pkgconfig(app-utils)
 BuildRequires: pkgconfig(tv-service)
 
diff --git a/res/layout/system.edc b/res/layout/system.edc
new file mode 100644 (file)
index 0000000..b425495
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+group {
+       name, GRP_LAYOUT_SYSTEM;
+       parts {
+               part {
+                       name, "area";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "padding.top";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 65 134;
+                               rel1 {
+                                       to, "area";
+                                       relative, 0.0 0.0;
+                               }
+                               rel2 {
+                                       to, "area";
+                                       relative, 0.0 0.0;
+                               }
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.bottom";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 65 148;
+                               rel1 {
+                                       to, "area";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2 {
+                                       to, "area";
+                                       relative, 1.0 1.0;
+                               }
+                               align, 1.0 1.0;
+                               fixed, 0 1;
+                       }
+               }
+               part {
+                       name, PART_SYSTEM;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "padding.top";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2 {
+                                       to, "padding.bottom";
+                                       relative, 0.0 0.0;
+                               }
+                               fixed, 1 1;
+                       }
+               }
+       }
+}
index 118824c..0cfbfa9 100644 (file)
@@ -22,4 +22,5 @@ collections {
        #include "layout/channel.edc"
        #include "layout/support.edc"
        #include "layout/network.edc"
+       #include "layout/system.edc"
 }
index 125e60f..8d62827 100644 (file)
  */
 
 #include <Elementary.h>
+#include <system_settings.h>
+#include <utils_i18n.h>
 #include <layoutmgr.h>
+#include <inputmgr.h>
+#include <app_debug.h>
 
 #include "define.h"
 #include "layout.h"
+#include "utils.h"
+#include "menumgr.h"
+
+#define PADDING_X 26
+#define PADDING_Y 26
+
+#define CLOCK_AUTO "Auto"
+#define CLOCK_MANUAL "Manual"
+#define TIMER_OFF "Off"
+#define TIMER_ON "On"
+#define LOCALE_UNKNOWN "Unknown"
+
+struct _priv {
+       Evas_Object *base;
+       Evas_Object *ly;
+       Evas_Object *table;
+       layoutmgr *lmgr;
+       struct menumgr *menu;
+};
+
+enum {
+       MENU_CLOCK,
+       MENU_SLEEP_TIMER,
+       MENU_WAKEUP_TIMER,
+       MENU_CHANGE_PINCODE,
+       MENU_LANGUAGE,
+       MENU_SUBTITLE,
+       MENU_LOCATION,
+       MENU_RESET
+};
+
+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_language(void *data, int id);
+static char *_get_location(void *data, int id);
+static void _selected(void *data, int id);
+
+static struct menumgr_info menu_info[] = {
+       {
+               .id = MENU_CLOCK,
+               .title = "Clock",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_clock_mode,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_SLEEP_TIMER,
+               .title = "Sleep timer",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_sleep_timer,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_WAKEUP_TIMER,
+               .title = "Wake up timer",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_CHANGE_PINCODE,
+               .title = "Change Pincode",
+               .style = STYLE_NORMAL_BTN,
+               .disabled = EINA_TRUE,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_LANGUAGE,
+               .title = "Language",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_language,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_SUBTITLE,
+               .title = "Subtitile",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_LOCATION,
+               .title = "Location",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_location,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_RESET,
+               .title = "Reset",
+               .style = STYLE_NORMAL_BTN,
+               .disabled = EINA_TRUE,
+               .selected = _selected,
+       },
+};
+
+static char *_get_status(void *data, int id)
+{
+       return NULL;
+}
+static char *_get_clock_mode(void *data, int id)
+{
+       return strdup(CLOCK_AUTO);
+}
+
+static char *_get_sleep_timer(void *data, int id)
+{
+       return strdup(TIMER_OFF);
+}
+
+static char *_get_language(void *data, int id)
+{
+       char *lang;
+       char name[64];
+       i18n_uchar res[64];
+       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);
+}
+
+static char *_get_location(void *data, int id)
+{
+       char *country;
+       char *lang;
+       char name[64];
+       i18n_uchar res[64];
+       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 = system_settings_get_value_string(
+                       SYSTEM_SETTINGS_KEY_LOCALE_COUNTRY, &country);
+       if (r != SYSTEM_SETTINGS_ERROR_NONE) {
+               _ERR("failed to get country");
+               free(lang);
+               return strdup(LOCALE_UNKNOWN);
+       }
+
+       r = i18n_ulocale_get_display_country(country, lang, res, sizeof(res));
+       if (r < 0) {
+               _ERR("failed to get display country: %s", get_last_result());
+               free(lang);
+               free(country);
+               return strdup(LOCALE_UNKNOWN);
+       }
+
+       i18n_ustring_copy_au(name, res);
+
+       free(lang);
+       free(country);
+
+       return strdup(name);
+}
+
+static void _selected(void *data, int id)
+{
+}
+
+static bool _add_layout_contents(struct _priv *priv)
+{
+       Evas_Object *table;
+       struct menumgr *menu;
+
+       table = utils_add_table(priv->ly, PADDING_X, PADDING_Y);
+       if (!table) {
+               _ERR("failed to add table");
+               return false;
+       }
+
+       priv->table = table;
+
+       elm_object_part_content_set(priv->ly, PART_SYSTEM, table);
+
+       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
+       if (!menu) {
+               _ERR("failed to create menu manager");
+               evas_object_del(table);
+               return false;
+       }
+
+       priv->menu = menu;
+
+       return true;
+}
 
 static bool _create(layoutmgr *lmgr, void *data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+       Evas_Object *base, *ly;
+
+       if (!lmgr) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       base = layoutmgr_get_base(lmgr);
+       if (!base) {
+               _ERR("Get base layout failed.");
+               return false;
+       }
+
+       ly = utils_add_layout(base, GRP_LAYOUT_SYSTEM, EINA_FALSE);
+       if (!ly) {
+               _ERR("Add layout failed.");
+               return false;
+       }
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("Calloc failed.");
+               evas_object_del(ly);
+               return false;
+       }
+
+       priv->lmgr = lmgr;
+       priv->base = base;
+       priv->ly = ly;
+
+       if (!_add_layout_contents(priv)) {
+               _ERR("Add layout contents failed.");
+               evas_object_del(ly);
+               free(priv);
+               return false;
+       }
+
+       layoutmgr_set_layout_data(lmgr, LAYOUT_ID_SYSTEM, priv);
+
        return true;
 }
 
 static void _show(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       if (priv->ly) {
+               menumgr_update(priv->menu);
+
+               evas_object_show(priv->ly);
+               elm_object_part_content_set(priv->base, PART_CONTENT, priv->ly);
+       }
 }
 
 static void _hide(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       if (priv->ly) {
+               evas_object_hide(priv->ly);
+               elm_object_part_content_unset(priv->base, PART_CONTENT);
+       }
 }
 
 static void _destroy(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       menumgr_destroy(priv->menu);
+
+       evas_object_del(priv->ly);
+
+       free(priv);
 }
 
 static layout_class _lclass = {
index c64a502..c3deb8a 100644 (file)
@@ -70,7 +70,7 @@ static struct _menu_data _mdata[LAYOUT_MAX] = {
                .name = STR_SYSTEM,
                .layout_id = LAYOUT_ID_SYSTEM,
                .get_lclass = layout_system_get_lclass,
-               .enable = EINA_FALSE
+               .enable = EINA_TRUE
        },
        {
                .name = STR_SUPPORT,