add pin view 31/46431/3
authorSoohye Shin <soohye.shin@samsung.com>
Thu, 20 Aug 2015 07:43:56 +0000 (16:43 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Thu, 20 Aug 2015 08:14:50 +0000 (17:14 +0900)
Change-Id: Ieea8be7cb2ff6138c3032af996859547a7541121
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
edje/home.edc
edje/view/pin.edc [new file with mode: 0644]
include/defs.h
include/utils.h
include/view.h
src/utils.c
src/view/view_pin.c [new file with mode: 0644]
src/view/view_user.c
src/view/view_user_edit.c

index 3e97035..8d535b2 100644 (file)
@@ -48,6 +48,7 @@ SET(SRCS
                src/data/data_recent.c
                src/data/data_user.c
                src/data/data_photo.c
+               src/view/view_pin.c
                src/view/view_photo.c
                src/view/view_user_edit.c
                src/view/view_user.c
index 456c1a4..632c454 100644 (file)
@@ -24,4 +24,5 @@ collections {
        #include "view/useredit.edc"
        #include "view/photo.edc"
        #include "view/actionmenu.edc"
+       #include "view/pin.edc"
 }
diff --git a/edje/view/pin.edc b/edje/view/pin.edc
new file mode 100644 (file)
index 0000000..478266c
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+
+#include "../../include/defs.h"
+group {
+       name, GRP_PIN;
+       parts {
+               part {
+                       name, "up";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel2.relative, 1.0 0.0;
+                               min, 0 104;
+                               fixed, 0 1;
+                               align, 0.5 0.0;
+                       }
+               }
+               part {
+                       name, "title";
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1.to, "up";
+                               rel2.to, "up";
+                               fixed, 1 1;
+                               text {
+                                       text, "Pin Code";
+                                       size, 46;
+                                       font, "TizenSans";
+                               }
+                               color, 51 51 51 255;
+                       }
+               }
+               part {
+                       name, "bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "title";
+                                       relative, 0.0 1.0;
+                               }
+                               fixed, 1 1;
+                               color, 244 244 244 255;
+                       }
+               }
+               part {
+                       name, "pad.message";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "bg";
+                                       relative, 0.5 0.0;
+                               }
+                               rel2 {
+                                       to, "bg";
+                                       relative, 0.5 0.0;
+                               }
+                               fixed, 1 1;
+                               align, 0.5 0.0;
+                               min, 0 300;
+                               visible, 0;
+                       }
+               }
+               part {
+                       name, "message";
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "pad.message";
+                                       relative, 0.5 1.0;
+                               }
+                               rel2 {
+                                       to, "pad.message";
+                                       relative, 0.5 1.0;
+                               }
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                               min, 400 50;
+                               text {
+                                       text, "Enter your Pin Code";
+                                       size, 38;
+                                       font, "TizenSans";
+                               }
+                               color, 0 0 0 255;
+                       }
+               }
+               part {
+                       name, "pad.pin";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "message";
+                                       relative, 0.5 1.0;
+                               }
+                               rel2 {
+                                       to, "message";
+                                       relative, 0.5 1.0;
+                               }
+                               min, 0 30;
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                               visible, 0;
+                       }
+               }
+               part {
+                       name, PART_PIN;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "pad.pin";
+                                       relative, 0.5 1.0;
+                               }
+                               rel2 {
+                                       to, "pad.pin";
+                                       relative, 0.5 1.0;
+                               }
+                               min, 298 64;
+                               fixed, 1 1;
+                               align, 0.5 0.0;
+                       }
+               }
+       }
+}
index b190648..ca6399b 100644 (file)
@@ -23,6 +23,7 @@
 #define VIEW_USER_EDIT "VIEW_USER_EDIT"
 #define VIEW_PHOTO "VIEW_PHOTO"
 #define VIEW_ACTION_MENU "VIEW_ACTION_MENU"
+#define VIEW_PIN "VIEW_PIN"
 
 #define SRC_PROG "prog"
 #define SRC_EDJE "edje"
@@ -54,6 +55,7 @@
 #define GRP_ACTION_MENU "group.action.menu"
 #define GRP_ACTION_MENU_LIVETV "group.action.menu.livetv"
 #define GRP_ACTION_MENU_TABLE_ITEM "group.action.menu.table.item"
+#define GRP_PIN "group.pin"
 
 #define PART_HOME_MENU_BAR "part.home.menu.bar"
 #define PART_HOME_UP_ARROW "part.home.up.arrow"
 #define PART_ACTION_MENU_TABLE_ITEM_ICON_FOCUS "part.action.menu.table.item.icon.focus"
 #define PART_ACTION_MENU_TABLE_ITEM_TEXT "part.action.menu.table.item.text"
 #define PART_ACTION_MENU_TABLE_ITEM_TEXT_FOCUS "part.action.menu.table.item.text.focus"
+#define PART_PIN "part.pin"
 
 #define SIG_SHOW_NAVIGATION "sig.show.navigation"
 #define SIG_HIDE_NAVIGATION "sig.hide.navigation"
 #define STYLE_LABEL_TITLE_FOCUS "slide_home_title_focus"
 #define STYLE_LABEL_RECENT_TITLE "slide_recent_title"
 #define STYLE_LABEL_RECENT_SUBTITLE "slide_recent_subtitle"
