#include <fstream>
#include <mime_type.h>
#include <media_content.h>
+#include <algorithm>
using namespace Msg;
if(mime)
{
res = mime;
+ std::transform(res.begin(), res.end(), res.begin(), ::tolower);
free(mime);
}
}
virtual bool getState(ListItem &item, const char *part);
virtual void onDelete(ListItem &item);
virtual const char *getCheckPart(ListItem &item);
+ virtual bool getFilter(ListItem &item, void *key);
virtual void onRealized(ListItem &item) {};
virtual void onUnrealized(ListItem &item) {};
static Evas_Object * elm_gen_item_content_get_cb(void * data, Evas_Object * obj, const char * part);
static Eina_Bool elm_gen_item_state_get_cb(void * data, Evas_Object * obj, const char * part);
static void elm_gen_item_del_cb(void *data, Evas_Object *obj);
+ static Eina_Bool elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key);
private:
ListView *m_pOwner;
*/
void demoteItem(ListItem &item);
+ /**
+ * @brief Set filter for items
+ * @param[in] key The filter key
+ */
+ void setFilter(void *key);
+
/**
* @brief Enables(disables selection mode). Makes all list-view items to show(hide) a check-box.
* @param[in] check if true makes all items to show checkbox, otherwise make them to hide it.
m_pGenlistItemClass->func.state_get = &ListItem::elm_gen_item_state_get_cb;
m_pGenlistItemClass->func.del = &ListItem::elm_gen_item_del_cb;
m_pGenlistItemClass->func.content_get = &ListItem::elm_gen_item_content_get_cb;
+ m_pGenlistItemClass->func.filter_get = &ListItem::elm_gen_item_filter_cb;
}
void ListItemStyle::unregisterCallback()
m_pGenlistItemClass->func.state_get = nullptr;
m_pGenlistItemClass->func.del = nullptr;
m_pGenlistItemClass->func.content_get = nullptr;
+ m_pGenlistItemClass->func.filter_get = nullptr;
}
// ListItemClass:
ListItem *self = static_cast<ListItem*>(data);
if(!self)
- {
return nullptr;
- }
if(self->getOwner()->getCheckMode())
{
return self->getContent(*self, part);
}
+Eina_Bool ListItem::elm_gen_item_filter_cb(void *data, Evas_Object *obj, void *key)
+{
+ ListItem *self = static_cast<ListItem*>(data);
+ return self ? self->getFilter(*self, key) : false;
+}
+
Evas_Object *ListItem::addCheck()
{
Evas_Object *check = elm_check_add(*getOwner());
return std::string();
}
+bool ListItem::getFilter(ListItem &item, void *key)
+{
+ return true;
+}
+
Evas_Object* ListItem::getContent(ListItem &item, const char* part)
{
return nullptr;
elm_genlist_item_demote(item);
}
+void ListView::setFilter(void *key)
+{
+ elm_genlist_filter_set(getEo(), key);
+}
+
void ListView::notifyListener(void *data, Evas_Object *obj, void *event_info, ListenerMethod method)
{
ListItem *item = ListItem::staticCast<ListItem*>(event_info);
#include "MessageMms.h"
#include "WorkingDir.h"
#include "AppControlCompose.h"
-#include "Page.h"
#include "AttachmentHandler.h"
+#include "ComposeListItem.h"
#include <list>
#include <queue>
class PopupList;
class ConvList;
- // TODO: move page(controller) methods to Page class
class Body
: public BodyView
, private IAttachmentHandlerListener
+ , private IComposeListItemListener
{
public:
- Body(App &app, WorkingDirRef workingDir, ConvList &convList);
+ Body(Evas_Object *parent, App &app, WorkingDirRef workingDir, ConvList &convList);
virtual ~Body();
- void create(Evas_Object *parent);
void setListener(IBodyListener *listener);
void enableAutoFocusForAttachments(bool focus);
void addMedia(const std::list<std::string> &fileList);
void addMedia(const std::string &filePath);
-
+ void clear();
+ bool isEmpty() const;
bool isMms();
void setMmsRecipFlag(bool value);
const MsgTextMetric &getTextMetric();
long long getMsgSize();
- int getAttachmentsCountTotal() const;
void read(Message &msg);
void write(const Message &msg);
void execCmd(const AppControlComposeRef &cmd);
- Page &getDefaultPage();
private:
- Page &createPage();
+ ComposeListItem &getComposeItem();
+ const ComposeListItem &getComposeItem() const;
+ void notifyContentChanged();
+ void updateTextMetricIfNeeded();
void showTooLargePopup(const std::list <std::string> &tooBigFiles);
void showTooMuchAttachedPopup(int willBeAttached);
void showTooMuchAttachedPopup();
void read(MessageSMS &msg);
void read(MessageMms &msg);
void readAttachments(MessageMms &msg);
+ void readText(MessageMms &msg);
void write(const MessageSMS &msg);
void write(const MessageMms &msg);
+ void writeText(const Message &msg);
void writeAttachments(const MessageMms &msg);
- void writeTextToFile(TextPageViewItem &item);
+ void writeTextToFile();
void addAttachment( const std::string &filePath, const std::string &fileName = "");
void runFileProcessing();
+ PopupList &createPopupList(const std::string &title);
+
void onTooLargePopupDel(Evas_Object *obj, void *eventInfo);
void onTooMuchAttachedPopupDel(Evas_Object *obj, void *eventInfo);
void onResizingPopupDel(Evas_Object *obj, void *eventInfo);
// BodyView:
virtual void onContentChanged();
- virtual void onItemDelete(PageViewItem &item);
- virtual void onItemDelete(BodyAttachmentViewItem &item);
- virtual void onMaxLengthReached(TextPageViewItem &item);
- virtual void onCheckBoundaryText(TextPageViewItem &item, char **text);
+ virtual void onMaxLengthReached();
+ virtual void onCheckBoundaryText(char **text);
- //IMediaPageViewItemListener
- virtual void onClicked(MediaPageViewItem &item);
-
- //IBodyAttachmentViewListener
- virtual void onClicked(BodyAttachmentViewItem &item);
-
- PopupList &createPopupList(const std::string &title);
- void onRemoveMediaItemPressed(PopupListItem &item);
- void onRemoveBodyItemPressed(PopupListItem &item);
+ // IComposeListItemListener:
+ virtual void onAttachmentAdded(const std::list<std::string> &files);
+ virtual void onAttachmentDeleted(const std::list<std::string> &files);
//IAttachmentHandlerListener
virtual long long onFreeSpaceRequest();
std::queue<std::string> m_SelectedFiles;
bool m_AutoFocusForAttachments;
ConvList &m_ConvList;
+ std::string m_MmsTextFilePath;
+ MsgTextMetric m_TextMetric;
+ bool m_TextMetricUpdated;
+ int m_Utf8TextSize;
};
class IBodyListener
+++ /dev/null
-/*
- * Copyright (c) 2009-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 Page_h_
-#define Page_h_
-
-#include "PageView.h"
-#include "MsgEngine.h"
-#include "WorkingDir.h"
-#include "TextPageViewItem.h"
-
-namespace Msg
-{
- class Body;
- class Page
- : public PageView
- {
- public:
-
-
- public:
- Page(Body &parent, WorkingDirRef workingDir);
- virtual ~Page();
-
- int getAttachmentsCount() const;
- const MsgTextMetric &getTextMetric();
- long long getSize();
- bool isMms();
- void read(MsgPage &msgPage);
- void write(const MsgPage &msgPage);
- bool addMedia(const std::string &filePath);
-
- private:
- void updateMsgMetricIfNeeded();
-
- void readText(MsgPage &msgPage);
- void readSound(MsgPage &msgPage);
- void readImage(MsgPage &msgPage);
- void readVideo(MsgPage &msgPage);
-
- void writeText(const MsgMedia &msgMedia);
- void writeImage(const MsgMedia &msgMedia);
- void writeVideo(const MsgMedia &msgMedia);
- void writeSound(const MsgMedia &msgMedia);
- void writeTextToFile(TextPageViewItem &item);
-
- void addVideo(const std::string &videoPath);
- void addImage(const std::string &filePath);
- void addSound(const std::string &filePath, const std::string &fileName = "");
-
- private:
- Body &m_Body;
- MsgTextMetric m_MsgMetric;
- WorkingDirRef m_WorkingDir;
- int m_Utf8TextSize;
- };
-}
-
-#endif /* Page_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 PopupBodyAttachmentListItem_h_
-#define PopupBodyAttachmentListItem_h_
-
-#include "PopupListItem.h"
-
-namespace Msg
-{
- class PageViewItem;
- class BodyAttachmentViewItem;
-
- class PopupBodyAttachmentListItem
- : public PopupTextListItem
- {
- public:
- PopupBodyAttachmentListItem(PopupList &parent, const std::string &text,
- PageViewItem &pageItem, PopupListItemPressedCb cb, void *userData);
-
- virtual ~PopupBodyAttachmentListItem();
-
- PageViewItem &getPageItem();
-
- private:
- PageViewItem &m_PageItem;
- };
-
- //TODO: rename this class
- class BodyAttachmentListItem
- : public PopupTextListItem
- {
- public:
- BodyAttachmentListItem(PopupList &parent, const std::string &text,
- BodyAttachmentViewItem &bodyItem, PopupListItemPressedCb cb, void *userData);
-
- virtual ~BodyAttachmentListItem();
-
- BodyAttachmentViewItem &getBodyItem();
-
- private:
- BodyAttachmentViewItem &m_BodyItem;
- };
-
-}
-
-#endif /* PopupBodyAttachmentListItem_h_ */
#include "App.h"
#include "Body.h"
-#include "PageView.h"
#include "FileUtils.h"
-#include "TextPageViewItem.h"
-#include "ImagePageViewItem.h"
-#include "VideoPageViewItem.h"
#include "MediaType.h"
#include "MsgEngine.h"
#include "Logger.h"
#include "MediaUtils.h"
#include "PopupList.h"
-#include "PopupBodyAttachmentListItem.h"
#include "ComposeListItem.h"
#include "ConvList.h"
{
const std::string contactFileName = "Contact.vcf";
const std::string contactsFileName = "Contacts.vcf";
-
- inline TextPageViewItem *getTextItem(const PageView &page)
- {
- return page ? static_cast<TextPageViewItem*>(page.getItem(PageViewItem::TextType)) : nullptr;
- }
-
- PageViewItem::Type msgMediaTypeToPageItemType(MsgMedia::Type type)
- {
- switch(type)
- {
- case MsgMedia::ImageType:
- return PageViewItem::ImageType;
- case MsgMedia::AudioType:
- return PageViewItem::SoundType;
- case MsgMedia::VideoType:
- return PageViewItem::VideoType;
- case MsgMedia::TextType:
- return PageViewItem::TextType;
- default:
- return PageViewItem::UnknownType;
- }
- }
}
-Body::Body(App &app, WorkingDirRef workingDir, ConvList &convList)
- : BodyView()
+Body::Body(Evas_Object *parent, App &app, WorkingDirRef workingDir, ConvList &convList)
+ : BodyView(parent, app.getMsgEngine().getSettings().getMaxMsgTextLen())
, m_pListener(nullptr)
, m_App(app)
, m_WorkingDir(workingDir)
, m_AttachmentHandler(workingDir)
, m_AutoFocusForAttachments(true)
, m_ConvList(convList)
+ , m_TextMetric()
+ , m_TextMetricUpdated(false)
+ , m_Utf8TextSize(0)
{
m_AttachmentHandler.setListener(this);
}
-void Body::create(Evas_Object *parent)
-{
- BodyView::create(parent);
-
-}
-
-Page &Body::getDefaultPage()
-{
- return static_cast<Page&>(BodyView::getDefaultPage());
-}
-
Body::~Body()
{
if(m_pOnChangedIdler)
}
}
-Page &Body::createPage()
+bool Body::isEmpty() const
{
- Page *page = new Page(*this, m_WorkingDir);
- BodyView::addText(*page, m_App.getMsgEngine().getSettings().getMaxMsgTextLen());
- return *page;
+ return BodyView::isEmpty() && getComposeItem().isEmpty();
+}
+
+void Body::clear()
+{
+ BodyView::clear();
+ getComposeItem().clear();
}
void Body::setListener(IBodyListener *listener)
m_pListener = listener;
}
+ComposeListItem &Body::getComposeItem()
+{
+ ComposeListItem &item = m_ConvList.getComposeItem();
+ if(item.getListener() != this)
+ item.setListener(this);
+ return item;
+}
+
+const ComposeListItem &Body::getComposeItem() const
+{
+ return const_cast<Body*>(this)->getComposeItem();
+}
+
void Body::enableAutoFocusForAttachments(bool focus)
{
m_AutoFocusForAttachments = focus;
bool Body::isMms()
{
- if(m_MmsRecipFlag)
- return true;
-
- auto pages = getPages();
-
- if(pages.size() > 1)
- return true;
-
- if(getAttachments().size() > 0)
+ if(m_MmsRecipFlag || !getComposeItem().isEmpty())
return true;
- for(PageView *page : pages)
- {
- if(static_cast<Page*>(page)->isMms())
- return true;
- }
-
- return false;
+ updateTextMetricIfNeeded();
+ return m_TextMetric.isMms;
}
void Body::setMmsRecipFlag(bool value)
m_MmsRecipFlag = value;
}
+void Body::updateTextMetricIfNeeded()
+{
+ if(m_TextMetricUpdated)
+ {
+ std::string text = getPlainUtf8Text();
+ m_Utf8TextSize = text.length();
+ MsgEngine::calculateTextMetric(text, m_TextMetric);
+ m_TextMetricUpdated = false;
+ }
+}
+
const MsgTextMetric &Body::getTextMetric()
{
- return static_cast<Page&>(getDefaultPage()).getTextMetric();
+ updateTextMetricIfNeeded();
+ return m_TextMetric;
}
long long Body::getMsgSize()
{
- // Attachments:
- long long size = 0;
- auto attachments = getAttachments();
- for(BodyAttachmentViewItem *attachment : attachments)
- {
- long long fileSize = attachment->getFileSize();
- if(fileSize > 0)
- size += fileSize;
- }
+ long long totalSize = 0;
- // Pages:
- auto pages = getPages();
- for(PageView *pageView : pages)
+ // Attachments:
+ auto attachments = getComposeItem().getAttachments();
+ for(auto *attachment : attachments)
{
- size += static_cast<Page*>(pageView)->getSize();
+ totalSize += attachment->getFileSize();
}
- return size;
-}
-
-int Body::getAttachmentsCountTotal() const
-{
- int count = getAttachments().size();
-
- auto pages = getPages();
- for(PageView *pageView : pages)
- count += static_cast<Page*>(pageView)->getAttachmentsCount();
+ // Text:
+ updateTextMetricIfNeeded();
+ totalSize += isMms() ? m_Utf8TextSize : m_TextMetric.bytes;
- return count;
+ return totalSize;
}
void Body::read(Message &msg)
void Body::write(const MessageSMS &msg)
{
- TextPageViewItem *textItem = getTextItem(getDefaultPage());
- assert(textItem);
- if(textItem)
- textItem->setText(msg.getText());
+ setText(msg.getText());
}
void Body::write(const MessageMms &msg)
{
- // Pages:
- auto &pageList = msg.getPageList();
- for(int i = 0; i < pageList.getLength(); ++i)
- {
- Page &page = i == 0 ? getDefaultPage() : static_cast<Page&>(*addPage());
- page.write(pageList[i]);
- }
-
- // Attachments:
+ writeText(msg);
writeAttachments(msg);
}
+void Body::writeText(const Message &msg)
+{
+ setText(msg.getText());
+}
+
void Body::writeAttachments(const MessageMms &msg)
{
- auto &attachmentList = msg.getAttachmentList();
- for(int i = 0; i < attachmentList.getLength(); ++i)
+ // Pages:
+ const MsgPageList &pages = msg.getPageList();
+ int pageCount = pages.getLength();
+ for(int pageIndex = 0; pageIndex < pageCount; ++pageIndex)
{
- const MsgAttachment &attachment = attachmentList[i];
- addAttachment(attachment.getFilePath(), attachment.getFileName());
+ const MsgPage &page = pages[pageIndex];
+
+ // Media:
+ const MsgMediaList &mediaList = page.getMediaList();
+ int mediaCount = mediaList.getLength();
+ for(int mediaIndex = 0; mediaIndex < mediaCount; ++mediaIndex)
+ {
+ const MsgMedia &media = mediaList[mediaIndex];
+ std::string filePath = media.getFilePath();
+ if(!filePath.empty())
+ {
+ std::string mime = FileUtils::getMimeType(filePath);
+ if(mime != "text/plain") // Skip text on page
+ {
+ std::string newFilePath = m_WorkingDir->addFile(filePath);
+ getComposeItem().addAttachment(newFilePath);
+ }
+ }
+ }
+ }
+
+ // Attachments:
+ const MsgAttachmentList &attachments = msg.getAttachmentList();
+ int attachmentCount = attachments.getLength();
+ for(int i = 0; i < attachmentCount; ++i)
+ {
+ const MsgAttachment &attachment = attachments[i];
+ std::string filePath = attachment.getFilePath();
+ if(!filePath.empty())
+ {
+ std::string mime = FileUtils::getMimeType(filePath);
+ if(mime != "application/smil") // Skip SMIL layout
+ {
+ std::string newFilePath = m_WorkingDir->addFile(filePath);
+ getComposeItem().addAttachment(newFilePath);
+ }
+ }
}
}
-void Body::writeTextToFile(TextPageViewItem &item)
+void Body::writeTextToFile()
{
- if(item.getResourcePath().empty())
- item.setResourcePath(m_WorkingDir->addTextFile(item.getPlainUtf8Text()));
+ if(m_MmsTextFilePath.empty())
+ m_MmsTextFilePath = m_WorkingDir->addTextFile(getPlainUtf8Text());
else
- FileUtils::writeTextFile(item.getResourcePath(), item.getPlainUtf8Text());
+ FileUtils::writeTextFile(m_MmsTextFilePath, getPlainUtf8Text());
}
void Body::read(MessageSMS &msg)
{
- TextPageViewItem *textItem = getTextItem(getDefaultPage());
- assert(textItem);
- if(textItem)
- msg.setText(textItem->getPlainUtf8Text());
+ msg.setText(getPlainUtf8Text());
}
void Body::read(MessageMms &msg)
{
- // Pages:
- auto pages = getPages();
- for(PageView *page : pages)
- {
- MsgPage &msgPage = msg.addPage();
- static_cast<Page*>(page)->read(msgPage);
- }
-
- // Attachments:
readAttachments(msg);
+ readText(msg);
}
void Body::readAttachments(MessageMms &msg)
{
- auto attachments = getAttachments();
- for(BodyAttachmentViewItem *attachView : attachments)
+ const int defaultPageDuration = 5; // sec
+ const auto &attachments = getComposeItem().getAttachments();
+ for(auto *attachment : attachments)
+ {
+ const std::string &filePath = attachment->getFilePath();
+ if(!filePath.empty())
+ {
+ MsgPage &msgPage = msg.addPage();
+ msgPage.setPageDuration(defaultPageDuration);
+ MsgMedia &media = msgPage.addMedia();
+ media.setFilePath(filePath);
+ media.setFileName(FileUtils::getFileName(filePath));
+ }
+ }
+}
+
+void Body::readText(MessageMms &msg)
+{
+ if(!isEmpty())
{
- std::string resPath= attachView->getResourcePath();
- std::string mime = getMsgMediaTypeByFileExt(resPath).mime;
- long long fileSize = FileUtils::getFileSize(resPath);
-
- MsgAttachment &msgAttach = msg.addAttachment();
- msgAttach.setFilePath(resPath);
- msgAttach.setFileName(attachView->getFileName());
- msgAttach.setFileSize((int)fileSize);
+ writeTextToFile();
+ MsgPage &msgPage = msg.addPage();
+ MsgMedia &media = msgPage.addMedia();
+ media.setFilePath(m_MmsTextFilePath);
}
}
void Body::execCmd(const AppControlComposeRef &cmd)
{
- TextPageViewItem *textItem = getTextItem(getDefaultPage());
- if(textItem)
- textItem->setText(cmd->getMessageText());
-
+ setText(cmd->getMessageText());
std::list<std::string> path = cmd->getFileList();
if(!cmd->getVcfInfo().contactsIdList.empty())
path.push_back(createVcfFile(cmd));
{
std::string newFilePath = m_WorkingDir->addFile(filePath);
if(!newFilePath.empty())
- {
- long long fileSize = FileUtils::getFileSize(newFilePath);
- std::string newFileName = fileName.empty() ? FileUtils::getFileName(filePath) : fileName;
- BodyView::addAttachment(newFilePath, fileSize, newFileName);
- m_ConvList.getComposeItem()->addAttachment(newFilePath);
- }
-}
-
-void Body::onItemDelete(PageViewItem &item)
-{
- MSG_LOG("");
- if(auto video = dynamic_cast<VideoPageViewItem*>(&item))
- m_WorkingDir->removeFile(video->getImagePath());
-
- m_WorkingDir->removeFile(item.getResourcePath());
-}
-
-void Body::onItemDelete(BodyAttachmentViewItem &item)
-{
- m_WorkingDir->removeFile(item.getResourcePath());
+ getComposeItem().addAttachment(newFilePath);
}
-void Body::onMaxLengthReached(TextPageViewItem &item)
+void Body::onMaxLengthReached()
{
MSG_LOG("");
showMaxCharactersPopup();
}
-void Body::onCheckBoundaryText(TextPageViewItem &item, char **text)
+void Body::onCheckBoundaryText(char **text)
{
MSG_LOG("");
if(isMms())
}
}
-void Body::onClicked(MediaPageViewItem &item)
-{
- MSG_LOG("");
- PopupList &popupList = createPopupList(item.getFileName());
- popupList.appendItem(*new PopupBodyAttachmentListItem(popupList, msg("IDS_MSGF_OPT_REMOVE"), item,
- POPUPLIST_ITEM_PRESSED_CB(Body, onRemoveMediaItemPressed), this));
- popupList.show();
-}
-
-void Body::onClicked(BodyAttachmentViewItem &item)
-{
- MSG_LOG("");
- PopupList &popupList = createPopupList(item.getFileName());
-
- popupList.appendItem(*new BodyAttachmentListItem(popupList, msg("IDS_MSGF_OPT_REMOVE"), item,
- POPUPLIST_ITEM_PRESSED_CB(Body, onRemoveBodyItemPressed), this));
- popupList.show();
-}
-
PopupList &Body::createPopupList(const std::string &title)
{
PopupList &popupList = m_App.getPopupManager().getPopupList();
notification_status_message_post(notifText.c_str());
}
-void Body::onRemoveMediaItemPressed(PopupListItem &item)
-{
- MSG_LOG("");
- PopupBodyAttachmentListItem &listItem = static_cast<PopupBodyAttachmentListItem&>(item);
- PageViewItem &pageViewItem = listItem.getPageItem();
- pageViewItem.destroy();
- item.getParent().destroy();
-}
-
-void Body::onRemoveBodyItemPressed(PopupListItem &item)
-{
- MSG_LOG("");
- BodyAttachmentListItem &listItem = static_cast<BodyAttachmentListItem&>(item);
- BodyAttachmentViewItem &bodyItem = listItem.getBodyItem();
- bodyItem.destroy();
- item.getParent().destroy();
-}
-
void Body::onTooLargePopupDel(Evas_Object *obj, void *eventInfo)
{
MSG_LOG("");
return path;
}
-void Body::onContentChanged()
+void Body::notifyContentChanged()
{
if(!m_pOnChangedIdler)
{
}
}
+void Body::onContentChanged()
+{
+ m_TextMetricUpdated = true;
+ notifyContentChanged();
+}
+
+void Body::onAttachmentAdded(const std::list<std::string> &files)
+{
+ notifyContentChanged();
+}
+
+void Body::onAttachmentDeleted(const std::list<std::string> &files)
+{
+ for(const std::string &file : files)
+ {
+ m_WorkingDir->removeFile(file);
+ }
+ notifyContentChanged();
+}
+
void Body::onFileReady(const std::string &filePath)
{
- int numAttached = getAttachmentsCountTotal();
+ int numAttached = getComposeItem().getAttachments().size();
int numAttachMax = m_App.getMsgEngine().getSettings().getAttachmentsMaxCount();
if(numAttached == numAttachMax)
{
MediaTypeData mediaType = getMsgMediaTypeByFileExt(filePath);
MSG_LOG("Media type: ", mediaType.mime);
- m_ConvList.getComposeItem()->addAttachment(filePath);
-
- Page *page = nullptr;
- if(mediaType.type != MsgMedia::UnknownType && mediaType.type != MsgMedia::TextType)
- {
- page = static_cast<Page*>(getPageForMedia(msgMediaTypeToPageItemType(mediaType.type)));
- if(!page)
- return;
-
- page->addMedia(filePath);
-
- }
- else
- {
- addAttachment(filePath);
- page = &getDefaultPage();
- }
+ getComposeItem().addAttachment(filePath);
- if(page && m_AutoFocusForAttachments)
- BodyView::setFocus(*page, true); // TODO: check for multi insertion
+ if(m_AutoFocusForAttachments)
+ BodyView::setFocus(true);
m_SelectedFiles.pop();
if(!m_SelectedFiles.empty())
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "Page.h"
-#include "PageView.h"
-#include "Body.h"
-#include "Logger.h"
-#include "MsgEngine.h"
-#include "TextPageViewItem.h"
-#include "MediaPageViewItem.h"
-#include "FileUtils.h"
-#include "MediaUtils.h"
-#include "MediaType.h"
-
-using namespace Msg;
-
-namespace
-{
- const int defaultPageDuration = 5; // sec
-}
-
-Page::Page(Body &parent, WorkingDirRef workingDir)
- : PageView(parent)
- , m_Body(parent)
- , m_MsgMetric()
- , m_WorkingDir(workingDir)
- , m_Utf8TextSize(0)
-{
-}
-
-Page::~Page()
-{
-}
-
-const MsgTextMetric &Page::getTextMetric()
-{
- updateMsgMetricIfNeeded();
- return m_MsgMetric;
-}
-
-void Page::updateMsgMetricIfNeeded()
-{
- TextPageViewItem *item = static_cast<TextPageViewItem*>(getItem(PageViewItem::TextType));
- if(item)
- {
- if(item->hasChanged())
- {
- std::string text = item->getPlainUtf8Text();
- m_Utf8TextSize = text.length();
- MsgEngine::calculateTextMetric(text, m_MsgMetric);
- item->resetChangedFlag();
- }
- }
- else
- {
- m_MsgMetric.reset();
- }
-}
-
-long long Page::getSize()
-{
- long long totalSize = 0;
- auto items = getItems();
- for(PageViewItem *item : items)
- {
- MediaPageViewItem *mediaItem = dynamic_cast<MediaPageViewItem*>(item);
- if(mediaItem)
- {
- int size = mediaItem->getFileSize();
- if(size > 0)
- totalSize += size;
- }
- }
- updateMsgMetricIfNeeded();
- totalSize += m_Body.isMms() ? m_Utf8TextSize : m_MsgMetric.bytes;
- return totalSize;
-}
-
-int Page::getAttachmentsCount() const
-{
- int res = 0;
- auto items = getItems();
- for(PageViewItem *item : items)
- {
- MediaPageViewItem *mediaItem = dynamic_cast<MediaPageViewItem*>(item);
- if(mediaItem)
- ++res;
- }
- return res;
-}
-
-bool Page::isMms()
-{
- auto pageItems = getItems();
- for(PageViewItem *pageItem : pageItems)
- {
- PageViewItem::Type itemType = pageItem->getType();
- if(itemType != PageViewItem::TextType)
- return true;
- }
-
- updateMsgMetricIfNeeded();
- return m_MsgMetric.isMms;
-}
-
-bool Page::addMedia(const std::string &filePath)
-{
- MediaTypeData typeData = getMsgMediaTypeByFileExt(filePath);
- MSG_LOG("Media type: ", typeData.mime);
-
- switch(typeData.type)
- {
- case MsgMedia::ImageType:
- {
- addImage(filePath);
- break;
- }
-
- case MsgMedia::AudioType:
- {
- addSound(filePath);
- break;
- }
-
- case MsgMedia::VideoType:
- {
- addVideo(filePath);
- break;
- }
-
- default:
- MSG_LOG_WARN("Can't add type: ", typeData.mime);
- return false;
- break;
- }
-
- return true;
-}
-
-void Page::write(const MsgPage &msgPage)
-{
- auto &mediaList = msgPage.getMediaList();
- for(int i = 0; i < mediaList.getLength(); ++i)
- {
- const MsgMedia &msgMedia = mediaList[i];
- switch(msgMedia.getType())
- {
- case MsgMedia::TextType:
- writeText(msgMedia);
- break;
- case MsgMedia::ImageType:
- writeImage(msgMedia);
- break;
- case MsgMedia::AudioType:
- writeSound(msgMedia);
- break;
- case MsgMedia::VideoType:
- writeVideo(msgMedia);
- break;
-
- default:
- MSG_LOG_WARN("Skip unsupported Smil type");
- break;
- }
- }
-}
-
-void Page::writeText(const MsgMedia &msgMedia)
-{
- TextPageViewItem *textItem = static_cast<TextPageViewItem*>(getItem(PageViewItem::TextType));;
- assert(textItem);
- if(textItem)
- textItem->setText(FileUtils::readTextFile(msgMedia.getFilePath()));
-}
-
-void Page::writeImage(const MsgMedia &msgMedia)
-{
- addImage(msgMedia.getFilePath());
-}
-
-void Page::writeVideo(const MsgMedia &msgMedia)
-{
- addVideo(msgMedia.getFilePath());
-}
-
-void Page::writeSound(const MsgMedia &msgMedia)
-{
- addSound(msgMedia.getFilePath(), msgMedia.getFileName());
-}
-
-void Page::writeTextToFile(TextPageViewItem &item)
-{
- if(item.getResourcePath().empty())
- item.setResourcePath(m_WorkingDir->addTextFile(item.getPlainUtf8Text()));
- else
- FileUtils::writeTextFile(item.getResourcePath(), item.getPlainUtf8Text());
-}
-
-void Page::read(MsgPage &msgPage)
-{
- readText(msgPage);
- readImage(msgPage);
- readVideo(msgPage);
- readSound(msgPage);
-
- if(msgPage.getPageDuration() < defaultPageDuration)
- msgPage.setPageDuration(defaultPageDuration);
-}
-
-void Page::readText(MsgPage &msgPage)
-{
- TextPageViewItem *textItem = static_cast<TextPageViewItem*>(getItem(PageViewItem::TextType));
- if(textItem && !textItem->isEmpty())
- {
- writeTextToFile(*textItem);
- MsgMedia &media = msgPage.addMedia();
- media.setFilePath(textItem->getResourcePath());
- }
-}
-
-void Page::readSound(MsgPage &msgPage)
-{
- SoundPageViewItem *soundItem = static_cast<SoundPageViewItem*>(getItem(PageViewItem::SoundType));
- if(soundItem)
- {
- MsgMedia &media = msgPage.addMedia();
- media.setFilePath(soundItem->getResourcePath());
- int sec = MediaUtils::getDurationSec(soundItem->getResourcePath());
- if(msgPage.getPageDuration() < sec)
- msgPage.setPageDuration(sec);
- }
-}
-
-void Page::readImage(MsgPage &msgPage)
-{
- ImagePageViewItem *imgItem = static_cast<ImagePageViewItem*>(getItem(PageViewItem::ImageType));
- if(imgItem)
- {
- MsgMedia &media = msgPage.addMedia();
- media.setFilePath(imgItem->getResourcePath());
- }
-}
-
-void Page::readVideo(MsgPage &msgPage)
-{
- VideoPageViewItem *videoItem = static_cast<VideoPageViewItem*>(getItem(PageViewItem::VideoType));
- if(videoItem)
- {
- MsgMedia &media = msgPage.addMedia();
- media.setFilePath(videoItem->getResourcePath());
- int sec = MediaUtils::getDurationSec(videoItem->getResourcePath());
- if(msgPage.getPageDuration() < sec)
- msgPage.setPageDuration(sec);
- }
-}
-
-void Page::addVideo(const std::string &videoFilePath)
-{
- const std::string thumbFileName = "thumbnail.jpeg";
- std::string thumbFilePath = m_WorkingDir->genUniqueFilePath(thumbFileName);
- std::string newVideoFilePath = m_WorkingDir->addFile(videoFilePath);
-
- if(!newVideoFilePath.empty())
- {
- long long fileSize = FileUtils::getFileSize(newVideoFilePath);
- // FIXME: if getVideoFrame returns false ?
- MediaUtils::getVideoFrame(videoFilePath, thumbFilePath);
- m_Body.addVideo(*this, newVideoFilePath, fileSize, thumbFilePath);
- }
-}
-
-void Page::addImage(const std::string &filePath)
-{
- std::string newFilePath = m_WorkingDir->addFile(filePath);
- if(!newFilePath.empty())
- {
- long long fileSize = FileUtils::getFileSize(newFilePath);
- m_Body.addImage(*this, newFilePath, fileSize);
- }
-}
-
-void Page::addSound(const std::string &filePath, const std::string &fileName)
-{
- std::string newFilePath = m_WorkingDir->addFile(filePath);
- if(!newFilePath.empty())
- {
- long long fileSize = FileUtils::getFileSize(newFilePath);
- std::string newFileName = fileName.empty() ? FileUtils::getFileName(filePath) : fileName;
- m_Body.addSound(*this, newFilePath, fileSize, newFileName);
- }
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "PopupBodyAttachmentListItem.h"
-#include "BodyAttachmentViewItem.h"
-
-using namespace Msg;
-
-PopupBodyAttachmentListItem::PopupBodyAttachmentListItem(PopupList &parent,
- const std::string &text,
- PageViewItem &pageItem,
- PopupListItemPressedCb cb,
- void *userData)
- : PopupTextListItem(parent, text, cb, userData)
- , m_PageItem(pageItem)
-{
-}
-
-PopupBodyAttachmentListItem::~PopupBodyAttachmentListItem()
-{
-}
-
-PageViewItem &PopupBodyAttachmentListItem::getPageItem()
-{
- return m_PageItem;
-}
-
-BodyAttachmentListItem::BodyAttachmentListItem(PopupList &parent,
- const std::string &text,
- BodyAttachmentViewItem &bodyItem,
- PopupListItemPressedCb cb,
- void *userData)
- : PopupTextListItem(parent, text, cb, userData)
- , m_BodyItem(bodyItem)
-{
-}
-
-BodyAttachmentListItem::~BodyAttachmentListItem()
-{
-}
-
-BodyAttachmentViewItem &BodyAttachmentListItem::getBodyItem()
-{
- return m_BodyItem;
-}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 BodyAttachmentViewItem_h_
-#define BodyAttachmentViewItem_h_
-
-#include "BodyViewItem.h"
-
-namespace Msg
-{
- class BodyView;
- class IBodyAttachmentViewListener;
-
- class BodyAttachmentViewItem
- : public BodyViewItem
- {
- public:
- BodyAttachmentViewItem(BodyView &parent, const std::string &resourePath, long long fileSize, const std::string &dispName = "");
- virtual ~BodyAttachmentViewItem();
-
- void setListener(IBodyAttachmentViewListener *listener);
- const std::string &getResourcePath() const;
- const std::string &getFileName() const;
- long long getFileSize() const;
-
- private:
- Evas_Object *createLayout(Evas_Object *parent);
- Evas_Object *createButton(Evas_Object *parent);
- Evas_Object *createLabel(Evas_Object *parent, const std::string &name);
-
- private:
- Evas_Object *m_pLayaout;
- IBodyAttachmentViewListener *m_pListener;
- const std::string m_ResourePath;
- std::string m_FileName;
- long long m_FileSize;
- };
-
- class IBodyAttachmentViewListener
- {
- public:
- virtual ~IBodyAttachmentViewListener() {}
- virtual void onClicked(BodyAttachmentViewItem &item) {};
- virtual void onDelete(BodyAttachmentViewItem &item) {};
- };
-}
-
-#endif /* BodyAttachmentViewItem_h_ */
#define BodyView_h_
#include "View.h"
-#include "BodyViewItem.h"
-#include "MediaPageViewItem.h"
-#include "TextPageViewItem.h"
-#include "ImagePageViewItem.h"
-#include "SoundPageViewItem.h"
-#include "VideoPageViewItem.h"
-#include "BodyAttachmentViewItem.h"
#include <vector>
namespace Msg
{
- class PageView;
- class PageSeparator;
-
- typedef std::vector<PageView*> PageViewCollection;
- typedef std::vector<BodyAttachmentViewItem*> BodyAttachmentCollection;
- typedef std::vector<BodyViewItem*> BodyViewItemCollection;
-
class BodyView
: public View
- , private ITextPageViewItemListener
- , private IMediaPageViewItemListener
- , private IBodyAttachmentViewListener
{
- friend class PageView;
-
public:
- BodyView();
+ BodyView(Evas_Object *parent, int maxCharCount);
virtual ~BodyView();
- void create(Evas_Object *parent);
bool isEmpty() const;
void clear();
void setFocus(bool focus);
- const PageView &getDefaultPage() const;
- PageView &getDefaultPage();
- PageViewCollection getPages() const;
- int getPageCount() const;
- PageView *getNextPage(PageView &page) const;
- PageView *getPrevPage(PageView &page) const;
- PageView *addPage();
- BodyAttachmentCollection getAttachments() const;
-
- TextPageViewItem *addText(PageView &page, int maxCharCount);
- ImagePageViewItem *addImage(PageView &page, const std::string &filePath, long long fileSize);
- VideoPageViewItem *addVideo(PageView &page, const std::string &filePath, long long fileSize, const std::string &imagePath);
- SoundPageViewItem *addSound(PageView &page, const std::string &filePath, long long fileSize, const std::string &dispName = "");
+ void setText(const std::string &text);
+ std::string getText() const;
+ std::string getPlainUtf8Text() const;
protected:
- virtual PageView &createPage() = 0;
-
- BodyAttachmentViewItem *addAttachment(const std::string &filePath, long long fileSize, const std::string &dispName = "");
- PageView *getPageForMedia(PageViewItem::Type type);
- void setFocus(PageView &page, bool focus);
-
- private:
- /*====Input signals====*/
-
- void onContentBoxGeometryChanged(Evas_Object *obj, void *event_info);
-
- // ITextPageViewItemListener:
- virtual void onCursorChanged(TextPageViewItem &item);
- virtual void onFocused(TextPageViewItem &item);
- virtual void onUnfocused(TextPageViewItem &item);
- virtual void onPreeditChanged(TextPageViewItem &item);
- virtual void onPress(TextPageViewItem &item);
- virtual void onClicked(TextPageViewItem &item);
- virtual void onKeyDown(TextPageViewItem &obj, Evas_Event_Key_Down &event);
- virtual void onKeyUp(TextPageViewItem &obj, Evas_Event_Key_Up &event);
- virtual void onChanged(TextPageViewItem &item);
-
- // IMediaPageViewItemListener:
- virtual void onDelete(PageViewItem &item);
- virtual void onPressed(MediaPageViewItem &item);
- virtual void onUnpressed(MediaPageViewItem &item);
- virtual void onFocused(MediaPageViewItem &item);
- virtual void onUnfocused(MediaPageViewItem &item);
- virtual void onKeyDown(MediaPageViewItem &item, Evas_Event_Key_Down &event);
- virtual void onKeyUp(MediaPageViewItem &item, Evas_Event_Key_Up &event);
-
- // IBodyAttachmentViewListener:
- virtual void onDelete(BodyAttachmentViewItem &item);
-
- /*====Output signals====*/
virtual void onContentChanged() {};
- virtual void onItemDelete(PageViewItem &item) {};
- virtual void onItemDelete(BodyAttachmentViewItem &item) {};
- virtual void onClicked(BodyAttachmentViewItem &item) {};
- virtual void onClicked(MediaPageViewItem &item) {};
+ virtual void onMaxLengthReached() {};
+ virtual void onCheckBoundaryText(char **text) {};
private:
- template<typename T>
- std::vector<T*> getItems() const;
- BodyViewItemCollection getAllItems() const;
- int getItemCount(BodyViewItem::Type type) const;
- void showInputPanel(PageView &page, bool show);
- void showInputPanel(PageViewItem &pageItem, bool show);
- void removePage(PageView &page, bool setNextFocus);
- void removeAttachment(BodyAttachmentViewItem &attachment);
- void updateLastFocusedPage(PageViewItem &pageItem);
- void backKeyHandler(MediaPageViewItem &item);
- void backKeyHandler(TextPageViewItem &item);
- void clear(PageView &page);
- void prepare(BodyViewItem &item);
- void insertAfter(BodyViewItem &item, BodyViewItem &after);
- void insertBefore(BodyViewItem &item, BodyViewItem &before);
- void append(BodyViewItem &item);
- void remove(BodyViewItem &item);
- void rebuildSeparators();
- void updateSeparators();
- PageSeparator *createSep();
+ Evas_Object *createEntry(Evas_Object *parent, int maxCharCount);
Evas_Object *createContentBox(Evas_Object *parent);
- void updateSep(PageSeparator &sep, int number, int maxNumber);
+
+ void onContentBoxGeometryChanged(Evas_Object *obj, void *eventInfo);
private:
Evas_Object *m_pRootBox;
Evas_Object *m_pContentBox;
Evas_Object *m_pScroller;
- BodyViewItemCollection m_Items;
- PageView *m_pDefaultPage;
- int m_LastTextCursorPos;
- PageView *m_pLastFocusedPage;
+ Evas_Object *m_pEntry;
};
}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 BodyViewItem_h_
-#define BodyViewItem_h_
-
-#include "View.h"
-
-namespace Msg
-{
- class BodyViewItem
- : public View
- {
- public:
- enum Type
- {
- SeparatorType,
- PageType,
- AttachmentType
- };
-
- public:
- BodyViewItem(Type type);
- virtual ~BodyViewItem();
-
- Type getType() const;
-
- protected:
- std::string getEdjPath() const;
-
- private:
- Type m_Type;
- };
-}
-
-#endif /* BodyViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 ImagePageViewItem_h_
-#define ImagePageViewItem_h_
-
-#include "MediaPageViewItem.h"
-
-#include <vector>
-
-namespace Msg
-{
- class ImagePageViewItem
- : public MediaPageViewItem
- {
- public:
- ImagePageViewItem(PageView &parent, const std::string &reourcePath, long long fileSize, const std::string &imagePath);
- virtual ~ImagePageViewItem();
-
- void showPlayIcon();
- const std::string &getImagePath() const;
- virtual Type getType() const;
- virtual bool isEmpty() const;
- virtual void highlight(bool value);
- virtual std::string getFileName() const;
-
- private:
- Evas_Object *createImageLayout(Evas_Object *parent);
- Evas_Object *createRect(Evas_Object *parent);
- Evas_Object *createImage(Evas_Object *parent);
-
- private:
- Evas_Object *m_pImageLayout;
- const std::string m_ImagePath;
- };
-}
-
-#endif /* ImagePageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 MediaPageViewItem_h_
-#define MediaPageViewItem_h_
-
-#include "PageViewItem.h"
-
-#include <vector>
-
-namespace Msg
-{
- class IMediaPageViewItemListener;
-
- class MediaPageViewItem
- : public PageViewItem
- {
- public:
- MediaPageViewItem(PageView &parent, const std::string &resourcePath, long long fileSize);
- virtual ~MediaPageViewItem();
-
- void setListener(IMediaPageViewItemListener *l);
- long long getFileSize() const;
- virtual void highlight(bool value) = 0;
-
- virtual std::string getFileName() const = 0;
- protected:
- Evas_Object *getMediaLayout() const;
- Evas_Object *getButtonLayout() const;
- void setButtonContent(Evas_Object *layout);
- void setRect(Evas_Object *layout);
-
- private:
-
- Evas_Object *createMainLayout(Evas_Object *parent);
- Evas_Object *createButton(Evas_Object *parent);
- Evas_Object *createRect(Evas_Object *parent);
- Evas_Object *createGestureLayer(Evas_Object *parent);
-
- template<class...Args>
- static void notifyListener(void *data, void (IMediaPageViewItemListener::*method)(MediaPageViewItem &, Args...args), Args&&...args);
-
- private:
- IMediaPageViewItemListener *m_pListener;
- Evas_Object *m_pButton;
- long long m_FileSize;
- };
-
- class IMediaPageViewItemListener
- : public IPageViewItemListener
- {
- public:
- virtual ~IMediaPageViewItemListener() {}
-
- virtual void onClicked(MediaPageViewItem &item) {};
- virtual void onPressed(MediaPageViewItem &item) {};
- virtual void onUnpressed(MediaPageViewItem &item) {};
- virtual void onFocused(MediaPageViewItem &item) {};
- virtual void onUnfocused(MediaPageViewItem &item) {};
- virtual void onKeyDown(MediaPageViewItem &item, Evas_Event_Key_Down &event) {};
- virtual void onKeyUp(MediaPageViewItem &item, Evas_Event_Key_Up &event) {};
- };
-}
-
-#endif /* MediaPageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 PageSeparator_h_
-#define PageSeparator_h_
-
-#include "BodyViewItem.h"
-
-namespace Msg
-{
- class BodyView;
-
- class PageSeparator
- : public BodyViewItem
- {
- public:
- PageSeparator(BodyView &parent);
- virtual ~PageSeparator();
-
- void setText(const std::string &text);
-
- private:
- Evas_Object *m_pTextLayout;
- };
-}
-
-#endif /* PageSeparator_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 PageView_h_
-#define PageView_h_
-
-#include "BodyViewItem.h"
-#include "PageViewItem.h"
-
-#include <vector>
-#include <map>
-
-namespace Msg
-{
- class BodyView;
- class PageView
- : public BodyViewItem
- {
- public:
- typedef std::vector<PageViewItem*> ItemList;
-
- public:
- PageView(BodyView &parent);
- virtual ~PageView();
-
- bool hasMedia() const;
- ItemList getItems() const;
- bool canItemBeAdded(PageViewItem::Type type) const;
- void addItem(PageViewItem &item);
- void removeItem(PageViewItem &item);
- PageViewItem *getItem(PageViewItem::Type type) const;
- bool isEmpty() const;
- Evas_Object *getItemParent() const;
-
- private:
- typedef std::map<PageViewItem::Type, PageViewItem*> PageItemMap;
-
- Evas_Object *createMainLayout(Evas_Object *parent);
- Evas_Object *createLayout(Evas_Object *parent);
- Evas_Object *createBox(Evas_Object *parent);
-
- private:
- Evas_Object *m_pBox;
- PageItemMap m_PageItemMap;
- };
-}
-
-#endif /* PageView_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 PageViewItem_h_
-#define PageViewItem_h_
-
-#include "View.h"
-
-namespace Msg
-{
- class PageView;
- class IPageViewItemListener;
-
- class PageViewItem
- : public View
- {
- public:
- enum Type
- {
- UnknownType,
- TextType,
- ImageType,
- SoundType,
- VideoType
- };
-
- public:
- PageViewItem(PageView &parent, const std::string &resourcePath = "");
- virtual ~PageViewItem();
-
- virtual Type getType() const = 0;
- virtual bool isEmpty() const = 0;
-
- void setListener(IPageViewItemListener *l);
- void setResourcePath(const std::string &resourcePath);
- const std::string &getResourcePath() const;
- const PageView &getParentPage() const;
- PageView &getParentPage();
- void destroy();
-
- protected:
- const std::string &getEdjPath() const;
-
- virtual void onBeforeDelete(View &view);
-
- private:
- PageView &m_Parent;
- std::string m_ResourcePath;
- IPageViewItemListener *m_pListener;
- };
-
- class IPageViewItemListener
- {
- public:
- virtual ~IPageViewItemListener() {}
- virtual void onDelete(PageViewItem &item) {};
- };
-}
-
-#endif /* PageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 SoundPageViewItem_h_
-#define SoundPageViewItem_h_
-
-#include "MediaPageViewItem.h"
-
-namespace Msg
-{
- class SoundPageViewItem
- : public MediaPageViewItem
- {
- public:
- SoundPageViewItem(PageView &parent, const std::string &resourcePath, long long fileSize, const std::string &dispName = "");
- virtual ~SoundPageViewItem();
-
- virtual Type getType() const;
- virtual bool isEmpty() const;
- virtual void highlight(bool value);
- virtual std::string getFileName() const;
-
- private:
- Evas_Object *createLabel(Evas_Object *parent, const std::string &fileName);
-
- private:
- std::string m_DispName;
- };
-}
-
-#endif /* SoundPageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 TextPageViewItem_h_
-#define TextPageViewItem_h_
-
-#include "PageViewItem.h"
-#include "LangUtils.h"
-
-namespace Msg
-{
- class ITextPageViewItemListener;
-
- class TextPageViewItem
- : public PageViewItem
- {
- public:
- TextPageViewItem(PageView &parent, int maxCharCount);
- virtual ~TextPageViewItem();
-
- virtual Type getType() const;
- virtual bool isEmpty() const;
- void resetChangedFlag();
- bool hasChanged() const;
-
- void showInputPanel(bool show);
- int getCursorPos() const;
- void setCursorPos(int pos);
- void setEndCursorPos();
- void setBeginCursorPos();
- void setListener(ITextPageViewItemListener *l);
- void setGuideText(const TText &text);
- void clear();
- std::string getText() const;
- std::string getPlainUtf8Text() const;
- void setText(const std::string &text);
-
- private:
- Evas_Object *createEntry(Evas_Object *parent, int maxCharCount);
- static void entryFilterCheckBoundary(void *data, Evas_Object *entry, char **text);
-
- template<class...Args>
- static void notifyListener(void *data, void (ITextPageViewItemListener::*method)(TextPageViewItem &, Args...args), Args&&...args);
-
- private:
- Evas_Object *m_pEntry;
- ITextPageViewItemListener *m_pListener;
- bool m_Changed;
- };
-
- class ITextPageViewItemListener
- {
- public:
- virtual ~ITextPageViewItemListener() {}
- virtual void onCursorChanged(TextPageViewItem &obj) {};
- virtual void onFocused(TextPageViewItem &obj) {};
- virtual void onUnfocused(TextPageViewItem &obj) {};
- virtual void onChanged(TextPageViewItem &obj) {};
- virtual void onPreeditChanged(TextPageViewItem &obj) {};
- virtual void onPress(TextPageViewItem &obj) {};
- virtual void onClicked(TextPageViewItem &obj) {};
- virtual void onMaxLengthReached(TextPageViewItem &obj) {};
- virtual void onKeyDown(TextPageViewItem &obj, Evas_Event_Key_Down &event) {};
- virtual void onKeyUp(TextPageViewItem &obj, Evas_Event_Key_Up &event) {};
- virtual void onCheckBoundaryText(TextPageViewItem &obj, char **text) {};
- };
-}
-
-#endif /* TextPageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 VideoPageViewItem_h_
-#define VideoPageViewItem_h_
-
-#include "ImagePageViewItem.h"
-
-#include <vector>
-
-namespace Msg
-{
- class VideoPageViewItem
- : public ImagePageViewItem
- {
- public:
- VideoPageViewItem(PageView &parent, const std::string &reourcePath, long long fileSize, const std::string &imagePath);
- virtual ~VideoPageViewItem();
-
- virtual Type getType() const;
- virtual std::string getFileName() const;
- };
-}
-
-#endif /* VideoPageViewItem_h_ */
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "BodyAttachmentViewItem.h"
-#include "BodyView.h"
-#include "FileUtils.h"
-#include "Logger.h"
-
-using namespace Msg;
-
-namespace
-{
- const char *mediaMainGroup = "conv/body/media_main";
- const char *mediaMainSwlContent = "swl.content";
- const char *buttonStyle = "focus";
- const char *buttonSwlContent = "elm.swallow.content";
- const char *labelLayout = "conv/body/media_label";
- const char *fileNamePart = "text.filename";
-}
-
-BodyAttachmentViewItem::BodyAttachmentViewItem(BodyView &parent, const std::string &resourePath, long long fileSize, const std::string &dispName)
- : BodyViewItem(AttachmentType)
- , m_pLayaout(nullptr)
- , m_pListener(nullptr)
- , m_ResourePath(resourePath)
- , m_FileName(dispName)
- , m_FileSize(fileSize)
-{
- setEo(createLayout(parent));
- Evas_Object *button = createButton(getEo());
- Evas_Object *label = createLabel(button, m_FileName);
-
- elm_layout_content_set(button, buttonSwlContent, label);
- setContent(button, mediaMainSwlContent);
-}
-
-BodyAttachmentViewItem::~BodyAttachmentViewItem()
-{
- if(m_pListener)
- m_pListener->onDelete(*this);
-}
-
-void BodyAttachmentViewItem::setListener(IBodyAttachmentViewListener *listener)
-{
- m_pListener = listener;
-}
-
-const std::string &BodyAttachmentViewItem::getResourcePath() const
-{
- return m_ResourePath;
-}
-
-const std::string &BodyAttachmentViewItem::getFileName() const
-{
- return m_FileName;
-}
-
-long long BodyAttachmentViewItem::getFileSize() const
-{
- return m_FileSize;
-}
-
-Evas_Object *BodyAttachmentViewItem::createLayout(Evas_Object *parent)
-{
- m_pLayaout = elm_layout_add(parent);
- elm_layout_file_set(m_pLayaout, getEdjPath().c_str(), mediaMainGroup);
- expand(m_pLayaout);
- evas_object_show(m_pLayaout);
- return m_pLayaout;
-}
-
-Evas_Object *BodyAttachmentViewItem::createButton(Evas_Object *parent)
-{
- Evas_Object *button = elm_button_add(parent);
- elm_object_style_set(button, buttonStyle);
- evas_object_show(button);
-
- evas_object_smart_callback_add(button, "clicked", [](void *data, Evas_Object *obj, void *event_info)
- {
- BodyAttachmentViewItem *self = (BodyAttachmentViewItem*)data;
- if(self && self->m_pListener)
- self->m_pListener->onClicked(*self);
- }, this);
-
- return button;
-}
-
-Evas_Object *BodyAttachmentViewItem::createLabel(Evas_Object *parent, const std::string &fileName)
-{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_file_set(layout, getEdjPath().c_str(), labelLayout);
- elm_object_part_text_set(layout, fileNamePart, fileName.c_str());
- evas_object_show(layout);
- return layout;
-}
*/
#include "BodyView.h"
-#include "PageView.h"
-#include "PageSeparator.h"
#include "Logger.h"
-#include "MediaType.h"
+#include "LangUtils.h"
#include <assert.h>
#include <algorithm>
+#include <efl_extension.h>
using namespace Msg;
}
}
-BodyView::BodyView()
+BodyView::BodyView(Evas_Object *parent, int maxCharCount)
: m_pRootBox(nullptr)
, m_pContentBox(nullptr)
, m_pScroller(nullptr)
- , m_pDefaultPage(nullptr)
- , m_LastTextCursorPos(0)
- , m_pLastFocusedPage(nullptr)
-{
-}
-
-BodyView::~BodyView()
-{
-
-}
-
-void BodyView::create(Evas_Object *parent)
+ , m_pEntry(nullptr)
{
// Root box:
m_pRootBox = elm_box_add(parent);
elm_box_pack_end(m_pRootBox, m_pScroller);
elm_object_content_set(m_pScroller, contentBox);
- m_pDefaultPage = addPage();
+ elm_box_pack_end(contentBox, createEntry(contentBox, maxCharCount));
+}
+
+BodyView::~BodyView()
+{
}
Evas_Object *BodyView::createContentBox(Evas_Object *parent)
return m_pContentBox;
}
-void BodyView::onContentBoxGeometryChanged(Evas_Object *obj, void *event_info)
-{
- int w = 0;
- int h = 0;
-
- evas_object_geometry_get(m_pContentBox, nullptr, nullptr, &w, &h);
- MSG_LOG(h);
-
- if(h > maxBodyHeight)
- h = maxBodyHeight;
-
- evas_object_size_hint_min_set(m_pRootBox, w, h);
- evas_object_size_hint_max_set(m_pRootBox, w, h);
-}
-
-const PageView &BodyView::getDefaultPage() const
-{
- assert(m_pDefaultPage);
- return *m_pDefaultPage;
-}
-
-PageView &BodyView::getDefaultPage()
-{
- assert(m_pDefaultPage);
- return *m_pDefaultPage;
-}
-
bool BodyView::isEmpty() const
{
- const auto pages = getPages();
-
- if(pages.size() > 1)
- return false;
-
- for(PageView *page : pages)
- {
- if(!page->isEmpty())
- return false;
- }
-
- return getAttachments().empty();
-}
-
-PageView *BodyView::getNextPage(PageView &page) const
-{
- auto pages = getPages();
- auto itEnd = pages.end();
- auto it = std::find(pages.begin(), pages.end(), &page);
-
- if(it != itEnd)
- ++it;
-
- return it != itEnd ? *it : nullptr;
+ const char *text = elm_entry_entry_get(m_pEntry);
+ return text ? text[0] == '\0' : true;
}
-PageView *BodyView::getPrevPage(PageView &page) const
-{
- auto pages = getPages();
-
- auto itBegin = pages.begin();
- auto itEnd = pages.end();
- auto it = std::find(pages.begin(), pages.end(), &page);
-
- if(it != itEnd && it != itBegin)
- --it;
-
- return it != itEnd ? *it : nullptr;
-}
-
-int BodyView::getItemCount(BodyViewItem::Type type) const
-{
- int count = 0;
- auto list = getAllItems();
- for(BodyViewItem *item : list)
- {
- if(item->getType() == type)
- ++count;
- }
- return count;
-}
-
-PageSeparator *BodyView::createSep()
-{
- PageSeparator *sep = new PageSeparator(*this);
- return sep;
-}
-
-void BodyView::updateSep(PageSeparator &sep, int number, int maxNumber)
+void BodyView::clear()
{
- std::ostringstream ss;
- ss << number << '/' << maxNumber;
- sep.setText(ss.str());
+ elm_object_text_set(m_pEntry, "");
}
-void BodyView::rebuildSeparators()
+void BodyView::setText(const std::string &text)
{
- auto separators = getItems<PageSeparator>();
- for(PageSeparator *sep : separators)
- remove(*sep);
-
- auto pages = getPages();
- PageView *prevPage = nullptr;
- int number = 0;
-
- for(PageView *page : pages)
+ if(!text.empty())
{
- if(prevPage)
+ char *markupText = elm_entry_utf8_to_markup(text.c_str());
+ if(markupText)
{
- ++number;
- PageSeparator *sep = createSep();
- updateSep(*sep, number, pages.size());
- insertAfter(*sep, *prevPage);
+ elm_object_text_set(m_pEntry, markupText);
+ free(markupText);
}
- prevPage = page;
- }
-}
-
-void BodyView::updateSeparators()
-{
- auto separators = getItems<PageSeparator>();
- if(separators.empty())
- return;
-
- int index = 1;
- for(PageSeparator *sep : separators)
- {
- updateSep(*sep, index, separators.size() + 1);
- ++index;
}
}
-void BodyView::prepare(BodyViewItem &item)
-{
- expand(item);
- item.show();
-}
-
-void BodyView::append(BodyViewItem &item)
-{
- prepare(item);
- elm_box_pack_end(m_pContentBox, item);
- item.show();
- onContentChanged();
-}
-
-void BodyView::insertAfter(BodyViewItem &item, BodyViewItem &after)
-{
- prepare(item);
- elm_box_pack_after(m_pContentBox, item, after);
- onContentChanged();
-}
-
-void BodyView::insertBefore(BodyViewItem &item, BodyViewItem &before)
-{
- prepare(item);
- elm_box_pack_before(m_pContentBox, item, before);
- onContentChanged();
-}
-
-void BodyView::remove(BodyViewItem &item)
-{
- elm_box_unpack(m_pContentBox, item);
- item.destroy();
- onContentChanged();
-}
-
-int BodyView::getPageCount() const
-{
- return getPages().size();
-}
-
-PageViewCollection BodyView::getPages() const
+void BodyView::setFocus(bool focus)
{
- return getItems<PageView>();
+ elm_object_focus_set(m_pEntry, focus);
+ if(focus)
+ elm_entry_cursor_end_set(m_pEntry);
}
-BodyAttachmentCollection BodyView::getAttachments() const
+std::string BodyView::getText() const
{
- return getItems<BodyAttachmentViewItem>();
+ return m_pEntry ? elm_object_text_get(m_pEntry) : "";
}
-template<typename T>
-std::vector<T*> BodyView::getItems() const
+std::string BodyView::getPlainUtf8Text() const
{
- std::vector<T*> res;
- BodyViewItemCollection all = getAllItems();
- for(BodyViewItem *item : all)
- {
- if(T *itemT = dynamic_cast<T*>(item))
- res.push_back(itemT);
- }
- return res;
-}
+ std::string res;
+ const char *plainText = elm_entry_entry_get(m_pEntry);
-BodyViewItemCollection BodyView::getAllItems() const
-{
- BodyViewItemCollection res;
- Eina_List *list = elm_box_children_get(m_pContentBox);
- if(list)
+ if(plainText)
{
- Eina_List *l = nullptr;
- void *obj = nullptr;
-
- EINA_LIST_FOREACH(list, l, obj)
+ char *text = elm_entry_markup_to_utf8(plainText);
+ if(text)
{
- BodyViewItem *item = reinterpretCast<BodyViewItem*>(obj);
- if(item)
- res.push_back(item);
+ res.assign(text);
+ free(text);
}
- eina_list_free(list);
}
-
return res;
}
-PageView *BodyView::addPage()
+Evas_Object *BodyView::createEntry(Evas_Object *parent, int maxCharCount)
{
- PageView &page = createPage();
+ m_pEntry = elm_entry_add(parent);
+ elm_entry_prediction_allow_set(m_pEntry, true);
+ elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_SENTENCE);
+ elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
+ elm_object_focus_allow_set(m_pEntry, true);
+ // elm_entry_input_panel_enabled_set(m_pEntry, false); // Keypad is manually controlled
+ eext_entry_selection_back_event_allow_set(m_pEntry, true);
+ evas_object_show(m_pEntry);
+ expand(m_pEntry);
- int pageCount = getItemCount(BodyViewItem::PageType);
- if(pageCount > 0)
- {
- append(*createSep());
- updateSeparators();
- }
-
- append(page);
-
- //scroll to the end
- Evas_Coord_Point pt{0, 0};
- Evas_Coord_Size sz{0, 0};
- elm_scroller_region_get(m_pScroller, &pt.x, &pt.y, &sz.w, &sz.h);
- elm_scroller_region_show(m_pScroller, 0, sz.h + pt.y, 0, sz.h + pt.y);
- return &page;
-}
+ View::setText(m_pEntry, msgt("IDS_MSG_TMBODY_TEXT_MESSAGES"), "elm.guide");
-BodyAttachmentViewItem *BodyView::addAttachment(const std::string &filePath, long long fileSize, const std::string &dispName)
-{
- BodyAttachmentViewItem *attachment = new BodyAttachmentViewItem(*this, filePath, fileSize, dispName);
- insertBefore(*attachment, *m_pDefaultPage);
- attachment->setListener(this);
- onContentChanged();
- return attachment;
-}
-
-void BodyView::setFocus(PageView &page, bool focus)
-{
- TextPageViewItem *textItem = static_cast<TextPageViewItem*>(page.getItem(PageViewItem::TextType));
- if(textItem)
- {
- textItem->setFocus(focus);
- textItem->setEndCursorPos();
- }
-}
-
-void BodyView::setFocus(bool focus)
-{
- setFocus(*m_pDefaultPage, focus);
-}
-
-void BodyView::clear(PageView &page)
-{
- auto pageItems = page.getItems();
- for(PageViewItem *pageItem : pageItems)
- {
- if(pageItem->getType() == PageViewItem::TextType)
- static_cast<TextPageViewItem*>(pageItem)->clear();
- else
- page.removeItem(*pageItem);
- }
-}
-
-void BodyView::clear()
-{
- auto items = getAllItems();
- for(BodyViewItem *item : items)
- {
- if(item->getType() == BodyViewItem::PageType)
+ Elm_Entry_Filter_Limit_Size limitFilter = {};
+ limitFilter.max_char_count = maxCharCount;
+ elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter);
+ elm_entry_markup_filter_append
+ (
+ m_pEntry,
+ [](void *data, Evas_Object *entry, char **text)
{
- PageView *page = static_cast<PageView*>(item);
- if(page == m_pDefaultPage)
- clear(*page);
- else
- removePage(*page, false);
- }
- else if(item->getType() == BodyViewItem::AttachmentType)
- {
- BodyAttachmentViewItem *attachment = static_cast<BodyAttachmentViewItem*>(item);
- removeAttachment(*attachment);
- }
- }
-}
-
-void BodyView::showInputPanel(PageView &page, bool show)
-{
- TextPageViewItem *item = static_cast<TextPageViewItem*>(page.getItem(PageViewItem::TextType));
- if(item)
- item->showInputPanel(show);
-}
-
-void BodyView::showInputPanel(PageViewItem &pageItem, bool show)
-{
- if(pageItem.getType() == PageViewItem::TextType)
- static_cast<TextPageViewItem&>(pageItem).showInputPanel(show);
- else
- showInputPanel(pageItem.getParentPage(), show);
-}
-
-ImagePageViewItem *BodyView::addImage(PageView &page, const std::string &filePath, long long fileSize)
-{
- ImagePageViewItem *item = new ImagePageViewItem(page, filePath, fileSize, filePath);
- item->setListener(this);
- item->show();
- page.addItem(*item);
- onContentChanged();
- return item;
-}
-
-SoundPageViewItem *BodyView::addSound(PageView &page, const std::string &filePath, long long fileSize, const std::string &dispName)
-{
- SoundPageViewItem *item = new SoundPageViewItem(page, filePath, fileSize, dispName);
- item->setListener(this);
- item->show();
- page.addItem(*item);
- onContentChanged();
- return item;
-}
-
-VideoPageViewItem *BodyView::addVideo(PageView &page, const std::string &filePath, long long fileSize, const std::string &imagePath)
-{
- VideoPageViewItem *item = new VideoPageViewItem(page, filePath, fileSize, imagePath);
- item->setListener(this);
- item->show();
- page.addItem(*item);
- onContentChanged();
- return item;
-}
+ ((BodyView*)data)->onCheckBoundaryText(text);
+ }, this );
-TextPageViewItem *BodyView::addText(PageView &page, int maxCharCount)
-{
- TextPageViewItem *item = new TextPageViewItem(page, maxCharCount);
- item->setListener(this);
- item->show();
- item->setGuideText(msgt("IDS_MSG_TMBODY_TEXT_MESSAGES"));
- page.addItem(*item);
- onContentChanged();
- return item;
-}
+ // Preset max width to avoid blink
+ const int maxWidth = ELM_SCALE_SIZE(720);
+ evas_object_resize(m_pEntry, maxWidth, 0);
-void BodyView::updateLastFocusedPage(PageViewItem &pageItem)
-{
- m_pLastFocusedPage = &pageItem.getParentPage();
-}
-
-PageView *BodyView::getPageForMedia(PageViewItem::Type type)
-{
- if(m_pLastFocusedPage && m_pLastFocusedPage->canItemBeAdded(type))
- {
- return m_pLastFocusedPage;
- }
- else
+ evas_object_smart_callback_add(m_pEntry, "changed", [](void *data, Evas_Object *obj, void *event_info)
{
- auto pages = getPages();
- for(PageView *page : pages)
- {
- if(page->canItemBeAdded(type))
- return page;
- }
- }
+ ((BodyView*)data)->onContentChanged();
+ }, this);
- return addPage();
-}
-
-void BodyView::removePage(PageView &page, bool setNextFocus)
-{
- if(m_pDefaultPage != &page && getPageCount() > 1)
+ evas_object_smart_callback_add(m_pEntry, "preedit,changed", [](void *data, Evas_Object *obj, void *event_info)
{
- if(setNextFocus)
- {
- PageView *prevPage = getPrevPage(page);
- if(prevPage)
- setFocus(*prevPage, true);
- }
+ // TODO: check
+ }, this);
- page.View::destroy();
- rebuildSeparators();
-
- if(m_pLastFocusedPage == &page)
- m_pLastFocusedPage = nullptr;
- }
-}
-
-void BodyView::removeAttachment(BodyAttachmentViewItem &attachment)
-{
- remove(attachment);
-}
-
-void BodyView::backKeyHandler(MediaPageViewItem &item)
-{
- item.destroy();
-}
-
-void BodyView::backKeyHandler(TextPageViewItem &item)
-{
- if(m_LastTextCursorPos == 0)
+ evas_object_smart_callback_add(m_pEntry, "maxlength,reached", [](void *data, Evas_Object *obj, void *event_info)
{
- MSG_LOG("Last text cursor position");
- PageView &page = item.getParentPage();
+ ((BodyView*)data)->onMaxLengthReached();
+ }, this);
- PageViewItem *topItem = page.getItem(PageViewItem::ImageType);
- if(!topItem)
- topItem = page.getItem(PageViewItem::VideoType);
- if(topItem)
- topItem->setFocus(true);
- else
- removePage(page, true);
- }
-}
-
-void BodyView::onCursorChanged(TextPageViewItem &item)
-{
- m_LastTextCursorPos = item.getCursorPos();
- MSG_LOG("Cursor pos: ", item.getCursorPos());
-}
-
-void BodyView::onFocused(TextPageViewItem &item)
-{
- MSG_LOG("");
- updateLastFocusedPage(item);
- item.showInputPanel(true);
-}
-
-void BodyView::onUnfocused(TextPageViewItem &item)
-{
- MSG_LOG("");
- item.showInputPanel(false);
-}
-
-void BodyView::onPreeditChanged(TextPageViewItem &item)
-{
- MSG_LOG("");
-}
-
-void BodyView::onPress(TextPageViewItem &item)
-{
- MSG_LOG("");
-}
-
-void BodyView::onClicked(TextPageViewItem &item)
-{
- MSG_LOG("");
- showInputPanel(item, true);
-}
-
-void BodyView::onKeyDown(TextPageViewItem &item, Evas_Event_Key_Down &event)
-{
- MSG_LOG("");
- if(isBackKey(event.keyname))
- backKeyHandler(item);
-}
-
-void BodyView::onKeyUp(TextPageViewItem &item, Evas_Event_Key_Up &event)
-{
- MSG_LOG("");
-}
-
-void BodyView::onChanged(TextPageViewItem &item)
-{
- MSG_LOG("");
- onContentChanged();
-}
-
-void BodyView::onPressed(MediaPageViewItem &item)
-{
- MSG_LOG("");
-}
-
-void BodyView::onUnpressed(MediaPageViewItem &item)
-{
- MSG_LOG("");
+ return m_pEntry;
}
-void BodyView::onFocused(MediaPageViewItem &item)
-{
- MSG_LOG("");
- updateLastFocusedPage(item);
- item.highlight(true);
- showInputPanel(item, true);
-}
-
-void BodyView::onUnfocused(MediaPageViewItem &item)
-{
- MSG_LOG("");
- item.highlight(false);
- showInputPanel(item, false);
-}
-
-void BodyView::onKeyDown(MediaPageViewItem &item, Evas_Event_Key_Down &event)
+void BodyView::onContentBoxGeometryChanged(Evas_Object *obj, void *event_info)
{
- MSG_LOG("");
- if(isBackKey(event.keyname))
- backKeyHandler(item);
-}
+ int w = 0;
+ int h = 0;
-void BodyView::onKeyUp(MediaPageViewItem &item, Evas_Event_Key_Up &event)
-{
- MSG_LOG("");
-}
+ evas_object_geometry_get(m_pContentBox, nullptr, nullptr, &w, &h);
-void BodyView::onDelete(BodyAttachmentViewItem &item)
-{
- MSG_LOG("");
- onItemDelete(item);
- onContentChanged();
-}
+ if(h > maxBodyHeight)
+ h = maxBodyHeight;
-void BodyView::onDelete(PageViewItem &item)
-{
- MSG_LOG("");
- onItemDelete(item);
- onContentChanged();
+ evas_object_size_hint_min_set(m_pRootBox, w, h);
+ evas_object_size_hint_max_set(m_pRootBox, w, h);
}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "BodyViewItem.h"
-
-#include <assert.h>
-
-using namespace Msg;
-
-
-BodyViewItem::BodyViewItem(Type type)
- : m_Type(type)
-{
-}
-
-BodyViewItem::~BodyViewItem()
-{
-}
-
-std::string BodyViewItem::getEdjPath() const
-{
- return PathUtils::getResourcePath(MSG_BODY_EDJ_PATH);
-}
-
-BodyViewItem::Type BodyViewItem::getType() const
-{
- return m_Type;
-}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "ImagePageViewItem.h"
-#include "PageView.h"
-#include "Logger.h"
-#include "FileUtils.h"
-#include <assert.h>
-
-using namespace Msg;
-
-namespace
-{
- const char *mediaImagePortraitSig = "media.image.portrait";
- const char *mediaImageLandscapeSig = "media.image.landscape";
- const char *mediaImageEqualSig = "media.image.equal";
- const char *imageLayout = "conv/body/media_image";
- const char *imageContentPart = "swl.thumbnail";
- const char *showPlayIconSig = "play_icon_show";
-
- const int thumbOriginHeight = 75;
- const int thumbLandscapeHeight = 102;
- const int thumbPortraitHeight = 128;
- const int thumbEqual = 106;
-}
-
-ImagePageViewItem::ImagePageViewItem(PageView &parent, const std::string &reourcePath, long long fileSize, const std::string &imagePath)
- : MediaPageViewItem(parent, reourcePath, fileSize)
- , m_pImageLayout(nullptr)
- , m_ImagePath(imagePath)
-{
- Evas_Object *imageLayout = createImageLayout(getMediaLayout());
- Evas_Object *rect = createRect(getMediaLayout());
- Evas_Object *icon = createImage(imageLayout);
- elm_object_part_content_set(m_pImageLayout, imageContentPart, icon);
- setRect(rect);
- setButtonContent(imageLayout);
-}
-
-ImagePageViewItem::~ImagePageViewItem()
-{
-
-}
-
-void ImagePageViewItem::showPlayIcon()
-{
- emitSignal(m_pImageLayout, showPlayIconSig, "");
-}
-
-const std::string &ImagePageViewItem::getImagePath() const
-{
- return m_ImagePath;
-}
-
-ImagePageViewItem::Type ImagePageViewItem::getType() const
-{
- return ImageType;
-}
-
-bool ImagePageViewItem::isEmpty() const
-{
- return getResourcePath().empty();
-}
-
-void ImagePageViewItem::highlight(bool value)
-{
- const char *sig = value ? "focused" : "unfocused";
- emitSignal(m_pImageLayout, sig, "*");
-}
-
-std::string ImagePageViewItem::getFileName() const
-{
- return FileUtils::getFileName(m_ImagePath);
-}
-
-Evas_Object *ImagePageViewItem::createImageLayout(Evas_Object *parent)
-{
- m_pImageLayout = elm_layout_add(parent);
- elm_layout_file_set(m_pImageLayout, getEdjPath().c_str(), imageLayout);
- evas_object_show(m_pImageLayout);
- return m_pImageLayout;
-}
-
-Evas_Object *ImagePageViewItem::createRect(Evas_Object *parent)
-{
- Evas_Object *rect = evas_object_rectangle_add(evas_object_evas_get(parent));
- evas_object_color_set(rect, 0, 0, 0, 0);
- evas_object_size_hint_min_set(rect, 0, ELM_SCALE_SIZE(thumbOriginHeight));
- evas_object_show(rect);
- return rect;
-}
-
-Evas_Object *ImagePageViewItem::createImage(Evas_Object *parent)
-{
- // Get image dimension:
- Evas *evas = evas_object_evas_get(parent);
- Evas_Object *img = evas_object_image_add(evas);
- evas_object_image_load_orientation_set(img, true);
- evas_object_image_file_set(img, m_ImagePath.c_str(), nullptr);
-
- int err = evas_object_image_load_error_get(img);
- if (err != EVAS_LOAD_ERROR_NONE)
- {
- evas_object_del(img);
- MSG_LOG_ERROR("Image loading is failed: ", m_ImagePath);
- return nullptr;
- }
-
- int width = 0;
- int height = 0;
- float ratio = 0.0;
- evas_object_image_size_get(img, &width, &height);
- evas_object_del(img);
-
- MSG_LOG("Image: width = ", width, " height = ", height);
- if(height > 0)
- ratio = width / (float)height;
- // Set orientation of media layout and icon dimension:
- int iconWidth = 0;
- int iconHeight = 0;
- const char *sig = nullptr;
-
- if(width > height) // Landscape
- {
- iconWidth = (int)ELM_SCALE_SIZE(ratio * thumbLandscapeHeight);
- iconHeight = (int)ELM_SCALE_SIZE(thumbLandscapeHeight);
- sig = mediaImageLandscapeSig;
- }
- else if(height > width) // Portrait
- {
- iconWidth = (int)ELM_SCALE_SIZE(ratio * thumbPortraitHeight);
- iconHeight = (int)ELM_SCALE_SIZE(thumbPortraitHeight);
- sig = mediaImagePortraitSig;
- }
- else // Equal
- {
- iconWidth = (int)ELM_SCALE_SIZE(thumbEqual);
- iconHeight = (int)ELM_SCALE_SIZE(thumbEqual);
- sig = mediaImageEqualSig;
- }
- emitSignal(getMediaLayout(), sig, "*");
-
- // Create and load icon image:
- Evas_Object *icon = elm_icon_add(parent);
- elm_image_file_set(icon, m_ImagePath.c_str(), NULL);
- evas_object_size_hint_align_set(icon, 0.0, EVAS_HINT_FILL);
- evas_object_size_hint_min_set(icon, iconWidth, iconHeight);
- elm_image_aspect_fixed_set(icon, EINA_TRUE);
- evas_object_show(icon);
-
- return icon;
-}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "MediaPageViewItem.h"
-#include "PageView.h"
-
-#include <assert.h>
-
-using namespace Msg;
-
-namespace
-{
- const char *mediaMainGroup = "conv/body/media_main";
- const char *buttonSwlContent = "elm.swallow.content";
-}
-
-MediaPageViewItem::MediaPageViewItem(PageView &parent, const std::string &resourcePath, long long fileSize)
- : PageViewItem(parent, resourcePath)
- , m_pListener(nullptr)
- , m_pButton(nullptr)
- , m_FileSize(fileSize)
-{
- View::setEo(createMainLayout(parent.getItemParent()));
- Evas_Object *button = createButton(getEo());
- setContent(button, "swl.content");
-}
-
-MediaPageViewItem::~MediaPageViewItem()
-{
-
-}
-
-template<class...Args>
-void MediaPageViewItem::notifyListener(void *data, void (IMediaPageViewItemListener::*method)(MediaPageViewItem &, Args...args), Args&&...args)
-{
- MediaPageViewItem *self = static_cast<MediaPageViewItem*>(data);
- if(self && self->m_pListener)
- (self->m_pListener->*method)(*self, args...);
-}
-
-Evas_Object *MediaPageViewItem::getMediaLayout() const
-{
- return getEo();
-}
-
-Evas_Object *MediaPageViewItem::getButtonLayout() const
-{
- return m_pButton;
-}
-
-void MediaPageViewItem::setButtonContent(Evas_Object *layout)
-{
- elm_object_part_content_set(m_pButton, buttonSwlContent, layout);
-}
-
-void MediaPageViewItem::setRect(Evas_Object *layout)
-{
- setContent(layout, "swl.rect");
-}
-
-void MediaPageViewItem::setListener(IMediaPageViewItemListener *l)
-{
- PageViewItem::setListener(l);
- m_pListener = l;
-}
-
-long long MediaPageViewItem::getFileSize() const
-{
- return m_FileSize;
-}
-
-Evas_Object *MediaPageViewItem::createMainLayout(Evas_Object *parent)
-{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_file_set(layout, getEdjPath().c_str(), mediaMainGroup);
- evas_object_show(layout);
- return layout;
-}
-
-Evas_Object *MediaPageViewItem::createGestureLayer(Evas_Object *parent)
-{
- // TODO: impl if needed
- return nullptr;
-}
-
-Evas_Object *MediaPageViewItem::createButton(Evas_Object *parent)
-{
- Evas_Object *button = elm_button_add(parent);
- m_pButton = button;
- elm_object_style_set(button, "focus");
- evas_object_show(button);
-
- evas_object_smart_callback_add(button, "clicked", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onClicked);
- }, this);
-
- evas_object_smart_callback_add(button, "pressed", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onPressed);
- }, this);
-
- evas_object_smart_callback_add(button, "focused", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onFocused);
- }, this);
-
- evas_object_smart_callback_add(button, "unfocused", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onUnfocused);
- }, this);
-
- evas_object_smart_callback_add(button, "unpressed", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onUnpressed);
- }, this);
-
- evas_object_event_callback_add(button, EVAS_CALLBACK_KEY_DOWN, [](void *data, Evas *e, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onKeyDown, *(Evas_Event_Key_Down*)event_info);
- }, this);
-
- evas_object_event_callback_add(button, EVAS_CALLBACK_KEY_UP, [](void *data, Evas *e, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &IMediaPageViewItemListener::onKeyUp, *(Evas_Event_Key_Up*)event_info);
- }, this);
-
- return button;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "PageSeparator.h"
-#include "BodyView.h"
-
-using namespace Msg;
-
-namespace
-{
- const char *pageSeparatorGroup = "conv/body/page_divider";
- const char *itemLayoutGroup = "conv/body/item_layout";
-}
-
-PageSeparator::PageSeparator(BodyView &parent)
- : BodyViewItem(SeparatorType)
-{
- setEo(elm_layout_add(parent));
- elm_layout_file_set(getEo(), getEdjPath().c_str(), itemLayoutGroup);
- emitSignal("show.normal.mode", "*");
- expand();
- show();
-
- m_pTextLayout = elm_layout_add(getEo());
- evas_object_show(m_pTextLayout);
- elm_layout_file_set(m_pTextLayout, getEdjPath().c_str(), pageSeparatorGroup);
-
- setContent(m_pTextLayout, "swl.content");
-}
-
-PageSeparator::~PageSeparator()
-{
-
-}
-
-void PageSeparator::setText(const std::string &text)
-{
- elm_object_part_text_set(m_pTextLayout, "text.page_info", text.c_str());
-}
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "PageView.h"
-#include "BodyView.h"
-#include "TextPageViewItem.h"
-#include "ImagePageViewItem.h"
-#include "Logger.h"
-
-#include <efl_extension.h>
-#include <assert.h>
-
-using namespace Msg;
-
-namespace
-{
- const char *pageGroup = "conv/body/page";
- const char *itemLayoutGroup = "conv/body/item_layout";
-}
-
-PageView::PageView(BodyView &parent)
- : BodyViewItem(PageType)
- , m_pBox(nullptr)
-{
- setEo(createMainLayout(parent));
- Evas_Object *layout = createLayout(getEo());
- Evas_Object *box = createBox(layout);
-
- elm_object_part_content_set(layout, "swl.page", box);
- setContent(layout, "swl.content");
-}
-
-PageView::~PageView()
-{
-
-}
-
-bool PageView::isEmpty() const
-{
- for(auto it : m_PageItemMap)
- {
- if(!it.second->isEmpty())
- return false;
- }
- return true;
-}
-
-Evas_Object *PageView::getItemParent() const
-{
- return m_pBox;
-}
-
-bool PageView::hasMedia() const
-{
- for(auto item : m_PageItemMap)
- {
- if(item.first != PageViewItem::TextType)
- return true;
- }
- return false;
-}
-
-bool PageView::canItemBeAdded(PageViewItem::Type type) const
-{
- auto it = m_PageItemMap.find(type);
- if(it != m_PageItemMap.end())
- return false;
-
- if(type == PageViewItem::VideoType && hasMedia())
- return false;
-
- if(getItem(PageViewItem::VideoType) && type != PageViewItem::TextType)
- return false;
-
- return true;
-}
-
-void PageView::addItem(PageViewItem &item)
-{
- /* Page items order:
- * Image/Video
- * Text
- * Audio
- */
- switch(item.getType())
- {
- case PageViewItem::TextType:
- {
- // Middle:
- auto itEnd = m_PageItemMap.end();
- auto it = m_PageItemMap.find(PageViewItem::ImageType);
- if(it != itEnd)
- elm_box_pack_after(m_pBox, item, *it->second);
- else if((it = m_PageItemMap.find(PageViewItem::SoundType)) != itEnd)
- elm_box_pack_before(m_pBox, item, *it->second);
- else
- elm_box_pack_start(m_pBox, item);
- break;
- }
-
- case PageViewItem::VideoType:
- case PageViewItem::ImageType:
- {
- // Top:
- elm_box_pack_start(m_pBox, item);
- break;
- }
-
- case PageViewItem::SoundType:
- {
- // Bottom:
- elm_box_pack_end(m_pBox, item);
- break;
- }
-
- default:
- assert(false);
- return;
- break;
- }
-
- item.expand();
- item.show();
-
- m_PageItemMap[item.getType()] = &item;
-}
-
-void PageView::removeItem(PageViewItem &item)
-{
- auto it = m_PageItemMap.find(item.getType());
- if(it != m_PageItemMap.end())
- m_PageItemMap.erase(it);
- item.View::destroy();
-}
-
-PageViewItem *PageView::getItem(PageViewItem::Type type) const
-{
- auto it = m_PageItemMap.find(type);
- return it == m_PageItemMap.end() ? nullptr : it->second;
-}
-
-PageView::ItemList PageView::getItems() const
-{
- ItemList res;
- Eina_List *list = elm_box_children_get(m_pBox);
- Eina_List *l = nullptr;
- void *data = nullptr;
-
- EINA_LIST_FOREACH(list, l, data)
- {
- PageViewItem *item = reinterpretCast<PageViewItem*>(data);
- res.push_back(item);
- }
- eina_list_free(list);
-
- return res;
-}
-
-Evas_Object *PageView::createLayout(Evas_Object *parent)
-{
- Evas_Object *layout = elm_layout_add(parent);
- evas_object_show(layout);
- elm_layout_file_set(layout, getEdjPath().c_str(), pageGroup);
- expand(layout);
- return layout;
-}
-
-Evas_Object *PageView::createMainLayout(Evas_Object *parent)
-{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_file_set(layout, getEdjPath().c_str(), itemLayoutGroup);
- emitSignal(layout, "show.normal.mode", "*");
- expand(layout);
- evas_object_show(layout);
- return layout;
-}
-
-Evas_Object *PageView::createBox(Evas_Object *parent)
-{
- m_pBox = elm_box_add(parent);
- elm_box_homogeneous_set(m_pBox, false);
- evas_object_show(m_pBox);
- return m_pBox;
-}
-
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "PageViewItem.h"
-#include "Resource.h"
-#include "PageView.h"
-
-using namespace Msg;
-
-PageViewItem::PageViewItem(PageView &parent, const std::string &resourcePath)
- : m_Parent(parent)
- , m_ResourcePath(resourcePath)
- , m_pListener(nullptr)
-{
-
-}
-
-PageViewItem::~PageViewItem()
-{
-
-}
-
-void PageViewItem::destroy()
-{
- m_Parent.removeItem(*this);
-}
-
-const std::string &PageViewItem::getEdjPath() const
-{
- static std::string path = PathUtils::getResourcePath(MSG_BODY_EDJ_PATH);
- return path;
-}
-
-const std::string &PageViewItem::getResourcePath() const
-{
- return m_ResourcePath;
-}
-
-void PageViewItem::setResourcePath(const std::string &resourcePath)
-{
- m_ResourcePath = resourcePath;
-}
-
-void PageViewItem::setListener(IPageViewItemListener *l)
-{
- m_pListener = l;
-}
-
-const PageView &PageViewItem::getParentPage() const
-{
- return m_Parent;
-}
-
-PageView &PageViewItem::getParentPage()
-{
- return m_Parent;
-}
-
-void PageViewItem::onBeforeDelete(View &view)
-{
- if(m_pListener)
- m_pListener->onDelete(*this);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "SoundPageViewItem.h"
-#include "FileUtils.h"
-
-using namespace Msg;
-
-namespace
-{
- const char *labelLayout = "conv/body/media_label";
- const char *fileNamePart = "text.filename";
-}
-
-SoundPageViewItem::SoundPageViewItem(PageView &parent, const std::string &resourcePath, long long fileSize, const std::string &dispName)
- : MediaPageViewItem(parent, resourcePath, fileSize)
-{
- m_DispName = dispName.empty() ? FileUtils::getFileName(resourcePath) : dispName;
- Evas_Object *label = createLabel(getButtonLayout(), m_DispName);
-
- setButtonContent(label);
-}
-
-SoundPageViewItem::~SoundPageViewItem()
-{
-
-}
-
-SoundPageViewItem::Type SoundPageViewItem::getType() const
-{
- return SoundType;
-}
-
-bool SoundPageViewItem::isEmpty() const
-{
- return false;
-}
-
-void SoundPageViewItem::highlight(bool value)
-{
-}
-
-std::string SoundPageViewItem::getFileName() const
-{
- return m_DispName;
-}
-
-Evas_Object *SoundPageViewItem::createLabel(Evas_Object *parent, const std::string &fileName)
-{
- Evas_Object *layout = elm_layout_add(parent);
- elm_layout_file_set(layout, getEdjPath().c_str(), labelLayout);
- elm_object_part_text_set(layout, fileNamePart, fileName.c_str());
- evas_object_show(layout);
- return layout;
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "TextPageViewItem.h"
-#include "PageView.h"
-#include "BaseController.h"
-
-#include <efl_extension.h>
-
-using namespace Msg;
-
-
-TextPageViewItem::TextPageViewItem(PageView &parent, int maxCharCount)
- : PageViewItem(parent)
- , m_pEntry(nullptr)
- , m_pListener(nullptr)
- , m_Changed(true)
-{
- setEo(createEntry(parent.getItemParent(), maxCharCount));
-}
-
-TextPageViewItem::~TextPageViewItem()
-{
-
-}
-
-template<class...Args>
-void TextPageViewItem::notifyListener(void *data, void (ITextPageViewItemListener::*method)(TextPageViewItem &, Args...args), Args&&...args)
-{
- TextPageViewItem *self = static_cast<TextPageViewItem*>(data);
- if(self && self->m_pListener)
- (self->m_pListener->*method)(*self, args...);
-}
-
-TextPageViewItem::Type TextPageViewItem::getType() const
-{
- return TextType;
-}
-
-bool TextPageViewItem::isEmpty() const
-{
- const char *text = elm_entry_entry_get(m_pEntry);
- return text ? text[0] == '\0' : true;
-}
-
-void TextPageViewItem::setListener(ITextPageViewItemListener *l)
-{
- m_pListener = l;
-}
-
-void TextPageViewItem::resetChangedFlag()
-{
- m_Changed = false;
-}
-
-bool TextPageViewItem::hasChanged() const
-{
- return m_Changed;
-}
-
-int TextPageViewItem::getCursorPos() const
-{
- return elm_entry_cursor_pos_get(getEo());
-}
-
-void TextPageViewItem::showInputPanel(bool show)
-{
- if(show)
- elm_entry_input_panel_show(m_pEntry);
- else
- elm_entry_input_panel_hide(m_pEntry);
-}
-
-void TextPageViewItem::setCursorPos(int pos)
-{
-
- elm_entry_cursor_pos_set(getEo(), pos);
-}
-
-void TextPageViewItem::setEndCursorPos()
-{
- elm_entry_cursor_end_set(getEo());
-}
-
-void TextPageViewItem::setBeginCursorPos()
-{
- elm_entry_cursor_begin_set(getEo());
-}
-
-void TextPageViewItem::setGuideText(const TText &text)
-{
- View::setText(m_pEntry, text, "elm.guide");
- int cur = elm_entry_cursor_pos_get(m_pEntry);
- if(!cur)
- elm_entry_cursor_line_end_set(m_pEntry);
-}
-
-void TextPageViewItem::clear()
-{
- elm_object_text_set(m_pEntry, "");
-}
-
-std::string TextPageViewItem::getText() const
-{
- return m_pEntry ? elm_object_text_get(m_pEntry) : "";
-}
-
-std::string TextPageViewItem::getPlainUtf8Text() const
-{
- std::string res;
- const char *plainText = elm_entry_entry_get(m_pEntry);
-
- if(plainText)
- {
- char *text = elm_entry_markup_to_utf8(plainText);
- if(text)
- {
- res.assign(text);
- free(text);
- }
- }
- return res;
-}
-
-void TextPageViewItem::setText(const std::string &text)
-{
- if(!text.empty())
- {
- char *markupText = elm_entry_utf8_to_markup(text.c_str());
- if(markupText)
- {
- elm_object_text_set(m_pEntry, markupText);
- free(markupText);
- }
- }
-}
-
-Evas_Object *TextPageViewItem::createEntry(Evas_Object *parent, int maxCharCount)
-{
- m_pEntry = elm_entry_add(parent);
- elm_entry_prediction_allow_set(m_pEntry, EINA_TRUE);
- elm_entry_autocapital_type_set(m_pEntry, ELM_AUTOCAPITAL_TYPE_SENTENCE);
- elm_entry_input_panel_return_key_type_set(m_pEntry, ELM_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
- elm_object_focus_allow_set(m_pEntry, true);
- elm_entry_input_panel_enabled_set(m_pEntry, EINA_FALSE); // Keypad is manually controlled
- eext_entry_selection_back_event_allow_set(m_pEntry, EINA_TRUE);
- expand(m_pEntry);
-
- Elm_Entry_Filter_Limit_Size limitFilter = {};
- limitFilter.max_char_count = maxCharCount;
- elm_entry_markup_filter_append(m_pEntry, elm_entry_filter_limit_size, &limitFilter);
- elm_entry_markup_filter_append(m_pEntry, entryFilterCheckBoundary, this);
-
- // Preset max width to avoid blink
- const int maxWidth = ELM_SCALE_SIZE(720);
- evas_object_resize(m_pEntry, maxWidth, 0);
-
- evas_object_smart_callback_add(m_pEntry, "changed", [](void *data, Evas_Object *obj, void *event_info)
- {
- TextPageViewItem *self = (TextPageViewItem*)data;
- self->m_Changed = true;
- notifyListener(data, &ITextPageViewItemListener::onChanged);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "cursor,changed", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onCursorChanged);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "focused", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onFocused);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "unfocused", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onUnfocused);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "preedit,changed", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onPreeditChanged);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "press", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onPress);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "clicked", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onClicked);
- }, this);
-
- evas_object_smart_callback_add(m_pEntry, "maxlength,reached", [](void *data, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onMaxLengthReached);
- }, this);
-
- evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_DOWN, [](void *data, Evas *e, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onKeyDown, *(Evas_Event_Key_Down*)event_info);
- }, this);
-
- evas_object_event_callback_add(m_pEntry, EVAS_CALLBACK_KEY_UP, [](void *data, Evas *e, Evas_Object *obj, void *event_info)
- {
- notifyListener(data, &ITextPageViewItemListener::onKeyUp, *(Evas_Event_Key_Up*)event_info);
- }, this);
-
- return m_pEntry;
-}
-
-void TextPageViewItem::entryFilterCheckBoundary(void *data, Evas_Object *entry, char **text)
-{
- notifyListener(data, &ITextPageViewItemListener::onCheckBoundaryText, &*text);
-}
-
+++ /dev/null
-/*
- * Copyright (c) 2009-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 "VideoPageViewItem.h"
-#include "FileUtils.h"
-
-using namespace Msg;
-
-VideoPageViewItem::VideoPageViewItem(PageView &parent, const std::string &reourcePath, long long fileSize, const std::string &imagePath)
- : ImagePageViewItem(parent, reourcePath, fileSize, imagePath)
-{
- showPlayIcon();
-}
-
-VideoPageViewItem::~VideoPageViewItem()
-{
-}
-
-std::string VideoPageViewItem::getFileName() const
-{
- return FileUtils::getFileName(getResourcePath());
-}
-
-VideoPageViewItem::Type VideoPageViewItem::getType() const
-{
- return VideoType;
-}
-
virtual ~BubbleAudioEntity();
virtual BubbleAudioViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
private:
- const std::string m_FilePath;
const std::string m_FileName;
const std::string m_Duration;
};
: public BubbleEntity
{
public:
- BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath = "");
virtual ~BubbleBgEntity();
void setBgType(BubbleBgViewItem::BgType type);
BubbleBgViewItem::BgType m_BgType;
};
- inline BubbleBgEntity::BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction)
- : BubbleEntity(type, direction)
+ inline BubbleBgEntity::BubbleBgEntity(Type type, BubbleBgViewItem::BgType bgType, Message::Direction direction, const std::string &filePath)
+ : BubbleEntity(type, direction, filePath)
, m_BgType(bgType)
{
}
virtual ~BubbleCalEventEntity();
virtual BubbleCalEventViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
private:
- std::string m_FilePath;
std::string m_Name;
std::string m_DateTime;
};
virtual ~BubbleContactEntity();
virtual BubbleContactViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
private:
ThumbnailMaker &m_ThumbMaker;
- std::string m_FilePath;
std::string m_Name;
std::string m_Address;
std::string m_ThumbPath;
virtual ~BubbleDownloadButtonEntity();
virtual BubbleDownloadButtonViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
};
inline BubbleDownloadButtonEntity::BubbleDownloadButtonEntity(Message::Direction direction)
auto *item = new BubbleDownloadButtonViewItem(*this, parent);
return item;
}
-
- inline std::string BubbleDownloadButtonEntity::getFilePath() const
- {
- return {};
- }
}
#endif /* BubbleDownloadButtonEntity_h_ */
};
public:
- BubbleEntity(Type type, Message::Direction direction);
+ BubbleEntity(Type type, Message::Direction direction, const std::string &filePath = "");
virtual ~BubbleEntity();
Type getType() const;
Message::Direction getDirection() const;
- virtual std::string getFilePath() const = 0;
+ const std::string &getFilePath() const;
+ long long getFileSize() const;
virtual BubbleViewItem *createView(Evas_Object *parent) = 0;
private:
Type m_Type;
Message::Direction m_Direction;
+ std::string m_FilePath;
+ long long m_FileSize;
};
- inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction)
+ inline BubbleEntity::BubbleEntity(Type type, Message::Direction direction, const std::string &filePath)
: m_Type(type)
, m_Direction(direction)
+ , m_FilePath(filePath)
+ , m_FileSize(!filePath.empty() ? FileUtils::getFileSize(filePath) : 0)
{
}
return m_Direction;
}
+ inline const std::string &BubbleEntity::getFilePath() const
+ {
+ return m_FilePath;
+ }
+
+ inline long long BubbleEntity::getFileSize() const
+ {
+ return m_FileSize;
+ }
+
}
#endif /* BubbleEntity_h_ */
BubbleDownloadButtonEntity *createDownloadButtonEntity(Message::Direction direction);
private:
- BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleEntity *createEntity(const std::string &filePath, const std::string &fileName, const std::string &mime, BubbleBgViewItem::BgType bgType, Message::Direction direction);
BubbleEntityFactory(BubbleEntityFactory&) = delete;
BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete;
virtual ~BubbleImageEntity();
virtual BubbleImageViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
-
- private:
- const std::string m_ImgPath;
};
inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction)
- : BubbleEntity(ImageItem, direction)
- , m_ImgPath(filePath)
+ : BubbleEntity(ImageItem, direction, filePath)
{
}
inline BubbleImageViewItem *BubbleImageEntity::createView(Evas_Object *parent)
{
- auto *item = new BubbleImageViewItem(*this, parent, m_ImgPath);
+ auto *item = new BubbleImageViewItem(*this, parent, getFilePath());
return item;
}
-
- inline std::string BubbleImageEntity::getFilePath() const
- {
- return m_ImgPath;
- }
-
}
#endif /* BubbleImageEntity_h_ */
BubbleTextEntity(BubbleBgViewItem::BgType type, Message::Direction direction, const std::string &text);
virtual ~BubbleTextEntity();
- virtual std::string getFilePath() const;
virtual BubbleTextViewItem *createView(Evas_Object *parent);
private:
{
}
- inline std::string BubbleTextEntity::getFilePath() const
- {
- static std::string empty;
- return empty;
- }
-
inline BubbleTextViewItem *BubbleTextEntity::createView(Evas_Object *parent)
{
auto *item = new BubbleTextViewItem(*this ,parent, m_BgType, m_Text);
virtual ~BubbleUnknownFileEntity();
virtual BubbleUnknownFileViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
private:
- const std::string m_FilePath;
const std::string m_FileName;
};
}
virtual ~BubbleVideoEntity();
virtual BubbleVideoViewItem *createView(Evas_Object *parent);
- virtual std::string getFilePath() const;
private:
- std::string m_VideoPath;
std::string m_ImgPath;
WorkingDirRef m_WorkingDir;
};
#define ComposeListItem_H_
#include "ComposeListViewItem.h"
-#include "BubbleEntity.h"
#include "BubbleEntityFactory.h"
#include <list>
namespace Msg
{
class IComposeListItemListener;
+ typedef std::list<BubbleEntity*> BubbleEntityList;
class ComposeListItem
: public ComposeListViewItem
ComposeListItem(BubbleEntityFactory &entityFactory);
virtual ~ComposeListItem();
- std::list<std::string> getAttachments() const;
+ void clear(bool updateUi = true);
void addAttachment(const std::string &filePath);
+ const BubbleEntityList &getAttachments() const;
+ bool isEmpty() const;
void setListener(IComposeListItemListener *l);
+ IComposeListItemListener *getListener() const;
protected:
virtual Evas_Object *getBubbleContent();
{
public:
virtual ~IComposeListItemListener() {}
- virtual void onAttachmentDeleted(const std::string &filePath) {};
+ virtual void onAttachmentAdded(const std::list<std::string> &files) {};
+ virtual void onAttachmentDeleted(const std::list<std::string> &files) {};
};
}
* @brief Get compose item
* @return compose item
*/
- ComposeListItem *getComposeItem();
+ ComposeListItem &getComposeItem();
private:
typedef std::unordered_map<MsgId::Type, ConvListItem*> ConvListItemMap;
}
BubbleAudioEntity::BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
- : BubbleBgEntity(AudioItem, bgType, direction)
- , m_FilePath(filePath)
+ : BubbleBgEntity(AudioItem, bgType, direction, filePath)
, m_FileName(fileName)
, m_Duration(makeDurationStr(filePath))
{
return item;
}
-std::string BubbleAudioEntity::getFilePath() const
-{
- return m_FilePath;
-}
-
using namespace Msg;
BubbleCalEventEntity::BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
- : BubbleBgEntity(CalendarEventItem, bgType, direction)
- , m_FilePath(filePath)
+ : BubbleBgEntity(CalendarEventItem, bgType, direction, filePath)
{
auto list = VCalendarParser::getInst().parse(filePath);
if(list.size() == 1)
item->setSubText(m_DateTime);
return item;
}
-
-std::string BubbleCalEventEntity::getFilePath() const
-{
- return m_FilePath;
-}
using namespace Msg;
BubbleContactEntity::BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
- : BubbleBgEntity(ContactItem, bgType, direction)
+ : BubbleBgEntity(ContactItem, bgType, direction, filePath)
, m_ThumbMaker(app.getThumbnailMaker())
- , m_FilePath(filePath)
{
- auto list = app.getContactManager().parseVcard(m_FilePath);
+ auto list = app.getContactManager().parseVcard(getFilePath());
if(!list.empty())
{
if(list.size() == 1)
item->setSubText(m_Address);
return item;
}
-
-std::string BubbleContactEntity::getFilePath() const
-{
- return m_FilePath;
-}
BubbleTextEntity *BubbleEntityFactory::createTextEntity(const std::string &text, BubbleBgViewItem::BgType bgType, Message::Direction direction)
{
- return new BubbleTextEntity(bgType, direction, text);
+ return text.empty() ? nullptr : new BubbleTextEntity(bgType, direction, text);
}
BubbleDownloadButtonEntity *BubbleEntityFactory::createDownloadButtonEntity(Message::Direction direction)
return new BubbleDownloadButtonEntity(direction);
}
-BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, const std::string &fileName, std::string mime, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, const std::string &fileName, const std::string &mime, BubbleBgViewItem::BgType bgType, Message::Direction direction)
{
- std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
- MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
-
- switch(msgMediaType)
+ if(FileUtils::isExists(filePath))
{
- case MsgMedia::ImageType:
- // TODO: msg service corrupts thumbnail's metadata, so it lost rotation. Use getPath instead getThumbPath until fix
- return new BubbleImageEntity(filePath, direction);
- case MsgMedia::AudioType:
- return new BubbleAudioEntity(filePath, fileName, bgType, direction);
- case MsgMedia::VideoType:
- return new BubbleVideoEntity(m_WorkingDir, filePath, direction);
- default:
- if(mime == "text/x-vcalendar" || mime == "text/calendar")
- return new BubbleCalEventEntity(filePath, fileName, bgType, direction);
- else if(mime == "text/x-vcard" || mime == "text/vcard")
- return new BubbleContactEntity(m_App, filePath, fileName , bgType, direction);
- else if(mime != "application/smil")
- return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction);
+ MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
+ switch(msgMediaType)
+ {
+ case MsgMedia::ImageType:
+ // TODO: msg service corrupts thumbnail's metadata, so it lost rotation. Use getPath instead getThumbPath until fix
+ return new BubbleImageEntity(filePath, direction);
+ case MsgMedia::AudioType:
+ return new BubbleAudioEntity(filePath, fileName, bgType, direction);
+ case MsgMedia::VideoType:
+ return new BubbleVideoEntity(m_WorkingDir, filePath, direction);
+ default:
+ if(mime == "text/x-vcalendar" || mime == "text/calendar")
+ return new BubbleCalEventEntity(filePath, fileName, bgType, direction);
+ else if(mime == "text/x-vcard" || mime == "text/vcard")
+ return new BubbleContactEntity(m_App, filePath, fileName , bgType, direction);
+ else if(mime != "application/smil")
+ return new BubbleUnknownFileEntity(filePath, fileName, bgType, direction);
+ }
}
return nullptr;
using namespace Msg;
BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
- : BubbleBgEntity(UnknownFileItem, bgType, direction)
- , m_FilePath(filePath)
+ : BubbleBgEntity(UnknownFileItem, bgType, direction, filePath)
, m_FileName(fileName)
{
item->setMainText(m_FileName);
return item;
}
-
-std::string BubbleUnknownFileEntity::getFilePath() const
-{
- return m_FilePath;
-}
BubbleVideoEntity::BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction)
- : BubbleEntity(VideoItem, direction)
- , m_VideoPath(filePath)
+ : BubbleEntity(VideoItem, direction, filePath)
, m_WorkingDir(workingDir)
{
static const std::string thumbFileName = "thumbnail.jpeg";
m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName);
if(!m_ImgPath.empty())
- MediaUtils::getVideoFrame(m_VideoPath, m_ImgPath);
+ MediaUtils::getVideoFrame(getFilePath(), m_ImgPath);
}
BubbleVideoEntity::~BubbleVideoEntity()
return item;
}
-std::string BubbleVideoEntity::getFilePath() const
-{
- return m_VideoPath;
-}
-
ComposeListItem::~ComposeListItem()
{
- for(BubbleEntity *entity : m_BubbleEntityList)
- {
- delete entity;
- }
- m_BubbleEntityList.clear();
+ m_pListener = nullptr;
+ clear(false);
}
void ComposeListItem::addAttachment(const std::string &filePath)
{
- if(!filePath.empty())
+ auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::DraftStyle, Message::MD_Sent);
+ if(entity)
{
- auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::SentStyle, Message::MD_Sent);
- if(entity)
- {
- m_BubbleEntityList.push_back(entity);
- updateBubblePart();
- getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
- }
+ m_BubbleEntityList.push_back(entity);
+ updateBubblePart();
+ getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
+ show(true);
+ if(m_pListener)
+ m_pListener->onAttachmentAdded({filePath});
}
}
-std::list<std::string> ComposeListItem::getAttachments() const
+void ComposeListItem::setListener(IComposeListItemListener *l)
{
- std::list<std::string> res;
- for(BubbleEntity *entity : m_BubbleEntityList)
- {
- res.push_back(entity->getFilePath());
- }
- return res;
+ m_pListener = l;
}
-void ComposeListItem::setListener(IComposeListItemListener *l)
+IComposeListItemListener *ComposeListItem::getListener() const
{
- m_pListener = l;
+ return m_pListener;
+}
+
+const BubbleEntityList &ComposeListItem::getAttachments() const
+{
+ return m_BubbleEntityList;
+}
+
+bool ComposeListItem::isEmpty() const
+{
+ return m_BubbleEntityList.empty();
+}
+
+void ComposeListItem::clear(bool updateUi)
+{
+ std::list<std::string> fileList;
+ for(BubbleEntity *entity : m_BubbleEntityList)
+ {
+ fileList.push_back(entity->getFilePath());
+ delete entity;
+ }
+ m_BubbleEntityList.clear();
+ if(updateUi)
+ {
+ show(false);
+ ComposeListItem::updateBubblePart();
+ }
+ if(m_pListener)
+ m_pListener->onAttachmentDeleted(fileList);
}
Evas_Object *ComposeListItem::getBubbleContent()
{
+ if(m_BubbleEntityList.empty())
+ return nullptr;
+
auto *bubble = new BubbleItemContainer(*getOwner());
for(BubbleEntity *entity : m_BubbleEntityList)
{
if(item)
{
item->showDelButton(true);
- bubble->append(*item, entity->getDirection());
item->setListener(this);
+ bubble->append(*item, entity->getDirection());
}
}
bubble->go();
std::string filePath = entity.getFilePath();
delete *it;
m_BubbleEntityList.erase(it);
+ if(isEmpty())
+ show(false);
updateBubblePart();
if(m_pListener)
- m_pListener->onAttachmentDeleted(filePath);
+ m_pListener->onAttachmentDeleted({filePath});
}
}
m_pListener->onConvListItemChecked();
}
-ComposeListItem *ConvList::getComposeItem()
+ComposeListItem &ConvList::getComposeItem()
{
if(!m_pComposeItem)
{
m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory);
m_pList->appendItem(*m_pComposeItem);
+ m_pComposeItem->show(false);
}
- return m_pComposeItem;
+ return *m_pComposeItem;
}
void ConvList::onListItemLongPressed(ListItem &listItem)
{
- ConvListItem &item = static_cast<ConvListItem&>(listItem);
- item.showPopup();
+ ConvListItem *item = dynamic_cast<ConvListItem*>(&listItem);
+ if(item)
+ item->showPopup();
}
void ConvList::onSelectAllChanged(Evas_Object *obj, void *eventInfo)
ComposeListViewItem();
virtual ~ComposeListViewItem();
+ void show(bool show);
+
protected:
virtual Evas_Object *getBubbleContent() = 0;
virtual std::string getTime() = 0;
private:
virtual std::string getText(ListItem &item, const char *part);
virtual Evas_Object *getContent(ListItem &item, const char *part);
+ virtual bool getFilter(ListItem &item, void *key);
private:
+ bool m_Visibility;
};
}
void BubbleViewItem::showDelButton(bool show)
{
- if(!m_pDelButton)
+ if(show && !m_pDelButton)
{
m_pDelButton = elm_button_add(getEo());
elm_object_style_set(m_pDelButton, "transparent");
ComposeListViewItem::ComposeListViewItem()
: ListItem(sentStyle)
+ , m_Visibility(false)
{
}
{
updateFields(bubbleContentPart, ELM_GENLIST_ITEM_FIELD_CONTENT);
}
+
+bool ComposeListViewItem::getFilter(ListItem &item, void *key)
+{
+ return m_Visibility;
+}
+
+void ComposeListViewItem::show(bool show)
+{
+ // FIXME: setFilter() do not works properly
+ // m_Visibility = show;
+ // getOwner()->setFilter(&m_Visibility);
+}
assert(m_pMsgInputPanel);
if(!m_pBody && m_pMsgInputPanel)
{
- m_pBody = new Body(getApp(), m_WorkingDir, convList);
- m_pBody->create(*m_pMsgInputPanel);
+ m_pBody = new Body(*m_pMsgInputPanel, getApp(), m_WorkingDir, convList);
m_pBody->setListener(this);
m_pBody->show();
m_pMsgInputPanel->setEntry(*m_pBody);
void Conversation::onFileSelected(AttachPanel &panel, const AttachPanel::FileList &files)
{
MSG_LOG("");
- m_pBody->enableAutoFocusForAttachments(true);
m_pBody->addMedia(files);
}