Edje, Elementary: Remove <password=off> tag when password mode is disabled 76/75676/1
authorYoungbok Shin <youngb.shin@samsung.com>
Tue, 21 Jun 2016 03:40:13 +0000 (12:40 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Tue, 21 Jun 2016 03:40:13 +0000 (12:40 +0900)
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

Change-Id: I622ecdfa3ed5fafe15a6085cc86f5538a5ca1b6e

src/bin/test.c
src/bin/test_entry.c
src/lib/elm_entry.c

index 77d6b11..13394f4 100644 (file)
@@ -70,6 +70,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);
@@ -607,6 +608,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, "Buttons", "Button", test_button);
index 3054573..f05a2ae 100644 (file)
@@ -2791,3 +2791,67 @@ test_entry_emoticon(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
    evas_object_resize(win, 400, 500);
    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);
+}
index 73359de..c00bcc3 100644 (file)
@@ -1589,6 +1589,8 @@ _elm_entry_elm_widget_theme_apply(Eo *obj, Elm_Entry_Data *sd)
    edje_object_part_text_freeze(sd->entry_edje, "elm.text");
    //
 
+   edje_object_part_text_hide_visible_password(sd->entry_edje, "elm.text");
+
    edje_object_mirrored_set
      (wd->resize_obj, elm_widget_mirrored_get(obj));