Add autofill hint test demo 56/164856/2
authorJihoon Kim <jihoon48.kim@samsung.com>
Wed, 20 Dec 2017 01:07:35 +0000 (10:07 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 21 Dec 2017 10:32:50 +0000 (10:32 +0000)
Change-Id: I766010b2de3d6b2547045c89ae606f45354312d0
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
ism/demos/isf_prediction_hint_efl.cpp

index 58736fa54fa41b05d3c493f316915d72d4856f72..97c5318ac0a74f6cfa29ef565ac7e20ef1d90ca5 100644 (file)
 #include "isf_demo_efl.h"
 #include "isf_prediction_hint_efl.h"
 
-static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, const char *guide_text, const char *prediction_hint, const char *res_id, Ecore_IMF_Input_Hints input_hints = ECORE_IMF_INPUT_HINT_NONE)
+struct _autofill_item {
+    const char *name;
+    const char *guide_text;
+    const char *res_id;
+    Ecore_IMF_Input_Hints autofill_hint;
+    Elm_Input_Panel_Layout layout;
+};
+
+static struct _autofill_item autofill_test_itsc[] = {
+    { N_("Name"), N_("click to enter"), "name", ECORE_IMF_INPUT_HINT_AUTOFILL_NAME, ELM_INPUT_PANEL_LAYOUT_NORMAL },
+    { N_("Email"), N_("click to enter"), "email", ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS, ELM_INPUT_PANEL_LAYOUT_EMAIL },
+    { N_("Address"), N_("click to enter"), "address", ECORE_IMF_INPUT_HINT_AUTOFILL_POSTAL_ADDRESS, ELM_INPUT_PANEL_LAYOUT_NORMAL },
+    { N_("Phone"), N_("click to enter"), "phone", ECORE_IMF_INPUT_HINT_AUTOFILL_PHONE, ELM_INPUT_PANEL_LAYOUT_PHONENUMBER },
+    { N_("ID"), N_("click to enter"), "id", ECORE_IMF_INPUT_HINT_AUTOFILL_ID, ELM_INPUT_PANEL_LAYOUT_NORMAL },
+    { N_("Card Number"), N_("click to enter"), "card_number", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_NUMBER, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+    { N_("Card Security code"), N_("click to enter"), "card_security_code", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_SECURITY_CODE, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+    { N_("Card Expiration date"), N_("click to enter"), "card_expiration_date", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_EXPIRATION_DATE, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+    { N_("Card Expiration day"), N_("click to enter"), "card_expiration_day", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_EXPIRATION_DAY, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+    { N_("Card Expiration month"), N_("click to enter"), "card_expiration_month", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_EXPIRATION_MONTH, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+    { N_("Card Expiration year"), N_("click to enter"), "card_expiration_year", ECORE_IMF_INPUT_HINT_AUTOFILL_CREDIT_CARD_EXPIRATION_YEAR, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY },
+
+    /* do not delete below */
+    { NULL, NULL, NULL, ECORE_IMF_INPUT_HINT_AUTOFILL_NAME, ELM_INPUT_PANEL_LAYOUT_NORMAL }
+};
+
+static Evas_Object *_create_ef_layout (Evas_Object *parent, const char *label, const char *guide_text, const char *prediction_hint, const char *res_id, Ecore_IMF_Input_Hints input_hints = ECORE_IMF_INPUT_HINT_NONE, Elm_Input_Panel_Layout layout = ELM_INPUT_PANEL_LAYOUT_NORMAL)
 {
     Evas_Object *en;
     Evas_Object *ef = create_ef (parent, label, guide_text, &en);
     if (!ef || !en) return NULL;
 
+    elm_entry_input_panel_layout_set (en, layout);
+
     Ecore_IMF_Context *ic = NULL;
     ic = (Ecore_IMF_Context *)elm_entry_imf_context_get (en);
     if (ic) {
@@ -55,8 +82,8 @@ static Evas_Object * create_inner_layout (void *data)
     struct appdata *ad = (struct appdata *)data;
     Evas_Object *bx = NULL;
     Evas_Object *ef = NULL;
-
     Evas_Object *parent = ad->naviframe;
+    unsigned int idx = 0;
 
     bx = elm_box_add (parent);
     evas_object_size_hint_weight_set (bx, EVAS_HINT_EXPAND, 0.0);
@@ -74,17 +101,13 @@ static Evas_Object * create_inner_layout (void *data)
     ef = _create_ef_layout (parent, _("Text: What's the weather?"), _("click to enter"), prediction_hint, NULL);
     elm_box_pack_end (bx, ef);
 
-    /* Name */
-    ef = _create_ef_layout (parent, _("Name"), _("click to enter"), NULL, "name", ECORE_IMF_INPUT_HINT_AUTOFILL_NAME);
-    elm_box_pack_end (bx, ef);
-
-    /* Email */
-    ef = _create_ef_layout (parent, _("Email"), _("click to enter"), NULL, "email", ECORE_IMF_INPUT_HINT_AUTOFILL_EMAIL_ADDRESS);
-    elm_box_pack_end (bx, ef);
-
-    /* Address */
-    ef = _create_ef_layout (parent, _("Address"), _("click to enter"), NULL, "address", ECORE_IMF_INPUT_HINT_AUTOFILL_POSTAL_ADDRESS);
-    elm_box_pack_end (bx, ef);
+    /* Autofill test */
+    while (autofill_test_itsc[idx].name != NULL) {
+        ef = _create_ef_layout (parent, autofill_test_itsc[idx].name, autofill_test_itsc[idx].guide_text, NULL,
+                                autofill_test_itsc[idx].res_id, autofill_test_itsc[idx].autofill_hint, autofill_test_itsc[idx].layout);
+        elm_box_pack_end (bx, ef);
+        ++idx;
+    }
 
     return bx;
 }