virtual Eina_Bool getState(Evas_Object *parent, const char *part) override;
/**
+ * @see GenlistItem::onInserted()
+ */
+ virtual void onInserted() override;
+
+ /**
* @see GenlistItem::onFocused()
*/
virtual void onFocused() override;
--- /dev/null
+/*
+ * Copyright (c) 2015 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_RINGTONE_FIELD_ITEM_H
+#define CONTACTS_INPUT_CONTACT_RINGTONE_FIELD_ITEM_H
+
+#include "Contacts/Input/ContactFieldItem.h"
+#include "App/AppControl.h"
+
+namespace Contacts
+{
+ namespace Input
+ {
+ /**
+ * @brief Genlist item representing FieldRingtone field.
+ */
+ class ContactRingtoneFieldItem : public ContactFieldItem
+ {
+ public:
+ using ContactFieldItem::ContactFieldItem;
+
+ /**
+ * @see GenlistItem::isFocusable()
+ */
+ virtual bool isFocusable() const override;
+
+ private:
+ virtual Elm_Genlist_Item_Class *getItemClass() const override;
+ virtual char *getText(Evas_Object *parent, const char *part) override;
+ virtual Evas_Object *getContent(Evas_Object *parent, const char *part) override;
+
+ virtual void onInserted() override;
+ virtual void onSelected() override;
+ virtual void onFocused() override;
+
+ char *getRingtonePath() const;
+ void pickRingtone();
+ void onPickResult(app_control_h request, app_control_h reply,
+ app_control_result_e result);
+
+ App::AppControl m_AppControl;
+ };
+ }
+}
+
+#endif /* CONTACTS_INPUT_CONTACT_RINGTONE_FIELD_ITEM_H */
FieldNote,
FieldNickname,
FieldRelationship,
+ FieldRingtone,
FieldEnd
};
ObjectTypeMessenger,
ObjectTypeNickname,
ObjectTypeCompany,
- ObjectTypePhoneticName
+ ObjectTypePhoneticName,
+ ObjectTypeRingtone
};
/**
/* [FieldEvent] = */ "IDS_PB_MBODY_EVENT",
/* [FieldNote] = */ "IDS_PB_BUTTON_NOTES",
/* [FieldNickname] = */ "IDS_PB_BODY_NICKNAME_ABB",
- /* [FieldRelationship] = */ "IDS_PB_OPT_RELATIONSHIP_ABB2"
+ /* [FieldRelationship] = */ "IDS_PB_OPT_RELATIONSHIP_ABB2",
+ /* [FieldRingtone] = */ "Ringtone",
};
const char *childFieldNames[] = {
/* [FieldNote] = */ "IDS_PB_BODY_NOTES",
/* [FieldNickname] = */ "IDS_PB_BODY_NICKNAME_ABB",
/* [FieldRelationship] = */ "IDS_PB_BODY_NAME",
+ /* [FieldRingtone] = */ "Ringtone",
/* [CompanyFieldName] = */ "IDS_PB_BODY_COMPANY_ABB",
/* [CompanyFieldJobTitle] = */ "IDS_PB_BODY_JOB_TITLE_ABB",
/* [FieldEvent] = */ true,
/* [FieldNote] = */ true,
/* [FieldNickname] = */ true,
- /* [FieldRelationship] = */ true
+ /* [FieldRelationship] = */ true,
+ /* [FieldRingtone] = */ true
};
}
void ContactFieldItem::onInserted()
{
+ ContactFieldSubItem::onInserted();
elm_genlist_item_expanded_set(getObjectItem(), EINA_TRUE);
}
Evas_Object *button = elm_button_add(parent);
elm_object_style_set(button, "icon_expand_delete");
elm_object_focus_allow_set(button, EINA_FALSE);
+ evas_object_propagate_events_set(button, EINA_FALSE);
evas_object_smart_callback_add(button, "clicked",
makeCallback(&ContactFieldItem::onRemovePressed), this);
return parentItem ? parentItem->getState(parent, part) : EINA_FALSE;
}
+void ContactFieldSubItem::onInserted()
+{
+ elm_genlist_item_select_mode_set(getObjectItem(), ELM_OBJECT_SELECT_MODE_NONE);
+}
+
void ContactFieldSubItem::onFocused()
{
Ui::Control *control = getFieldControl();
--- /dev/null
+/*
+ * Copyright (c) 2015 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/ContactRingtoneFieldItem.h"
+#include "Contacts/Model/ContactObject.h"
+#include "Contacts/Model/ContactTextField.h"
+#include "Contacts/Common/Strings.h"
+
+#include "App/AppControlRequest.h"
+#include "Utils/Callback.h"
+#include "Utils/Logger.h"
+
+#include "InputItemLayout.h"
+
+#include <app_i18n.h>
+#include <system_settings.h>
+
+using namespace Contacts::Input;
+using namespace Contacts::Model;
+
+bool ContactRingtoneFieldItem::isFocusable() const
+{
+ return false;
+}
+
+Elm_Genlist_Item_Class *ContactRingtoneFieldItem::getItemClass() const
+{
+ static Elm_Genlist_Item_Class itc = createItemClass("type2");
+ return &itc;
+}
+
+char *ContactRingtoneFieldItem::getText(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.text") == 0) {
+ char *value = getRingtonePath();
+ return strcpy(value, basename(value));
+ } else if (strcmp(part, "elm.text.sub") == 0) {
+ const char *name = Common::getContactFieldName(ContactFieldId(getObject().getId()));
+ return Utils::safeDup(_(name));
+ }
+
+ return nullptr;
+}
+
+Evas_Object *ContactRingtoneFieldItem::getContent(Evas_Object *parent, const char *part)
+{
+ if (strcmp(part, "elm.swallow.end") == 0) {
+ return ContactFieldItem::getContent(parent, PART_RIGHT);
+ }
+
+ return nullptr;
+}
+
+void ContactRingtoneFieldItem::onInserted()
+{
+ ContactFieldItem::onInserted();
+ elm_genlist_item_select_mode_set(getObjectItem(), ELM_OBJECT_SELECT_MODE_DEFAULT);
+}
+
+void ContactRingtoneFieldItem::onSelected()
+{
+ pickRingtone();
+}
+
+void ContactRingtoneFieldItem::onFocused()
+{
+ pickRingtone();
+}
+
+char *ContactRingtoneFieldItem::getRingtonePath() const
+{
+ char *value = nullptr;
+ const char *fieldValue = getField().cast<ContactTextField>().getValue();
+ if (fieldValue) {
+ value = strdup(fieldValue);
+ } else {
+ char *defaultValue = nullptr;
+ system_settings_get_value_string(SYSTEM_SETTINGS_KEY_INCOMING_CALL_RINGTONE, &defaultValue);
+ value = defaultValue;
+ }
+
+ return value;
+}
+
+void ContactRingtoneFieldItem::pickRingtone()
+{
+ char *value = getRingtonePath();
+ m_AppControl = App::requestPickRingtone(value);
+ m_AppControl.launch(makeCallbackWithLastParam(&ContactRingtoneFieldItem::onPickResult), this);
+ free(value);
+}
+
+void ContactRingtoneFieldItem::onPickResult(app_control_h request, app_control_h reply,
+ app_control_result_e result)
+{
+ char *path = nullptr;
+ int err = app_control_get_extra_data(reply, "result", &path);
+ WARN_IF_ERR(err, "app_control_get_extra_data() failed.");
+
+ getField().cast<ContactTextField>().setValue(path);
+ free(path);
+}
#include "Contacts/Input/ContactCompoundFieldItem.h"
#include "Contacts/Input/ContactImageFieldItem.h"
#include "Contacts/Input/ContactRelationshipFieldItem.h"
+#include "Contacts/Input/ContactRingtoneFieldItem.h"
#include "Contacts/Input/ContactTypedFieldItem.h"
#include "Contacts/Details/DetailsView.h"
/* [FieldEvent] = */ true,
/* [FieldNote] = */ true,
/* [FieldNickname] = */ true,
- /* [FieldRelationship] = */ true
+ /* [FieldRelationship] = */ true,
+ /* [FieldRingtone] = */ true
};
}
m_Genlist = new Ui::Genlist();
m_Genlist->create(parent);
- elm_genlist_select_mode_set(m_Genlist->getEvasObject(), ELM_OBJECT_SELECT_MODE_NONE);
m_AddFieldsItem = new AddFieldsItem();
m_AddFieldsItem->setAddFieldCallback(std::bind(&InputView::onAddField, this, _1));
m_Genlist->insert(m_AddFieldsItem);
for (unsigned id = FieldBegin; id < FieldEnd; ++id) {
- if (!isFieldVisible[id]) {
+ if (!isFieldVisible[id] || !m_Contact.getFieldById(id)) {
m_AddFieldsItem->setAddFieldState(ContactFieldId(id), false);
}
}
item = new ContactImageFieldItem(field);
} else if (field.getId() == FieldRelationship) {
item = new ContactRelationshipFieldItem(field);
+ } else if (field.getId() == FieldRingtone) {
+ item = new ContactRingtoneFieldItem(field);
} else if (field.getInterfaces() & InterfaceTypedObject) {
item = new ContactTypedFieldItem(field);
} else if (field.getInterfaces() & InterfaceCompoundObject) {
_contacts_image._uri, _contacts_image.id, makeRange(contactImageFields)
};
+/****************************** Ringtone Object *******************************/
+const ContactFieldMetadata contactRingtoneFields[] = {
+ { FieldRingtone, _contacts_contact.ringtone_path, false, &contactRegularText }
+};
+const ContactObjectMetadata contactRingtone = {
+ { TypeObject, ObjectTypeRingtone }, InterfaceNone,
+ _contacts_contact._uri, _contacts_contact.id, makeRange(contactRingtoneFields)
+};
+
/****************************** Number Object *********************************/
const int contactNumberTypeValues[] = {
CONTACTS_NUMBER_TYPE_CELL,
/****************************** Contact Object ********************************/
const ContactFieldMetadata contactFields[] = {
- { FieldFavorite, _contacts_contact.is_favorite, false, &contactBool },
- { FieldDisplayName, _contacts_contact.display_name, false, &contactRegularText },
- { FieldImage, _contacts_contact.image, false, UPCAST(&contactImage) },
- { FieldName, _contacts_contact.name, true, UPCAST(&contactName) },
- { FieldPhoneticName, _contacts_contact.name, false, UPCAST(&contactPhName) },
- { FieldCompany, _contacts_contact.company, true, UPCAST(&contactCompany) },
- { FieldNumber, _contacts_contact.number, true, UPCAST(&contactNumbers) },
- { FieldEmail, _contacts_contact.email, true, UPCAST(&contactEmails) },
- { FieldAddress, _contacts_contact.address, false, UPCAST(&contactAddrs) },
- { FieldUrl, _contacts_contact.url, false, UPCAST(&contactUrls) },
- { FieldMessenger, _contacts_contact.messenger, false, UPCAST(&contactMsgs) },
- { FieldEvent, _contacts_contact.event, false, UPCAST(&contactEvents) },
- { FieldNote, _contacts_contact.note, false, UPCAST(&contactNote) },
- { FieldNickname, _contacts_contact.nickname, true, UPCAST(&contactNick) },
- { FieldRelationship, _contacts_contact.relationship, false, UPCAST(&contactRels) }
+ { FieldFavorite, _contacts_contact.is_favorite, false, &contactBool },
+ { FieldDisplayName, _contacts_contact.display_name, false, &contactRegularText },
+ { FieldImage, _contacts_contact.image, false, UPCAST(&contactImage) },
+ { FieldName, _contacts_contact.name, true, UPCAST(&contactName) },
+ { FieldPhoneticName, _contacts_contact.name, false, UPCAST(&contactPhName) },
+ { FieldCompany, _contacts_contact.company, true, UPCAST(&contactCompany) },
+ { FieldNumber, _contacts_contact.number, true, UPCAST(&contactNumbers) },
+ { FieldEmail, _contacts_contact.email, true, UPCAST(&contactEmails) },
+ { FieldAddress, _contacts_contact.address, false, UPCAST(&contactAddrs) },
+ { FieldUrl, _contacts_contact.url, false, UPCAST(&contactUrls) },
+ { FieldMessenger, _contacts_contact.messenger, false, UPCAST(&contactMsgs) },
+ { FieldEvent, _contacts_contact.event, false, UPCAST(&contactEvents) },
+ { FieldNote, _contacts_contact.note, false, UPCAST(&contactNote) },
+ { FieldNickname, _contacts_contact.nickname, true, UPCAST(&contactNick) },
+ { FieldRelationship, _contacts_contact.relationship, false, UPCAST(&contactRels) },
+ { FieldRingtone, _contacts_contact.ringtone_path, false, UPCAST(&contactRingtone) }
};
const ContactObjectMetadata contactObject = {
{ TypeObject, ObjectTypeContact }, InterfaceNone,
contacts_record_add_child_record(record, metadata.propId, childRecord);
}
- return childRecord;
+ return childRecord ? childRecord : record;
}