#define COMPOSER_LAYOUT_EDJ_PATH EDJ_PATH"/composer_layout.edj"
#define MSG_BODY_EDJ_PATH EDJ_PATH"/msg_body.edj"
#define SEARCH_BAR_EDJ_PATH EDJ_PATH"/search_bar.edj"
+#define COMMON_GENLIST_THEME_EDJ_PATH EDJ_PATH"/common_genlist_theme.edj"
#define CONV_GENLIST_THEME_EDJ_PATH EDJ_PATH"/conv_genlist_theme.edj"
#define INPUT_LAYOUT_EDJ_PATH EDJ_PATH"/input_layout.edj"
#define CONV_LIST_BUBBLE_EDJ_PATH EDJ_PATH"/conv_list_bubble.edj"
--- /dev/null
+#include "macros.inl"
+
+collections {
+ BASE_SCALE;
+ group {
+ name: "elm/genlist/item/custom_title/default";
+ data.item: "contents" "swl.content";
+ parts{
+ PADDING_TOP("pad.top", 37);
+ PADDING_BOTTOM("pad.bottom", 7);
+ swallow { "swl.content"; scale; nomouse;
+ desc { "default";
+ align: 0.5 1.0;
+ min: 0 39;
+ max: 240 39;
+ rel1 { relative : 0.0 1.0; to_y: "pad.top"; }
+ rel2 { relative : 1.0 0.0; to_y: "pad.bottom"; }
+ }
+ }
+ }
+ }
+}
}
}
}
-
- group {
- name: "elm/genlist/item/conv_title/default";
- data.item: "contents" "swl.content";
- parts{
- PADDING_TOP("pad.top", 37);
- PADDING_BOTTOM("pad.bottom", 7);
- swallow { "swl.content"; scale; nomouse;
- desc { "default";
- align: 0.5 1.0;
- min: 0 39;
- max: 240 39;
- rel1 { relative : 0.0 1.0; to_y: "pad.top"; }
- rel2 { relative : 1.0 0.0; to_y: "pad.bottom"; }
- }
- }
- }
- }
-
group {
name: "elm/genlist/item/1lineitem/default";
inherit: "elm/genlist/item/dateline/default";
void onLowBattery(app_event_info_h appEvent);
void onRegionChanged(app_event_info_h appEvent);
+ private:
+ void addTheme(const std::string &themePath);
+
private:
Window *m_pWindow;
MsgEngine *m_pEngine;
return m_IsPause;
}
+void App::addTheme(const std::string &themePath)
+{
+ std::string path = PathUtils::getResourcePath(themePath);
+ elm_theme_extension_add(nullptr, path.c_str());
+}
+
bool App::onCreate()
{
TRACE;
if (!appInstance)
return false;
- std::string convGenlistThemePath = PathUtils::getResourcePath(CONV_GENLIST_THEME_EDJ_PATH);
- elm_theme_extension_add(nullptr, convGenlistThemePath.c_str());
-
- std::string imagesPath = PathUtils::getResourcePath(IMAGES_EDJ_PATH);
- elm_theme_extension_add(nullptr, imagesPath.c_str());
-
- std::string threadThemePath = PathUtils::getResourcePath(THREAD_THEME_EDJ_PATH);
- elm_theme_extension_add(nullptr, threadThemePath.c_str());
-
- std::string threadComposeThemePath = PathUtils::getResourcePath(THREAD_COMPOSE_LIST_VIEW_ITEM);
- elm_theme_extension_add(nullptr, threadComposeThemePath.c_str());
+ addTheme(COMMON_GENLIST_THEME_EDJ_PATH);
+ addTheme(CONV_GENLIST_THEME_EDJ_PATH);
+ addTheme(IMAGES_EDJ_PATH);
+ addTheme(THREAD_THEME_EDJ_PATH);
+ addTheme(THREAD_COMPOSE_LIST_VIEW_ITEM);
feedback_initialize();
getWindow();
// Constructor for nullptr;
TText(std::nullptr_t)
: m_pDomain(nullptr)
- , m_pMsg(nullptr)
, m_IsTranslatable(false)
{
}
- // Constructor for translatable string;
- TText(bool dummy, const char *stringId, const char *domainName)
- : m_pDomain(domainName)
- , m_pMsg(stringId)
- , m_IsTranslatable(true)
+ // Move Constructor;
+ TText(TText &&text)
+ : m_pDomain(text.m_pDomain)
+ , m_Str(std::move(text.m_Str))
+ , m_IsTranslatable(text.m_IsTranslatable)
{
}
- // Constructor for plain C string;
- TText(const char *str)
- : m_pDomain(nullptr)
- , m_pMsg(str)
- , m_IsTranslatable(false)
+ // Constructor for C string
+ TText(const char *str, bool translatable = false, const char *domainName = MSG_DOMAIN)
+ : m_pDomain(domainName)
+ , m_Str(str ? str : "")
+ , m_IsTranslatable(translatable)
{
}
- // Constructor for plain std::string;
- TText(std::string str)
- : m_pDomain(nullptr)
+ // Constructor for C++ string
+ TText(std::string str, bool translatable = false, const char *domainName = MSG_DOMAIN)
+ : m_pDomain(domainName)
, m_Str(std::move(str))
- , m_pMsg(m_Str.c_str())
- , m_IsTranslatable(false)
+ , m_IsTranslatable(translatable)
{
}
+ void clear()
+ {
+ m_Str.clear();
+ m_pDomain = nullptr;
+ m_IsTranslatable = false;
+ }
+
const char *getMsg() const
{
- return m_pMsg;
+ return m_Str.c_str();
}
const char *getDomain() const
{
+ if (m_pDomain && m_pDomain[0] == 0)
+ return nullptr;
return m_pDomain;
}
bool isTranslatable() const
{
- return m_IsTranslatable;
+ return m_IsTranslatable;
}
private:
- TText(TText&) = delete;
- TText operator =(TText&) = delete;
-
const char *m_pDomain;
std::string m_Str;
- const char *m_pMsg;
bool m_IsTranslatable;
};
const char *m_pMsg;
};
- #define msgt(strId) TText(true, strId, MSG_DOMAIN)
+ #define msgt(strId) TText(strId, true, MSG_DOMAIN)
#define msg(strId) DText(strId, MSG_DOMAIN)
#define msgArgs(strId, ...) DText(0, strId, MSG_DOMAIN, __VA_ARGS__)
#define sys(strId) DText(strId, SYS_DOMAIN)
- #define syst(strId) TText(true, strId, SYS_DOMAIN)
+ #define syst(strId) TText(strId, true, SYS_DOMAIN)
#define sysArgs(strId, ...) DText(0, strId, SYS_DOMAIN, __VA_ARGS__)
}
public:
TextStyle();
+ TextStyle(const TextStyle&) = default;
+ TextStyle(TextStyle &&style);
TextStyle(int size, const std::string &color, Align align = Align::None);
~TextStyle();
TextStyle &setSize(int size);
TextStyle &setAlign(Align align);
TextStyle &setWeight(Weight weight);
+ bool isEmpty() const;
const std::string &getColor() const;
int getSize() const;
{
}
+TextStyle::TextStyle(TextStyle &&style)
+ : m_Weight(style.m_Weight)
+ , m_Color(std::move(style.m_Color))
+ , m_Align(style.m_Align)
+ , m_Size(style.m_Size)
+{
+}
+
TextStyle::TextStyle(int size, const std::string &color, Align align)
: m_Weight(Weight::None)
, m_Color(color)
return *this;
}
+bool TextStyle::isEmpty() const
+{
+ return m_Weight == Weight::None &&
+ m_Align == Align::None &&
+ m_Color.empty() &&
+ m_Size == 0;
+}
+
const std::string &TextStyle::getColor() const
{
return m_Color;
std::string make(const std::string &text, const TextStyle &style)
{
+ if (style.isEmpty())
+ return text;
return make(text, style.getSize(), style.getColor(), style.getAlign(), style.getWeight());
}
#include <memory>
#include <vector>
#include <Elementary.h>
+#include <functional>
namespace Msg
{
friend class ListView;
public:
+ using OnSelectedCb = std::function<void(ListItem &item)>;
+
/**
* @brief Creates instance of ListItem of specified genlist-item type.
* @param[in] type genlist item-type.
*/
bool isSame(const ListItem &item) const;
+ /**
+ * @brief Sets custom selected callback to item
+ * @param[in] cb OnSelectedCb callback
+ */
+ void setOnSelectedCb(OnSelectedCb cb);
+
protected:
virtual std::string getText(ListItem &item, const char *part);
virtual Evas_Object *getContent(ListItem &item, const char *part);
ListItemStyleRef m_ItemStyle;
Elm_Genlist_Item_Type m_Type;
bool m_Checked;
+ OnSelectedCb m_OnSelectedCb;
};
}
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 TitleListItem_h_
+#define TitleListItem_h_
+
+#include "ListItem.h"
+#include "TextDecorator.h"
+
+namespace Msg {
+ class TitleListItem
+ : public ListItem {
+ public:
+ TitleListItem();
+
+ void setTitle(std::string title, bool translate);
+
+ private:
+ Evas_Object *getContent(ListItem &item, const char *part) override;
+ Evas_Object *createLabel();
+
+ private:
+ std::string m_Title;
+ bool m_Translate;
+ };
+}
+
+#endif /* TitleListItem_h_ */
, m_ItemStyle(itemStyle)
, m_Type(type)
, m_Checked(false)
+ , m_OnSelectedCb()
{
}
return item.getElmObjItem() == getElmObjItem();
}
+void ListItem::setOnSelectedCb(OnSelectedCb cb)
+{
+ m_OnSelectedCb = cb;
+}
+
void ListItem::onCheckChanged(Evas_Object *obj, void *eventInfo)
{
m_Checked = elm_check_state_get(obj);
item->changeCheckedState(true);
notifyListener(data, obj, event_info, &IListViewListener::onListItemChecked);
} else {
+ if (item->m_OnSelectedCb)
+ item->m_OnSelectedCb(*item);
notifyListener(data, obj, event_info, &IListViewListener::onListItemSelected);
}
}
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "TitleListItem.h"
+#include "ListView.h"
+#include "TextDecorator.h"
+#include "LangUtils.h"
+
+using namespace Msg;
+
+const auto titleTextStyle = TextStyle().
+ setSize(30).
+ setAlign(TextStyle::Align::Center).
+ setWeight(TextStyle::Weight::Bold).
+ setColor("#ffae0d");
+
+TitleListItem::TitleListItem()
+ : ListItem(ListItemStyle::create("custom_title"))
+ , m_Translate(false)
+{
+}
+
+void TitleListItem::setTitle(std::string title, bool translate)
+{
+ m_Title = std::move(title);
+ m_Translate = translate;
+}
+
+Evas_Object *TitleListItem::createLabel()
+{
+ static const double slideDuration = 3.0;
+
+ Evas_Object *label = elm_label_add(*getOwner());
+ elm_object_focus_allow_set(label, false);
+ elm_object_style_set(label, "slide_roll");
+ elm_label_ellipsis_set(label, true);
+ elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
+ elm_label_slide_duration_set(label, slideDuration);
+
+ std::string text = m_Translate ? msg(m_Title) : m_Title;
+ std::string resultText = TextDecorator::make(text, titleTextStyle);
+
+ View::setText(label, resultText);
+ elm_label_slide_go(label);
+ return label;
+}
+
+Evas_Object *TitleListItem::getContent(ListItem &item, const char *part)
+{
+ return createLabel();
+}
class PaddingListViewItem;
class ConvReplyListItem;
class IConvListListener;
- class ConvTitleListItem;
+ class TitleListItem;
class ConvList
: public ListView
PaddingListViewItem *m_pBottomPadItem;
ConvReplyListItem *m_pReplyItem;
ListItem *m_pItemAfterConv; // Reply or Bottom padding.
- ConvTitleListItem *m_pConvTitleItem;
+ TitleListItem *m_pTitleItem;
WorkingDirRef m_WorkingDir;
BubbleEntityFactory m_BubbleEntityFactory;
ConvListItemMap m_ConvListItemMap;
#include "Window.h"
#include "ConvReplyListItem.h"
#include "PaddingListViewItem.h"
-#include "ConvTitleListItem.h"
+#include "TitleListItem.h"
#include "ConvDateLineListItem.h"
#include "TimeUtils.h"
#include "BubbleEntityFactory.h"
, m_pBottomPadItem(nullptr)
, m_pReplyItem(nullptr)
, m_pItemAfterConv(nullptr)
- , m_pConvTitleItem(nullptr)
+ , m_pTitleItem(nullptr)
, m_WorkingDir(workingDir)
, m_BubbleEntityFactory(m_WorkingDir)
{
void ConvList::updateTitle()
{
MsgAddressListRef list = getMsgStorage().getAddressList(m_ThreadId);
- if (list && !list->isEmpty() && m_pConvTitleItem) {
- m_pConvTitleItem->setTitle(list->at(0).getAddress());
+ if (list && !list->isEmpty() && m_pTitleItem) {
+ m_pTitleItem->setTitle(list->at(0).getAddress(), false);
// TODO: Find address in contacts
}
}
clear();
// Recipient name:
- m_pConvTitleItem = new ConvTitleListItem;
- ListView::appendItem(*m_pConvTitleItem);
+ m_pTitleItem = new TitleListItem;
+ ListView::appendItem(*m_pTitleItem);
MsgConversationListRef convList = getMsgStorage().getConversationList(m_ThreadId);
int convListLen = convList->getLength();
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 ConvTitleListItem_h_
-#define ConvTitleListItem_h_
-
-#include "ListItem.h"
-
-namespace Msg {
- class ConvTitleListItem
- : public ListItem {
- public:
- ConvTitleListItem();
-
- void setTitle(const std::string &title);
-
- private:
- Evas_Object *getContent(ListItem &item, const char *part) override;
- Evas_Object *createLabel() const;
-
- private:
- std::string m_Title;
- };
-}
-
-#endif /* ConvTitleListItem_h_ */
+++ /dev/null
-/*
- * Copyright 2016 Samsung Electronics Co., Ltd
- *
- * Licensed under the Flora License, Version 1.1 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://floralicense.org/license/
- *
- * 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 "ConvTitleListItem.h"
-#include "ListView.h"
-#include "TextDecorator.h"
-
-using namespace Msg;
-
-const TextStyle titleTextStyle = TextStyle().
- setSize(30).
- setAlign(TextStyle::Align::Center).
- setWeight(TextStyle::Weight::Bold).
- setColor("#ffae0d");
-
-ConvTitleListItem::ConvTitleListItem()
- : ListItem(ListItemStyle::create("conv_title"))
-{
-}
-
-void ConvTitleListItem::setTitle(const std::string &title)
-{
- m_Title = TextDecorator::make(title, titleTextStyle);
-}
-
-Evas_Object *ConvTitleListItem::createLabel() const
-{
- static const double slideDuration = 3.0;
-
- Evas_Object *label = elm_label_add(*getOwner());
- elm_object_focus_allow_set(label, false);
- elm_object_style_set(label, "slide_roll");
- elm_label_ellipsis_set(label, true);
- elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO);
- elm_label_slide_duration_set(label, slideDuration);
- elm_label_slide_go(label);
- View::setText(label, m_Title);
- return label;
-}
-
-Evas_Object *ConvTitleListItem::getContent(ListItem &item, const char *part)
-{
- return createLabel();
-}
#define SettingsBlockListFrame_h_
#include "FrameController.h"
-#include "ListView.h"
namespace Msg
{
+ class ListView;
+
class SettingsBlockListFrame
: public FrameController
- , private IListViewListener
{
public:
SettingsBlockListFrame(NaviFrameController &parent);
void onAttached(ViewItem &item) override;
private:
- // IListViewListener:
- void onListItemSelected(ListItem &listItem) override;
+ void onBlockedNumberSelected(ListItem &listItem);
+ void onBlockedMsgSelected(ListItem &listItem);
void preapareList();
+ void fillList();
private:
ListView *m_pList;
*/
#include "SettingsBlockListFrame.h"
+#include "SettingsMenuListItem.h"
+#include "PaddingListViewItem.h"
#include "App.h"
#include "Window.h"
#include "Logger.h"
+#include "ListView.h"
+#include "TitleListItem.h"
+#include "ListView.h"
using namespace Msg;
{
if (!m_pList) {
m_pList = new ListView(getParent(), App::getInst().getWindow().getCircleSurface());
- m_pList->setListener(this);
m_pList->setHomogeneous(false);
m_pList->setMultiSelection(false);
+ fillList();
}
}
-void SettingsBlockListFrame::onListItemSelected(ListItem &listItem)
+void SettingsBlockListFrame::fillList()
{
+ using namespace std::placeholders;
+ // Title:
+ auto *titleItem = new TitleListItem;
+ titleItem->setTitle("WDS_MSG_MBODY_BLOCK_LIST", true);
+ m_pList->appendItem(*titleItem);
+
+ // Blocked number:
+ auto *blockedNum = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle);
+ blockedNum->setText("WDS_MSG_MBODY_BLOCKED_NUMBERS");
+ std::bind(&SettingsBlockListFrame::onBlockedNumberSelected, this);
+ blockedNum->setOnSelectedCb(std::bind(&SettingsBlockListFrame::onBlockedNumberSelected, this, _1));
+ m_pList->appendItem(*blockedNum);
+
+ // Blocked messages:
+ auto *blockedMsg = new SettingsMenuListItem(SettingsMenuListItem::oneTextStyle);
+ blockedMsg->setText("WDS_MSG_MBODY_BLOCKED_NUMBERS");
+ blockedMsg->setOnSelectedCb(std::bind(&SettingsBlockListFrame::onBlockedMsgSelected, this, _1));
+ m_pList->appendItem(*blockedMsg);
+
+ // Bottom padding:
+ m_pList->appendItem(*new PaddingListViewItem);
+}
+
+void SettingsBlockListFrame::onBlockedNumberSelected(ListItem &listItem)
+{
+ MSG_LOG("");
}
+
+void SettingsBlockListFrame::onBlockedMsgSelected(ListItem &listItem)
+{
+ MSG_LOG("");
+}
+
: public ListItem {
public:
BlockedNumberListViewItem();
- ~BlockedNumberListViewItem();
+ virtual ~BlockedNumberListViewItem();
public:
static ListItemStyleRef numberStyle;
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 SettingsMenuListItem_h_
+#define SettingsMenuListItem_h_
+
+#include "ListItem.h"
+
+namespace Msg {
+ class SettingsMenuListItem
+ : public ListItem {
+
+ public:
+ static ListItemStyleRef oneTextStyle;
+ static ListItemStyleRef twoTextStyle;
+
+ public:
+ SettingsMenuListItem(const ListItemStyleRef &itemStyle);
+ virtual ~SettingsMenuListItem();
+
+ void setText(std::string text);
+ void setSubText(std::string text);
+
+ private:
+ std::string getText(ListItem &item, const char *part) override;
+
+ private:
+ std::string m_Text;
+ std::string m_SubText;
+ };
+}
+
+#endif // SettingsMenuListItem_h_
--- /dev/null
+/*
+ * Copyright 2016 Samsung Electronics Co., Ltd
+ *
+ * Licensed under the Flora License, Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * 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 "SettingsMenuListItem.h"
+#include "LangUtils.h"
+
+using namespace Msg;
+
+namespace {
+ const char *mainTextPart = "elm.text";
+ const char *subTextPart = "elm.text.1";
+}
+
+ListItemStyleRef SettingsMenuListItem::oneTextStyle = ListItemStyle::create("1text");
+ListItemStyleRef SettingsMenuListItem::twoTextStyle = ListItemStyle::create("2text");
+
+SettingsMenuListItem::SettingsMenuListItem(const ListItemStyleRef &itemStyle)
+ : ListItem(itemStyle)
+{
+}
+
+SettingsMenuListItem::~SettingsMenuListItem()
+{
+}
+
+void SettingsMenuListItem::setText(std::string text)
+{
+ m_Text = std::move(text);
+}
+
+void SettingsMenuListItem::setSubText(std::string text)
+{
+ m_SubText = std::move(text);
+}
+
+std::string SettingsMenuListItem::getText(ListItem &item, const char *part)
+{
+ if (strcmp(part, mainTextPart) == 0)
+ return msg(m_Text.c_str());
+
+ if (strcmp(part, subTextPart) == 0)
+ return msg(m_SubText.c_str());
+
+ return "";
+}
+