-#define STYLE_INPUT "contents"
+#define STYLE_INPUT_CONTENTS "contents"
+#define STYLE_INPUT_PIN "pin"
 #define STYLE_GENGRID_ITEM "gengrid_item"
 #define STYLE_LABEL_ACTION_MENU_TITLE "slide_action_menu_title"
 #define STYLE_LABEL_ACTION_MENU_TITLE_FOCUS "slide_action_menu_title_focus"
index b69e716..6c42fe5 100644 (file)
@@ -45,8 +45,8 @@ Evas_Object *utils_add_scroller(Evas_Object *base);
 Evas_Object *utils_add_table(Evas_Object *base, bool homo, const char *part);
 Evas_Object *utils_add_box(Evas_Object *base, bool horizon);
 Evas_Object *utils_add_button(Evas_Object *base, char *text, const char *part);
-Evas_Object *utils_add_entry(Evas_Object *base, char *text, bool password,
-               const char *part);
+Evas_Object *utils_add_entry(Evas_Object *base, bool password, bool scroll,
+               const char *part, const char *style);
 Evas_Object *utils_add_popup(Evas_Object *base, char *title, char *message);
 Evas_Object *utils_add_rectangle(Evas_Object *base, int r, int g, int b, int a);
 bool utils_launch_app(const char *pkg, const char *key, const char *value);
index 2b34f75..5159a71 100644 (file)
@@ -31,5 +31,6 @@ view_class *view_user_edit_get_vclass(void);
 view_class *view_photo_get_vclass(void);
 view_class *view_recent_get_vclass(void);
 view_class *view_action_menu_get_vclass(void);
+view_class *view_pin_get_vclass(void);
 
 #endif /* __AIR_HOME_VIEW_H__ */
index d938bd1..28655dc 100644 (file)
@@ -316,33 +316,47 @@ Evas_Object *utils_add_button(Evas_Object *base, char *text, const char *part)
        return btn;
 }
 
-Evas_Object *utils_add_entry(Evas_Object *base, char *text, bool password,
-               const char *part)
+Evas_Object *utils_add_entry(Evas_Object *base, bool password,
+               bool scroll, const char *part, const char *style)
 {
        Evas_Object *entry;
 
+       if (!base) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
        entry = elm_entry_add(base);
        if (!entry) {
                _ERR("failed to add entry");
                return NULL;
        }
 
+       evas_object_size_hint_align_set(entry, EVAS_HINT_FILL,
+                       EVAS_HINT_FILL);
+       evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+       elm_entry_cursor_end_set(entry);
+
        if (password) {
                elm_entry_password_set(entry, EINA_TRUE);
                elm_config_password_show_last_set(EINA_FALSE);
        }
 
-       elm_object_style_set(entry, STYLE_INPUT);
-       elm_entry_single_line_set(entry, EINA_TRUE);
-       elm_entry_input_panel_language_set(entry,
-                       ELM_INPUT_PANEL_LANG_ALPHABET);
-       elm_entry_cursor_end_set(entry);
-       elm_entry_scrollable_set(entry, EINA_TRUE);
-       elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
-                       ELM_SCROLLER_POLICY_OFF);
-       if (text)
-               elm_entry_entry_set(entry, text);
-       elm_object_part_content_set(base, part, entry);
+       if (scroll) {
+               elm_entry_single_line_set(entry, EINA_TRUE);
+               elm_entry_scrollable_set(entry, EINA_TRUE);
+               elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
+                               ELM_SCROLLER_POLICY_OFF);
+               elm_entry_input_panel_language_set(entry,
+                               ELM_INPUT_PANEL_LANG_ALPHABET);
+       }
+
+       if (style)
+               elm_object_style_set(entry, style);
+
+       if (part)
+               elm_object_part_content_set(base, part, entry);
 
        evas_object_show(entry);
 
