From d0db82f3174683992c9a7af4f4f062893bcc6a3c Mon Sep 17 00:00:00 2001 From: Eugene Kurzberg Date: Thu, 29 Sep 2016 16:54:40 +0300 Subject: [PATCH] TizenRefApp-5991 Implement Note as multiline control in the Input View Change-Id: I08cbad6e26193ecfe6916f47ff748bf51f28e0d4 Signed-off-by: Eugene Kurzberg --- lib-apps-common/inc/Ui/Editfield.h | 7 ++- lib-apps-common/src/Ui/Editfield.cpp | 7 +++ .../inc/Contacts/Input/ContactNoteFieldItem.h | 51 ++++++++++++++++ .../src/Contacts/Input/ContactNoteFieldItem.cpp | 67 ++++++++++++++++++++++ .../src/Contacts/Input/ContactTextFieldControl.cpp | 8 ++- lib-contacts/src/Contacts/Input/InputView.cpp | 5 +- 6 files changed, 142 insertions(+), 3 deletions(-) create mode 100644 lib-contacts/inc/Contacts/Input/ContactNoteFieldItem.h create mode 100644 lib-contacts/src/Contacts/Input/ContactNoteFieldItem.cpp diff --git a/lib-apps-common/inc/Ui/Editfield.h b/lib-apps-common/inc/Ui/Editfield.h index bd71b77..9dcb09d 100644 --- a/lib-apps-common/inc/Ui/Editfield.h +++ b/lib-apps-common/inc/Ui/Editfield.h @@ -42,6 +42,12 @@ namespace Ui static Editfield *create(Evas_Object *parent, const char *guideText); /** + * @brief Set entry multiline state. + * @param[in] isMultiline Whether entry is multiline + */ + void setMultiline(bool isMultiline); + + /** * @brief Set entry guide text. * @param[in] guideText Text to be displayed when entry is empty */ @@ -76,7 +82,6 @@ namespace Ui static void onFocused(Evas_Object *layout, Evas_Object *entry, void *eventInfo); static void onUnfocused(Evas_Object *layout, Evas_Object *entry, void *eventInfo); static void onClearPressed(Evas_Object *entry, Evas_Object *button, void *eventInfo); - }; } diff --git a/lib-apps-common/src/Ui/Editfield.cpp b/lib-apps-common/src/Ui/Editfield.cpp index 2bc1c3a..c814f61 100644 --- a/lib-apps-common/src/Ui/Editfield.cpp +++ b/lib-apps-common/src/Ui/Editfield.cpp @@ -52,6 +52,13 @@ Evas_Object *Editfield::onCreate(Evas_Object *parent) return layout; } +void Editfield::setMultiline(bool isMultiline) +{ + elm_entry_single_line_set(getEntry(), !isMultiline); + elm_entry_scrollable_set(getEntry(), !isMultiline); + elm_entry_line_wrap_set(getEntry(), isMultiline ? ELM_WRAP_MIXED : ELM_WRAP_NONE); +} + void Editfield::setGuideText(const char *guideText) { elm_object_translatable_part_text_set(getEntry(), "elm.guide", guideText); diff --git a/lib-contacts/inc/Contacts/Input/ContactNoteFieldItem.h b/lib-contacts/inc/Contacts/Input/ContactNoteFieldItem.h new file mode 100644 index 0000000..d93884c --- /dev/null +++ b/lib-contacts/inc/Contacts/Input/ContactNoteFieldItem.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef CONTACTS_INPUT_CONTACT_NOTE_FIELD_ITEM_H +#define CONTACTS_INPUT_CONTACT_NOTE_FIELD_ITEM_H + +#include "Contacts/Input/ContactFieldItem.h" +#include "Contacts/Input/ContactTextFieldControl.h" + +namespace Contacts +{ + namespace Input + { + /** + * @brief Genlist item representing FieldNote field. + */ + class ContactNoteFieldItem : public ContactFieldItem + { + public: + /** + * @see ContactFieldItem::ContactFieldItem() + */ + ContactNoteFieldItem(Model::ContactObject &object); + virtual ~ContactNoteFieldItem() override; + + private: + virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override; + virtual void onInserted() override; + virtual void onUnrealized() override; + void onFieldControlResized(Evas *e, Evas_Object *obj, void *eventInfo); + + ContactTextFieldControl *m_FieldControl; + }; + } +} + +#endif /* CONTACTS_INPUT_CONTACT_NOTE_FIELD_ITEM_H */ diff --git a/lib-contacts/src/Contacts/Input/ContactNoteFieldItem.cpp b/lib-contacts/src/Contacts/Input/ContactNoteFieldItem.cpp new file mode 100644 index 0000000..fff4ef7 --- /dev/null +++ b/lib-contacts/src/Contacts/Input/ContactNoteFieldItem.cpp @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2015-2016 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "Contacts/Input/ContactNoteFieldItem.h" +#include "Utils/Callback.h" + +#include "InputItemLayout.h" + +using namespace Contacts::Input; +using namespace Contacts::Model; + +ContactNoteFieldItem::ContactNoteFieldItem(ContactObject &object) + : ContactFieldItem(object), m_FieldControl(nullptr) +{ +} + +ContactNoteFieldItem::~ContactNoteFieldItem() +{ + if (m_FieldControl) { + evas_object_unref(m_FieldControl->getEvasObject()); + } +} + +Evas_Object *ContactNoteFieldItem::getContent(Evas_Object *parent, const char *part) +{ + if (strcmp(part, PART_VALUE) == 0) { + return m_FieldControl ? m_FieldControl->getEvasObject() : nullptr; + } + + return ContactFieldItem::getContent(parent, part); +} + +void ContactNoteFieldItem::onInserted() +{ + ContactFieldItem::onInserted(); + + m_FieldControl = new ContactTextFieldControl(this, getField().cast()); + m_FieldControl->create(getParent()->getEvasObject()); + m_FieldControl->setMultiline(true); + evas_object_ref(m_FieldControl->getEvasObject()); + evas_object_event_callback_add(m_FieldControl->getEvasObject(), EVAS_CALLBACK_CHANGED_SIZE_HINTS, + makeCallback(&ContactNoteFieldItem::onFieldControlResized), this); +} + +void ContactNoteFieldItem::onUnrealized() +{ + evas_object_hide(m_FieldControl->getEvasObject()); +} + +void ContactNoteFieldItem::onFieldControlResized(Evas *e, Evas_Object *obj, void *eventInfo) +{ + GenItem::update(PART_VALUE, ELM_GENLIST_ITEM_FIELD_CONTENT); +} diff --git a/lib-contacts/src/Contacts/Input/ContactTextFieldControl.cpp b/lib-contacts/src/Contacts/Input/ContactTextFieldControl.cpp index 38e720f..a6a57b5 100644 --- a/lib-contacts/src/Contacts/Input/ContactTextFieldControl.cpp +++ b/lib-contacts/src/Contacts/Input/ContactTextFieldControl.cpp @@ -67,7 +67,9 @@ void ContactTextFieldControl::update() void ContactTextFieldControl::updateReturnKey() { - setNextItem(findNextItem(m_ParentItem)); + if (elm_entry_single_line_get(getEntry())) { + setNextItem(findNextItem(m_ParentItem)); + } } void ContactTextFieldControl::updateEntryLayout() @@ -161,6 +163,10 @@ void ContactTextFieldControl::onUnfocused(Evas_Object *entry, void *eventInfo) void ContactTextFieldControl::onActivated(Evas_Object *entry, void *eventInfo) { + if (!elm_entry_single_line_get(entry)) { + return; + } + if (m_NextItem) { m_NextItem->focus(ELM_GENLIST_ITEM_SCROLLTO_IN, true); } else { diff --git a/lib-contacts/src/Contacts/Input/InputView.cpp b/lib-contacts/src/Contacts/Input/InputView.cpp index a8a00cf..7931f7d 100644 --- a/lib-contacts/src/Contacts/Input/InputView.cpp +++ b/lib-contacts/src/Contacts/Input/InputView.cpp @@ -20,6 +20,7 @@ #include "Contacts/Input/BasicInfoItem.h" #include "Contacts/Input/ContactCompoundFieldItem.h" #include "Contacts/Input/ContactGroupsFieldItem.h" +#include "Contacts/Input/ContactNoteFieldItem.h" #include "Contacts/Input/ContactRelationshipFieldItem.h" #include "Contacts/Input/ContactRingtoneFieldItem.h" #include "Contacts/Input/ContactTypedFieldItem.h" @@ -198,7 +199,9 @@ bool InputView::onBackPressed() ContactFieldItem *InputView::createFieldItem(ContactObject &field) { ContactFieldItem *item = nullptr; - if (field.getId() == FieldRelationship) { + if (field.getId() == FieldNote) { + item = new ContactNoteFieldItem(field); + } else if (field.getId() == FieldRelationship) { item = new ContactRelationshipFieldItem(field); } else if (field.getId() == FieldRingtone) { item = new ContactRingtoneFieldItem(field); -- 2.7.4