<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
- <triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
constexpr auto WINDOW_NAME = "org.tizen.gallery";
constexpr auto BASE_SCALE = 1.3;
+
+ // TODO Temporary feature while support only offline mode
+ constexpr auto SCAN_MEDIA_ON_RESUME = true;
}
#endif // __GALLERY_CONFIG_H__
#include "ucl/appfw/IInstance.h"
#include "ucl/appfw/IInstanceAppControlExt.h"
-#include "ucl/appfw/SysEventProvider.h"
+#include "ucl/gui/Theme.h"
+#include "ucl/gui/Naviframe.h"
+
+#include "model/types.h"
+#include "presentation/types.h"
namespace gallery {
- class Instance :
+ class Instance final :
public ucl::IInstance,
public ucl::IInstanceAppControlExt {
public:
Instance(ucl::SysEventProvider &sysEventProvider);
+ virtual ~Instance();
// IInstance //
virtual void onAppControl(app_control_h appControl) final override;
private:
- void onBack(Evas_Object *obj, void *event_info);
+ ucl::Result setupTheme();
+
+ void rescanMediaContent();
+ void stopMediaContentScan();
+ void startMediaContentScan();
+ void onScanComplete(media_content_error_e error);
+
void onSysEvent(const ucl::SysEvent sysEvent);
+ void onPageExitRequest(Page &page);
+
private:
ucl::SysEventProvider &m_sysEventProvider;
ucl::IInstanceContext *m_context;
+
+ GallerySRef m_gallery;
+ bool m_isScanInProgress;
+
ucl::WindowSRef m_win;
+ ucl::Theme m_theme;
+ ucl::NaviframeSRef m_navi;
+
+ PageWRef m_page;
};
}
// ucl::InstanceManagerBase //
- virtual ucl::IInstance *newInstance() const final override;
+ virtual ucl::IInstanceSRef newInstance() const final override;
};
}
IMediaAlbumSRef m_album;
};
+ public:
+ void reload();
+
private:
friend class ucl::RefCountObj<ThumbnailPage>;
ThumbnailPage(ucl::RefCountObjBase &rc, const ucl::NaviframeSRef &navi,
--- /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_RESOURCES_H__
+#define __GALLERY_RESOURCES_H__
+
+#include "config.h"
+
+namespace gallery {
+
+ constexpr auto THEME_EDJE_PATH = "edje/theme.edj";
+}
+
+#endif // __GALLERY_RESOURCES_H__
#include "main/Instance.h"
#include <system_settings.h>
-#include <efl_extension.h>
+
+#include "ucl/appfw/SysEventProvider.h"
+#include "ucl/appfw/helpers.h"
+
+#include "model/Gallery.h"
+
+#include "presentation/ThumbnailPage.h"
+
+#include "resources.h"
#include "../common.h"
+namespace gallery { namespace { namespace impl {
+
+ // TODO Since feature is temporary using hard-coded path
+ constexpr auto MEDIA_FOLDER = "/opt/usr/home/owner/media";
+}}}
+
namespace gallery {
using namespace ucl;
Instance::Instance(SysEventProvider &sysEventProvider) :
- m_sysEventProvider(sysEventProvider)
+ m_sysEventProvider(sysEventProvider),
+ m_isScanInProgress(false)
{
}
+ Instance::~Instance()
+ {
+ stopMediaContentScan();
+ }
+
Result Instance::onCreate(IInstanceContext *const context)
{
m_context = context;
+ m_gallery = Gallery::newInstance();
+ if (!m_gallery) {
+ LOG_RETURN(RES_FAIL, "Gallery::newInstance() failed!");
+ }
+
m_win = m_context->getWindow();
+ FAIL_RETURN(setupTheme(), "setupTheme() failed!");
+
+ m_navi = Naviframe::Builder().
+ build(m_win->getConformant());
+ if (!m_navi) {
+ LOG_RETURN(RES_FAIL, "Naviframe::build() failed!");
+ }
+
+ m_win->getConformant().setContent(*m_navi);
+
m_sysEventProvider.addEventHandler(
DELEGATE(Instance::onSysEvent, this));
- eext_object_event_callback_add(*m_win, EEXT_CALLBACK_BACK,
- CALLBACK_A(Instance::onBack), this);
+ return RES_OK;
+ }
+
+ Result Instance::setupTheme()
+ {
+ m_theme = Theme::create();
+ if (isNotValid(m_theme)) {
+ LOG_RETURN(RES_FAIL, "Theme::create() failed!");
+ }
+
+ m_theme.addExtension(getResPath(THEME_EDJE_PATH));
+
+ m_win->setTheme(m_theme);
return RES_OK;
}
void Instance::onPause()
{
- ILOG("PAUSED");
+ DLOG("PAUSE");
}
void Instance::onResume()
{
- ILOG("RESUMED");
+ DLOG("RESUME");
+
+ if (SCAN_MEDIA_ON_RESUME) {
+ rescanMediaContent();
+ }
}
- void Instance::onAppControl(app_control_h appControl)
+ void Instance::rescanMediaContent()
+ {
+ stopMediaContentScan();
+ startMediaContentScan();
+ }
+
+ void Instance::stopMediaContentScan()
{
- char *op = {};
- app_control_get_operation(appControl, &op);
- ILOG("operation: %s", op);
- free(op);
+ if (m_isScanInProgress) {
+ m_isScanInProgress = false;
+ DLOG("Scan is in progress. Terminating...");
+ const int ret = media_content_cancel_scan_folder(
+ impl::MEDIA_FOLDER);
+ if (ret != 0) {
+ WLOG("media_content_cancel_scan_folder() failed: %d", ret);
+ }
+ }
+ }
- if (!m_win->isVisible()) {
- show(*m_win);
+ void Instance::startMediaContentScan()
+ {
+ DLOG("Starting media scan...");
+
+ int ret = media_content_scan_folder(impl::MEDIA_FOLDER, true,
+ CALLBACK_B(Instance::onScanComplete), this);
+ if (ret != 0) {
+ ELOG("media_content_scan_folder() failed: %d", ret);
+ return;
+ }
+
+ m_isScanInProgress = true;
+ }
+
+ void Instance::onScanComplete(media_content_error_e error)
+ {
+ DLOG("Media scan complete. error: %d", error);
+
+ m_isScanInProgress = false;
+
+ const auto thumbPage = dynamicRefCast<ThumbnailPage>(m_page);
+ if (thumbPage) {
+ DLOG("Reloading the ThumbnailPage...");
+ thumbPage->reload();
}
}
- void Instance::onBack(Evas_Object *obj, void *event_info)
+ void Instance::onAppControl(app_control_h appControl)
{
- ILOG("Exiting the application...");
- m_context->exitApp();
+ 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 (!m_win->isVisible()) {
+ DLOG("Show the window.");
+ show(*m_win);
+ }
}
void Instance::onSysEvent(const SysEvent sysEvent)
{
switch(sysEvent) {
case SysEvent::LANGUAGE_CHANGED:
- ILOG("SysEvent::LANGUAGE_CHANGED");
+ DLOG("SysEvent::LANGUAGE_CHANGED");
{
char *locale = NULL;
system_settings_get_value_string(
}
break;
default:
- ILOG("sysEvent: %d", sysEvent);
+ DLOG("sysEvent: %d", 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();
+ }
+ }
}
{
}
- IInstance *InstanceManager::newInstance() const
+ IInstanceSRef InstanceManager::newInstance() const
{
- return new Instance(getSysEventProvider());
+ return makeShared<Instance>(getSysEventProvider());
}
}
params.imagePath.c_str(), NULL);
int w, h;
- getSize(m_image, &w, &h);
+ evas_object_image_size_get(m_image, &w, &h);
m_image.setARHint(WidgetARHint::NEITHER, w, h);
makeWhite(m_image);
m_imageGrid->setListener(nullptr);
}
+ void ThumbnailPage::reload()
+ {
+ ImageGrid::Unrealizer u(*m_imageGrid);
+
+ m_mediaItems.clear();
+
+ FAIL_LOG(m_album->forEachMedia(
+ DELEGATE(ThumbnailPage::onEachMedia, this)),
+ "m_album->forEachMedia() failed!");
+
+ m_imageGrid->setItemCount(m_mediaItems.size());
+ }
+
Result ThumbnailPage::prepare()
{
FAIL_RETURN(m_album->forEachMedia(
namespace ucl {
- class IInstance;
- using IInstanceUPtr = std::unique_ptr<IInstance>;
+ UCL_DECLARE_REF_ALIASES(IInstance);
class IInstance : public Polymorphic {
public:
void setSysEventProvider(SysEventProviderUPtr provider);
- virtual IInstance *newInstance() const = 0;
+ virtual IInstanceSRef newInstance() const = 0;
protected:
SysEventProvider &getSysEventProvider() const;
private:
InstanceManagerBase &m_instanceMgr;
WindowSRef m_window;
- IInstanceUPtr m_instance;
+ IInstanceSRef m_instance;
};
}
--- /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 __UCL_APPFW_HELPERS_H__
+#define __UCL_APPFW_HELPERS_H__
+
+#include "types.h"
+
+namespace ucl {
+
+ std::string getResPath(const char *relativePath);
+}
+
+#endif // __UCL_APPFW_HELPERS_H__
void setEnabled(bool value);
bool isEnabled() const;
+ void setTheme(Elm_Theme *th);
+ Elm_Theme *getTheme();
+
protected:
virtual void setFocusedImpl(bool value) final override;
virtual bool isFocusedImpl() const final override;
return !elm_object_disabled_get(getEo());
}
+ inline void ElmWidget::setTheme(Elm_Theme *th)
+ {
+ elm_object_theme_set(getEo(), th);
+ }
+
+ inline Elm_Theme *ElmWidget::getTheme()
+ {
+ return elm_object_theme_get(getEo());
+ }
+
// Non-member functions //
inline void enable(ElmWidget &widget)
--- /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 __UCL_GUI_THEME_H__
+#define __UCL_GUI_THEME_H__
+
+#include "types.h"
+
+namespace ucl {
+
+ class Theme final : NonCopyable {
+ public:
+ static Theme create();
+
+ friend void swap(Theme &x, Theme &y);
+
+ public:
+ Theme();
+ Theme(nullptr_t);
+ explicit Theme(Elm_Theme *th, bool isOwner = false);
+ Theme(Theme &&tmp);
+ Theme &operator=(Theme &&tmp);
+ ~Theme();
+
+ Elm_Theme *getTh();
+ const Elm_Theme *getTh() const;
+
+ operator Elm_Theme *();
+ operator const Elm_Theme *() const;
+
+ void addExtension(const std::string edjePath);
+ void addOverlay(const std::string edjePath);
+
+ private:
+ Elm_Theme *m_th;
+ bool m_isOwner;
+ };
+
+ // Non-member functions //
+
+ bool isValid(const Theme &item);
+}
+
+#include "Theme.hpp"
+
+#endif // __UCL_GUI_THEME_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.
+ */
+
+namespace ucl {
+
+ inline Theme Theme::create()
+ {
+ Elm_Theme *const th = elm_theme_new();
+ if (th) {
+ elm_theme_ref_set(th, nullptr);
+ }
+ return Theme(th, true);
+ }
+
+ inline Theme::Theme() :
+ m_th(nullptr),
+ m_isOwner(false)
+ {
+ }
+
+ inline Theme::Theme(nullptr_t) :
+ Theme()
+ {
+ }
+
+ inline Theme::Theme(Elm_Theme *const th, const bool isOwner) :
+ m_th(th),
+ m_isOwner(isOwner)
+ {
+ }
+
+ inline Theme::Theme(Theme &&tmp)
+ {
+ m_th = tmp.m_th;
+ tmp.m_th = nullptr;
+ }
+
+ inline Theme &Theme::operator=(Theme &&tmp)
+ {
+ swap(*this, tmp);
+ return *this;
+ }
+
+ inline Theme::~Theme()
+ {
+ if (m_isOwner && m_th) {
+ elm_theme_free(m_th);
+ }
+ }
+
+ inline Elm_Theme *Theme::getTh()
+ {
+ return m_th;
+ }
+
+ inline const Elm_Theme *Theme::getTh() const
+ {
+ return m_th;
+ }
+
+ inline Theme::operator Elm_Theme *()
+ {
+ return getTh();
+ }
+
+ inline Theme::operator const Elm_Theme *() const
+ {
+ return getTh();
+ }
+
+ inline void Theme::addExtension(const std::string edjePath)
+ {
+ elm_theme_extension_add(getTh(), edjePath.c_str());
+ }
+
+ inline void Theme::addOverlay(const std::string edjePath)
+ {
+ elm_theme_overlay_add(getTh(), edjePath.c_str());
+ }
+
+ // Non-member functions //
+
+ inline bool isValid(const Theme &item)
+ {
+ return !!item.getTh();
+ }
+
+ inline void swap(Theme &x, Theme &y)
+ {
+ std::swap(x.m_th, y.m_th);
+ std::swap(x.m_isOwner, y.m_isOwner);
+ }
+}
Result UIApp::createInstance()
{
- auto instance = util::makeUnique(m_instanceMgr.newInstance());
+ auto instance = m_instanceMgr.newInstance();
if (!instance) {
LOG_RETURN(RES_FAIL, "m_instanceMgr.newInstance() failed!");
}
--- /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/appfw/helpers.h"
+
+#include "../common.h"
+
+namespace ucl {
+
+ std::string getResPath(const char *const relativePath)
+ {
+ std::string result;
+ char *const resDir = app_get_resource_path();
+ if (resDir) {
+ result = resDir;
+ free(resDir);
+ } else {
+ ELOG("app_get_resource_path() failed!");
+ }
+ result += relativePath;
+ return result;
+ }
+}