diff --git a/src/view/view_pin.c b/src/view/view_pin.c
new file mode 100644 (file)
index 0000000..3e4b627
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+ * 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.
+ */
+
+#include <Elementary.h>
+#include <app_debug.h>
+#include <viewmgr.h>
+#include <inputmgr.h>
+
+#include "defs.h"
+#include "view.h"
+#include "utils.h"
+
+#define COUNT_PIN 4
+#define PADDING_PIN 14
+#define WIDTH_PIN 64
+
+enum input_handler_type {
+       INPUT_HANDLER_TYPE_PIN
+};
+
+struct _priv {
+       Evas_Object *win;
+       Evas_Object *base;
+       Evas_Object *pin[COUNT_PIN];
+       Evas_Object *box;
+};
+
+static void _focused(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item)
+{
+       switch (id) {
+       case INPUT_HANDLER_TYPE_PIN:
+               elm_object_signal_emit(obj, SIG_SELECT, SRC_ELM);
+               break;
+       default:
+               return;
+       }
+}
+
+static void _unfocused(int id, void *data, Evas_Object *obj,
+               Elm_Object_Item *item)
+{
+       switch (id) {
+       case INPUT_HANDLER_TYPE_PIN:
+               elm_object_signal_emit(obj, SIG_UNSELECT, SRC_ELM);
+               break;
+       default:
+               return;
+       }
+}
+
+static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
+               Evas_Event_Key_Down *ev)
+{
+       switch (id) {
+       case INPUT_HANDLER_TYPE_PIN:
+               if (!strcmp(ev->keyname, KEY_BACK) ||
+                               !strcmp(ev->keyname, KEY_BACK_REMOTE)) {
+                       viewmgr_hide_view(VIEW_PIN);
+               }
+               break;
+       default:
+               return;
+       }
+}
+
+static input_handler handler = {
+       .focused = _focused,
+       .unfocused = _unfocused,
+       .key_down = _key_down
+};
+
+static bool _add_pins(Evas_Object *base, struct _priv *priv)
+{
+       Evas_Object *box, *pin;
+       Elm_Entry_Filter_Limit_Size pin_size = {
+               .max_char_count = 1,
+       };
+       Elm_Entry_Filter_Accept_Set pin_char = {
+               .accepted = "0123456789",
+       };
+       int i;
+
+       box = utils_add_box(base, true);
+       if (!box) {
+               _ERR("failed to add box");
+               return false;
+       }
+       elm_box_padding_set(box, PADDING_PIN, 0);
+       elm_object_part_content_set(base, PART_PIN, box);
+
+       for (i = 0; i < COUNT_PIN; i++) {
+               pin = utils_add_entry(box, true, false, NULL, STYLE_INPUT_PIN);
+               if (!pin) {
+                       _ERR("failed to add entry");
+                       memset(priv->pin, 0x00, sizeof(priv->pin));
+                       evas_object_del(box);
+                       return false;
+               }
+               elm_entry_markup_filter_append(pin, elm_entry_filter_limit_size,
+                               &pin_size);
+               elm_entry_markup_filter_append(pin, elm_entry_filter_accept_set,
+                               &pin_char);
+               elm_box_pack_end(box, pin);
+               elm_object_focus_next_object_set(pin, pin, ELM_FOCUS_DOWN);
+               elm_object_focus_next_object_set(pin, pin, ELM_FOCUS_UP);
+               inputmgr_add_callback(pin, INPUT_HANDLER_TYPE_PIN, &handler,
+                               priv);
+               priv->pin[i] = pin;
+       }
+
+       priv->box = box;
+
+       return true;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv;
+       Evas_Object *base;
+
+       if (!win) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to calloc priv");
+               return NULL;
+       }
+
+       base = utils_add_layout(win, GRP_PIN, false, NULL);
+       if (!base) {
+               _ERR("failed to create base");
+               free(priv);
+               return NULL;
+       }
+       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND,
+                       EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(win, base);
+
+       priv->win = win;
+       priv->base = base;
+
+       viewmgr_set_view_data(VIEW_PIN, priv);
+
+       return base;
+}
+
+static void _show(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_show(priv->base);
+
+       if (!_add_pins(priv->base, priv)) {
+               _ERR("failed to add pins");
+               return;
+       }
+
+       if (priv->pin[0])
+               elm_object_focus_set(priv->pin[0], EINA_TRUE);
+}
+
+static void _hide(void *data)
+{
+       struct _priv *priv;
+       int i;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_hide(priv->base);
+
+       elm_box_clear(priv->box);
+       evas_object_del(priv->box);
+       priv->box = NULL;
+
+       for (i = 0 ; i < COUNT_PIN; i++) {
+               inputmgr_remove_callback(priv->pin[i], &handler);
+               evas_object_del(priv->pin[i]);
+       }
+
+       memset(priv->pin, 0x00, sizeof(priv->pin));
+}
+
+static void _destroy(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_del(priv->base);
+       free(priv);
+}
+
+static view_class vclass = {
+       .view_id = VIEW_PIN,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy
+};
+
+view_class *view_pin_get_vclass(void)
+{
+       return &vclass;
+}
index 108c124..2815bb7 100644 (file)
@@ -278,6 +278,7 @@ static Evas_Object *_create(Evas_Object *win, void *data)
 
        viewmgr_set_view_data(VIEW_USER, priv);
        viewmgr_add_view(view_user_edit_get_vclass(), dm);
+       viewmgr_add_view(view_pin_get_vclass(), NULL);
        inputmgr_add_callback(base, INPUT_HANDLER_TYPE_BASE, &handler, priv);
        elm_object_signal_callback_add(base, SIG_HIDE_DONE, SRC_EDJE,
                        _hide_done, NULL);
index 3e30479..75bf69d 100644 (file)
@@ -393,7 +393,8 @@ static Evas_Object *_add_layout(struct _priv *priv)
        if (!photo)
                goto err;
 
-       name = utils_add_entry(ly, "", false, PART_USER_EDIT_CONTENTS_NAME);
+       name = utils_add_entry(ly, false, true, PART_USER_EDIT_CONTENTS_NAME,
+                       STYLE_INPUT_CONTENTS);
        if (!name)
                goto err;