#include <memory>
#include <Evas.h>
#include <Elementary.h>
+#include <efl_assist.h>
#include <dpl/log/log.h>
+#include <dpl/log/secure_log.h>
+#include <dpl/unused.h>
#include <dpl/assert.h>
#include <dpl/wrt-dao-ro/common_dao_types.h>
#include <wrt-commons/certificate-dao/certificate_dao.h>
#include <widget_model.h>
#include <widget_string.h>
+#include <common/view_logic_get_parent_window_util.h>
namespace ViewModule {
namespace {
-const char* const DAEMON_EDJ_PATH = "/usr/share/edje/wrt/Daemon.edj";
+const double MAX_POPUP_HEIGHT = 0.80;
+const double MAX_SCROLLER_HEIGHT = 0.5;
+
+struct CallbackData {
+ Evas_Smart_Cb eaKeyCallback;
+};
+
+static void deleteCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo);
+static void resizeCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo);
+
+static void deleteCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo)
+{
+ _D("called");
+
+ Assert(obj);
+
+ DPL_UNUSED_PARAM(e);
+ DPL_UNUSED_PARAM(eventInfo);
+
+ CallbackData* callbackData = static_cast<CallbackData*>(data);
+ if (callbackData) {
+ ea_object_event_callback_del(obj, EA_CALLBACK_BACK, callbackData->eaKeyCallback);
+ delete callbackData;
+ }
+ evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE, resizeCallback);
+}
+
+static void resizeCallback(void* data, Evas* e, Evas_Object* obj, void* eventInfo)
+{
+ _D("called");
+
+ Assert(obj);
+
+ DPL_UNUSED_PARAM(data);
+ DPL_UNUSED_PARAM(e);
+ DPL_UNUSED_PARAM(eventInfo);
+
+ Evas_Object* popup = obj;
+ int popupH;
+ evas_object_geometry_get(popup, 0, 0, 0, &popupH);
+
+ Evas_Object* parent = PopupUtil::getParentWindow(popup);
+ int parentW, parentH;
+ evas_object_geometry_get(parent, 0, 0, &parentW, &parentH);
+
+ // compare current popup height with screen height.
+ // To avoid popup is filled full screen, used magic number to be filled 80% of screen height.
+ // TODO: Automatically add scroller feature should implement in the elementary
+ double threshold = parentH * MAX_POPUP_HEIGHT;
+ double currentH = popupH;
+ if (threshold < currentH) {
+ _D("text is overflow popup height. add scroller");
+ Evas_Object* layout = elm_object_content_get(obj);
+ Evas_Object* label = elm_object_part_content_get(layout, "elm.swallow.label");
+
+ Evas_Object* scroller = elm_scroller_add(layout);
+ elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_AUTO);
+ evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_scroller_content_min_limit(scroller, EINA_TRUE, EINA_TRUE);
+ int scrollerHeight = parentW > parentH ? parentH : parentW;
+ evas_object_size_hint_max_set(scroller, -1, scrollerHeight * MAX_SCROLLER_HEIGHT);
+
+ elm_object_part_content_unset(layout, "elm.swallow.label");
+ elm_object_content_set(scroller, label);
+ elm_object_part_content_set(layout, "elm.swallow.label", scroller);
+ evas_object_show(layout);
+ }
+}
}
class CertificateSupportImplementation
Evas_Object* window,
const char* bodyText,
const char* checkText,
- Evas_Smart_Cb
- buttonCallback,
+ Evas_Smart_Cb buttonCallback,
+ Evas_Smart_Cb keyCallback,
void* data)
{
LogDebug("createPopup");
- Evas_Object* popup = elm_popup_add(window);
- Evas_Object* label = elm_label_add(popup);
- elm_object_style_set(label, "popup/default");
- elm_label_line_wrap_set(label, ELM_WRAP_MIXED);
- elm_object_text_set(label, bodyText);
- evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0.0);
- evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_show(label);
+ Evas_Object* parentWindow = PopupUtil::getParentWindow(window);
+ Evas_Object* popup = elm_popup_add(parentWindow);
+
+ CallbackData* callbackData = NULL;
+ if (keyCallback) {
+ callbackData = new CallbackData;
+ callbackData->eaKeyCallback = keyCallback;
+ ea_object_event_callback_add(popup, EA_CALLBACK_BACK, keyCallback, data);
+ }
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, deleteCallback, static_cast<void*>(callbackData));
+ evas_object_event_callback_add(popup, EVAS_CALLBACK_RESIZE, resizeCallback, NULL);
+
+ elm_object_style_set(popup, "popup/default");
+ evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
Evas_Object* layout = elm_layout_add(popup);
- elm_layout_file_set(layout, DAEMON_EDJ_PATH, "popupWithCheck");
+ elm_layout_file_set(layout, WRT_EDJ_PATH, "popupWithCheck");
evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
- Evas_Object* check = elm_check_add(popup);
- evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- evas_object_show(check);
+ Evas_Object* label = elm_label_add(popup);
+ elm_label_line_wrap_set(label, ELM_WRAP_WORD);
+ elm_object_text_set(label, bodyText);
+ evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
- elm_object_part_text_set(layout, "elm.text", checkText);
- elm_object_part_content_set(layout, "elm.swallow.content", label);
- elm_object_part_content_set(layout, "elm.swallow.end", check);
+ Evas_Object* check = elm_check_add(layout);
+ elm_object_text_set(check, checkText);
- evas_object_show(layout);
+ elm_object_part_content_set(layout, "elm.swallow.label", label);
+ elm_object_part_content_set(layout, "elm.swallow.checkbox", check);
elm_object_content_set(popup, layout);
+
Evas_Object* btn1 = elm_button_add(popup);
- elm_object_text_set(btn1, WRT_SK_YES);
+ elm_object_text_set(btn1, WRT_OPT_ALLOW);
elm_object_part_content_set(popup, "button1", btn1);
evas_object_smart_callback_add(btn1, "clicked", buttonCallback, data);
Evas_Object* btn2 = elm_button_add(popup);
- elm_object_text_set(btn2, WRT_SK_NO);
+ elm_object_text_set(btn2, WRT_SK_CANCEL);
elm_object_part_content_set(popup, "button2", btn2);
evas_object_smart_callback_add(btn2, "clicked", buttonCallback, data);
+
return popup;
}
}
Evas_Object* check = elm_object_part_content_get(
elm_object_content_get(popup),
- "elm.swallow.end");
+ "elm.swallow.checkbox");
return check;
}
if (popup == NULL) {
return RESULT_UNKNOWN;
}
- bool allow = !strcmp(WRT_SK_YES, elm_object_text_get(button));
+ bool allow = !strcmp(WRT_OPT_ALLOW, elm_object_text_get(button));
// get check evas_object
Evas_Object* check = getCheck(popup);