pin view: use the pin ui-gadget 89/46789/1
authorMinkyu Kang <mk7.kang@samsung.com>
Wed, 26 Aug 2015 06:49:24 +0000 (15:49 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Wed, 26 Aug 2015 06:49:24 +0000 (15:49 +0900)
Change-Id: I1de9cfb09735632ca5eee07247470fb6440ad6ab
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
CMakeLists.txt
edje/home.edc
edje/view/pin.edc [deleted file]
include/defs.h
packaging/org.tizen.home.spec
src/main.c
src/view/view_pin.c

index 8d535b2..1aecd4e 100644 (file)
@@ -74,6 +74,7 @@ pkg_check_modules(PKGS REQUIRED
                notification
                tv-service
                ecore-wayland
+               ui-gadget-1
                capi-appfw-application)
 
 FOREACH(flag ${PKGS_CFLAGS})
index 632c454..456c1a4 100644 (file)
@@ -24,5 +24,4 @@ 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
deleted file mode 100644 (file)
index e87109b..0000000
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * 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 280;
-                               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;
-                       }
-               }
-               part {
-                       name, "pad.wrong";
-                       type, RECT;
-                       scale, 1;
-                       description {
-                               state, "default" 0.0;
-                               rel1 {
-                                       to, PART_PIN;
-                                       relative, 0.5 1.0;
-                               }
-                               rel2 {
-                                       to, PART_PIN;
-                                       relative, 0.5 1.0;
-                               }
-                               min, 0 30;
-                               align, 0.5 0.0;
-                               fixed, 1 1;
-                               visible, 0;
-                       }
-               }
-               part {
-                       name, "wrong";
-                       type, TEXT;
-                       scale, 1;
-                       description {
-                               state, "default" 0.0;
-                               rel1 {
-                                       to, "pad.wrong";
-                                       relative, 0.5 1.0;
-                               }
-                               rel2 {
-                                       to, "pad.wrong";
-                                       relative, 0.5 1.0;
-                               }
-                               align, 0.5 0.0;
-                               fixed, 1 1;
-                               min, 400 28;
-                               color, 254 78 78 255;
-                               text {
-                                       text, "Wrong code. Plese try again";
-                                       font, "TizenSans";
-                                       size, 28;
-                                       align, 0.5 0.0;
-                               }
-                               visible, 0;
-                       }
-                       description {
-                               state, "show" 0.0;
-                               inherit, "default" 0.0;
-                               visible, 1;
-                       }
-               }
-       }
-       programs {
-               program {
-                       name, "sig,show";
-                       signal, SIG_SHOW;
-                       source, SRC_PROG;
-                       action, STATE_SET "show" 0.0;
-                       target, "wrong";
-                       transition, LINEAR 1.0;
-                       after, "sig,hide";
-               }
-               program {
-                       name, "sig,hide";
-                       action, STATE_SET "default" 0.0;
-                       target, "wrong";
-                       transition, LINEAR 0.5;
-               }
-       }
-}
index 63cbc31..532c62a 100644 (file)
@@ -55,7 +55,6 @@
 #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 MESSAGE_DELETE_CONTENTS "If you delete this user, their data will also be deleted."
 #define MESSAGE_DISCARD_CONTENTS "Discard all entered data?<br> If you are out of this screen, data won't be saved"
 #define MESSAGE_RESET_CONTENTS "Reset all entered data?<br>If you choose the Reset, all data will be deleted"
+#define MESSAGE_SUCCESS "success"
+#define MESSAGE_FAIL "fail"
 
 #define KEY_MEDIA "media_id"
 #define KEY_CHANNEL "service_id"
index 102abf4..ec14234 100644 (file)
@@ -20,6 +20,7 @@ BuildRequires: pkgconfig(pkgmgr-info)
 BuildRequires: pkgconfig(tv-service)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(ecore-wayland)
+BuildRequires: pkgconfig(ui-gadget-1)
 BuildRequires: edje-bin
 BuildRequires: gettext-devel
 
index d80714c..d0efa05 100644 (file)
@@ -21,6 +21,7 @@
 #include <key_define.h>
 #include <app_define.h>
 #include <Ecore_Wayland.h>
