Autofill create fix 41/87341/4
authorKamil Nowac <k.nowac@samsung.com>
Wed, 7 Sep 2016 11:13:17 +0000 (13:13 +0200)
committerKamil Nowa? <k.nowac@samsung.com>
Wed, 7 Sep 2016 12:49:49 +0000 (05:49 -0700)
[Issue]    http://suprem.sec.samsung.net/jira/browse/TWF-2046
[Problem]  Not visible view
[Solution] Changed edj location and some other
           small changes
[Verify]   Go to the Autofill forms create list
           It should be visible

Change-Id: Ie74430bef4a29d316c58becf20ddc4b541d02fe7

services/SettingsUI/AutoFillForm/AutoFillFormItem.cpp
services/SettingsUI/SettingsAFCreator.cpp
services/SettingsUI/SettingsAFProfile.cpp

index 4f0784fb302534cd493a6452ff1b4146c95c8cba..094119dbc6cfc00874d838c2f0aa28444b108859 100644 (file)
@@ -59,7 +59,7 @@ profileSaveErrorcode AutoFillFormItem::saveItem(void)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
 
-    Ewk_Autofill_Profile *profile = ewk_autofill_profile_new();
+    auto profile = ewk_autofill_profile_new();
     if (!profile) {
         BROWSER_LOGE("Failed to ewk_autofill_profile_new");
         return profile_create_failed;
index 9ff9d98312fb95d20ac58ebeb08a2b56b60a7736..e57fd9f93b1af60a092b9519ab969679b1ddf5cb 100644 (file)
@@ -24,6 +24,8 @@
 namespace tizen_browser{
 namespace base_ui{
 
+using namespace tools::EflTools;
+
 inline std::string _trim(std::string& s, const std::string& drop = TRIM_SPACE)
 {
     std::string r = s.erase(s.find_last_not_of(drop) + 1);
@@ -99,7 +101,7 @@ bool SettingsAFCreator::populateLayout(Evas_Object* parent)
     m_entryLimitSize.max_char_count = 0;
     m_entryLimitSize.max_byte_count = AUTO_FILL_FORM_ENTRY_MAX_COUNT;
     m_edjFilePath = EDJE_DIR;
-    m_edjFilePath.append("SettingsUI/AutoFillMobileUI.edj");
+    m_edjFilePath.append("SettingsUI/SettingsMobileUI.edj");
 
     m_scroller = createScroller(parent);
     evas_object_show(m_scroller);
@@ -117,29 +119,31 @@ bool SettingsAFCreator::populateLayout(Evas_Object* parent)
     m_naviframe->setRightButtonText(_("IDS_BR_SK_DONE"));
     m_naviframe->setLeftButtonText(_("IDS_BR_SK_CANCEL"));
 
-    if (m_item->getItemComposeMode() == profile_create)
-        m_naviframe->setRightButtonEnabled(true);
+    m_naviframe->setRightButtonEnabled(false);
 
     m_layout = m_scroller;
     return true;
 }
 
-void SettingsAFCreator::createInputLayout(Evas_Object* parent, char* fieldName,
-                                                        genlistCallbackData* cb_data)
+void SettingsAFCreator::createInputLayout(
+    Evas_Object* parent,
+    char* fieldName,
+    genlistCallbackData* cb_data)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
-    Evas_Object* layout = elm_layout_add(parent);
-    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
-    elm_layout_file_set(layout, m_edjFilePath.c_str(), "affcv_item");
+    auto layout(elm_layout_add(parent));
+    setExpandHints(layout);
+    if (!elm_layout_file_set(layout, m_edjFilePath.c_str(), "affcv_item"))
+        BROWSER_LOGD("[%s:%d] item layout creation failed", __PRETTY_FUNCTION__, __LINE__);
     elm_object_part_text_set(layout, "field_name", fieldName);
 
-    Evas_Object* editfield = elm_layout_add(layout);
-    elm_layout_file_set(editfield, m_edjFilePath.c_str(), "edit-field");
+    auto editfield(elm_layout_add(layout));
+    if (!elm_layout_file_set(editfield, m_edjFilePath.c_str(), "edit-field"))
+        BROWSER_LOGD("[%s:%d] item layout creation failed", __PRETTY_FUNCTION__, __LINE__);
     evas_object_size_hint_align_set(editfield, EVAS_HINT_FILL, 0.0);
     evas_object_size_hint_weight_set(editfield, EVAS_HINT_EXPAND, 0.0);
 
-    Evas_Object* entry = elm_entry_add(editfield);
+    auto entry(elm_entry_add(editfield));
     elm_object_style_set(entry, "entry_style");
     elm_entry_single_line_set(entry, EINA_TRUE);
     elm_entry_scrollable_set(entry, EINA_TRUE);
@@ -162,17 +166,18 @@ void SettingsAFCreator::createInputLayout(Evas_Object* parent, char* fieldName,
 
     elm_object_part_content_set(editfield, "editfield_entry", entry);
 
-    Evas_Object *button = elm_button_add(editfield);
+    auto button(elm_button_add(editfield));
     elm_object_style_set(button, "basic_button");
     evas_object_smart_callback_add(button, "clicked", __entry_clear_button_clicked_cb, entry);
     elm_object_part_content_set(editfield, "entry_clear_button", button);
 
-    if (!elm_entry_is_empty(entry)) {
-        BROWSER_LOGE("entry is empty");
+    if (!elm_entry_is_empty(entry))
         elm_object_signal_emit(editfield, "show,clear,button,signal", "");
-    }
 
     elm_object_part_content_set(layout, "entry_swallow", editfield);
+    evas_object_show(cb_data->editfield);
+    evas_object_show(cb_data->entry);
+    evas_object_show(cb_data->it);
     evas_object_show(layout);
 }
 
@@ -270,24 +275,25 @@ void SettingsAFCreator::addItems()
     elm_entry_prediction_allow_set(m_emailItemCallbackData.entry, EINA_FALSE);
 }
 
-Evas_Object* SettingsAFCreator::createScroller(Evas_Object *parent)
+Evas_Object* SettingsAFCreator::createScroller(Evas_Objectparent)
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
 
-    Evas_Object *scroller = elm_scroller_add(parent);
-    if (!scroller) {
-        BROWSER_LOGE("elm_scroller_add failed");
-        return nullptr;
-    }
+    auto scroller(elm_scroller_add(parent));
 
     m_box = elm_box_add(scroller);
-    evas_object_size_hint_weight_set(m_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-    evas_object_size_hint_align_set(m_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
     elm_box_align_set(m_box, 0.0, 0.0);
-    elm_object_content_set(scroller, m_box);
 
     addItems();
 
+    elm_object_content_set(scroller, m_box);
+
+    setExpandHints(m_box);
+    setExpandHints(scroller);
+
+    evas_object_show(m_box);
+    evas_object_show(scroller);
+
     return scroller;
 }
 
@@ -322,9 +328,9 @@ Eina_Bool SettingsAFCreator::applyEntryData(void)
 
     if (full_name && strlen(full_name) && !isEntryHasOnlySpace(full_name))
         m_item->setName(full_name);
-    else {
+    else
         return EINA_FALSE;
-    }
+
     const char *company_name = elm_entry_entry_get(m_companyNameItemCallbackData.entry);
     m_item->setCompany(company_name);
     const char *primary_address = elm_entry_entry_get(m_addressLine1ItemCallbackData.entry);
@@ -345,15 +351,14 @@ Eina_Bool SettingsAFCreator::applyEntryData(void)
     m_item->setEmailAddress(email);
 
     if (m_item->getItemComposeMode() == profile_edit) {
-
         m_editErrorcode = m_item->updateItem();
-        if (m_editErrorcode == profile_edit_failed || m_editErrorcode == profile_already_exist) {
+        if (m_editErrorcode != update_error_none) {
             BROWSER_LOGD("Update failed!");
             return EINA_FALSE;
         }
     } else {
         m_saveErrorcode = m_item->saveItem();
-        if (m_saveErrorcode != profile_create_failed && m_saveErrorcode != duplicate_profile){
+        if (m_saveErrorcode != save_error_none) {
             BROWSER_LOGD("Cannot save autofill data");
             return EINA_FALSE;
         }
@@ -411,7 +416,7 @@ void SettingsAFCreator::__entry_changed_cb(void* data, Evas_Object* obj, void*)
         elm_object_signal_emit(cb_data->editfield, "hide,clear,button,signal", "");
 
     auto isEmpty(elm_entry_is_empty(view->m_fullNameItemCallbackData.entry) == EINA_TRUE);
-    view->m_naviframe->setRightButtonEnabled(isEmpty);
+    view->m_naviframe->setRightButtonEnabled(!isEmpty);
 }
 
 void SettingsAFCreator::__entry_clicked_cb(void* data, Evas_Object*, void*)
index 3fb4a77a3be3069463e36eac74822bf5fabbe9f7..b07eabe51b0829e05ef4ac6e95d3000822fd46df 100644 (file)
@@ -24,7 +24,6 @@ SettingsAFProfile::SettingsAFProfile(Evas_Object* parent)
     : m_profile(nullptr)
 {
     init(parent);
-    updateButtonMap();
 };
 
 SettingsAFProfile::~SettingsAFProfile()
@@ -35,6 +34,7 @@ SettingsAFProfile::~SettingsAFProfile()
 void SettingsAFProfile::updateButtonMap()
 {
     BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    // TODO Fix profile name update after profile saving
     ItemData profileName;
     m_profile = ewk_context_form_autofill_profile_get(ewk_context_default_get(), 1);
     if (!m_profile)
@@ -46,11 +46,15 @@ void SettingsAFProfile::updateButtonMap()
 
 bool SettingsAFProfile::populateList(Evas_Object* genlist)
 {
+    BROWSER_LOGD("[%s:%d] ", __PRETTY_FUNCTION__, __LINE__);
+    updateButtonMap();
+
     m_naviframe->setLeftButtonVisible(false);
     m_naviframe->setRightButtonVisible(false);
     m_naviframe->setPrevButtonVisible(true);
     m_naviframe->setTitle(Translations::SettingsAutoFillProfileTitle.c_str());
 
+    elm_genlist_clear(genlist);
     appendGenlist(genlist, m_setting_item_class, &m_buttonsMap[0], _select_profile_cb);
     return true;
 }