TizenRefApp-9558 [Call UI] Reimplement AcceptDialog using base Dialog class 97/154497/5
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Tue, 10 Oct 2017 10:02:53 +0000 (13:02 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Tue, 10 Oct 2017 12:33:14 +0000 (15:33 +0300)
Change-Id: I70367e2e8bcd1c3cfc6fe01c9f78cf8f5c37aaae

.cproject
call-ui/presenters/dialogs/AcceptDialog.cpp
call-ui/presenters/dialogs/AcceptDialog.h
call-ui/presenters/dialogs/base/Dialog.cpp [new file with mode: 0644]
call-ui/presenters/dialogs/base/Dialog.h [new file with mode: 0644]
call-ui/presenters/dialogs/base/Dialog.hpp [new file with mode: 0644]
call-ui/view/common.h
project_def.prop

index ae875a3e26d550edccaddbcfe4aef65fd0990ba8..d1a9f6877798c2a9a0f8500c82be832989de0c3e 100644 (file)
--- a/.cproject
+++ b/.cproject
@@ -35,7 +35,6 @@
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.2060575755" 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;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/pkgmgr&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/privacy-privilege-manager/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/rua/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1481628386" 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;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/pkgmgr&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/privacy-privilege-manager/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/rua/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
                                                                <option command="-id " id="sbi.gnu.edc.compiler.option.misc.id.434887912" name="Image Path (-id)" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList">
                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/images&quot;"/>
                                                                </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.sd.272942437" superClass="sbi.gnu.edc.compiler.option.misc.sd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/sounds&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.fd.2099492430" superClass="sbi.gnu.edc.compiler.option.misc.fd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/fonts&quot;"/>
+                                                               </option>
                                                        </tool>
                                                </toolChain>
                                        </folderInfo>
                                                                <option id="sbi.gnu.cpp.compiler.option.frameworks_inc.core.1432667313" 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;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/privacy-privilege-manager/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
                                                                <option id="sbi.gnu.c.compiler.option.frameworks_inc.core.1440527129" 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;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include&quot;"/>
-                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-agent&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appcore-watch&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/appfw&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/notification&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/nsd/&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/phonenumber-utils&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/privacy-privilege-manager/&quot;"/>
+                                                                       <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/SDL2&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/sensor&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/storage&quot;"/>
                                                                        <listOptionValue builtIn="false" value="&quot;${SBI_SYSROOT}/usr/include/system&quot;"/>
                                                        <tool id="org.tizen.nativecore.tool.ast.cpp.1169680363" name="C++ Static Analyzer" superClass="org.tizen.nativecore.tool.ast.cpp"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib.765743958" name="Archive Generator" superClass="org.tizen.nativecore.tool.sbi.gnu.archiver.mergelib"/>
                                                        <tool id="org.tizen.nativecore.tool.sbi.po.compiler.1889777798" name="PO Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.po.compiler"/>
-                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1860406220" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler"/>
+                                                       <tool id="org.tizen.nativecore.tool.sbi.edc.compiler.1860406220" name="EDC Resource Compiler" superClass="org.tizen.nativecore.tool.sbi.edc.compiler">
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.id.1760090476" superClass="sbi.gnu.edc.compiler.option.misc.id" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/images&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.sd.1539334293" superClass="sbi.gnu.edc.compiler.option.misc.sd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/sounds&quot;"/>
+                                                               </option>
+                                                               <option id="sbi.gnu.edc.compiler.option.misc.fd.1141822320" superClass="sbi.gnu.edc.compiler.option.misc.fd" valueType="stringList">
+                                                                       <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/edc/fonts&quot;"/>
+                                                               </option>
+                                                       </tool>
                                                </toolChain>
                                        </folderInfo>
                                        <sourceEntries>
index 676b706bd6b448f3df2f49562e2fcf3814c8b224..c6c3710248eb2aeebd5e63e213e64d701c444b66 100644 (file)
@@ -26,10 +26,6 @@ namespace callui { namespace { namespace impl {
 
        constexpr ElmStyle POPUP_STYLE {"circle"};
 
-       constexpr SmartEvent POPUP_DISMISSED {"dismissed"};
-
-       constexpr EdjePart PART_SWL_CONTENT{"elm.swallow.content"};
-
        void *asData(const AcceptDialog::Event event)
        {
                return reinterpret_cast<void *>(static_cast<intptr_t>(event));
@@ -68,14 +64,15 @@ namespace callui {
                FAIL_RETURN_VALUE(result->prepare(parent), {},
                                "result->prepare() failed!");
 
+               result->show();
+
                return result;
        }
 
        AcceptDialog::AcceptDialog(IRefCountObj &rc,
                        const EventHandler &handler):
-               GuiPresenter(rc),
-               m_handler(handler),
-               m_isDismissed(false)
+               Dialog(rc),
+               m_handler(handler)
        {
        }
 
@@ -86,46 +83,29 @@ namespace callui {
 
        Result AcceptDialog::prepare(ElmWidget &parent)
        {
-               FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
-                               "Presenter::prepare() failed!");
-
-               FAIL_RETURN(createPopup(parent, impl::POPUP_STYLE),
-                               "createPopup() failed!");
-
-               FAIL_RETURN(createGenlist(),
-                               "createGenlist() failed!");
-
-               m_selfRef = asShared(*this);
-
-               setLanguageChangeCallback();
-
-               addDeactivatorException(this);
-               broadcastDeactivate();
+               FAIL_RETURN(Dialog::prepare(parent, PopupType::NORMAL,
+                               [this]()
+                               {
+                                       return doPrepare();
+                               }),
+                               "Dialog::prepare failed");
 
                return RES_OK;
        }
 
-       Result AcceptDialog::createPopup(ElmWidget &parent, ElmStyle style)
+       Result AcceptDialog::doPrepare()
        {
-               Evas_Object *const popupEo = elm_popup_add(parent);
-               if (!popupEo) {
-                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
-               }
-               m_popup = makeShared<StyledWidget>(popupEo);
-               m_popup->setStyle(style);
-               m_popup->setWeight(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-               show(*m_popup);
+               m_popup->setStyle(impl::POPUP_STYLE);
 
-               m_popup->addEventHandler(impl::POPUP_DISMISSED,
-                               WEAK_DELEGATE_THIS(onPopupDismissed));
+               FAIL_RETURN(createGenlist(), "createGenlist() failed!");
 
-               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
-                               CALLBACK_A(AcceptDialog::onPopupHWBackKey), this);
+               setLanguageChangeCallback();
 
                return RES_OK;
        }
 
-       void AcceptDialog::onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo)
+       void AcceptDialog::onGenlistItemClickedCb(Evas_Object *obj,
+                       void *eventInfo)
        {
                if (!eventInfo)
                        LOG_RETURN_VOID(RES_FAIL, "eventInfo is NULL");
@@ -155,7 +135,7 @@ namespace callui {
 
                FAIL_RETURN(fillGenlist(), "fillGenlist() failed!");
 
-               m_popup->setContent(glEo, impl::PART_SWL_CONTENT);
+               m_popup->setContent(glEo);
 
                return RES_OK;
        }
@@ -164,7 +144,8 @@ namespace callui {
        {
                static Elm_Genlist_Item_Class titleItc =
                                utils::createGenlistItemClass("title",
-                               [](void *data, Evas_Object *obj, const char *part) -> char * {
+                               [](void *data, Evas_Object *obj, const char *part) -> char *
+                               {
                                        return strdup(STR_ANSWER_CALL.translate());
                                });
 
@@ -184,7 +165,8 @@ namespace callui {
        {
                static Elm_Genlist_Item_Class textItc =
                                utils::createGenlistItemClass("1text.1icon",
-                               [](void *data, Evas_Object *obj, const char *part) -> char * {
+                               [](void *data, Evas_Object *obj, const char *part) -> char *
+                               {
                                        switch (impl::asEvent(data)) {
                                        case Event::HOLD_AND_ACCEPT:
                                                return strdup(STR_HOLD_AND_ACCEPT.translate());
@@ -223,7 +205,6 @@ namespace callui {
                return RES_OK;
        }
 
-
        Result AcceptDialog::fillGenlist()
        {
                FAIL_RETURN(addGenlistTitleItem(), "addGenlistTitleItem() failed!");
@@ -275,45 +256,9 @@ namespace callui {
                return true;
        }
 
-       void AcceptDialog::onPopupDismissed(ucl::Widget &widget, void *eventInfo)
-       {
-               dispose();
-       }
-
-       void AcceptDialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
+       void AcceptDialog::onBackKey()
        {
-               if (!m_isDismissed) {
-                       handleEvent(Event::BACK);
-               }
-       }
-
-       void AcceptDialog::dismiss()
-       {
-               if (m_popup && !m_isDismissed) {
-                       m_isDismissed = true;
-                       deactivateBy(m_popup.get());
-                       elm_popup_dismiss(*m_popup);
-               }
+               handleEvent(Event::BACK);
        }
 
-       void AcceptDialog::dispose()
-       {
-               if (m_popup) {
-
-                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
-                                       CALLBACK_A(AcceptDialog::onPopupHWBackKey));
-
-                       deactivateBy(m_popup.get());
-                       broadcastActivate();
-
-                       m_popup.reset();
-
-                       m_selfRef.reset();
-               }
-       }
-
-       bool AcceptDialog::isDisposed() const
-       {
-               return (!m_popup);
-       }
 }
index fae6945d81f27fbf272f205cd2a1e278ccfb315e..6fb1cb8ce3a64ec7530858377fe873344613c215 100644 (file)
@@ -17,9 +17,7 @@
 #ifndef __CALL_UI_PRESENTERS_DIALOGS_ACCEPT_DIALOG_H__
 #define __CALL_UI_PRESENTERS_DIALOGS_ACCEPT_DIALOG_H__
 
-#include "ucl/mvp/GuiPresenter.h"
-
-#include "ucl/gui/StyledWidget.h"
+#include "base/Dialog.h"
 
 #include "call-ui/types.h"
 
@@ -30,8 +28,7 @@ namespace callui {
        /**
         * @brief Presenter of Accept call dialog
         */
-       class AcceptDialog final : public ucl::GuiPresenter,
-                       public ucl::IDisposable {
+       class AcceptDialog final : public Dialog {
        public:
 
                /**
@@ -51,7 +48,7 @@ namespace callui {
        public:
 
                /**
-                * AcceptDialog builer
+                * AcceptDialog builder
                 */
                class Builder {
                public:
@@ -77,32 +74,13 @@ namespace callui {
                        EventHandler m_handler;
                };
 
-       public:
-
-               /**
-                * @brief Dismisses dialog
-                */
-               void dismiss();
-
-               // ucl::IDisposable //
-
-               /**
-                * @see ucl::IDisposable::dispose()
-                */
-               virtual void dispose() final override;
-
-               /**
-                * @see ucl::IDisposable::isDisposed()
-                */
-               virtual bool isDisposed() const final override;
-
        private:
                AcceptDialog(ucl::IRefCountObj &rc, const EventHandler &handler);
                ~AcceptDialog();
 
                ucl::Result prepare(ucl::ElmWidget &parent);
+               ucl::Result doPrepare();
 
-               ucl::Result createPopup(ucl::ElmWidget &parent, ucl::ElmStyle style);
                ucl::Result createGenlist();
                ucl::Result fillGenlist();
                ucl::Result addGenlistTitleItem();
@@ -116,17 +94,15 @@ namespace callui {
                void handleEvent(Event event);
                bool dispatchEvent(Event event);
 
-               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
-               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
-
                void onGenlistItemClickedCb(Evas_Object *obj, void *eventInfo);
 
+               // Dialog //
+
+               virtual void onBackKey() override final;
+
        private:
                const EventHandler m_handler;
-               ucl::StyledWidgetSRef m_popup;
                ucl::StyledWidgetSRef m_genlist;
-               AcceptDialogSRef m_selfRef;
-               bool m_isDismissed;
 
                friend class ucl::ReffedObj<AcceptDialog>;
        };
diff --git a/call-ui/presenters/dialogs/base/Dialog.cpp b/call-ui/presenters/dialogs/base/Dialog.cpp
new file mode 100644 (file)
index 0000000..7cde517
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * 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 "Dialog.h"
+
+#include "call-ui/presenters/common.h"
+
+namespace callui {
+
+       Dialog::Dialog(IRefCountObj &rc) :
+               GuiPresenter(rc),
+               m_isDismissed(false)
+       {
+               deactivateSelf();
+       }
+
+       Dialog::~Dialog()
+       {
+               if (const auto window = getWindowRef()) {
+                       window->delEventHandler(
+                                       WidgetEvent::DEL, DELEGATE_THIS(onWindowDel));
+               }
+       }
+
+       Result Dialog::createPopup(ElmWidget &parent, const PopupType popupType)
+       {
+               Evas_Object *const popupEo = ((popupType == PopupType::NORMAL) ?
+                               elm_popup_add(parent) : elm_ctxpopup_add(parent));
+               if (!popupEo) {
+                       LOG_RETURN(RES_FAIL, "elm_popup_add() failed!");
+               }
+
+               m_popup = makeShared<StyledWidget>(popupEo);
+
+               m_popup->addEventHandler(
+                               POPUP_DISMISSED, WEAK_DELEGATE_THIS(onPopupDismissed));
+
+               eext_object_event_callback_add(*m_popup, EEXT_CALLBACK_BACK,
+                               CALLBACK_A(Dialog::onPopupHWBackKey), this);
+
+               getWindow().addEventHandler(
+                               WidgetEvent::DEL, WEAK_DELEGATE_THIS(onWindowDel));
+
+               return RES_OK;
+       }
+
+       void Dialog::show()
+       {
+               using ucl::show;
+               if (m_popup && !m_isDismissed && !m_popup->isVisible()) {
+                       show(*m_popup);
+                       onShow();
+                       broadcastDeactivate();
+                       activateSelf();
+               }
+       }
+
+       void Dialog::dismiss()
+       {
+               if (m_popup && !m_isDismissed && m_popup->isVisible()) {
+                       m_isDismissed = true;
+                       deactivateSelf();
+                       elm_popup_dismiss(*m_popup);
+                       onDismiss();
+               }
+       }
+
+       void Dialog::dispose()
+       {
+               if (m_popup) {
+                       eext_object_event_callback_del(*m_popup, EEXT_CALLBACK_BACK,
+                                       CALLBACK_A(Dialog::onPopupHWBackKey));
+
+                       deactivateSelf();
+                       m_popup.reset();
+                       m_selfRef.reset();
+
+                       broadcastActivate();
+               }
+       }
+
+       bool Dialog::isDisposed() const
+       {
+               return !!m_popup;
+       }
+
+       void Dialog::onPopupDismissed(Widget &widget, void *eventInfo)
+       {
+               dispose();
+       }
+
+       void Dialog::onPopupHWBackKey(Evas_Object *obj, void *eventInfo)
+       {
+               if (isActive()) {
+                       onBackKey();
+               }
+       }
+
+       void Dialog::onWindowDel(Widget &widget, void *eventInfo)
+       {
+               dispose();
+       }
+
+       void Dialog::onShow()
+       {
+       }
+
+       void Dialog::onDismiss()
+       {
+       }
+
+       void Dialog::onBackKey()
+       {
+               dismiss();
+       }
+}
diff --git a/call-ui/presenters/dialogs/base/Dialog.h b/call-ui/presenters/dialogs/base/Dialog.h
new file mode 100644 (file)
index 0000000..bcb4155
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * 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 __CALL_UI_PRESENTERS_DIALOGS_BASE_DIALOG_H__
+#define __CALL_UI_PRESENTERS_DIALOGS_BASE_DIALOG_H__
+
+#include "ucl/gui/StyledWidget.h"
+
+#include "ucl/mvp/GuiPresenter.h"
+
+#include "call-ui/presenters/types.h"
+
+namespace callui {
+
+       UCL_DECLARE_REF_ALIASES(Dialog);
+
+       /**
+        * @brief Base class for Dialogs
+        */
+       class Dialog : public ucl::GuiPresenter,
+                       public ucl::IDisposable {
+       public:
+
+               /**
+                * @brief Shows dialog
+                */
+               void show();
+
+               /**
+                * @brief Dismisses dialog
+                */
+               void dismiss();
+
+               // ucl::IDisposable //
+
+               /**
+                * @see ucl::IDisposable::dispose()
+                */
+               virtual void dispose() final override;
+
+               /**
+                * @see ucl::IDisposable::isDisposed()
+                */
+               virtual bool isDisposed() const final override;
+
+       protected:
+               /**
+                * @brief Enumeration of popup type for Dialog
+                */
+               enum class PopupType {
+                       NORMAL,                /** < Default popup type */
+                       CONTEXT                /** < Context popup type */
+               };
+
+       protected:
+               /**
+                * @brief Constructor
+                * @param[in] rc Pointer to IRefCountObj (passed automatically)
+                */
+               Dialog(ucl::IRefCountObj &rc);
+
+               /**
+                * @brief Destructor
+                */
+               ~Dialog();
+
+               /**
+                * @brief Prepares Dialog data
+                * @param[in] parent Parent for the popup
+                * @param[in] popupType Popup type
+                * @param[in] onPrepare Callback function to be called
+                *  on child side to initialize child defined data
+                * @return RES_OK on success, otherwise error result.
+                */
+               template <class ON_PREPARE>
+               ucl::Result prepare(ucl::ElmWidget &parent, PopupType popupType,
+                               ON_PREPARE &&onPrepare);
+
+               /**
+                * @brief Called on Dialog show event.
+                */
+               virtual void onShow();
+
+               /**
+                * @brief Called on Dialog dismiss event.
+                */
+               virtual void onDismiss();
+
+               /**
+                * @brief Called on Dialog back key press event.
+                */
+               virtual void onBackKey();
+
+       private:
+               ucl::Result createPopup(ucl::ElmWidget &parent, PopupType popupType);
+
+               void onPopupDismissed(ucl::Widget &widget, void *eventInfo);
+               void onPopupHWBackKey(Evas_Object *obj, void *eventInfo);
+               void onWindowDel(ucl::Widget &widget, void *eventInfo);
+
+       protected:
+               ucl::StyledWidgetSRef m_popup;
+       private:
+               DialogSRef m_selfRef;
+               bool m_isDismissed;
+       };
+}
+
+#include "Dialog.hpp"
+
+#endif // __CALL_UI_PRESENTERS_DIALOGS_BASE_DIALOG_H__
diff --git a/call-ui/presenters/dialogs/base/Dialog.hpp b/call-ui/presenters/dialogs/base/Dialog.hpp
new file mode 100644 (file)
index 0000000..090edfc
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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 callui {
+
+       template <class ON_PREPARE>
+       inline ucl::Result Dialog::prepare(ucl::ElmWidget &parent,
+                       const PopupType popupType, ON_PREPARE &&onPrepare)
+       {
+               UCL_FAIL_RETURN(GuiPresenter::prepare(parent, PF_DEACTIVATOR),
+                               "GuiPresenter::prepare() failed!");
+
+               UCL_FAIL_RETURN(createPopup(parent, popupType),
+                               "createPopup() failed!");
+
+               setDeactivatorSink(m_popup);
+
+               UCL_FAIL_RETURN(onPrepare(), "onPrepare() failed!");
+
+               m_selfRef = asShared(*this);
+
+               return ucl::RES_OK;
+       }
+}
index cf9b0d4e9d49ddc1ec0b48b4f1dc27b8387600ae..c8e210025de909c55789120d4f60cc3346385c1b 100644 (file)
@@ -37,6 +37,7 @@ namespace callui {
 
        constexpr ucl::SmartEvent BTN_CLICKED {"clicked"};
        constexpr ucl::SmartEvent ATSPI_HIGHLIGHTED {"atspi,highlighted"};
+       constexpr ucl::SmartEvent POPUP_DISMISSED {"dismissed"};
 }
 
 #endif // __CALL_UI_VIEW_COMMON_H__
index c5169af2154d41ddb28a654eee417b799f3aa0fa..22da83ab371a608fb336027f987fd185913d5b84 100644 (file)
@@ -9,7 +9,7 @@ type = app
 profile = wearable-4.0
 
 # C/CPP Sources
-USER_SRCS = call-ui/view/VolumeControl.cpp call-ui/model/impl/CallInfo.cpp call-ui/model/impl/IncomingCall.cpp ucl/source/appfw/helpers.cpp ucl/source/mvp/ListItemPresenter.cpp call-ui/model/impl/RejectMsg.cpp ucl/source/gui/Genlist.cpp ucl/source/util/types/Result.cpp call-ui/model/impl/ConferenceCallInfo.cpp call-ui/model/impl/BluetoothManager.cpp ucl/source/gui/Layout.cpp call-ui/presenters/misc/MotionSensorPresenter.cpp call-ui/model/impl/RssiStateSource.cpp call-ui/presenters/Instance.cpp call-ui/model/impl/ActiveCall.cpp call-ui/model/impl/SimSlotStateSource.cpp call-ui/presenters/misc/AcceptRejectPresenter.cpp ucl/source/gui/WidgetItem.cpp call-ui/presenters/pages/MainPage.cpp ucl/source/gui/NaviItem.cpp call-ui/presenters/misc/DeviceStatePresenter.cpp call-ui/model/impl/ContactInfoProvider.cpp call-ui/model/impl/HdVoiceStateSource.cpp ucl/source/gui/Window.cpp call-ui/model/impl/ConnectionStateSource.cpp call-ui/presenters/misc/RejectMsgPresenter.cpp call-ui/presenters/pages/KeypadPage.cpp ucl/source/util/logging.cpp ucl/source/appfw/UIApp.cpp call-ui/presenters/misc/AccessoryPresenter.cpp call-ui/model/impl/ContactInfo.cpp call-ui/model/impl/EndCall.cpp call-ui/view/Slider.cpp call-ui/model/impl/RejectMsgProvider.cpp ucl/source/mvp/GuiPresenter.cpp ucl/source/appfw/InstanceManagerBase.cpp call-ui/model/impl/BatteryStateSource.cpp ucl/source/gui/Widget.cpp call-ui/presenters/dialogs/AcceptDialog.cpp call-ui/types.cpp call-ui/presenters/misc/helpers.cpp call-ui/model/impl/IndicatorStateProvider.cpp call-ui/view/AcceptRejectWidget.cpp ucl/source/misc/Timeout.cpp call-ui/resources.cpp ucl/source/util/types/classTypes.cpp call-ui/model/CallUIBuilder.cpp call-ui/presenters/misc/CallStatusPresenter.cpp call-ui/model/impl/HeldCall.cpp call-ui/model/impl/SoundManager.cpp ucl/source/gui/EdjeWidget.cpp call-ui/model/impl/MsgClient.cpp call-ui/presenters/InstanceManager.cpp call-ui/presenters/pages/base/Page.cpp call-ui/presenters/misc/MoreOptionsPresenter.cpp call-ui/presenters/misc/IndicatorPresenter.cpp call-ui/presenters/misc/AtspiHighlightHelper.cpp ucl/source/gui/Naviframe.cpp call-ui/model/impl/CallUI.cpp ucl/source/gui/ElmWidget.cpp ucl/source/gui/RadioBox.cpp ucl/source/misc/Variant.cpp call-ui/view/helpers.cpp call-ui/main.cpp call-ui/model/impl/CallManager.cpp call-ui/presenters/misc/CallInfoPresenter.cpp ucl/source/appfw/SysEventProvider.cpp call-ui/model/impl/CallClient.cpp ucl/source/mvp/ListPresenter.cpp 
+USER_SRCS = call-ui/presenters/dialogs/base/Dialog.cpp call-ui/view/VolumeControl.cpp call-ui/model/impl/CallInfo.cpp call-ui/model/impl/IncomingCall.cpp ucl/source/appfw/helpers.cpp ucl/source/mvp/ListItemPresenter.cpp call-ui/model/impl/RejectMsg.cpp ucl/source/gui/Genlist.cpp ucl/source/util/types/Result.cpp call-ui/model/impl/ConferenceCallInfo.cpp call-ui/model/impl/BluetoothManager.cpp ucl/source/gui/Layout.cpp call-ui/presenters/misc/MotionSensorPresenter.cpp call-ui/model/impl/RssiStateSource.cpp call-ui/presenters/Instance.cpp call-ui/model/impl/ActiveCall.cpp call-ui/model/impl/SimSlotStateSource.cpp call-ui/presenters/misc/AcceptRejectPresenter.cpp ucl/source/gui/WidgetItem.cpp call-ui/presenters/pages/MainPage.cpp ucl/source/gui/NaviItem.cpp call-ui/presenters/misc/DeviceStatePresenter.cpp call-ui/model/impl/ContactInfoProvider.cpp call-ui/model/impl/HdVoiceStateSource.cpp ucl/source/gui/Window.cpp call-ui/model/impl/ConnectionStateSource.cpp call-ui/presenters/misc/RejectMsgPresenter.cpp call-ui/presenters/pages/KeypadPage.cpp ucl/source/util/logging.cpp ucl/source/appfw/UIApp.cpp call-ui/presenters/misc/AccessoryPresenter.cpp call-ui/model/impl/ContactInfo.cpp call-ui/model/impl/EndCall.cpp call-ui/view/Slider.cpp call-ui/model/impl/RejectMsgProvider.cpp ucl/source/mvp/GuiPresenter.cpp ucl/source/appfw/InstanceManagerBase.cpp call-ui/model/impl/BatteryStateSource.cpp ucl/source/gui/Widget.cpp call-ui/presenters/dialogs/AcceptDialog.cpp call-ui/types.cpp call-ui/presenters/misc/helpers.cpp call-ui/model/impl/IndicatorStateProvider.cpp call-ui/view/AcceptRejectWidget.cpp ucl/source/misc/Timeout.cpp call-ui/resources.cpp ucl/source/util/types/classTypes.cpp call-ui/model/CallUIBuilder.cpp call-ui/presenters/misc/CallStatusPresenter.cpp call-ui/model/impl/HeldCall.cpp call-ui/model/impl/SoundManager.cpp ucl/source/gui/EdjeWidget.cpp call-ui/model/impl/MsgClient.cpp call-ui/presenters/InstanceManager.cpp call-ui/presenters/pages/base/Page.cpp call-ui/presenters/misc/MoreOptionsPresenter.cpp call-ui/presenters/misc/IndicatorPresenter.cpp call-ui/presenters/misc/AtspiHighlightHelper.cpp ucl/source/gui/Naviframe.cpp call-ui/model/impl/CallUI.cpp ucl/source/gui/ElmWidget.cpp ucl/source/gui/RadioBox.cpp ucl/source/misc/Variant.cpp call-ui/view/helpers.cpp call-ui/main.cpp call-ui/model/impl/CallManager.cpp call-ui/presenters/misc/CallInfoPresenter.cpp ucl/source/appfw/SysEventProvider.cpp call-ui/model/impl/CallClient.cpp ucl/source/mvp/ListPresenter.cpp 
 
 # EDC Sources
 USER_EDCS =