+#include <ui-gadget.h>
 
 #include "defs.h"
 #include "view.h"
@@ -123,6 +124,7 @@ static Eina_Bool _key_timer(void *data)
 static bool _create(void *user_data)
 {
        struct _appdata *ad;
+       int r;
 
        if (!user_data) {
                _ERR("Invalid argument");
@@ -141,6 +143,10 @@ static bool _create(void *user_data)
        }
        ecore_timer_add(3, _key_timer, ad->win);
 
+       r = ug_init_efl(ad->win, UG_OPT_INDICATOR_ENABLE);
+       if (r < 0)
+               _ERR("failed to init ug");
+
        if (!viewmgr_create(ad->win)) {
                _ERR("failed to create viewmgr");
                evas_object_del(ad->win);
index 16fa465..2ebbe9b 100644 (file)
  */
 
 #include <Elementary.h>
+#include <ui-gadget.h>
 #include <app_debug.h>
 #include <viewmgr.h>
 #include <inputmgr.h>
+#include <app_define.h>
 
 #include "defs.h"
 #include "view.h"
-#include "utils.h"
-
-#define COUNT_PIN 4
-#define PADDING_PIN 14
-#define WIDTH_PIN 64
-#define KEY_PIN "pin"
-
-enum input_handler_type {
-       INPUT_HANDLER_TYPE_PIN
-};
 
 struct _priv {
        Evas_Object *win;
-       Evas_Object *base;
-       Evas_Object *pin[COUNT_PIN];
-       Evas_Object *box;
+       ui_gadget_h ug;
 };
 
-static void _focused(int id, void *data, Evas_Object *obj,
-               Elm_Object_Item *item)
+static void _send_message(struct _priv *priv, const char *result)
 {
-       switch (id) {
-       case INPUT_HANDLER_TYPE_PIN:
-               elm_object_signal_emit(obj, SIG_SELECT, SRC_ELM);
-               break;
-       default:
+       service_h service;
+       int r;
+
+       r = service_create(&service);
+       if (r != SERVICE_ERROR_NONE) {
+               _ERR("failed to create service");
                return;
        }
-}
 
-static void _key_down(int id, void *data, Evas *e, Evas_Object *obj,
-               Evas_Event_Key_Down *ev);
-
-static input_handler handler = {
-       .focused = _focused,
-       .key_down = _key_down
-};
+       r = service_add_extra_data(service, PARAM_PIN, result);
+       if (r != SERVICE_ERROR_NONE) {
+               _ERR("failed to add data");
+               service_destroy(service);
+               return;
+       }
 
-static bool _check_valid_pin(struct _priv *priv)
-{
-       /* It should be implemented later */
+       ug_send_message(priv->ug, service);
 
-       return false;
+       service_destroy(service);
 }
 
-static void _unload_pins(struct _priv *priv)
+static void _check_pincode(struct _priv *priv, const char *pincode)
 {
-       int i;
+       /* FIXME: should check the pincode correctly */
+       if (!strcmp(pincode, "1111")) {
+               /* TODO: do something before hiding view */
 
-       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]);
+               viewmgr_hide_view(VIEW_PIN);
+       } else {
+               _send_message(priv, MESSAGE_FAIL);
        }
-
-       memset(priv->pin, 0x00, sizeof(priv->pin));
 }
 
-static bool _load_pins(struct _priv *priv)
+static void _ug_result_cb(ui_gadget_h ug, service_h result, void *p)
 {
-       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(priv->base, true);
-       if (!box) {
-               _ERR("failed to add box");
-               return false;
+       char *pincode;
+       int r;
+
+       if (!p) {
+               _ERR("Invalid argument");
+               return;
        }
-       elm_box_padding_set(box, PADDING_PIN, 0);
-       elm_object_part_content_set(priv->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);
-               elm_object_focus_next_object_set(pin, pin, ELM_FOCUS_RIGHT);
-               elm_object_focus_next_object_set(pin, pin, ELM_FOCUS_LEFT);
-               inputmgr_add_callback(pin, INPUT_HANDLER_TYPE_PIN, &handler,
-                               priv);
-               priv->pin[i] = pin;
-               evas_object_data_set(pin, KEY_PIN, (void *)i);
-               if (i != 0)
-                       elm_object_focus_allow_set(pin, EINA_FALSE);
-               else
-                       elm_object_focus_set(pin, EINA_TRUE);
+
+       r = service_get_extra_data(result, PARAM_PIN, &pincode);
+       if (r != SERVICE_ERROR_NONE || !pincode) {
+               _ERR("failed to get data");
+               return;
        }
 
-       priv->box = box;
+       _check_pincode(p, pincode);
 
-       return true;
+       free(pincode);
 }
 
-static void _selected(void *data, Evas_Object *obj)
+static void _ug_destroy_cb(ui_gadget_h ug, void *p)
 {
-       struct _priv *priv;
-       int i;
+       viewmgr_hide_view(VIEW_PIN);
+}
 
-       if (!data || !obj) {
-               _ERR("Invalid argument");
-               return;
-       }
+static ui_gadget_h _load_ug(struct _priv *priv)
+{
+       ui_gadget_h ug;
+       struct ug_cbs cb = {0,};
 
-       priv = data;
-       i = (int)evas_object_data_get(obj, KEY_PIN);
+       cb.result_cb = _ug_result_cb;
+       cb.destroy_cb = _ug_destroy_cb;
+       cb.priv = priv;
 
-       if (i < COUNT_PIN - 1) {
-               elm_object_focus_allow_set(obj, EINA_FALSE);
-               elm_object_signal_emit(obj, SIG_DISABLE, SRC_ELM);
-               elm_object_focus_allow_set(priv->pin[i + 1], EINA_TRUE);
-               elm_object_focus_set(priv->pin[i + 1], EINA_TRUE);
-       } else {
-               if (!_check_valid_pin(priv)) {
-                       elm_object_signal_emit(priv->base, SIG_SHOW, SRC_PROG);
-                       _unload_pins(priv);
-                       _load_pins(priv);
-               } else
-                       viewmgr_hide_view(VIEW_PIN);
-       }
-}
+       ug = ug_create(NULL, UG_ID_PIN, UG_MODE_FRAMEVIEW, NULL, &cb);
 
-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);
-               } else if (!strcmp(ev->keyname, KEY_0) ||
-                               !strcmp(ev->keyname, KEY_1) ||
-                               !strcmp(ev->keyname, KEY_2) ||
-                               !strcmp(ev->keyname, KEY_3) ||
-                               !strcmp(ev->keyname, KEY_4) ||
-                               !strcmp(ev->keyname, KEY_5) ||
-                               !strcmp(ev->keyname, KEY_6) ||
-                               !strcmp(ev->keyname, KEY_7) ||
-                               !strcmp(ev->keyname, KEY_8) ||
-                               !strcmp(ev->keyname, KEY_9)) {
-                       _selected(data, obj);
-               }
-               break;
-       default:
-               return;
-       }
+       return ug;
 }
 
 static Evas_Object *_create(Evas_Object *win, void *data)
 {
        struct _priv *priv;
-       Evas_Object *base;
 
        if (!win) {
                _ERR("Invalid argument");
@@ -203,27 +119,17 @@ static Evas_Object *_create(Evas_Object *win, void *data)
                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;
+       return win;
 }
 
 static void _show(void *data)
 {
        struct _priv *priv;
+       ui_gadget_h ug;
 
        if (!data) {
                _ERR("Invalid argument");
@@ -232,9 +138,13 @@ static void _show(void *data)
 
        priv = data;
 
-       evas_object_show(priv->base);
+       ug = _load_ug(priv);
+       if (!ug) {
+               _ERR("failed to create ug");
+               return;
+       }
 
-       _load_pins(priv);
+       priv->ug = ug;
 }
 
 static void _hide(void *data)
@@ -248,9 +158,8 @@ static void _hide(void *data)
 
        priv = data;
 
-       evas_object_hide(priv->base);
-
-       _unload_pins(priv);
+       if (priv->ug)
+               ug_destroy(priv->ug);
 }
 
 static void _destroy(void *data)
@@ -264,7 +173,6 @@ static void _destroy(void *data)
 
        priv = data;
 
-       evas_object_del(priv->base);
        free(priv);
 }