#ifndef __GALLERY_EDC_COLORS_H__
#define __GALLERY_EDC_COLORS_H__
+#define GALLERY_COLOR_WHITE 255 255 255 255
+
#define GALLERY_COLOR_AO0112 0 0 0 0
#define GALLERY_COLOR_AO0112P 0 0 0 102
#define GALLERY_COLOR_AO0112D 0 0 0 77
--- /dev/null
+/*
+ * Copyright 2017 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.
+ */
+
+#define RES_IMAGE(FILE_NAME, WIDTH, HEIGHT, COLOR) \
+ group { "elm/layout/gallery_image/"FILE_NAME; \
+ images.image: FILE_NAME COMP; \
+ parts { \
+ image { "image"; \
+ scale: 1; \
+ description { "default"; \
+ image.normal: FILE_NAME; \
+ min: WIDTH HEIGHT; \
+ max: WIDTH HEIGHT; \
+ aspect: (WIDTH / HEIGHT) (WIDTH / HEIGHT); \
+ aspect_preference: BOTH; \
+ color: COLOR; \
+ } \
+ } \
+ } \
+ }
+
+#define RES_SQUARE_IMAGE(FILE_NAME, SIZE, COLOR) \
+ RES_IMAGE(FILE_NAME, SIZE, SIZE, COLOR)
+
+RES_SQUARE_IMAGE("gallery_icon_no_photos.png", 98, GALLERY_COLOR_WHITE)
public:
virtual ucl::Result forEachMedia(EachCb cb) const = 0;
+ virtual ucl::Result getMediaCount(int &count) const = 0;
};
+
+ // Non-member functions //
+
+ bool isEmpty(const IMediaAlbum &album);
}
+#include "IMediaAlbum.hpp"
+
#endif // __GALLERY_MODEL_I_MEDIA_ALBUM_H__
--- /dev/null
+/*
+ * Copyright 2017 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 "ucl/util/logging.h"
+
+namespace gallery {
+
+ // Non-member functions //
+
+ inline bool isEmpty(const IMediaAlbum &album)
+ {
+ int count = 0;
+ UCL_FAIL_RETURN_VALUE(album.getMediaCount(count), true,
+ "album.getMediaCount() failed!");
+ return (count == 0);
+ }
+}
void startMediaContentScan();
void onScanComplete(media_content_error_e error);
- void onSysEvent(const ucl::SysEvent sysEvent);
+ void createNoContentPage();
+ void createThumbnailPage();
void onPageExitRequest(Page &page);
+ void onSysEvent(const ucl::SysEvent sysEvent);
+
private:
ucl::SysEventProvider &m_sysEventProvider;
ucl::IInstanceContext *m_context;
--- /dev/null
+/*
+ * Copyright 2017 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 __GALLERY_PRESENTATION_NO_CONTENT_PAGE_H__
+#define __GALLERY_PRESENTATION_NO_CONTENT_PAGE_H__
+
+#include "Page.h"
+
+namespace gallery {
+
+ class NoContentPage final : public Page {
+ public:
+ class Builder {
+ public:
+ Builder();
+ ~Builder();
+ Builder &setNaviframe(const ucl::NaviframeSRef &navi);
+ NoContentPageSRef build(ExitRequestHandler onExitRequest) const;
+ private:
+ ucl::NaviframeSRef m_navi;
+ };
+
+ private:
+ friend class ucl::RefCountObj<NoContentPage>;
+ NoContentPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
+ ExitRequestHandler onExitRequest);
+ virtual ~NoContentPage();
+
+ ucl::Result prepare();
+ };
+}
+
+#endif // __GALLERY_PRESENTATION_NO_CONTENT_PAGE_H__
namespace gallery {
- using namespace ucl;
-
template <class ITEM_FACTORY>
- inline Result Page::prepare(ITEM_FACTORY &&makeItem)
+ inline ucl::Result Page::prepare(ITEM_FACTORY &&makeItem)
{
m_item = makeItem();
if (isNotValid(m_item)) {
- UCL_LOG_RETURN(RES_FAIL, "m_item is NULL");
+ UCL_LOG_RETURN(ucl::RES_FAIL, "m_item is NULL");
}
return preparePart2();
}
template <class ...ARGS>
- inline NaviItem Page::insertAfter(ARGS &&...args)
+ inline ucl::NaviItem Page::insertAfter(ARGS &&...args)
{
return m_navi->insertAfter(m_item, std::forward<ARGS>(args)...);
}
template <class ...ARGS>
- inline NaviItem Page::insertBefore(ARGS &&...args)
+ inline ucl::NaviItem Page::insertBefore(ARGS &&...args)
{
return m_navi->insertBefore(m_item, std::forward<ARGS>(args)...);
}
- inline Naviframe &Page::getNaviframe()
+ inline ucl::Naviframe &Page::getNaviframe()
{
UCL_ASSERT(m_navi, "m_navi is NULL");
return *m_navi;
ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
virtual ~ThumbnailPage();
- Result prepare();
+ ucl::Result prepare();
bool onEachMedia(MediaItemUPtr &&media);
ExitRequestHandler onExitRequest, const IMediaAlbumSRef &album);
virtual ~ViewerPage();
- Result prepare();
+ ucl::Result prepare();
void showItem(int itemIndex);
bool onEachMedia(MediaItemUPtr &&media);
UCL_DECLARE_REF_ALIASES(Page);
UCL_DECLARE_REF_ALIASES(ThumbnailPage);
-
UCL_DECLARE_REF_ALIASES(ViewerPage);
+ UCL_DECLARE_REF_ALIASES(NoContentPage);
}
#endif // __GALLERY_PRESENTATION_TYPES_H__
#include "config.h"
+#include "ucl/misc/TString.h"
+
namespace gallery {
constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
+
+ extern const ucl::TString STR_APP_NAME;
+ extern const ucl::TString STR_NO_PHOTOS;
}
#endif // __GALLERY_RESOURCES_H__
}
#include "../../edc/colors.h"
+ #include "../../edc/images.edc"
#include "../../edc/image-grid.edc"
#include "../../edc/button.edc"
}
#include "ucl/gui/stdTheme.h"
#include "ucl/gui/helpers.h"
+#include "resources.h"
+
#undef UCL_LOG_TAG
#define UCL_LOG_TAG "GALLERY"
return RES_OK;
}
+
+ Result GalleryAlbum::getMediaCount(int &count) const
+ {
+ const int ret = media_info_get_media_count_from_db(m_filter, &count);
+ if ((ret != 0) || (count < 0)) {
+ count = 0;
+ LOG_RETURN(RES_FAIL,
+ "media_info_foreach_media_from_db() failed: %d", ret);
+ }
+ return RES_OK;
+ }
}
// IMediaAlbum //
virtual ucl::Result forEachMedia(EachCb cb) const final override;
+ virtual ucl::Result getMediaCount(int &count) const final override;
private:
friend class ucl::RefCountObj<GalleryAlbum>;
#include "ucl/appfw/helpers.h"
#include "model/Gallery.h"
+#include "model/IMediaAlbum.h"
+#include "presentation/NoContentPage.h"
#include "presentation/ThumbnailPage.h"
-#include "resources.h"
-
#include "common.h"
namespace gallery { namespace { namespace impl {
if (SCAN_MEDIA_ON_RESUME) {
rescanMediaContent();
}
+
+ ecore_animator_frametime_set(1.0 / 60.0);
}
void Instance::rescanMediaContent()
m_isScanInProgress = false;
const auto thumbPage = dynamicRefCast<ThumbnailPage>(m_page);
- if (thumbPage) {
- DLOG("Reloading the ThumbnailPage...");
- thumbPage->reload();
+
+ if (isNotEmpty(m_gallery->getAlbum())) {
+ if (thumbPage) {
+ DLOG("Reloading the ThumbnailPage...");
+ thumbPage->reload();
+ } else {
+ if (m_page) {
+ m_page->exitNoTransition();
+ }
+ createThumbnailPage();
+ }
+ } else if (thumbPage) {
+ DLOG("Exit from ThumbnailPage witout transition...");
+ thumbPage->exitNoTransition();
+ createNoContentPage();
}
}
DLOG("APP CONTROL");
if (!m_page) {
- DLOG("Creating ThumbnailPage.");
- m_page = ThumbnailPage::Builder().
- setNaviframe(m_navi).
- setAlbum(m_gallery->getAlbum()).
- build(DELEGATE(Instance::onPageExitRequest, this));
+ if (isEmpty(m_gallery->getAlbum())) {
+ createNoContentPage();
+ } else {
+ createThumbnailPage();
+ }
}
if (!m_win->isVisible()) {
}
}
+ void Instance::createNoContentPage()
+ {
+ DLOG("Creating NoContentPage.");
+ m_page = NoContentPage::Builder().setNaviframe(m_navi).
+ build(DELEGATE(Instance::onPageExitRequest, this));
+ }
+
+ void Instance::createThumbnailPage()
+ {
+ DLOG("Creating ThumbnailPage.");
+ m_page = ThumbnailPage::Builder().setNaviframe(m_navi).
+ setAlbum(m_gallery->getAlbum()).
+ build(DELEGATE(Instance::onPageExitRequest, this));
+ }
+
+ void Instance::onPageExitRequest(Page &page)
+ {
+ if (page.isAtBottom()) {
+ DLOG("Bottom page. Lowering the window.");
+ m_win->lower();
+ } else {
+ DLOG("Exit page.");
+ page.exit();
+ }
+ }
+
void Instance::onSysEvent(const SysEvent sysEvent)
{
switch(sysEvent) {
break;
}
}
-
- void Instance::onPageExitRequest(Page &page)
- {
- if (isLast(page)) {
- DLOG("Last page. Lowering the window.");
- m_win->lower();
- } else {
- DLOG("Exit page.");
- page.exit();
- }
- }
}
--- /dev/null
+/*
+ * Copyright 2017 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 "presentation/NoContentPage.h"
+
+#include "ucl/gui/Layout.h"
+
+#include "common.h"
+
+namespace gallery {namespace { namespace impl {
+
+ using namespace ucl;
+
+ constexpr LayoutTheme ICON_THEME
+ {"layout", "gallery_image", "gallery_icon_no_photos.png"};
+}}}
+
+namespace gallery {
+
+ using namespace ucl;
+
+ // NoContentPage::Builder //
+
+ NoContentPage::Builder::Builder()
+ {
+ }
+
+ NoContentPage::Builder::~Builder()
+ {
+ }
+
+ NoContentPage::Builder &NoContentPage::Builder::setNaviframe(
+ const NaviframeSRef &navi)
+ {
+ m_navi = navi;
+ return *this;
+ }
+
+ NoContentPageSRef NoContentPage::Builder::build(
+ const ExitRequestHandler onExitRequest) const
+ {
+ if (!onExitRequest) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
+ "onExitRequest is NULL");
+ }
+ if (!m_navi) {
+ LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
+ }
+
+ auto result = makeShared<NoContentPage>(m_navi, onExitRequest);
+
+ FAIL_RETURN_VALUE(result->prepare(), {}, "result->prepare() failed!");
+
+ return result;
+ }
+
+ // NoContentPage //
+
+ NoContentPage::NoContentPage(RefCountObjBase &rc,
+ const NaviframeSRef &navi,
+ const ExitRequestHandler onExitRequest) :
+ Page(rc, navi, onExitRequest)
+ {
+ }
+
+ NoContentPage::~NoContentPage()
+ {
+ }
+
+ Result NoContentPage::prepare()
+ {
+ const auto layout = Layout::Builder().
+ setIsOwner(true).
+ setTheme(LAYOUT_NO_CONTENTS).
+ build(getNaviframe());
+ if (!layout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ const auto icon = Layout::Builder().
+ setTheme(impl::ICON_THEME).
+ build(*layout);
+ if (!layout) {
+ LOG_RETURN(RES_FAIL, "Layout::build() failed!");
+ }
+
+ layout->setContent(*icon);
+ layout->setText(PART_TITLE, STR_APP_NAME);
+ layout->setText(STR_NO_PHOTOS);
+
+ FAIL_RETURN(Page::prepare(
+ [this, &layout]()
+ {
+ return getNaviframe().push(*layout);
+ }),
+ "Page::prepare() failed!");
+
+ layout->setIsOwner(false);
+
+ return RES_OK;
+ }
+}
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
"onExitRequest is NULL");
}
-
if (!m_navi) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
}
-
if (!m_album) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
}
ThumbnailPage::~ThumbnailPage()
{
+ if (m_page) {
+ m_page->exitNoTransition();
+ }
m_imageGrid->setListener(nullptr);
}
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {},
"onExitRequest is NULL");
}
-
if (!m_navi) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_navi is NULL");
}
-
if (!m_album) {
LOG_RETURN_VALUE(RES_INVALID_ARGUMENTS, {}, "m_album is NULL");
}
--- /dev/null
+/*
+ * Copyright 2017 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 "resources.h"
+
+namespace gallery {
+
+ // TODO replace with IDS in the future
+
+ const ucl::TString STR_APP_NAME {"Gallery"};
+ const ucl::TString STR_NO_PHOTOS {"No photos"};
+}
inline Layout::Builder::Builder() :
m_isOwner(false),
- m_needBindToEo(true)
+ m_needBindToEo(false)
{
}
// Parts //
- constexpr EdjePart PART_TEXT {"elm.text"};
+ constexpr EdjePart PART_TEXT {"elm.text"};
+ constexpr EdjePart PART_TITLE {"elm.text.title"};
+
constexpr EdjePart PART_CONTENT {"elm.swallow.content"};
+ constexpr EdjePart PART_ICON {"elm.swallow.icon"};
}
#endif // __UCL_GUI_STD_THEME_COMMON_H__
namespace ucl {
constexpr LayoutTheme LAYOUT_DEFAULT {"layout", "application", "default"};
+
+ constexpr LayoutTheme LAYOUT_NO_CONTENTS
+ {"layout", "nocontents", "default"};
}
#endif // __UCL_GUI_STD_THEME_LAYOUT_H__
constexpr bool isEmpty(const char *value);
+ template <class T>
+ constexpr auto isEmpty(const T &value) -> decltype(isEmpty(*value))
+ {
+ return isEmpty(*value);
+ }
+
template <class T>
constexpr auto isEmpty(const T &value) -> decltype(value.empty())
{
{
Evas_Object *const eo = elm_layout_add(parent);
if (!eo) {
- ELOG("elm_layout_add() failed!");
- return {};
+ LOG_RETURN_VALUE(RES_FAIL, {}, "elm_layout_add() failed!");
}
auto result = makeShared<Layout>(eo, m_isOwner);
result->bindToEo();
}
+ bool isOk = false;
+
if (isNotEmpty(m_edjeFilePath) && isValid(m_edjeGroup)) {
- result->setEdjeFile(m_edjeFilePath, m_edjeGroup);
+ isOk = result->setEdjeFile(m_edjeFilePath, m_edjeGroup);
} else {
- result->setTheme(isValid(m_theme) ? m_theme : LAYOUT_DEFAULT);
+ isOk = result->setTheme(isValid(m_theme) ?
+ m_theme : LAYOUT_DEFAULT);
+ }
+
+ if (!isOk) {
+ LOG_RETURN_VALUE(RES_FAIL, {}, "Layout init failed!");
}
show(*result);