TizenRefApp-7954 Implement main controller for Task Manager 24/112224/2
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Mon, 30 Jan 2017 09:51:22 +0000 (11:51 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Tue, 31 Jan 2017 08:51:05 +0000 (10:51 +0200)
Change-Id: I212ebef250656efeed439fb0dd2d8e56aa7046af
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
31 files changed:
.cproject
inc/Config.h
inc/Resource.h
res/edje/main-layout.edc
src/App/inc/App.h
src/App/inc/IndexView.h
src/App/inc/MainController.h
src/App/inc/MainLayout.h
src/App/inc/TaskListView.h
src/App/inc/TaskListViewItem.h
src/App/inc/TaskMngrService.h
src/App/src/App.cpp
src/App/src/IndexView.cpp
src/App/src/MainController.cpp
src/App/src/MainLayout.cpp
src/App/src/TaskListView.cpp
src/App/src/TaskListViewItem.cpp
src/App/src/TaskMngrService.cpp
src/Common/inc/AtspiAccessibleInterface.h
src/Common/inc/BaseView.h
src/Common/inc/Callback.h
src/Common/inc/LangUtils.h
src/Common/inc/Logger.h
src/Common/inc/PathUtils.h
src/Common/inc/View.h
src/Common/inc/Window.h
src/Common/src/Logger.cpp
src/Common/src/PathUtils.cpp
src/Common/src/View.cpp
src/Common/src/Window.cpp
src/main.cpp

index 1ad3295..baf6712 100644 (file)
--- a/.cproject
+++ b/.cproject
                                                        <targetPlatform binaryParser="org.eclipse.cdt.core.ELF" id="org.tizen.nativeide.target.sbi.gnu.platform.base.1359202976" osList="linux,win32" superClass="org.tizen.nativeide.target.sbi.gnu.platform.base"/>
                                                        <builder autoBuildTarget="all" buildPath="${workspace_loc:/taskmanager}/Debug" enableAutoBuild="true" id="org.tizen.nativecore.target.sbi.gnu.builder.1995741082" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Tizen Application Builder" superClass="org.tizen.nativecore.target.sbi.gnu.builder"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.1817006367" name="Archiver" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver"/>
-                                                       <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1770946160" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
+                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler.1770946160" name="C++ Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.compiler">
                                                                <option id="gnu.cpp.compiler.option.optimization.level.1345501733" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
                                                                <option defaultValue="gnu.cpp.compiler.debugging.level.max" id="sbi.gnu.cpp.compiler.option.debugging.level.core.1210835446" name="Debug level" superClass="sbi.gnu.cpp.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.compiler.option.misc.pic.core.1883867003" name="-fPIC option" superClass="sbi.gnu.cpp.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.compiler.option.1516130097" name="Tizen-Target" superClass="sbi.gnu.cpp.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-3.0-emulator.core.private_gcc49.i386.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-3.0-emulator.core.private_llvm37.i386.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.371616908" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.cpp.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                <option id="gnu.cpp.compiler.option.dialect.std.1800306444" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" value="gnu.cpp.compiler.dialect.c++1y" valueType="enumerated"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1246859271" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
                                                        </tool>
-                                                       <tool command="i386-linux-gnueabi-gcc" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.944164800" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
+                                                       <tool command="clang" id="org.tizen.nativecore.tool.sbi.gnu.c.compiler.944164800" name="C Compiler" superClass="org.tizen.nativecore.tool.sbi.gnu.c.compiler">
                                                                <option defaultValue="gnu.c.optimization.level.none" id="gnu.c.compiler.option.optimization.level.669046459" name="Optimization Level" superClass="gnu.c.compiler.option.optimization.level" valueType="enumerated"/>
                                                                <option defaultValue="gnu.c.debugging.level.max" id="sbi.gnu.c.compiler.option.debugging.level.core.146661021" name="Debug level" superClass="sbi.gnu.c.compiler.option.debugging.level.core" valueType="enumerated"/>
                                                                <option defaultValue="false" id="sbi.gnu.c.compiler.option.misc.pic.core.480122954" name="-fPIC option" superClass="sbi.gnu.c.compiler.option.misc.pic.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.c.compiler.option.756861607" name="Tizen-Target" superClass="sbi.gnu.c.compiler.option" valueType="userObjs">
-                                                                       <listOptionValue builtIn="false" value="wearable-3.0-emulator.core.private_gcc49.i386.core.app"/>
+                                                                       <listOptionValue builtIn="false" value="wearable-3.0-emulator.core.private_llvm37.i386.core.app"/>
                                                                </option>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.793002243" name="Tizen-Frameworks-Include-Path" superClass="sbi.gnu.c.compiler.option.frameworks_inc.core" valueType="includePath">
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/libxml2&quot;"/>
                                                                <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1206948254" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
                                                        </tool>
                                                        <tool id="org.tizen.nativeide.tool.sbi.gnu.c.linker.base.1529618324" name="C Linker" superClass="org.tizen.nativeide.tool.sbi.gnu.c.linker.base"/>
-                                                       <tool command="i386-linux-gnueabi-g++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.2042523143" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
+                                                       <tool command="clang++" id="org.tizen.nativecore.tool.sbi.gnu.cpp.linker.2042523143" name="C++ Linker" superClass="org.tizen.nativecore.tool.sbi.gnu.cpp.linker">
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.shared_flag.core.801463445" name="Linker.Shared" superClass="sbi.gnu.cpp.linker.option.shared_flag.core" valueType="boolean"/>
                                                                <option defaultValue="false" id="sbi.gnu.cpp.linker.option.noundefined.core.612946377" name="Report unresolved symbol references (-Wl,--no-undefined)" superClass="sbi.gnu.cpp.linker.option.noundefined.core" valueType="boolean"/>
                                                                <option id="sbi.gnu.cpp.linker.option.frameworks_lflags.core.1145756352" name="Tizen-Frameworks-Other-Lflags" superClass="sbi.gnu.cpp.linker.option.frameworks_lflags.core" valueType="stringList">
index 943182d..55b7c93 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 998f3a2..c85d2c6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -24,5 +24,6 @@
 #define ANIM_ITEM_EDJ    "anim-item.edj"
 #define TASK_ITEM_EDJ    "task-item.edj"
 #define ICONS_EDJ        "icons.edj"
+#define APP_ICON_IMG     "taskmanager.png"
 
 #endif /* RESOURCE_H_ */
index aa74551..793d7f9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -65,11 +65,11 @@ collections {
                 type: SWALLOW;
                 scale: 1;
                 description { state: "default" 0.0;
-                    visible: 1;
+                    visible: 0;
                 }
-                description { state: "hide" 0.0;
+                description { state: "show" 0.0;
                     inherit: "default" 0.0;
-                    visible: 0;
+                    visible: 1;
                 }
             }
             part {
@@ -176,18 +176,18 @@ collections {
         }
         programs {
             program {
-                name : "show_bg";
-                signal : "show_bg";
+                name : "hide_bg";
+                signal : "hide_bg";
                 source : "*";
                 action : STATE_SET "default" 0.0;
-               target : "swl.bg";
+                target : "swl.bg";
             }
             program {
-                name : "hide_bg";
-                signal : "hide_bg";
+                name : "show_bg";
+                signal : "show_bg";
                 source : "*";
-                action : STATE_SET "hide" 0.0;
-               target : "swl.bg";
+                action : STATE_SET "show" 0.0;
+                target : "swl.bg";
             }
             program {
                 name : "close,clicked";
index 2d95496..ff304de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
 #ifndef App_h_
 #define App_h_
 
+#include "TaskMngrService.h"
+
 #include <app.h>
 #include <app_control.h>
-
-#include "TaskMngrService.h"
+#include <Evas.h>
 
 namespace TaskMngr {
     class Window;
@@ -53,6 +54,8 @@ namespace TaskMngr {
             void onLowBattery(app_event_info_h appEvent);
             void onRegionChanged(app_event_info_h appEvent);
 
+            void onHwBackButton(Evas_Object *obj, void *event_info);
+
         private:
             static App m_AppInst;
             Window *m_pWindow;
index 581bc37..0346089 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -56,7 +56,6 @@ namespace TaskMngr {
         private:
             int m_IndexSize;
             int m_SelectedIndex;
-            bool m_IsSelected;
     };
 }
 #endif /* IndexView_h_ */
index bce94cf..3af841d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -19,6 +19,7 @@
 
 #include "MainLayout.h"
 #include "TaskListView.h"
+#include "IndexView.h"
 
 namespace TaskMngr {
     class MainController
@@ -29,18 +30,27 @@ namespace TaskMngr {
             MainController(Evas_Object *parent);
             virtual ~MainController();
 
-        private:
+            void pause();
+            void resume();
+
+        protected:
             // MainLayout:
             void onCloseAllButtonClicked() override;
 
             // ITaskListViewListener:
-            void onPageChanged() override;
-            void onKillAnimFinished(TaskListViewItem &item) override;
+            void onListChanged(TaskListView &obj, int itemsCount) override;
+            void onCurrentPageChanged(TaskListView &obj) override;
             void onClicked(TaskListViewItem &item) override;
-            void onKillAllAnimFinished() override;
+            void onItemBeforeDelete(TaskListViewItem &item) override;
+
+        private:
+            void update();
+            void updateIndex(int itemsCount);
+            void updateNoContents(int itemsCount);
 
         private:
             TaskListView *m_pTaskListView;
+            IndexView *m_pIndexView;
     };
 }
 
index 91809a0..11d503d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -35,6 +35,9 @@ namespace TaskMngr {
             virtual void onCloseAllButtonClicked() {};
 
         private:
+            void prepareNoContents();
+
+        private:
             Evas_Object *m_pNoContent;
     };
 }
index 19cf9eb..312ee71 100644 (file)
@@ -20,6 +20,9 @@
 #include "View.h"
 #include "TaskListViewItem.h"
 
+#include <vector>
+#include <Ecore.h>
+
 namespace TaskMngr
 {
     class ITaskListViewListener;
@@ -35,32 +38,44 @@ namespace TaskMngr
 
             void setListener(ITaskListViewListener *listener);
             void appendItem(TaskListViewItem &item);
+            std::vector<TaskListViewItem*> getItems() const;
+            int getItemsCount() const;
+            int getCurrentPageIndex() const;
             TaskListViewItem *getCurrentPage() const;
-            void playKillAllAnim();
-            void freezeScrollPush();
-            void freezeScrollPop();
+            void killAll();
+            void clear();
 
         private:
             Evas_Object *createPadding();
+            void freezeScrollPush();
+            void freezeScrollPop();
+
             void onDelRequest(TaskListViewItem &item);
             void onAppClicked(TaskListViewItem &item);
 
+            void onPageChanged(Evas_Object *obj, void *event_info);
+            Eina_Bool onBoxSizeChangedIlder();
+            void onBoxSizeChanged(Evas *e, Evas_Object *obj, void *event_info);
+
         private:
             ITaskListViewListener *m_pListener;
             Evas_Object *m_pScroller;
             Evas_Object *m_pBox;
             Evas_Object *m_RightPadding;
+            Evas_Object *m_LeftPadding;
             AppInfo m_AppInfo;
+            Ecore_Idler *m_pBoxSizeChangedIdler;
+            int m_LastItemsCount;
     };
 
     class ITaskListViewListener
     {
         public:
             virtual ~ITaskListViewListener() {}
-            virtual void onPageChanged() {};
-            virtual void onKillAnimFinished(TaskListViewItem &item) {};
+            virtual void onListChanged(TaskListView &obj, int itemsCount) {};
+            virtual void onCurrentPageChanged(TaskListView &obj) {};
             virtual void onClicked(TaskListViewItem &item) {};
-            virtual void onKillAllAnimFinished() {};
+            virtual void onItemBeforeDelete(TaskListViewItem &item) {};
     };
 }
 
index 1923b04..e81c9c2 100644 (file)
@@ -36,6 +36,7 @@ namespace TaskMngr
             void playKillAnim();
             void playKillUpAnim();
             void playKillDownAnim();
+            const AppInfo &getAppInfo() const;
 
         private:
             void onMove(Evas *e, Evas_Object *obj, void *event_info);
index 971890a..68ea032 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -21,6 +21,7 @@
 #include <vector>
 #include <app_info.h>
 #include <rua.h>
+#include <rua_util.h>
 
 namespace TaskMngr {
     struct AppInfo {
index a7a34ee..8d3f656 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -21,6 +21,8 @@
 #include "Window.h"
 #include "MainController.h"
 
+#include <efl_extension.h>
+
 using namespace TaskMngr;
 
 App App::m_AppInst;
@@ -101,6 +103,7 @@ bool App::onCreate()
 
     m_pWindow = new Window;
     m_pWindow->show();
+    eext_object_event_callback_add(*m_pWindow, EEXT_CALLBACK_BACK, makeCbFirst(&App::onHwBackButton), this);
 
     m_pRootController = new MainController(m_pWindow->getHostEvasObject());
     m_pWindow->setContent(*m_pRootController);
@@ -109,6 +112,13 @@ bool App::onCreate()
     return true;
 }
 
+void App::onHwBackButton(Evas_Object *obj, void *event_info)
+{
+    LOG("");
+    if (m_pWindow)
+        m_pWindow->lower();
+}
+
 void App::onTerminate()
 {
     TRACE;
@@ -118,11 +128,15 @@ void App::onTerminate()
 void App::onPause()
 {
     TRACE;
+    if (m_pRootController)
+        m_pRootController->pause();
 }
 
 void App::onResume()
 {
     TRACE;
+    if (m_pRootController)
+        m_pRootController->resume();
 }
 
 void App::onControl(app_control_h app_control)
index 74ff0b1..189d9ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -18,6 +18,8 @@
 #include <vector>
 #include <string>
 
+#include "Logger.h"
+
 using namespace TaskMngr;
 
 namespace {
@@ -74,37 +76,32 @@ namespace {
 IndexView::IndexView(Evas_Object *parent)
     : m_IndexSize(0)
     , m_SelectedIndex(-1)
-    , m_IsSelected(false)
 {
     setEo(elm_index_add(parent));
     setStyle("circle");
-    expand();
     setHorizontal(true);
     setAutohide(false);
-    show(true);
 }
 
 IndexView::~IndexView()
 {
-
 }
 
 void IndexView::setSelectedItem(int index, bool value)
 {
-    if(index != m_SelectedIndex || value != m_IsSelected) {
+    if (index != m_SelectedIndex) {
         m_SelectedIndex = index;
-        m_IsSelected = value;
         elm_index_item_selected_set(findItem(index), value);
     }
 }
 
 void IndexView::setItemsCount(int size)
 {
-    if(size != m_IndexSize)
-    {
-        m_IndexSize = size;
-        clear();
-    }
+    if (size == m_IndexSize)
+        return;
+
+    m_IndexSize = size;
+    clear();
 
     if (size > maxScrollSize)
         size = maxScrollSize;
@@ -132,6 +129,7 @@ Elm_Widget_Item* IndexView::appendItem(int index)
 
 void IndexView::clear()
 {
+    m_SelectedIndex = -1;
     elm_index_item_clear(getEo());
 }
 
index ad987dc..491a0f3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -23,58 +23,96 @@ using namespace TaskMngr;
 MainController::MainController(Evas_Object *parent)
     : MainLayout(parent)
     , m_pTaskListView(nullptr)
+    , m_pIndexView(nullptr)
 {
     m_pTaskListView = new TaskListView(getEo());
     m_pTaskListView->setListener(this);
     setList(*m_pTaskListView);
 
+    m_pIndexView = new IndexView(getEo());
+    setIndex(*m_pIndexView);
+    update();
+}
+
+MainController::~MainController()
+{
+}
+
+void MainController::update()
+{
+    m_pTaskListView->clear();
+    auto list = App::getInst().getTaskMngr().getAppInfo();
+    for (const AppInfo &appInfo : list) {
+        m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
+    }
+
     //TODO: only for test will be removed.
-    AppInfo appInfo;
+/*  AppInfo appInfo;
     appInfo.icon = PathUtils::getResourcePath("images/test.jpg");
     appInfo.name = "Hello";
     m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
     m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
     m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
+    m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));*/
 
+    int itemsCount = m_pTaskListView->getItemsCount();
+    updateIndex(itemsCount);
+    updateNoContents(itemsCount);
+}
 
-    auto list = App::getInst().getTaskMngr().getAppInfo();
-    for (const AppInfo &appInfo : list) {
-        m_pTaskListView->appendItem(*new TaskListViewItem(*m_pTaskListView, appInfo));
-    }
+void MainController::updateIndex(int itemsCount)
+{
+    m_pIndexView->setItemsCount(itemsCount);
+    m_pIndexView->setSelectedItem(m_pTaskListView->getCurrentPageIndex());
 }
 
-MainController::~MainController()
+void MainController::updateNoContents(int itemsCount)
 {
+    bool empty = itemsCount <= 0;
+    showNoContents(empty);
+    showCloseButton(!empty);
 }
 
-void MainController::onCloseAllButtonClicked()
+void MainController::pause()
 {
     LOG("");
 }
 
-void MainController::onPageChanged()
+void MainController::resume()
 {
     LOG("");
+    update();
+}
+
+void MainController::onCloseAllButtonClicked()
+{
+    LOG("");
+    m_pTaskListView->killAll();
+}
+
+void MainController::onListChanged(TaskListView &obj, int itemsCount)
+{
+    LOG("", itemsCount);
+    if (itemsCount <= 0)
+        App::getInst().exit();
+    updateIndex(itemsCount);
+    updateNoContents(itemsCount);
 }
 
-void MainController::onKillAnimFinished(TaskListViewItem &item)
+void MainController::onCurrentPageChanged(TaskListView &obj)
 {
     LOG("");
+    updateIndex(m_pTaskListView->getItemsCount());
 }
 
 void MainController::onClicked(TaskListViewItem &item)
 {
     LOG("");
+    App::getInst().getTaskMngr().launchApp(item.getAppInfo().appid, item.getAppInfo().uri);
 }
 
-void MainController::onKillAllAnimFinished()
+void MainController::onItemBeforeDelete(TaskListViewItem &item)
 {
     LOG("");
+    App::getInst().getTaskMngr().killApp(item.getAppInfo().appid, item.getAppInfo().instanceId);
 }
index 2273444..eb836fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -16,6 +16,8 @@
 
 #include "MainLayout.h"
 #include "Resource.h"
+#include "PathUtils.h"
+#include "Logger.h"
 
 using namespace TaskMngr;
 
@@ -49,13 +51,26 @@ void MainLayout::setIndex(Evas_Object *obj)
     setContent(obj, "swl.index");
 }
 
+void MainLayout::prepareNoContents()
+{
+    if (m_pNoContent)
+        return;
+
+    m_pNoContent = elm_layout_add(getEo());
+    elm_layout_theme_set(m_pNoContent, "layout", "nocontents", "text");
+    Evas_Object *icon = elm_image_add(m_pNoContent);
+    elm_image_file_set(icon, PathUtils::getSharedResPath(APP_ICON_IMG).c_str(), nullptr);
+    elm_object_part_content_set(m_pNoContent, "elm.swallow.icon", icon);
+    elm_object_part_text_set(m_pNoContent, "elm.text.title", "Recent apps"); // TODO: localization
+    elm_object_part_text_set(m_pNoContent, "elm.text", "No recent apps"); // TODO: localization
+    emitSignal(m_pNoContent, "elm,state,title,enable", "elm");
+    setContent(m_pNoContent, "swl.bg");
+}
+
 void MainLayout::showNoContents(bool show)
 {
-    if (show && !m_pNoContent) {
-        m_pNoContent = elm_layout_add(getEo());
-        elm_layout_theme_set(getEo(), "layout", "nocontents", "text");
-        setContent(m_pNoContent, "swl.bg");
-    }
+    if (show)
+        prepareNoContents();
 
     const char *sig = show ? "show_bg" : "hide_bg";
     emitSignal(sig, "*");
index eca3223..65ccd37 100644 (file)
@@ -17,6 +17,9 @@
 #include "TaskListView.h"
 #include "App.h"
 #include "Window.h"
+#include "Logger.h"
+#include "Callback.h"
+
 #include <efl_extension.h>
 
 using namespace TaskMngr;
@@ -26,6 +29,9 @@ TaskListView::TaskListView(Evas_Object *parent)
     , m_pScroller(nullptr)
     , m_pBox(nullptr)
     , m_RightPadding(nullptr)
+    , m_LeftPadding(nullptr)
+    , m_pBoxSizeChangedIdler(nullptr)
+    , m_LastItemsCount(0)
 {
     m_pScroller = elm_scroller_add(parent);
     setEo(m_pScroller);
@@ -36,25 +42,31 @@ TaskListView::TaskListView(Evas_Object *parent)
     elm_scroller_page_scroll_limit_set(m_pScroller, 1, 0);
     elm_object_scroll_lock_y_set(m_pScroller, true);
     elm_object_style_set(m_pScroller, "effect");
+    evas_object_smart_callback_add(m_pScroller, "scroll,page,changed", makeCbFirst(&TaskListView::onPageChanged), this);
 
     Evas_Object *circleScroller = eext_circle_object_scroller_add(m_pScroller, nullptr);
     eext_circle_object_scroller_policy_set(circleScroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
     eext_rotary_object_event_activated_set(circleScroller, true);
     evas_object_show(circleScroller);
 
-    m_pBox = elm_box_add(m_pScroller);
-    elm_box_pack_end(m_pBox, createPadding());
     m_RightPadding = createPadding();
+    m_LeftPadding = createPadding();
+
+    m_pBox = elm_box_add(m_pScroller);
+    expand(m_pBox);
+    elm_box_pack_end(m_pBox, m_LeftPadding);
     elm_box_pack_end(m_pBox, m_RightPadding);
     elm_box_horizontal_set(m_pBox, true);
     elm_box_homogeneous_set(m_pBox, false);
-    expand(m_pBox);
+    evas_object_event_callback_add(m_pBox, EVAS_CALLBACK_RESIZE, makeCbFirst(&TaskListView::onBoxSizeChanged), this);
 
     elm_object_content_set(m_pScroller, m_pBox);
 }
 
 TaskListView::~TaskListView()
 {
+    if (m_pBoxSizeChangedIdler)
+        ecore_idler_del(m_pBoxSizeChangedIdler);
 }
 
 Evas_Object *TaskListView::createPadding()
@@ -74,7 +86,7 @@ Evas_Object *TaskListView::createPadding()
 
 void TaskListView::setListener(ITaskListViewListener *listener)
 {
-    m_pListener = nullptr;
+    m_pListener = listener;
 }
 
 void TaskListView::appendItem(TaskListViewItem &item)
@@ -85,12 +97,86 @@ void TaskListView::appendItem(TaskListViewItem &item)
 
 TaskListViewItem *TaskListView::getCurrentPage() const
 {
-    return nullptr;
+    TaskListViewItem *res = nullptr;
+    Eina_List *list = elm_box_children_get(m_pBox);
+
+    if (list) {
+        int currentIndex = getCurrentPageIndex();
+        int count = eina_list_count(list);
+        if (currentIndex >=0 && currentIndex < count)
+            res = staticCast<TaskListViewItem*>(eina_list_nth(list, currentIndex));
+    }
+
+    return res;
+}
+
+int TaskListView::getItemsCount() const
+{
+    int res = 0;
+    Eina_List *list = elm_box_children_get(m_pBox);
+    if (list) {
+        res = eina_list_count(list) - 2; // 2 paddings
+        eina_list_free(list);
+    }
+    return res;
 }
 
-void TaskListView::playKillAllAnim()
+std::vector<TaskListViewItem*> TaskListView::getItems() const
 {
+    std::vector<TaskListViewItem*> res;
+
+    Eina_List *list = elm_box_children_get(m_pBox);
+    if (list) {
+        Eina_List *l = nullptr;
+        void *data = nullptr;
+
+        res.reserve(eina_list_count(list));
+
+        EINA_LIST_FOREACH(list, l, data) {
+            Evas_Object *obj = (Evas_Object*)data;
 
+            if (obj == m_LeftPadding || obj == m_RightPadding)
+                continue;
+
+            res.push_back(staticCast<TaskListViewItem*>(obj));
+        }
+
+        eina_list_free(list);
+    }
+
+    return res;
+}
+
+int TaskListView::getCurrentPageIndex() const
+{
+    int index = 0;
+    elm_scroller_current_page_get(m_pScroller, &index, nullptr);
+    return index;
+}
+
+void TaskListView::killAll()
+{
+    auto items = getItems();
+    for (TaskListViewItem *item : items) {
+        item->playKillAnim();
+    }
+}
+
+void TaskListView::clear()
+{
+    Eina_List *list = elm_box_children_get(m_pBox);
+    if (list) {
+        Eina_List *l = nullptr;
+        void *data = nullptr;
+        EINA_LIST_FOREACH(list, l, data) {
+            Evas_Object *obj = (Evas_Object*)data;
+
+            if (obj == m_LeftPadding || obj == m_RightPadding)
+                   continue;
+                evas_object_del(obj);
+        }
+        eina_list_free(list);
+    }
 }
 
 void TaskListView::freezeScrollPush()
@@ -105,11 +191,43 @@ void TaskListView::freezeScrollPop()
 
 void TaskListView::onDelRequest(TaskListViewItem &item)
 {
-
+    LOG("");
+    if (m_pListener)
+        m_pListener->onItemBeforeDelete(item);
+    item.destroy();
 }
 
 void TaskListView::onAppClicked(TaskListViewItem &item)
 {
+    LOG("");
+    if (m_pListener)
+        m_pListener->onClicked(item);
+}
+
+void TaskListView::onPageChanged(Evas_Object *obj, void *event_info)
+{
+    LOG("");
+    if (m_pListener)
+        m_pListener->onCurrentPageChanged(*this);
+}
 
+Eina_Bool TaskListView::onBoxSizeChangedIlder()
+{
+    LOG("Current index:", getCurrentPageIndex());
+    m_pBoxSizeChangedIdler = nullptr;
+    int lastItemsCount = getItemsCount();
+    if (lastItemsCount != m_LastItemsCount) {
+        m_LastItemsCount = lastItemsCount;
+        if (m_pListener)
+            m_pListener->onListChanged(*this, m_LastItemsCount);
+    }
+    return false;
+}
+
+void TaskListView::onBoxSizeChanged(Evas *e, Evas_Object *obj, void *event_info)
+{
+    if (!m_pBoxSizeChangedIdler) {
+        m_pBoxSizeChangedIdler = ecore_idler_add(makeCbFirst(&TaskListView::onBoxSizeChangedIlder), this);
+    }
 }
 
index 01be79a..459242a 100644 (file)
@@ -66,6 +66,11 @@ TaskListViewItem::~TaskListViewItem()
 
 }
 
+const AppInfo &TaskListViewItem::getAppInfo() const
+{
+    return m_AppInfo;
+}
+
 void TaskListViewItem::setIcon(const std::string &path)
 {
     if (path.empty())
@@ -208,7 +213,7 @@ void TaskListViewItem::onUp(Evas *e, Evas_Object *obj, void *event_info)
     if (m_IsKillAnimPlaying)
         return;
 
-    static const double killThreshold = 0.3;
+    static const double killThreshold = 0.25;
 
     m_IsMouseDown = false;
     if (m_IsDragStart)  {
@@ -246,6 +251,5 @@ void TaskListViewItem::onKillAnimFinished(Evas_Object *obj, const char *emission
     LOG("");
     m_IsKillAnimPlaying = false;
     m_Parent.onDelRequest(*this);
-    destroy();
 }
 
index 78801a8..8ef0453 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 85aef1e..30ca8b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 6d956f9..6c6a099 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 9e3669b..f71259d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 8523c4c..f2bf21a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index ab13ec2..14b6bab 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -47,7 +47,7 @@ void loggerImpl(LogPriority prior
              , Tail... msg)
 {
     std::ostringstream messageStr;
-    std::initializer_list<bool> { (messageStr << msg, true)... };
+    (void)std::initializer_list<bool> { (messageStr << msg, true)... };
     dlog_print(static_cast<log_priority>(prior)
               , tag, "%s: %s(%d) -> %s", file, function, line
               , messageStr.str().c_str());
index c81e389..a2da05b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -60,6 +60,13 @@ namespace TaskMngr {
              * @return absolute path to file
              */
             std::string getEdjePath(const std::string &fileName);
+
+            /**
+             * @brief Gets the absolute path to app. shared resource file
+             * @param[in] base file name
+             * @return absolute path to file
+             */
+            std::string getSharedResPath(const std::string &fileName);
     };
 }
 
index e0695c2..af7fb35 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 33e5a2b..3d023bc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 5ee4c0a..1ac27ff 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index 6481958..a6c8f20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
@@ -120,5 +120,23 @@ std::string getEdjePath(const std::string &fileName)
     return getResourcePath(EDJ_PATH"/" + fileName);
 }
 
+std::string getSharedResPath(const std::string &fileName)
+{
+    std::string res;
+    static std::string basePath;
+    if (basePath.empty()) {
+        char *path = app_get_shared_resource_path();
+        if (path) {
+            basePath = path;
+            free(path);
+        }
+    }
+
+    res += basePath;
+    res += fileName;
+
+    return res;
+}
+
 } // PathUtils
 } // TaskMngr
index 56ff14b..0373758 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index d4f9354..7a040f4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.
index ab5e33f..f19b9d4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017  Samsung Electronics Co., Ltd
+ * 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.