Implemented missing behavior in Contact Input ContactObjectCustomTypePopup 72/57672/1
authorEugene Kurzberg <i.kurtsberg@samsung.com>
Tue, 19 Jan 2016 09:16:40 +0000 (11:16 +0200)
committerEugene Kurzberg <i.kurtsberg@samsung.com>
Thu, 21 Jan 2016 08:00:54 +0000 (10:00 +0200)
and genlist item for ContactDateField.

Change-Id: I04a96a1905835aa21bda120bd545a63faaf06e21
Signed-off-by: Eugene Kurzberg <i.kurtsberg@samsung.com>
lib-contact/inc/Contacts/Input/ContactDateFieldControl.h
lib-contact/inc/Contacts/Input/ContactObjectCustomTypePopup.h
lib-contact/src/Contacts/Input/ContactDateFieldControl.cpp
lib-contact/src/Contacts/Input/ContactFieldSubItem.cpp
lib-contact/src/Contacts/Input/ContactObjectCustomTypePopup.cpp

index fb1469b..19d293e 100644 (file)
@@ -42,6 +42,11 @@ namespace Contacts
                        ContactDateFieldControl(Model::ContactDateField &field);
 
                        /**
+                        * @brief Show date picker popup.
+                        */
+                       void showPicker();
+
+                       /**
                         * @brief Update the control using field's value.
                         */
                        void update();
index 4df54a1..0753818 100644 (file)
@@ -54,6 +54,7 @@ namespace Contacts
                private:
                        virtual void onCreated() override;
                        void onCreatePressed();
+                       void onDonePressed(Evas_Object *entry, void *eventInfo);
                        static void onEntryChanged(Evas_Object *button, Evas_Object *entry, void *eventInfo);
 
                        ResultCallback m_OnResult;
index 84a429e..60b78a3 100644 (file)
@@ -33,6 +33,16 @@ ContactDateFieldControl::ContactDateFieldControl(Model::ContactDateField &field)
 {
 }
 
+void ContactDateFieldControl::showPicker()
+{
+       Ui::DatePopup *popup = new Ui::DatePopup(m_Field.getValue());
+       popup->setResultCallback([this](const tm &date) {
+               m_Field.setValue(date);
+               update();
+       });
+       popup->create(getEvasObject());
+}
+
 void ContactDateFieldControl::update()
 {
        tm date = m_Field.getValue();
@@ -65,10 +75,5 @@ void ContactDateFieldControl::onCreated()
 
 void ContactDateFieldControl::onButtonPressed(Evas_Object *button, void *eventInfo)
 {
-       Ui::DatePopup *popup = new Ui::DatePopup(m_Field.getValue());
-       popup->setResultCallback([this](const tm &date) {
-               m_Field.setValue(date);
-               update();
-       });
-       popup->create(getEvasObject());
+       showPicker();
 }
index 8bf9887..8f928b0 100644 (file)
@@ -76,6 +76,8 @@ void ContactFieldSubItem::onFocused()
                if (m_Field.getType() == TypeText) {
                        Evas_Object *entry = static_cast<Ui::Editfield *>(control)->getEntry();
                        elm_object_focus_set(entry, EINA_TRUE);
+               } else if (m_Field.getType() == TypeDate) {
+                       static_cast<ContactDateFieldControl *>(control)->showPicker();
                }
        }
 }
index 5e3da13..ebe8bda 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "Contacts/Input/ContactObjectCustomTypePopup.h"
 #include "Ui/Editfield.h"
+#include "Utils/Callback.h"
 
 using namespace Contacts::Input;
 
@@ -48,6 +49,8 @@ void ContactObjectCustomTypePopup::onCreated()
        elm_entry_input_panel_return_key_type_set(entry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DONE);
        evas_object_smart_callback_add(entry, "changed",
                        (Evas_Smart_Cb) &ContactObjectCustomTypePopup::onEntryChanged, button);
+       evas_object_smart_callback_add(entry, "activated",
+                       makeCallback(&ContactObjectCustomTypePopup::onDonePressed), this);
        elm_object_focus_set(entry, EINA_TRUE);
 }
 
@@ -60,6 +63,12 @@ void ContactObjectCustomTypePopup::onCreatePressed()
        }
 }
 
+void ContactObjectCustomTypePopup::onDonePressed(Evas_Object *entry, void *eventInfo)
+{
+       onCreatePressed();
+       delete this;
+}
+
 void ContactObjectCustomTypePopup::onEntryChanged(Evas_Object *button, Evas_Object *entry, void *eventInfo)
 {
        elm_object_disabled_set(button, elm_entry_is_empty(entry));