Edje, Elementary: Remove <password=off> tag when password mode is disabled

Summary:
When edje_password_show_last option is enabled, the edje_entry uses <password=off>
for showing last character. But, when password mode is disabled by the elm_entry,
<password=off> is remained in the text. It can cause some problems.

Because, there is no way to control password mode by API for the edje_entry.
The elm_entry can't remove <password=off> tag before getting text from the edje_entry.
So, the patch adds edje_object_part_text_hide_visible_password() function and
the elm_entry will use this when elm_layout_theme_apply() is called.
@fix

Test Plan:
1. Run "elementary_test".
2. Show "Entry Password" demo. (Newly added by this patch)
3. Password mode is enabled. Put some text.
4. Click "Show Password" check box to disable password mode.
5. Put more text.
6. Click "Hide Password" check box to enable password mode again.
7. See a character among the text is visible. (without this patch)

Reviewers: tasn, herdsman, cedric, jpeg, thiepha, raster

Reviewed By: raster

Subscribers: Blackmole, z-wony, woohyun

Differential Revision: https://phab.enlightenment.org/D3988
This commit is contained in:
Youngbok Shin 2016-06-20 21:11:25 +09:00 committed by Carsten Haitzler (Rasterman)
parent 72bb457bcb
commit 14cbd23d29
7 changed files with 106 additions and 2 deletions

View File

@ -75,6 +75,7 @@ void test_multibuttonentry(void *data, Evas_Object *obj, void *event_info);
void test_entry_anchor2(void *data, Evas_Object *obj, void *event_info);
void test_entry_anchor(void *data, Evas_Object *obj, void *event_info);
void test_entry_emoticon(void *data, Evas_Object *obj, void *event_info);
void test_entry_password(void *data, Evas_Object *obj, void *event_info);
void test_toolbar(void *data, Evas_Object *obj, void *event_info);
void test_toolbar2(void *data, Evas_Object *obj, void *event_info);
void test_toolbar3(void *data, Evas_Object *obj, void *event_info);
@ -631,6 +632,7 @@ add_tests:
ADD_TEST(NULL, "Entries", "Entry Anchor", test_entry_anchor);
ADD_TEST(NULL, "Entries", "Entry Anchor2", test_entry_anchor2);
ADD_TEST(NULL, "Entries", "Entry Emoticon", test_entry_emoticon);
ADD_TEST(NULL, "Entries", "Entry Password", test_entry_password);
ADD_TEST(NULL, "Entries", "Efl UI Text", test_efl_ui_text);
//------------------------------//

View File

