Skip to content

Commit 7978db9

Browse files
committed
Apply reviewer's comment
1 parent 5821267 commit 7978db9

9 files changed

+82
-66
lines changed

flutter/shell/platform/tizen/BUILD.gn

-2
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ template("embedder") {
158158
"EGL",
159159
"GLESv2",
160160
]
161-
162-
defines += [ "AUTOFILL_SUPPORT" ]
163161
}
164162

165163
if (target_name == "flutter_tizen_common") {

flutter/shell/platform/tizen/channels/text_input_channel.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "flutter/shell/platform/tizen/flutter_tizen_engine.h"
99
#include "flutter/shell/platform/tizen/logger.h"
1010

11-
#ifdef AUTOFILL_SUPPORT
11+
#ifndef WEARABLE_PROFILE
1212
#include "flutter/shell/platform/tizen/tizen_autofill.h"
1313
#endif
1414

@@ -69,11 +69,11 @@ TextInputChannel::TextInputChannel(
6969
std::unique_ptr<MethodResult<rapidjson::Document>> result) {
7070
HandleMethodCall(call, std::move(result));
7171
});
72-
#ifdef AUTOFILL_SUPPORT
72+
#ifndef WEARABLE_PROFILE
7373
TizenAutofill& instance = TizenAutofill::GetInstance();
74-
instance.SetPopupCallback(
74+
instance.SetOnPopup(
7575
[this]() { input_method_context_->PopupAutofillItems(); });
76-
instance.SetCommitCallback([this](std::string value) { OnCommit(value); });
76+
instance.SetOnCommit([this](std::string value) { OnCommit(value); });
7777
#endif
7878
}
7979

