From c5676dbffe98f6abfe2052fb644a9964a1f71bb0 Mon Sep 17 00:00:00 2001 From: Jeong Seong-moon Date: Tue, 23 Aug 2016 14:38:07 +0900 Subject: [PATCH] Remove entry Change-Id: I61ed09f80eae2d67d9056fb72180ca74c7841ab5 --- res/edje/password.edc | 10 +++- src/sys_lock.c | 126 ++++++++++++++++++++++++++------------------------ 2 files changed, 74 insertions(+), 62 deletions(-) diff --git a/res/edje/password.edc b/res/edje/password.edc index 09146a9..eeaa1f8 100755 --- a/res/edje/password.edc +++ b/res/edje/password.edc @@ -15,6 +15,10 @@ styles { name: "close_style"; base: "font=Tizen:style=Regular color=#FFFFFF font_size=35 wrap=none align=center"; } + style { + name: "password_text_style"; + base: "font=Tizen:style=Regular color=#FFFFFF font_size=65 wrap=none align=center"; + } } group { "base"; @@ -240,7 +244,7 @@ group { "lock-base"; rel2 { relative: 1.0 1.0; to: "bg"; } } } - swallow { "sw.entry"; + textblock { "sw.entry"; desc { "default"; fixed: 1 1; min: 0 96; @@ -248,6 +252,10 @@ group { "lock-base"; align: 0.5 0; rel1 { relative: 0.0 1.0; to: "padding.title.entry"; offset: 0 9; } rel2 { relative: 1.0 1.0; to: "bg"; } + text { + style: "password_text_style"; + text: "_ _ _ _"; + } } } spacer { "padding.bottom"; scale; diff --git a/src/sys_lock.c b/src/sys_lock.c index e41a257..ce59068 100755 --- a/src/sys_lock.c +++ b/src/sys_lock.c @@ -27,8 +27,68 @@ #include "sys_lock.h" #include "log.h" +/* This application, password and UI are just examples for lazy-mount process */ + #define STR_PASSWORD "0430" -static bool isUnlocked = false; +#define BUF_SIZE 10 +static bool isUnlocked; +static char buf[BUF_SIZE]; +static int now; + +void _input_password(Evas_Object *ly, const char *txt) +{ + char tmp[BUF_SIZE] = { 0, }; + + if (now >= 4 || isUnlocked) + return; + + snprintf(tmp, BUF_SIZE, "%s%s", buf, txt); + strncpy(buf,tmp,BUF_SIZE); + now++; + + if (!strcmp(STR_PASSWORD, buf)) { + _dbus_send_sys_lock_unlock_signal(); + isUnlocked = true; + _update_password_view(ly, 5); + } else { + _update_password_view(ly, now); + } +} + +void _clear_password(Evas_Object *ly) +{ + if (now <= 0) + return; + + now--; + buf[now] = '\0'; + + _update_password_view(ly, now); +} + +void _clear_all_password(Evas_Object *ly) +{ + memset(buf, 0, BUF_SIZE); + now = 0; + + _update_password_view(ly, now); +} + +void _update_password_view(Evas_Object *ly, int num) +{ + if (num == 0) + elm_object_part_text_set(ly, "sw.entry", "_ _ _ _"); + else if (num == 1) + elm_object_part_text_set(ly, "sw.entry", "* _ _ _"); + else if (num == 2) + elm_object_part_text_set(ly, "sw.entry", "* * _ _"); + else if (num == 3) + elm_object_part_text_set(ly, "sw.entry", "* * * _"); + else if (num == 4) + elm_object_part_text_set(ly, "sw.entry", "* * * *"); + else if (num == 5) + elm_object_part_text_set(ly, "sw.entry", "= Password OK! ="); +} void _dbus_send_sys_lock_unlock_signal(void) { @@ -112,7 +172,6 @@ Evas_Object *_window_create(void) elm_win_borderless_set(win, EINA_TRUE); elm_win_autodel_set(win, EINA_TRUE); elm_win_fullscreen_set(win, EINA_TRUE); -// efl_util_set_window_opaque_state(win, 1); Evas_Object *ly = elm_layout_add(win); @@ -174,10 +233,7 @@ _cancel_button_clicked(void *data, Evas_Object *obj, void *event_info) { if (isUnlocked) return; //Disable key input after unlocked. - Evas_Object *entry = elm_object_part_content_get(data, "sw.entry"); - elm_object_focus_set(entry, EINA_TRUE); - elm_entry_entry_set(entry, ""); -// ui_app_exit(); + _clear_all_password(data); } static void @@ -186,24 +242,9 @@ _pin_button_clicked(void *data, Evas_Object *obj, const char *emission, const ch if (isUnlocked) return; //Disable key input after unlocked. const char *txt = edje_object_part_text_get(obj, "text.number"); - Evas_Object *entry = elm_object_part_content_get(data, "sw.entry"); - elm_object_focus_set(entry, EINA_TRUE); - DBG("_pin_button_clicked [%s]", txt); - - elm_entry_entry_append(entry, txt); - elm_entry_cursor_next(entry); + DBG("_pin_button_clicked!! [%s]", txt); - const char* old_entry_text = elm_entry_entry_get(entry); - - if (!strcmp(STR_PASSWORD, old_entry_text)) { - _dbus_send_sys_lock_unlock_signal(); - elm_entry_password_set(entry, EINA_FALSE); - elm_entry_text_style_user_push(entry, "DEFAULT='font=Sans style=Regular color=#FF0000 font_size=55 wrap=none align=center'"); - elm_entry_entry_set(entry, "= Password OK! ="); - elm_object_focus_set(entry, EINA_FALSE); - isUnlocked = true; -// ui_app_exit(); - } + _input_password(data, txt); } static void @@ -211,34 +252,7 @@ _clear_button_clicked(void *data, Evas_Object *obj, const char *emission, const { if (isUnlocked) return; //Disable key input after unlocked. - Evas_Object *entry = elm_object_part_content_get(data, "sw.entry"); - elm_object_focus_set(entry, EINA_TRUE); - - char *new_entry_text; - const char* old_entry_text = elm_entry_entry_get(entry); - new_entry_text = strdup(old_entry_text); - - if (new_entry_text) { - new_entry_text[strlen(old_entry_text) - 1] = '\0'; - elm_entry_entry_set(entry, new_entry_text); - free(new_entry_text); - } -} - -static void -_pin_entry_activated(void *data, Evas_Object *obj, void *event_info) -{ - const char *content = elm_entry_entry_get(obj); - - if (!strcmp(STR_PASSWORD, content)) { - _dbus_send_sys_lock_unlock_signal(); - elm_entry_password_set(obj, EINA_FALSE); - elm_entry_text_style_user_push(obj, "DEFAULT='font=Sans style=Regular color=#FF0000 font_size=55 wrap=none align=center'"); - elm_entry_entry_set(obj, "= Password OK! ="); - elm_object_focus_set(obj, EINA_FALSE); - isUnlocked = true; -// ui_app_exit(); - } + _clear_password(data); } static Evas_Object *_view_create(Evas_Object *win) @@ -263,13 +277,6 @@ static Evas_Object *_view_create(Evas_Object *win) evas_object_show(btn); evas_object_show(layout); - Evas_Object *entry = elm_entry_add(layout); - elm_entry_password_set(entry, EINA_TRUE); - elm_object_part_content_set(layout, "sw.entry", entry); - elm_entry_input_panel_enabled_set(entry, EINA_FALSE); - evas_object_pass_events_set(entry, EINA_TRUE); - evas_object_show(entry); - // Setup PIN pad _pin_button_setup(layout, 1, 1, "1", NULL, _pin_button_clicked); _pin_button_setup(layout, 1, 2, "2", "ABC" , _pin_button_clicked); @@ -285,8 +292,6 @@ static Evas_Object *_view_create(Evas_Object *win) _pin_button_setup(layout, 4, 1, NULL, NULL , NULL); elm_object_signal_emit(layout, "layout,pinpad,show", "lockscreen"); - elm_entry_text_style_user_push(entry, "DEFAULT='font=Sans style=Regular color=#FFFFFF font_size=110 wrap=none align=center'"); - evas_object_smart_callback_add(entry, "changed,user", _pin_entry_activated, layout); return layout; } @@ -331,7 +336,6 @@ bool _create_app(void *data) DBG("Syslock launch request."); elm_config_scale_set(2.6); -// elm_config_accel_preference_set("opengl"); DBG("base scale : %f", elm_app_base_scale_get()); DBG("edje scale : %f", edje_scale_get()); -- 2.7.4