From c3bcb369e62d42994a0036283807bdc8f026b6d8 Mon Sep 17 00:00:00 2001 From: Nataliia Sydorchuk Date: Wed, 7 Sep 2016 15:23:58 +0300 Subject: [PATCH] TizenRefApp-6915 Move contact Name into title in LogDetailsView Change-Id: Ic1e826d40350cd4e919ef02e66c3550cb53d8bd6 Signed-off-by: Nataliia Sydorchuk --- lib-common/res/details/edje/DetailsItemLayout.h | 3 - .../res/details/edje/DetailsItemLayoutMetrics.h | 12 +--- .../res/details/edje/details-item-layout.edc | 67 +--------------------- lib-logs/inc/Logs/Details/BasicInfoItem.h | 33 +++++------ lib-logs/inc/Logs/Details/DetailsView.h | 1 - .../details/edje/LogsDetailsItemLayoutMetrics.h | 5 -- .../res/details/edje/logs-details-item-layout.edc | 35 +---------- lib-logs/src/Logs/Details/BasicInfoItem.cpp | 62 +++++++------------- lib-logs/src/Logs/Details/DetailsView.cpp | 18 ++---- 9 files changed, 43 insertions(+), 193 deletions(-) diff --git a/lib-common/res/details/edje/DetailsItemLayout.h b/lib-common/res/details/edje/DetailsItemLayout.h index a03dbe5..cdd8b16 100644 --- a/lib-common/res/details/edje/DetailsItemLayout.h +++ b/lib-common/res/details/edje/DetailsItemLayout.h @@ -20,9 +20,6 @@ #define DETAILS_ITEM_STYLE "details_item" -#define PART_BACK_BTN "swallow.back" #define PART_THUMBNAIL "swallow.thumbnail" -#define PART_NAME "text.name" - #endif /* DETAILS_ITEM_LAYOUT_H */ diff --git a/lib-common/res/details/edje/DetailsItemLayoutMetrics.h b/lib-common/res/details/edje/DetailsItemLayoutMetrics.h index 80e0e2f..b79d5b0 100644 --- a/lib-common/res/details/edje/DetailsItemLayoutMetrics.h +++ b/lib-common/res/details/edje/DetailsItemLayoutMetrics.h @@ -20,18 +20,8 @@ #define ACTION_BTN_WH 80 -#define BACK_BTN_WH 80 -#define BACK_BTN_T 13 -#define BACK_BTN_L 10 - #define THUMBNAIL_WH 270 #define THUMBNAIL_T 60 - -#define TEXT_LR 24 -#define TEXT_T 2 - -#define NAME_H 76 -#define NAME_B 28 -#define NAME_TEXT_SIZE 56 +#define THUMBNAIL_B 110 #endif /* DETAILS_ITEM_LAYOUT_METRICS_H */ diff --git a/lib-common/res/details/edje/details-item-layout.edc b/lib-common/res/details/edje/details-item-layout.edc index 86b1f4a..d11f69d 100644 --- a/lib-common/res/details/edje/details-item-layout.edc +++ b/lib-common/res/details/edje/details-item-layout.edc @@ -19,13 +19,6 @@ #include "DetailsItemLayoutMetrics.h" #include "../../../../lib-apps-common/res/apps-common/edje/apps-common-colors.edc" -styles { - style { - name: "name_style"; - base: "font=Tizen:style=Light font_size="NAME_TEXT_SIZE" align=center wrap=mixed color=#fafafa ellipsis=1.0"; - } -} - collections { base_scale: 2.6; @@ -36,26 +29,9 @@ collections alias: "elm/genlist/tree/"DETAILS_ITEM_STYLE"/default"; alias: "elm/genlist/tree_compress/"DETAILS_ITEM_STYLE"/default"; - data.item: "texts" PART_NAME; - data.item: "contents" PART_BACK_BTN" "PART_THUMBNAIL; + data.item: "contents" PART_THUMBNAIL; parts { - spacer { "spacer.left_top"; scale; - desc { "default"; - min: BACK_BTN_L BACK_BTN_T; - align: 0.0 0.0; - rel1.relative: 0.0 0.0; - rel2.relative: 0.0 0.0; - } - } - swallow { PART_BACK_BTN; scale; - desc { "default"; - min: BACK_BTN_WH BACK_BTN_WH; - align: 0.0 0.0; - rel1 { relative: 1.0 1.0; to: "spacer.left_top"; } - rel2 { relative: 1.0 1.0; to: "spacer.left_top"; } - } - } spacer { "spacer.thumbnail_top"; scale; desc { "default"; min: 0 THUMBNAIL_T; @@ -72,48 +48,11 @@ collections rel2 { relative: 0.5 1.0; to_y: "spacer.thumbnail_top"; } } } - spacer { "spacer.text_left"; scale; + spacer { "spacer.thumbnail_bottom"; scale; desc { "default"; - min: TEXT_LR 0; - align: 0.0 0.5; - rel1.relative: 0.0 0.0; - rel2.relative: 0.0 1.0; - } - } - spacer { "spacer.text_right"; scale; - desc { "default"; - min: TEXT_LR 0; - align: 1.0 0.5; - rel1.relative: 1.0 0.0; - rel2.relative: 1.0 1.0; - } - } - spacer { "spacer.name_top"; scale; - desc { "default"; - min: 0 TEXT_T; + min: 0 THUMBNAIL_B; align: 0.5 0.0; rel1 { relative: 0.0 1.0; to_y: PART_THUMBNAIL; } - rel2 { relative: 1.0 1.0; to_y: PART_THUMBNAIL; } - } - } - textblock { PART_NAME; scale; - desc { "default"; - min: 0 NAME_H; - max: -1 NAME_H; - align: 0.5 0.0; - rel1 { relative: 1.0 1.0; to_x: "spacer.text_left"; to_y: "spacer.name_top"; } - rel2 { relative: 0.0 1.0; to_x: "spacer.text_right"; } - text { - align: 0.5 0.0; - style: "name_style"; - } - } - } - spacer { "spacer.bottom"; scale; - desc { "default"; - min: 0 NAME_B; - align: 0.5 0.0; - rel1 { relative: 0.0 1.0; to_y: PART_NAME; } rel2 { relative: 1.0 1.0; } } } diff --git a/lib-logs/inc/Logs/Details/BasicInfoItem.h b/lib-logs/inc/Logs/Details/BasicInfoItem.h index 2f14f35..1e4fb31 100644 --- a/lib-logs/inc/Logs/Details/BasicInfoItem.h +++ b/lib-logs/inc/Logs/Details/BasicInfoItem.h @@ -22,6 +22,11 @@ #include "App/AppControl.h" #include "Logs/Model/LogGroup.h" +namespace Ui +{ + class NavigatorPage; +} + namespace Logs { namespace Model @@ -39,11 +44,6 @@ namespace Logs { public: /** - * @brief Back button pressed callback - */ - typedef std::function BackCallback; - - /** * @brief Create basic info item. * @param[in] group Log group for display */ @@ -51,27 +51,22 @@ namespace Logs virtual ~BasicInfoItem() override; /** - * @brief Set "back" button callback. - * @param[in] callback "back" button callback - */ - void setBackCallback(BackCallback callback); - - /** * @brief Update log and item fields. * @param[in] group Log group for display */ void updateGroup(Model::LogGroup *group); - protected: /** - * @see GenItem::getItemClass() + * @brief Show title. + * @param[in] page The page */ - virtual Elm_Genlist_Item_Class *getItemClass() const override; + void showTitle(Ui::NavigatorPage *page); + protected: /** - * @see GenItem::getText() + * @see GenItem::getItemClass() */ - virtual char *getText(Evas_Object *parent, const char *part) override; + virtual Elm_Genlist_Item_Class *getItemClass() const override; /** * @see GenItem::getContent() @@ -90,19 +85,19 @@ namespace Logs private: bool isSavedLog(); - Evas_Object *createBackButton(Evas_Object *parent); Evas_Object *createUnsavedButtons(Evas_Object *parent); Evas_Object *createUnsavedButton(Evas_Object *box, const char *text, Evas_Smart_Cb func); - void onBackPressed(Evas_Object *button, void *eventInfo); void onCreatePressed(); void onUpdatePressed(); void onGroupChanged(int type); + void updateTitle(); + + Ui::NavigatorPage *m_Page; Model::LogGroup *m_Group; Model::Log *m_Log; App::AppControl m_AppControl; - BackCallback m_OnBackPressed; Model::LogGroup::ChangeCbHandle m_GroupChangeCbHandle; }; } diff --git a/lib-logs/inc/Logs/Details/DetailsView.h b/lib-logs/inc/Logs/Details/DetailsView.h index 24968b6..b48a082 100644 --- a/lib-logs/inc/Logs/Details/DetailsView.h +++ b/lib-logs/inc/Logs/Details/DetailsView.h @@ -63,7 +63,6 @@ namespace Logs private: virtual Evas_Object *onCreate(Evas_Object *parent) override; virtual void onCreated() override; - virtual void onPageAttached(Ui::NavigatorPage *page) override; virtual void onMenuPressed() override; virtual void onSelectModeChanged(Ux::SelectMode selectMode) override; diff --git a/lib-logs/res/details/edje/LogsDetailsItemLayoutMetrics.h b/lib-logs/res/details/edje/LogsDetailsItemLayoutMetrics.h index c3da3d8..9d64ebb 100644 --- a/lib-logs/res/details/edje/LogsDetailsItemLayoutMetrics.h +++ b/lib-logs/res/details/edje/LogsDetailsItemLayoutMetrics.h @@ -18,15 +18,10 @@ #ifndef LOGS_DETAILS_ITEM_LAYOUT_METRICS_H #define LOGS_DETAILS_ITEM_LAYOUT_METRICS_H -#define NAME_PAD_T 22 -#define NAME_PAD_B 59 - #define UNSAVED_BTN_PAD_T 46 #define UNSAVED_BTN_PAD_BETWEEN 16 #define UNSAVED_BTN_PAD_B 30 #define UNSAVED_BTN_H 78 -#define NUMBER_TYPE_TEXT_SIZE 32 - #endif /* LOGS_DETAILS_ITEM_LAYOUT_METRICS_H */ diff --git a/lib-logs/res/details/edje/logs-details-item-layout.edc b/lib-logs/res/details/edje/logs-details-item-layout.edc index 5f74e1d..ff6ae98 100644 --- a/lib-logs/res/details/edje/logs-details-item-layout.edc +++ b/lib-logs/res/details/edje/logs-details-item-layout.edc @@ -21,13 +21,6 @@ #include "../../../../lib-apps-common/res/apps-common/edje/apps-common-utils.edc" #include "../../../../lib-common/res/details/edje/details-item-layout.edc" -styles { - style { - name: "number_type_style"; - base: "font=Tizen:style=Regular font_size="NUMBER_TYPE_TEXT_SIZE" align=left wrap=mixed color=#808080 ellipsis=1.0"; - } -} - collections { base_scale: 2.6; @@ -44,26 +37,10 @@ collections alias: "elm/genlist/tree_compress/"LOGS_DETAILS_ITEM_STYLE"/default"; inherit: "elm/genlist/item/"DETAILS_ITEM_STYLE"/default"; - data.item: "texts" PART_NAME; - data.item: "contents" PART_BACK_BTN" "PART_THUMBNAIL" "PART_UNSAVED_BTNS; + data.item: "contents" PART_THUMBNAIL" "PART_UNSAVED_BTNS; data.item: "states" STATE_SAVED; parts { - spacer { "spacer.name_top"; scale; - desc { "default"; - min: 0 NAME_PAD_T; - } - } - textblock { PART_NAME; scale; - desc { "default"; - max: 0 0; - } - desc { "visible"; - inherit: "default"; - min: 0 NAME_H; - max: -1 NAME_H; - } - } spacer { "spacer.unsaved.top"; scale; desc { "default"; min: 0 UNSAVED_BTN_PAD_T; @@ -74,7 +51,6 @@ collections } swallow { PART_UNSAVED_BTNS; scale; desc { "default"; - max: 0 0; align: 0.5 0.0; rel1 { relative: 0.0 1.0; to_y: "spacer.unsaved.top"; } rel2 { relative: 1.0 1.0; } @@ -93,11 +69,6 @@ collections rel2 { relative: 1.0 1.0; } } } - spacer { "spacer.bottom"; scale; - desc { "default"; - min: 0 NAME_PAD_B; - } - } } programs { program { @@ -105,14 +76,10 @@ collections source: "elm"; action: STATE_SET "default" 0.0; target: PART_UNSAVED_BTNS; - action: STATE_SET "visible" 0.0; - target: PART_NAME; } program { signal: "elm,state,"STATE_SAVED",passive"; source: "elm"; - action: STATE_SET "default" 0.0; - target: PART_NAME; action: STATE_SET "visible" 0.0; target: PART_UNSAVED_BTNS; } diff --git a/lib-logs/src/Logs/Details/BasicInfoItem.cpp b/lib-logs/src/Logs/Details/BasicInfoItem.cpp index 296692e..cc73e5f 100644 --- a/lib-logs/src/Logs/Details/BasicInfoItem.cpp +++ b/lib-logs/src/Logs/Details/BasicInfoItem.cpp @@ -18,6 +18,7 @@ #include "Logs/Details/BasicInfoItem.h" #include "Ui/Genlist.h" +#include "Ui/NavigatorPage.h" #include "Ui/Thumbnail.h" #include "Utils/Callback.h" #include "App/AppControlRequest.h" @@ -36,7 +37,7 @@ using namespace Logs::Model; using namespace std::placeholders; BasicInfoItem::BasicInfoItem(LogGroup *group) - : m_Group(group) + : m_Page(nullptr), m_Group(group) { m_Log = m_Group->getLogList().back(); m_GroupChangeCbHandle = m_Group->addChangeCallback(std::bind(&BasicInfoItem::onGroupChanged, this, _1)); @@ -49,12 +50,6 @@ BasicInfoItem::~BasicInfoItem() } } - -void BasicInfoItem::setBackCallback(BackCallback callback) -{ - m_OnBackPressed = std::move(callback); -} - void BasicInfoItem::updateGroup(LogGroup *group) { m_Group = group; @@ -64,31 +59,21 @@ void BasicInfoItem::updateGroup(LogGroup *group) } } -Elm_Genlist_Item_Class *BasicInfoItem::getItemClass() const +void BasicInfoItem::showTitle(Ui::NavigatorPage *page) { - static Elm_Genlist_Item_Class itc = createItemClass(LOGS_DETAILS_ITEM_STYLE); - return &itc; + m_Page = page; + updateTitle(); } -char *BasicInfoItem::getText(Evas_Object *parent, const char *part) +Elm_Genlist_Item_Class *BasicInfoItem::getItemClass() const { - if (strcmp(part, PART_NAME) == 0) { - if (!m_Log->getNumber()) { - return strdup(_("IDS_LOGS_MBODY_UNKNOWN")); - } - if (isSavedLog()) { - return Utils::safeDup(m_Log->getName()); - } - } - - return nullptr; + static Elm_Genlist_Item_Class itc = createItemClass(LOGS_DETAILS_ITEM_STYLE); + return &itc; } Evas_Object *BasicInfoItem::getContent(Evas_Object *parent, const char *part) { - if (strcmp(part, PART_BACK_BTN) == 0) { - return createBackButton(parent); - } else if (strcmp(part, PART_THUMBNAIL) == 0) { + if (strcmp(part, PART_THUMBNAIL) == 0) { auto control = Ui::Thumbnail::create(parent, Ui::Thumbnail::SizeLarge, m_Log->getImagePath()); return control->getEvasObject(); } else if (!isSavedLog() && m_Log->getNumber() && strcmp(part, PART_UNSAVED_BTNS) == 0) { @@ -115,16 +100,6 @@ bool BasicInfoItem::isSavedLog() return m_Log->getPersonId() > 0; } -Evas_Object *BasicInfoItem::createBackButton(Evas_Object *parent) -{ - Evas_Object *button = elm_button_add(parent); - elm_object_style_set(button, "naviframe/back_btn/default"); - evas_object_propagate_events_set(button, EINA_FALSE); - evas_object_smart_callback_add(button, "clicked", - makeCallback(&BasicInfoItem::onBackPressed), this); - return button; -} - Evas_Object *BasicInfoItem::createUnsavedButtons(Evas_Object *parent) { Evas_Object *box = elm_box_add(parent); @@ -157,13 +132,6 @@ Evas_Object *BasicInfoItem::createUnsavedButton(Evas_Object *box, const char *te return button; } -void BasicInfoItem::onBackPressed(Evas_Object *button, void *eventInfo) -{ - if (m_OnBackPressed) { - m_OnBackPressed(); - } -} - void BasicInfoItem::onCreatePressed() { m_AppControl = App::requestContactCreate(m_Log->getNumber()); @@ -185,7 +153,7 @@ void BasicInfoItem::onGroupChanged(int type) elm_genlist_item_fields_update(getObjectItem(), PART_UNSAVED_BTNS, ELM_GENLIST_ITEM_FIELD_CONTENT); } if (type & LogGroup::ChangeName) { - elm_genlist_item_fields_update(getObjectItem(), PART_NAME, ELM_GENLIST_ITEM_FIELD_TEXT); + updateTitle(); } if (type & LogGroup::ChangeImage) { elm_genlist_item_fields_update(getObjectItem(), PART_THUMBNAIL, ELM_GENLIST_ITEM_FIELD_CONTENT); @@ -193,3 +161,13 @@ void BasicInfoItem::onGroupChanged(int type) } } +void BasicInfoItem::updateTitle() +{ + if (m_Page) { + if (!m_Log->getNumber()) { + m_Page->setTitle(_("IDS_LOGS_MBODY_UNKNOWN")); + } else if (isSavedLog()) { + m_Page->setTitle(m_Log->getName()); + } + } +} diff --git a/lib-logs/src/Logs/Details/DetailsView.cpp b/lib-logs/src/Logs/Details/DetailsView.cpp index 836ccc5..b057082 100644 --- a/lib-logs/src/Logs/Details/DetailsView.cpp +++ b/lib-logs/src/Logs/Details/DetailsView.cpp @@ -75,7 +75,9 @@ Evas_Object *DetailsView::onCreate(Evas_Object *parent) elm_theme_extension_add(nullptr, App::getResourcePath(LOGS_DETAILS_ITEM_LAYOUT_EDJ).c_str()); m_Genlist = new Ui::Genlist(); - return m_Genlist->create(parent); + m_Genlist->create(parent); + elm_genlist_homogeneous_set(m_Genlist->getEvasObject(), EINA_FALSE); + return m_Genlist->getEvasObject(); } void DetailsView::onCreated() @@ -87,12 +89,6 @@ void DetailsView::onCreated() }); } -void DetailsView::onPageAttached(Ui::NavigatorPage *page) -{ - SelectView::onPageAttached(page); - page->setTitleVisibility(getSelectMode() != SelectNone); -} - void DetailsView::onMenuPressed() { if (getSelectMode() != SelectNone) { @@ -109,10 +105,6 @@ void DetailsView::onMenuPressed() void DetailsView::onSelectModeChanged(SelectMode selectMode) { - if (auto page = getPage()) { - page->setTitleVisibility(getSelectMode() != SelectNone); - } - if (getSelectMode() == SelectNone) { insertBasicInfoItem(); insertActionItem(); @@ -145,9 +137,7 @@ void DetailsView::fillGenList() void DetailsView::insertBasicInfoItem() { m_BasicInfoItem = new BasicInfoItem(m_Group); - m_BasicInfoItem->setBackCallback([this] { - getPage()->close(); - }); + m_BasicInfoItem->showTitle(getPage()); m_Genlist->insert(m_BasicInfoItem, nullptr, nullptr, Ui::Genlist::After); } -- 2.7.4