@ -2817,6 +2817,70 @@ test_entry_emoticon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
evas_object_show(win);
}
static void
password_entry_changed_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
{
printf("Password : %s\n", elm_entry_entry_get(obj));
}
static void
show_password_check_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
{
Evas_Object *en = (Evas_Object *)data;
Eina_Bool state = elm_check_state_get(obj);
if (state)
{
printf(" * Show Password...\n");
elm_object_text_set(obj, "Hide Password");
elm_entry_password_set(en, EINA_FALSE);
}
else
{
printf(" * Hide Password...\n");
elm_object_text_set(obj, "Show Password");
elm_entry_password_set(en, EINA_TRUE);
}
}
void
test_entry_password(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
Evas_Object *win, *bx, *en, *ck;
edje_password_show_last_set(EINA_TRUE);
edje_password_show_last_timeout_set(-1);
win = elm_win_util_standard_add("entry", "Entry");
elm_win_autodel_set(win, EINA_TRUE);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
en = elm_entry_add(bx);
elm_entry_single_line_set(en, EINA_TRUE);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_password_set(en, EINA_TRUE);
elm_object_part_text_set(en, "elm.guide", "Enter Your Password");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, en);
evas_object_show(en);
evas_object_smart_callback_add(en, "changed", password_entry_changed_cb, NULL);
ck = elm_check_add(bx);
elm_object_text_set(ck, "Show Password");
evas_object_smart_callback_add(ck, "changed", show_password_check_changed_cb, en);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_resize(win, 300, 100);
evas_object_show(win);
}
static void
my_efl_ui_text_bt_5(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{

View File

@ -1442,9 +1442,10 @@ _delete_emit(Edje *ed, Evas_Textblock_Cursor *c, Entry *en, size_t pos,
info, _free_entry_change_info);
}
static void
Eina_Bool
_edje_entry_hide_visible_password(Edje *ed, Edje_Real_Part *rp)
{
Eina_Bool int_ret = EINA_FALSE;
const Evas_Object_Textblock_Node_Format *node;
node = evas_textblock_node_format_first_get(rp->object);
for (; node; node = evas_textblock_node_format_next_get(node))
@ -1457,11 +1458,14 @@ _edje_entry_hide_visible_password(Edje *ed, Edje_Real_Part *rp)
evas_textblock_node_format_remove_pair(rp->object,
(Evas_Object_Textblock_Node_Format *)node);
_edje_emit(ed, "entry,changed", rp->part->name);
int_ret = EINA_TRUE;
break;
}
}
}
_edje_entry_real_part_configure(ed, rp);
return int_ret;
}
static Eina_Bool
@ -1999,9 +2003,9 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
info, _free_entry_change_info);
_edje_emit(ed, "cursor,changed", rp->part->name);
cursor_changed = EINA_TRUE;
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
_edje_emit(ed, "entry,key,enter", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else
{

View File

@ -1985,6 +1985,15 @@ class Edje.Object (Efl.Canvas.Group.Clipped, Efl.File, Efl.Container, Efl.Part)
scale: double; [[The transition duration factor]]
}
}
part_text_hide_visible_password {
[[Hide visible last character for password mode.
@since 1.18.0]]
params {
@in part: const(char)*; [[The part name]]
}
return: bool; [[$true if the visible character is hidden. $false if there is no visible character or the object is not set for password mode.]]
}
}
implements {
Eo.Base.constructor;

View File

@ -2735,6 +2735,7 @@ void _edje_entry_input_panel_return_key_disabled_set(Edje_Real_Part *rp, Eina_Bo
Eina_Bool _edje_entry_input_panel_return_key_disabled_get(Edje_Real_Part *rp);
void _edje_entry_input_panel_show_on_demand_set(Edje_Real_Part *rp, Eina_Bool ondemand);
Eina_Bool _edje_entry_input_panel_show_on_demand_get(Edje_Real_Part *rp);
Eina_Bool _edje_entry_hide_visible_password(Edje *edje, Edje_Real_Part *rp);
void _edje_external_init(void);
void _edje_external_shutdown(void);

View File

@ -5759,6 +5759,28 @@ _edje_real_part_text_text_source_description_get(Edje_Real_Part *ep, Edje_Real_P
return et;
}
EOLIAN Eina_Bool
_edje_object_part_text_hide_visible_password(Eo *obj, Edje *ed, const char *part)
{
Edje_Real_Part *rp;
Eina_Bool int_ret;
if ((!ed) || (!part)) return EINA_FALSE;
rp = _edje_real_part_recursive_get(&ed, part);
if (!rp) return EINA_FALSE;
if (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) return EINA_FALSE;
if ((rp->type != EDJE_RP_TYPE_TEXT) ||
(!rp->typedata.text))
{
return EINA_FALSE;
}
if (rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD)
int_ret = _edje_entry_hide_visible_password(ed, rp);
return int_ret;
}
Edje_Real_Part *
_edje_real_part_recursive_get(Edje **ed, const char *part)
{

View File

@ -851,6 +851,8 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
evas_event_freeze(evas_object_evas_get(obj));
edje_obj_part_text_hide_visible_password(sd->entry_edje, "elm.text");
edje_object_mirrored_set
(wd->resize_obj, elm_widget_mirrored_get(obj));