@@ -320,7 +320,7 @@ void TextInputChannel::HandleMethodCall(
320320
}
321321
SendStateUpdate();
322322
} else if (method.compare(kRequestAutofillMethod) == 0) {
323-
#ifdef AUTOFILL_SUPPORT
323+
#ifndef WEARABLE_PROFILE
324324
TizenAutofill& instance = TizenAutofill::GetInstance();
325325
instance.RequestAutofill(autofill_hints_, autofill_id_);
326326
#else

flutter/shell/platform/tizen/nui_autofill_popup.cc

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void NuiAutofillPopup::PopupAutofill(Dali::Actor* actor) {
5454
PrepareAutofill();
5555
Dali::Toolkit::TableView content =
5656
Dali::Toolkit::TableView::New(items.size(), 1);
57-
// content.SetCellPadding(Dali::Size(10.0f, 0));
5857
content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT,
5958
Dali::Dimension::ALL_DIMENSIONS);
6059
content.SetProperty(Dali::Actor::Property::PADDING,

flutter/shell/platform/tizen/tizen_autofill.cc

+29-24
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,24 @@ void TizenAutofill::InitailizeAutofill() {
2424

2525
int ret = autofill_connect(
2626
autofill_,
27-
[](autofill_h ah, autofill_connection_status_e status, void* user_data) {
28-
},
29-
NULL);
27+
[](autofill_h autofill, autofill_connection_status_e status,
28+
void* user_data) {},
29+
nullptr);
3030
if (ret != AUTOFILL_ERROR_NONE) {
31-
FT_LOG(Error) << __FUNCTION__ << "connect_autofill_daemon error";
31+
FT_LOG(Error) << "connect_autofill_daemon error";
3232
}
3333

3434
autofill_fill_response_set_received_cb(
3535
autofill_,
36-
[](autofill_h ah, autofill_fill_response_h fill_response, void* data) {
36+
[](autofill_h autofill, autofill_fill_response_h fill_response,
37+
void* data) {
3738
int count = 0;
3839
autofill_fill_response_get_group_count(fill_response, &count);
3940
autofill_fill_response_foreach_group(
4041
fill_response,
41-
[](autofill_fill_response_group_h group_h, void* user_data) {
42+
[](autofill_fill_response_group_h group, void* user_data) {
4243
autofill_fill_response_group_foreach_item(
43-
group_h,
44+
group,
4445
[](autofill_fill_response_item_h item, void* user_data) {
4546
char* id = nullptr;
4647
char* value = nullptr;
@@ -74,11 +75,11 @@ void TizenAutofill::InitailizeAutofill() {
7475

7576
return true;
7677
},
77-
group_h);
78+
group);
7879
return true;
7980
},
8081
&count);
81-
TizenAutofill::GetInstance().CallPopupCallback();
82+
TizenAutofill::GetInstance().OnPopup();
8283
},
8384
nullptr);
8485

@@ -95,10 +96,14 @@ void TizenAutofill::RequestAutofill(std::vector<std::string> hints,
9596
autofill_view_info_set_app_id(view_info, app_id);
9697
autofill_view_info_set_view_id(view_info, id.c_str());
9798

99+
if (app_id) {
100+
free(app_id);
101+
}
102+
98103
for (auto hint : hints) {
99104
std::optional<autofill_hint_e> autofill_hint = ConvertAutofillHint(hint);
100105
if (autofill_hint.has_value()) {
101-
autofill_item_h item;
106+
autofill_item_h item = nullptr;
102107
autofill_item_create(&item);
103108
autofill_item_set_autofill_hint(item, autofill_hint.value());
104109
autofill_item_set_id(item, id.c_str());
@@ -119,36 +124,36 @@ void TizenAutofill::RequestAutofill(std::vector<std::string> hints,
119124

120125
void TizenAutofill::RegisterAutofillItem(std::string view_id,
121126
AutofillItem item) {
122-
autofill_save_item_h si_h;
127+
autofill_save_item_h save_item = nullptr;
123128

124-
autofill_save_item_create(&si_h);
125-
autofill_save_item_set_autofill_hint(si_h, item.hint_);
126-
autofill_save_item_set_id(si_h, item.id_.c_str());
127-
autofill_save_item_set_label(si_h, item.label_.c_str());
128-
autofill_save_item_set_sensitive_data(si_h, item.sensitive_data_);
129-
autofill_save_item_set_value(si_h, item.value_.c_str());
129+
autofill_save_item_create(&save_item);
130+
autofill_save_item_set_autofill_hint(save_item, item.hint_);
131+
autofill_save_item_set_id(save_item, item.id_.c_str());
132+
autofill_save_item_set_label(save_item, item.label_.c_str());
133+
autofill_save_item_set_sensitive_data(save_item, item.sensitive_data_);
134+
autofill_save_item_set_value(save_item, item.value_.c_str());
130135

131136
char* app_id;
132137
app_get_id(&app_id);
133138

134-
autofill_save_view_info_h svi_h;
139+
autofill_save_view_info_h save_view_info = nullptr;
135140

136-
autofill_save_view_info_create(&svi_h);
137-
autofill_save_view_info_set_app_id(svi_h, app_id);
138-
autofill_save_view_info_set_view_id(svi_h, view_id.c_str());
141+
autofill_save_view_info_create(&save_view_info);
142+
autofill_save_view_info_set_app_id(save_view_info, app_id);
143+
autofill_save_view_info_set_view_id(save_view_info, view_id.c_str());
139144

140-
autofill_save_view_info_add_item(svi_h, si_h);
145+
autofill_save_view_info_add_item(save_view_info, save_item);
141146

142147
if (app_id) {
143148
free(app_id);
144149
}
145150

146-
int ret = autofill_commit(autofill_, svi_h);
151+
int ret = autofill_commit(autofill_, save_view_info);
147152
if (ret != AUTOFILL_ERROR_NONE) {
148153
FT_LOG(Error) << "autofill_commit error";
149154
}
150155

151-
autofill_save_view_info_destroy(svi_h);
156+
autofill_save_view_info_destroy(save_view_info);
152157
}
153158

154159
std::optional<autofill_hint_e> TizenAutofill::ConvertAutofillHint(

flutter/shell/platform/tizen/tizen_autofill.h

+8-10
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,16 @@ class TizenAutofill {
3636
response_items_.push_back(move(item));
3737
}
3838

39-
void SetPopupCallback(std::function<void()> callback) {
40-
popup_callback_ = callback;
41-
}
39+
void SetOnPopup(std::function<void()> on_popup) { on_popup_ = on_popup; }
4240

43-
void SetCommitCallback(std::function<void(std::string)> callback) {
44-
commit_callback_ = callback;
41+
void SetOnCommit(std::function<void(std::string)> on_commit) {
42+
on_commit_ = on_commit;
4543
}
4644

47-
void OnCommit(std::string str) { commit_callback_(str); }
48-
49-
void CallPopupCallback() { popup_callback_(); }
45+
void OnCommit(std::string str) { on_commit_(str); }
5046

47+
void OnPopup() { on_popup_(); }
48+
#
5149
const std::vector<std::unique_ptr<AutofillItem>>& GetAutofillItems() {
5250
return response_items_;
5351
}
@@ -66,9 +64,9 @@ class TizenAutofill {
6664

6765
std::vector<std::unique_ptr<AutofillItem>> response_items_;
6866

69-
std::function<void()> popup_callback_;
67+
std::function<void()> on_popup_;
7068

71-
std::function<void(std::string)> commit_callback_;
69+
std::function<void(std::string)> on_commit_;
7270
};
7371

7472
#endif

flutter/shell/platform/tizen/tizen_view_elementary.cc

+16-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <string>
99

1010
#include "flutter/shell/platform/tizen/logger.h"
11-
#ifdef AUTOFILL_SUPPORT
11+
#ifndef WEARABLE_PROFILE
1212
#include "flutter/shell/platform/tizen/tizen_autofill.h"
1313
#endif
1414
#include "flutter/shell/platform/tizen/tizen_view_event_handler_delegate.h"
@@ -97,6 +97,9 @@ bool TizenViewElementary::CreateView() {
9797
evas_object_image_size_set(image_, initial_width_, initial_height_);
9898
evas_object_image_alpha_set(image_, EINA_TRUE);
9999
elm_object_part_content_set(container_, "overlay", image_);
100+
#ifndef WEARABLE_PROFILE
101+
ctxpopup_ = elm_ctxpopup_add(container_);
102+
#endif
100103
return true;
101104
}
102105

@@ -286,6 +289,13 @@ void TizenViewElementary::RegisterEventHandlers() {
286289
};
287290
evas_object_smart_callback_add(container_, "focused", focused_callback_,
288291
this);
292+
293+
#ifndef WEARABLE_PROFILE
294+
popup_hide_callback_ = [](void* data, Evas* e, Evas_Object* obj,
295+
void* event_info) { elm_ctxpopup_clear(obj); };
296+
evas_object_event_callback_add(ctxpopup_, EVAS_CALLBACK_HIDE,
297+
popup_hide_callback_, nullptr);
298+
#endif
289299
}
290300

291301
void TizenViewElementary::UnregisterEventHandlers() {
@@ -309,6 +319,10 @@ void TizenViewElementary::UnregisterEventHandlers() {
309319
evas_object_event_callback_del(container_, EVAS_CALLBACK_KEY_UP,
310320
evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]);
311321
evas_object_smart_callback_del(container_, "focused", focused_callback_);
322+
#ifndef WEARABLE_PROFILE
323+
evas_object_event_callback_del(ctxpopup_, EVAS_CALLBACK_HIDE,
324+
popup_hide_callback_);
325+
#endif
312326
}
313327

314328
TizenGeometry TizenViewElementary::GetGeometry() {
@@ -357,9 +371,7 @@ void TizenViewElementary::PrepareInputMethod() {
357371
[this]() { view_delegate_->OnComposeEnd(); });
358372
input_method_context_->SetOnCommit(
359373
[this](std::string str) { view_delegate_->OnCommit(str); });
360-
#ifdef AUTOFILL_SUPPORT
361-
ctxpopup_ = elm_ctxpopup_add(container_);
362-
374+
#ifndef WEARABLE_PROFILE
363375
input_method_context_->SetOnPopupAutofillContext([this]() {
364376
if (TizenAutofill::GetInstance().GetAutofillItems().size() > 0) {
365377
for (auto& item : TizenAutofill::GetInstance().GetAutofillItems()) {
@@ -377,13 +389,6 @@ void TizenViewElementary::PrepareInputMethod() {
377389
evas_object_move(ctxpopup_, 0, 0);
378390
evas_object_show(ctxpopup_);
379391
});
380-
381-
evas_object_event_callback_add(
382-
ctxpopup_, EVAS_CALLBACK_HIDE,
383-
[](void* data, Evas* e, Evas_Object* obj, void* event_info) {
384-
elm_ctxpopup_clear(obj);
385-
},
386-
nullptr);
387392
#endif
388393
}
389394

flutter/shell/platform/tizen/tizen_view_elementary.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ class TizenViewElementary : public TizenView {
5151
Evas_Object* parent_ = nullptr;
5252
Evas_Object* container_ = nullptr;
5353
Evas_Object* image_ = nullptr;
54-
#ifdef AUTOFILL_SUPPORT
54+
#ifndef WEARABLE_PROFILE
5555
Evas_Object* ctxpopup_ = nullptr;
56+
Evas_Object_Event_Cb popup_hide_callback_ = nullptr;
5657
#endif
5758

5859
std::unordered_map<Evas_Callback_Type, Evas_Object_Event_Cb>

flutter/shell/platform/tizen/tizen_window_elementary.cc

+20-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <memory>
1212

1313
#include "flutter/shell/platform/tizen/logger.h"
14-
#ifdef AUTOFILL_SUPPORT
14+
#ifndef WEARABLE_PROFILE
1515
#include "flutter/shell/platform/tizen/tizen_autofill.h"
1616
#endif
1717
#include "flutter/shell/platform/tizen/tizen_view_event_handler_delegate.h"
@@ -113,6 +113,10 @@ bool TizenWindowElementary::CreateWindow() {
113113
initial_geometry_.height);
114114
evas_object_raise(elm_win_);
115115

116+
#ifndef WEARABLE_PROFILE
117+
ctxpopup_ = elm_ctxpopup_add(elm_win_);
118+
119+
#endif
116120
image_ = evas_object_image_filled_add(evas_object_evas_get(elm_win_));
117121
evas_object_resize(image_, initial_geometry_.width, initial_geometry_.height);
118122
evas_object_move(image_, initial_geometry_.left, initial_geometry_.top);
@@ -135,6 +139,9 @@ bool TizenWindowElementary::CreateWindow() {
135139
void TizenWindowElementary::DestroyWindow() {
136140
evas_object_del(elm_win_);
137141
evas_object_del(image_);
142+
#ifndef WEARABLE_PROFILE
143+
evas_object_del(ctxpopup_);
144+
#endif
138145
}
139146

140147
void TizenWindowElementary::SetWindowOptions() {
@@ -326,6 +333,13 @@ void TizenWindowElementary::RegisterEventHandlers() {
326333
evas_object_event_callback_add(elm_win_, EVAS_CALLBACK_KEY_UP,
327334
evas_object_callbacks_[EVAS_CALLBACK_KEY_UP],
328335
this);
336+
337+
#ifndef WEARABLE_PROFILE
338+
popup_hide_callback_ = [](void* data, Evas* e, Evas_Object* obj,
339+
void* event_info) { elm_ctxpopup_clear(obj); };
340+
evas_object_event_callback_add(ctxpopup_, EVAS_CALLBACK_HIDE,
341+
popup_hide_callback_, nullptr);
342+
#endif
329343
}
330344

331345
void TizenWindowElementary::UnregisterEventHandlers() {
@@ -350,6 +364,10 @@ void TizenWindowElementary::UnregisterEventHandlers() {
350364
evas_object_callbacks_[EVAS_CALLBACK_KEY_DOWN]);
351365
evas_object_event_callback_del(elm_win_, EVAS_CALLBACK_KEY_UP,
352366
evas_object_callbacks_[EVAS_CALLBACK_KEY_UP]);
367+
#ifndef WEARABLE_PROFILE
368+
evas_object_event_callback_del(ctxpopup_, EVAS_CALLBACK_HIDE,
369+
popup_hide_callback_);
370+
#endif
353371
}
354372

355373
TizenGeometry TizenWindowElementary::GetGeometry() {
@@ -432,9 +450,7 @@ void TizenWindowElementary::PrepareInputMethod() {
432450
input_method_context_->SetOnCommit(
433451
[this](std::string str) { view_delegate_->OnCommit(str); });
434452

435-
#ifdef AUTOFILL_SUPPORT
436-
ctxpopup_ = elm_ctxpopup_add(elm_win_);
437-
453+
#ifndef WEARABLE_PROFILE
438454
input_method_context_->SetOnPopupAutofillContext([this]() {
439455
if (TizenAutofill::GetInstance().GetAutofillItems().size() > 0) {
440456
for (auto& item : TizenAutofill::GetInstance().GetAutofillItems()) {
@@ -452,13 +468,6 @@ void TizenWindowElementary::PrepareInputMethod() {
452468
evas_object_move(ctxpopup_, initial_geometry_.left, initial_geometry_.top);
453469
evas_object_show(ctxpopup_);
454470
});
455-
456-
evas_object_event_callback_add(
457-
ctxpopup_, EVAS_CALLBACK_HIDE,
458-
[](void* data, Evas* e, Evas_Object* obj, void* event_info) {
459-
elm_ctxpopup_clear(obj);
460-
},
461-
nullptr);
462471
#endif
463472
}
464473

flutter/shell/platform/tizen/tizen_window_elementary.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ class TizenWindowElementary : public TizenWindow {
7272

7373
Evas_Object* elm_win_ = nullptr;
7474
Evas_Object* image_ = nullptr;
75-
#ifdef AUTOFILL_SUPPORT
75+
#ifndef WEARABLE_PROFILE
7676
Evas_Object* ctxpopup_ = nullptr;
77+
Evas_Object_Event_Cb popup_hide_callback_ = nullptr;
7778
#endif
7879

7980
Evas_Smart_Cb rotation_changed_callback_ = nullptr;

0 commit comments

Comments
 (0)