bool appendItem(ListItem &listItem, ListItem *parent = nullptr);
/**
+ * @brief Inserts an item before another in a genlist widget
+ * @param[in] listItem an item to be appended.
+ * @param[in] before the item before which to place this new one
+ * @param[in] parent a parent item.
+ * @return true in case of success, false otherwise.
+ */
+ bool insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent = nullptr);
+
+ /**
* @brief Prepends specified list-view item into list-view.
* @param[in] listItem an item to be prepended.
* @param[in] parent a parent item.
return elmItem != nullptr;
}
+bool ListView::insertBeforeItem(ListItem &listItem, ListItem &before, ListItem *parent)
+{
+ Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr;
+
+ listItem.m_pOwner = this;
+ Elm_Object_Item *elmItem = elm_genlist_item_insert_before(getEo(), listItem.m_ItemStyle->m_pGenlistItemClass,
+ &listItem, parentItem, before, listItem.getType(), on_item_selected_cb, this);
+ listItem.setElmObjItem(elmItem);
+ return elmItem != nullptr;
+}
+
bool ListView::prependItem(ListItem &listItem, ListItem *parent)
{
Elm_Object_Item *parentItem = parent ? parent->getElmObjItem() : nullptr;
class App;
class PopupListItem;
class PopupList;
+ class ConvList;
// TODO: move page(controller) methods to Page class
, private IAttachmentHandlerListener
{
public:
- Body(App &app, WorkingDirRef workingDir);
+ Body(App &app, WorkingDirRef workingDir, ConvList &convList);
virtual ~Body();
void create(Evas_Object *parent);
AttachmentHandler m_AttachmentHandler;
std::queue<std::string> m_SelectedFiles;
bool m_AutoFocusForAttachments;
+ ConvList &m_ConvList;
};
class IBodyListener
#include "MediaUtils.h"
#include "PopupList.h"
#include "PopupBodyAttachmentListItem.h"
+#include "ComposeListItem.h"
+#include "ConvList.h"
#include <assert.h>
#include <string.h>
}
}
-Body::Body(App &app, WorkingDirRef workingDir)
+Body::Body(App &app, WorkingDirRef workingDir, ConvList &convList)
: BodyView()
, m_pListener(nullptr)
, m_App(app)
, m_MmsRecipFlag(false)
, m_AttachmentHandler(workingDir)
, m_AutoFocusForAttachments(true)
+ , m_ConvList(convList)
{
m_AttachmentHandler.setListener(this);
}
if(!cmd->getVcfInfo().contactsIdList.empty())
path.push_back(createVcfFile(cmd));
- //TODO: implement fill of subject.
-
addMedia(path);
}
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);
}
}
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)
{
: public BubbleBgEntity
{
public:
- BubbleAudioEntity(const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
virtual ~BubbleAudioEntity();
virtual BubbleAudioViewItem *createView(Evas_Object *parent);
: public BubbleBgEntity
{
public:
- BubbleCalEventEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
virtual ~BubbleCalEventEntity();
virtual BubbleCalEventViewItem *createView(Evas_Object *parent);
: public BubbleBgEntity
{
public:
- BubbleContactEntity(App &app, const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
virtual ~BubbleContactEntity();
virtual BubbleContactViewItem *createView(Evas_Object *parent);
virtual std::string getFilePath() const = 0;
virtual BubbleViewItem *createView(Evas_Object *parent) = 0;
- static std::string getFileName(const MsgConvMedia &media);
-
private:
Type m_Type;
Message::Direction m_Direction;
return m_Direction;
}
- inline std::string BubbleEntity::getFileName(const MsgConvMedia &media)
- {
- std::string res = media.getName();
- if(res.empty())
- res = FileUtils::getFileName(media.getPath());
- return res;
- }
}
#endif /* BubbleEntity_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 BubbleEntityFactory_h_
+#define BubbleEntityFactory_h_
+
+#include "App.h"
+#include "WorkingDir.h"
+#include "MsgConvMedia.h"
+
+// Bubble items:
+#include "BubbleTextEntity.h"
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleDownloadButtonEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+
+#include <string>
+
+namespace Msg
+{
+ class BubbleEntityFactory
+ {
+
+ public:
+ BubbleEntityFactory(App &app, WorkingDirRef workingDir);
+ ~BubbleEntityFactory();
+
+ BubbleEntity *createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleEntity *createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleTextEntity *createTextEntity(const std::string &text, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ 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);
+
+ BubbleEntityFactory(BubbleEntityFactory&) = delete;
+ BubbleEntityFactory& operator=(const BubbleEntityFactory&) = delete;
+
+ private:
+ App &m_App;
+ WorkingDirRef m_WorkingDir;
+ };
+}
+
+#endif /* BubbleEntityFactory_h_ */
: public BubbleEntity
{
public:
- BubbleImageEntity(const MsgConvMedia &media, Message::Direction direction);
+ BubbleImageEntity(const std::string &filePath, Message::Direction direction);
virtual ~BubbleImageEntity();
virtual BubbleImageViewItem *createView(Evas_Object *parent);
const std::string m_ImgPath;
};
- inline BubbleImageEntity::BubbleImageEntity(const MsgConvMedia &media, Message::Direction direction)
+
+ inline BubbleImageEntity::BubbleImageEntity(const std::string &filePath, Message::Direction direction)
: BubbleEntity(ImageItem, direction)
- , m_ImgPath(media.getPath())
+ , m_ImgPath(filePath)
{
}
: public BubbleBgEntity
{
public:
- BubbleUnknownFileEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction);
+ BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction);
virtual ~BubbleUnknownFileEntity();
virtual BubbleUnknownFileViewItem *createView(Evas_Object *parent);
: public BubbleEntity
{
public:
- BubbleVideoEntity(WorkingDir &workingDir, const MsgConvMedia &media, Message::Direction direction);
+ BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction);
virtual ~BubbleVideoEntity();
virtual BubbleVideoViewItem *createView(Evas_Object *parent);
private:
std::string m_VideoPath;
std::string m_ImgPath;
+ WorkingDirRef m_WorkingDir;
};
}
--- /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 ComposeListItem_H_
+#define ComposeListItem_H_
+
+#include "ComposeListViewItem.h"
+#include "BubbleEntity.h"
+#include "BubbleEntityFactory.h"
+
+#include <list>
+
+namespace Msg
+{
+ class IComposeListItemListener;
+
+ class ComposeListItem
+ : public ComposeListViewItem
+ , private IBubbleViewItemListener
+ {
+ public:
+ ComposeListItem(BubbleEntityFactory &entityFactory);
+ virtual ~ComposeListItem();
+
+ void addAttachment(const std::string &filePath);
+ void setListener(IComposeListItemListener *l);
+
+ protected:
+ virtual Evas_Object *getBubbleContent();
+ virtual std::string getTime();
+ virtual std::string getMsgType();
+
+ private:
+ // IBubbleViewItemListener:
+ virtual void onAction(BubbleViewItem &item);
+ virtual void onDelClicked(BubbleViewItem &item);
+
+ private:
+ IComposeListItemListener *m_pListener;
+ std::list<BubbleEntity*> m_BubbleEntityList;
+ BubbleEntityFactory &m_BubbleEntityFactory;
+ };
+
+ class IComposeListItemListener
+ {
+ public:
+ virtual ~IComposeListItemListener() {}
+ virtual void onAttachmentDeleted(const std::string &filePath) {};
+ };
+}
+
+#endif /* ComposeListItem_H_ */
#include "ConvListItem.h"
#include "ContactManager.h"
#include "FileViewer.h"
+#include "ComposeListItem.h"
#include <unordered_map>
#include <unordered_set>
*/
int getMessageCheckedCount() const;
+ /**
+ * @brief Get compose item
+ * @return compose item
+ */
+ ComposeListItem *getComposeItem();
+
private:
typedef std::unordered_map<MsgId::Type, ConvListItem*> ConvListItemMap;
typedef std::unordered_set<std::string> DateLineItemSet;
DateLineItemSet m_DateLineItemSet;
IConvListListener *m_pListener;
App &m_App;
- WorkingDirRef m_WorkingDir;
FileViewer m_FileViewer;
ThumbId m_RecipThumbId;
std::string m_SearchWord;
+ BubbleEntityFactory m_BubbleEntityFactory;
+ ComposeListItem *m_pComposeItem;
};
class IConvListListener
#include "BubbleViewItem.h"
#include "BubbleEntity.h"
#include "BubbleBgViewItem.h"
+#include "BubbleEntityFactory.h"
namespace Msg
{
* @brief Creates item for Conversation list
* @param[in] item MsgConversationItem model
* @param[in] app Main application
- * @param[in] workingDir Smart ptr to current working dir.
+ * @param[in] bubbleEntityFactory Bubble entity factory.
* @param[in] searchWord string for search in bubble
* @param[in] thumbId Reference to id of user thumbnail
*/
ConvListItem(const MsgConversationItem &item,
App &app,
FileViewer &fileViewer,
- WorkingDirRef workingDir,
+ BubbleEntityFactory &bubbleEntityFactory,
const std::string &searchWord,
const ThumbId &thumbId = invalidThumbId);
std::string m_TimeStr;
std::list<BubbleEntity*> m_BubbleEntityList;
const ThumbId &m_ThumbId;
+ BubbleEntityFactory &m_BubbleEntityFactory;
};
class IConvListItemListener
#include "BubbleAudioEntity.h"
#include "MediaUtils.h"
#include "Resource.h"
+#include "MediaUtils.h"
#include <sstream>
#include <iomanip>
return ss.str();
}
-BubbleAudioEntity::BubbleAudioEntity(const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleAudioEntity::BubbleAudioEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
: BubbleBgEntity(AudioItem, bgType, direction)
- , m_FilePath(media.getPath())
- , m_FileName(getFileName(media))
- , m_Duration(makeDurationStr(media.getPath()))
+ , m_FilePath(filePath)
+ , m_FileName(fileName)
+ , m_Duration(makeDurationStr(filePath))
{
}
using namespace Msg;
-
-BubbleCalEventEntity::BubbleCalEventEntity(const MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleCalEventEntity::BubbleCalEventEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
: BubbleBgEntity(CalendarEventItem, bgType, direction)
- , m_FilePath(convMedia.getPath())
+ , m_FilePath(filePath)
{
- auto list = VCalendarParser::getInst().parse(convMedia.getPath());
+ auto list = VCalendarParser::getInst().parse(filePath);
if(list.size() == 1)
{
const CalendarEvent &event = list.front();
}
else
{
- m_Name = getFileName(convMedia);
+ m_Name = fileName;
}
}
using namespace Msg;
-BubbleContactEntity::BubbleContactEntity(App &app, const MsgConvMedia &media, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleContactEntity::BubbleContactEntity(App &app, const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
: BubbleBgEntity(ContactItem, bgType, direction)
, m_ThumbMaker(app.getThumbnailMaker())
- , m_FilePath(media.getPath())
+ , m_FilePath(filePath)
{
auto list = app.getContactManager().parseVcard(m_FilePath);
if(!list.empty())
}
}
if(!m_Contact)
- m_Name = getFileName(media);
+ m_Name = fileName;
}
BubbleContactEntity::~BubbleContactEntity()
--- /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 "BubbleEntityFactory.h"
+#include "FileUtils.h"
+#include "MediaType.h"
+
+// Bubble items:
+#include "BubbleTextEntity.h"
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleDownloadButtonEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+
+#include <algorithm>
+
+using namespace Msg;
+
+BubbleEntityFactory::BubbleEntityFactory(App &app, WorkingDirRef workingDir)
+ : m_App(app)
+ , m_WorkingDir(workingDir)
+{
+
+}
+
+BubbleEntityFactory::~BubbleEntityFactory()
+{
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const MsgConvMedia &msgMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+ std::string mime = msgMedia.getMime();
+ std::string fileName = msgMedia.getName();
+ std::string filePath = msgMedia.getPath();
+
+ if(mime.empty())
+ mime = FileUtils::getMimeType(filePath);
+
+ if(fileName.empty())
+ fileName = FileUtils::getFileName(filePath);
+
+ return createEntity(filePath, fileName, mime, bgType, direction);
+}
+
+BubbleEntity *BubbleEntityFactory::createEntity(const std::string &filePath, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+ return createEntity(filePath, FileUtils::getFileName(filePath), FileUtils::getMimeType(filePath), bgType, direction);
+}
+
+BubbleTextEntity *BubbleEntityFactory::createTextEntity(const std::string &text, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+{
+ return 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)
+{
+ std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
+ 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 MsgConvMedia &convMedia, BubbleBgViewItem::BgType bgType, Message::Direction direction)
+BubbleUnknownFileEntity::BubbleUnknownFileEntity(const std::string &filePath, const std::string &fileName, BubbleBgViewItem::BgType bgType, Message::Direction direction)
: BubbleBgEntity(UnknownFileItem, bgType, direction)
- , m_FilePath(convMedia.getPath())
- , m_FileName(getFileName(convMedia))
+ , m_FilePath(filePath)
+ , m_FileName(fileName)
{
+
}
BubbleUnknownFileEntity::~BubbleUnknownFileEntity()
#include "BubbleVideoEntity.h"
#include "MediaUtils.h"
+#include "FileUtils.h"
using namespace Msg;
-BubbleVideoEntity::BubbleVideoEntity(WorkingDir &workingDir, const MsgConvMedia &media, Message::Direction direction)
+
+BubbleVideoEntity::BubbleVideoEntity(WorkingDirRef workingDir, const std::string &filePath, Message::Direction direction)
: BubbleEntity(VideoItem, direction)
- , m_VideoPath(media.getPath())
+ , m_VideoPath(filePath)
+ , m_WorkingDir(workingDir)
{
static const std::string thumbFileName = "thumbnail.jpeg";
- m_ImgPath = workingDir.genUniqueFilePath(thumbFileName);
+ m_ImgPath = m_WorkingDir->genUniqueFilePath(thumbFileName);
if(!m_ImgPath.empty())
MediaUtils::getVideoFrame(m_VideoPath, m_ImgPath);
}
BubbleVideoEntity::~BubbleVideoEntity()
{
+ m_WorkingDir->removeFile(m_ImgPath);
}
BubbleVideoViewItem *BubbleVideoEntity::createView(Evas_Object *parent)
--- /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 "ComposeListItem.h"
+#include "LangUtils.h"
+#include "TimeUtils.h"
+#include "BubbleItemContainer.h"
+#include "ListView.h"
+
+// Bubble items:
+#include "BubbleImageEntity.h"
+#include "BubbleVideoEntity.h"
+#include "BubbleAudioEntity.h"
+#include "BubbleUnknownFileEntity.h"
+#include "BubbleCalEventEntity.h"
+#include "BubbleContactEntity.h"
+
+using namespace Msg;
+
+ComposeListItem::ComposeListItem(BubbleEntityFactory &entityFactory)
+ : m_pListener(nullptr)
+ , m_BubbleEntityFactory(entityFactory)
+{
+
+}
+
+ComposeListItem::~ComposeListItem()
+{
+
+}
+
+void ComposeListItem::addAttachment(const std::string &filePath)
+{
+ if(!filePath.empty())
+ {
+ auto *entity = m_BubbleEntityFactory.createEntity(filePath, BubbleBgViewItem::SentStyle, Message::MD_Sent);
+ if(entity)
+ {
+ m_BubbleEntityList.push_back(entity);
+ update();
+ getOwner()->showItem(*this, ELM_GENLIST_ITEM_SCROLLTO_BOTTOM);
+ }
+ }
+}
+
+void ComposeListItem::setListener(IComposeListItemListener *l)
+{
+
+}
+
+Evas_Object *ComposeListItem::getBubbleContent()
+{
+ auto *bubble = new BubbleItemContainer(*getOwner());
+ for(BubbleEntity *entity : m_BubbleEntityList)
+ {
+ BubbleViewItem *item = entity->createView(*bubble);
+ if(item)
+ {
+ item->showDelButton(true);
+ bubble->append(*item, entity->getDirection());
+ item->setListener(this);
+ }
+ }
+ bubble->go();
+ bubble->show();
+ return *bubble;
+}
+
+std::string ComposeListItem::getTime()
+{
+ return TimeUtils::makeBubbleTimeString(time(nullptr));
+}
+
+std::string ComposeListItem::getMsgType()
+{
+ return msg("IDS_MSGF_BODY_MMS");
+}
+
+void ComposeListItem::onAction(BubbleViewItem &item)
+{
+
+}
+
+void ComposeListItem::onDelClicked(BubbleViewItem &item)
+{
+
+}
, m_DateLineItemSet()
, m_pListener(nullptr)
, m_App(app)
- , m_WorkingDir(workingDir)
, m_FileViewer()
, m_RecipThumbId(m_App.getThumbnailMaker().getThumbId(ThumbnailMaker::SingleThumb))
, m_SearchWord()
+ , m_BubbleEntityFactory(app, workingDir)
+ , m_pComposeItem(nullptr)
{
create(parent);
}
void ConvList::appendItem(const MsgConversationItem &item)
{
if(item.getDirection() == Message::MD_Received)
- appendItem(new ConvListItem(item, m_App, m_FileViewer, m_WorkingDir, m_SearchWord, m_RecipThumbId));
+ appendItem(new ConvListItem(item, m_App, m_FileViewer, m_BubbleEntityFactory, m_SearchWord, m_RecipThumbId));
else
- appendItem(new ConvListItem(item, m_App, m_FileViewer, m_WorkingDir, m_SearchWord));
+ appendItem(new ConvListItem(item, m_App, m_FileViewer, m_BubbleEntityFactory, m_SearchWord));
}
void ConvList::appendItem(ConvListItem *item)
dateLineAddIfNec(item);
m_ConvListItemMap[item->getMsgId()] = item;
item->setListener(this);
- m_pList->appendItem(*item);
+ if(m_pComposeItem)
+ m_pList->insertBeforeItem(*item, *m_pComposeItem);
+ else
+ m_pList->appendItem(*item);
}
void ConvList::deleteItem(ConvListItem *item)
dateLineDelIfNec(item);
dateLineAddIfNec(item);
m_pList->demoteItem(*item);
+ if(m_pComposeItem)
+ m_pList->demoteItem(*m_pComposeItem);
}
void ConvList::dateLineDelIfNec(ConvListItem *item)
{
DateLineItem *dateLine = new DateLineItem(item->getRawTime(), dateStr);
m_DateLineItemSet.insert(dateStr);
- m_pList->appendItem(*dateLine);
+ if(m_pComposeItem)
+ m_pList->insertBeforeItem(*dateLine, *m_pComposeItem);
+ else
+ m_pList->appendItem(*dateLine);
}
}
void ConvList::clear()
{
- m_pList->clear();
+ auto items = m_pList->getItems();
+ for(ListItem *item : items)
+ {
+ if(item != m_pComposeItem)
+ item->destroy();
+ }
m_ConvListItemMap.clear();
m_DateLineItemSet.clear();
}
m_pListener->onConvListItemChecked();
}
+ComposeListItem *ConvList::getComposeItem()
+{
+ if(!m_pComposeItem)
+ {
+ m_pComposeItem = new ComposeListItem(m_BubbleEntityFactory);
+ m_pList->appendItem(*m_pComposeItem);
+ }
+ return m_pComposeItem;
+}
+
void ConvList::onListItemLongPressed(ListItem &listItem)
{
ConvListItem &item = static_cast<ConvListItem&>(listItem);
ConvListItem::ConvListItem(const MsgConversationItem &item,
App &app,
FileViewer &fileViewer,
- WorkingDirRef workingDir,
+ BubbleEntityFactory &bubbleEntityFactory,
const std::string &searchWord,
const ThumbId &thumbId)
: ConvListViewItem(getConvItemType(item))
, m_pListener(nullptr)
, m_App(app)
- , m_WorkingDir(workingDir)
, m_FileViewer(fileViewer)
, m_MsgId(item.getMsgId())
, m_IsDraft(item.isDraft())
, m_Type(item.getType())
, m_Time(item.getTime())
, m_ThumbId(thumbId)
+ , m_BubbleEntityFactory(bubbleEntityFactory)
{
prepareBubble(item, searchWord);
}
if(findText(text, searchWord))
showSearch();
-
- return new BubbleTextEntity(bgType, direction, utf8ToMarkup(text));
+ return m_BubbleEntityFactory.createTextEntity(utf8ToMarkup(text), bgType, direction);
}
BubbleEntity *ConvListItem::createTextEntity(BubbleBgViewItem::BgType bgType, Message::Direction direction, std::string text, bool markup, const std::string &searchWord)
{
if(findText(text, searchWord))
showSearch();
-
std::string resText = markup ? utf8ToMarkup(text) : std::move(text);
-
- return new BubbleTextEntity(bgType, direction, resText);
+ return m_BubbleEntityFactory.createTextEntity(resText, bgType, direction);
}
void ConvListItem::addEntity(BubbleEntity *entity)
{
std::string text = MessageDetailContent::getMmsNotiConvListItemContent(m_App, m_MsgId);
addEntity(createTextEntity(bgType, direction, text, false, searchWord));
- addEntity(new BubbleDownloadButtonEntity(direction));
+ addEntity(m_BubbleEntityFactory.createDownloadButtonEntity(direction));
}
else
{
const MsgConvMediaList &list = item.getMediaList();
- for(int i = 0; i < list.getLength(); i++)
+ for(int i = 0; i < list.getLength(); ++i)
{
const MsgConvMedia &media = list.at(i);
std::string mime = media.getMime();
- MsgMedia::Type msgMediaType = getMsgMediaTypeByMime(mime);
std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
- BubbleEntity *entity = nullptr;
-
- switch(msgMediaType)
- {
- case MsgMedia::TextType:
- entity = createTextEntity(bgType, direction, media, searchWord);
- break;
- case MsgMedia::ImageType:
- // TODO: msg service corrupts thumbnail's metadata, so it lost rotation. Use getPath instead getThumbPath until fix
- entity = new BubbleImageEntity(media, direction);
- break;
- case MsgMedia::AudioType:
- entity = new BubbleAudioEntity(media, bgType, direction);
- break;
- case MsgMedia::VideoType:
- entity = new BubbleVideoEntity(*m_WorkingDir, media, direction);
- break;
- default:
- if(mime == "text/x-vcalendar" || mime == "text/calendar")
- entity = new BubbleCalEventEntity(media, bgType, direction);
- else if(mime == "text/x-vcard" || mime == "text/vcard")
- entity = new BubbleContactEntity(m_App, media, bgType, direction);
- else if(mime != "application/smil")
- entity = new BubbleUnknownFileEntity(media, bgType, direction);
- break;
- }
- addEntity(entity);
+ if(mime == "text/plain")
+ addEntity(createTextEntity(bgType, direction, media, searchWord));
+ else if(mime != "application/smil")
+ addEntity(m_BubbleEntityFactory.createEntity(media, bgType, direction));
}
}
}
public:
virtual ~IBubbleViewItemListener() {};
virtual void onAction(BubbleViewItem &item) {}; // Tap or Click
- virtual void onDelClecked(BubbleViewItem &item) {}; // Delete button clicked
+ virtual void onDelClicked(BubbleViewItem &item) {}; // Delete button clicked
};
}
--- /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 ComposeListViewItem_H_
+#define ComposeListViewItem_H_
+
+#include "ListItem.h"
+
+namespace Msg
+{
+ class ComposeListViewItem
+ : public ListItem
+ {
+ public:
+ ComposeListViewItem();
+ virtual ~ComposeListViewItem();
+
+ protected:
+ virtual Evas_Object *getBubbleContent() = 0;
+ virtual std::string getTime() = 0;
+ virtual std::string getMsgType() = 0;
+
+ private:
+ virtual std::string getText(ListItem &item, const char *part);
+ virtual Evas_Object *getContent(ListItem &item, const char *part);
+
+ private:
+ };
+}
+
+#endif /* ComposeListViewItem_H_ */
void BubbleViewItem::onDelButtonClicked(Evas_Object *obj, void *eventInfo)
{
if(m_pListener)
- m_pListener->onDelClecked(*this);
+ m_pListener->onDelClicked(*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 "ComposeListViewItem.h"
+#include "CallbackAssist.h"
+#include "ListView.h"
+#include "Resource.h"
+
+using namespace Msg;
+
+namespace
+{
+ ListItemStyleRef sentStyle = ListItemStyle::create("sentbubble");
+
+ const char *bubbleContentPart = "bubble.content";
+ const char *timeTextPart = "info.time";
+ const char *msgType = "msg.type";
+}
+
+ComposeListViewItem::ComposeListViewItem()
+ : ListItem(sentStyle)
+{
+}
+
+ComposeListViewItem::~ComposeListViewItem()
+{
+
+}
+
+std::string ComposeListViewItem::getText(ListItem &item, const char *part)
+{
+ if(!strcmp(part, timeTextPart))
+ return getTime();
+ else if(!strcmp(part, msgType))
+ return getMsgType();
+
+ return "";
+}
+
+Evas_Object *ComposeListViewItem::getContent(ListItem &item, const char *part)
+{
+ if(!strcmp(part, bubbleContentPart))
+ return getBubbleContent();
+
+ return nullptr;
+}
+
void setMode(Mode mode);
void setNewMessageMode();
void setConversationMode();
- void createBody(Evas_Object *parent);
+ void createBody(Evas_Object *parent, ConvList &convList);
void createRecipPanel(Evas_Object *parent);
void destroyRecipPanel();
void createContactList(Evas_Object *parent);
m_WorkingDir = std::make_shared<WorkingDir>();
createMainLayout(getParent());
createMsgInputPanel(*m_pLayout);
- createBody(*m_pMsgInputPanel);
createConvList(*m_pLayout);
+ createBody(*m_pMsgInputPanel, *m_pConvList);
updateMsgInputPanel();
getApp().getContactManager().addListener(*this);
}
}
-void Conversation::createBody(Evas_Object *parent)
+void Conversation::createBody(Evas_Object *parent, ConvList &convList)
{
assert(m_pMsgInputPanel);
if(!m_pBody && m_pMsgInputPanel)
{
- m_pBody = new Body(getApp(), m_WorkingDir);
+ m_pBody = new Body(getApp(), m_WorkingDir, convList);
m_pBody->create(*m_pMsgInputPanel);
m_pBody->setListener(this);
m_pBody->show();