Skip to content

Commit 8e382e3

Browse files
committed
Apply reviewer's comment.
1 parent f37e3fd commit 8e382e3

14 files changed

+166
-127
lines changed

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

-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ TextInputChannel::TextInputChannel(
7373

7474
#ifndef WEARABLE_PROFILE
7575
TizenAutofill& autofill = TizenAutofill::GetInstance();
76-
autofill.SetOnPopup(
77-
[this]() { input_method_context_->PopupAutofillItems(); });
7876
autofill.SetOnCommit([this](std::string value) { OnCommit(value); });
7977
#endif
8078
}

flutter/shell/platform/tizen/nui_autofill_popup.cc

+33-27
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
#include "flutter/shell/platform/tizen/nui_autofill_popup.h"
66

77
#include <dali-toolkit/dali-toolkit.h>
8-
#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
98
#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
109

11-
#include "flutter/shell/platform/tizen/tizen_autofill.h"
12-
1310
namespace flutter {
1411

1512
bool NuiAutofillPopup::Touched(Dali::Actor actor,
@@ -35,7 +32,32 @@ void NuiAutofillPopup::OutsideTouched() {
3532
popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN);
3633
}
3734

38-
void NuiAutofillPopup::Prepare() {
35+
Dali::Toolkit::TableView NuiAutofillPopup::MakeContent(
36+
const std::vector<std::unique_ptr<AutofillItem>>& items) {
37+
Dali::Toolkit::TableView content =
38+
Dali::Toolkit::TableView::New(items.size(), 1);
39+
content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT,
40+
Dali::Dimension::ALL_DIMENSIONS);
41+
content.SetProperty(Dali::Actor::Property::PADDING,
42+
Dali::Vector4(10, 10, 0, 0));
43+
for (uint32_t i = 0; i < items.size(); ++i) {
44+
Dali::Toolkit::TextLabel label =
45+
Dali::Toolkit::TextLabel::New(items[i]->label);
46+
label.SetProperty(Dali::Actor::Property::NAME, items[i]->value);
47+
label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY,
48+
Dali::Dimension::HEIGHT);
49+
label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR,
50+
Dali::Color::WHITE_SMOKE);
51+
label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f);
52+
label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched);
53+
content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0));
54+
content.SetFitHeight(i);
55+
}
56+
return content;
57+
}
58+
59+
void NuiAutofillPopup::Prepare(
60+
const std::vector<std::unique_ptr<AutofillItem>>& items) {
3961
popup_ = Dali::Toolkit::Popup::New();
4062
popup_.SetProperty(Dali::Actor::Property::NAME, "popup");
4163
popup_.SetProperty(Dali::Actor::Property::PARENT_ORIGIN,
@@ -49,6 +71,11 @@ void NuiAutofillPopup::Prepare() {
4971
popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::Hidden);
5072
popup_.SetProperty(Dali::Toolkit::Popup::Property::BACKING_ENABLED, false);
5173
popup_.SetProperty(Dali::Toolkit::Popup::Property::AUTO_HIDE_DELAY, 2500);
74+
popup_.SetProperty(Dali::Actor::Property::SIZE,
75+
Dali::Vector2(140.0f, 35.0f * items.size()));
76+
77+
Dali::Toolkit::TableView content = MakeContent(items);
78+
popup_.SetContent(content);
5279
}
5380

5481
void NuiAutofillPopup::Show(Dali::Actor* actor) {
@@ -58,29 +85,8 @@ void NuiAutofillPopup::Show(Dali::Actor* actor) {
5885
return;
5986
}
6087

61-
Prepare();
62-
Dali::Toolkit::TableView content =
63-
Dali::Toolkit::TableView::New(items.size(), 1);
64-
content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT,
65-
Dali::Dimension::ALL_DIMENSIONS);
66-
content.SetProperty(Dali::Actor::Property::PADDING,
67-
Dali::Vector4(10, 10, 0, 0));
68-
for (uint32_t i = 0; i < items.size(); ++i) {
69-
Dali::Toolkit::TextLabel label =
70-
Dali::Toolkit::TextLabel::New(items[i]->label_);
71-
label.SetProperty(Dali::Actor::Property::NAME, items[i]->value_);
72-
label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY,
73-
Dali::Dimension::HEIGHT);
74-
label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR,
75-
Dali::Color::WHITE_SMOKE);
76-
label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f);
77-
label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched);
78-
content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0));
79-
content.SetFitHeight(i);
80-
}
81-
popup_.SetProperty(Dali::Actor::Property::SIZE,
82-
Dali::Vector2(140.0f, 35.0f * items.size()));
83-
popup_.SetContent(content);
88+
Prepare(items);
89+
8490
popup_.SetDisplayState(Dali::Toolkit::Popup::SHOWN);
8591
actor->Add(popup_);
8692
}

flutter/shell/platform/tizen/nui_autofill_popup.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,38 @@
66
#define EMBEDDER_NUI_AUTOFILL_POPUP_H_
77

88
#include <dali-toolkit/devel-api/controls/popup/popup.h>
9+
#include <dali-toolkit/devel-api/controls/table-view/table-view.h>
910

1011
#include <functional>
1112

13+
#include "flutter/shell/platform/tizen/tizen_autofill.h"
14+
15+
using OnCommit = std::function<void(const std::string& str)>;
16+
1217
namespace flutter {
1318

1419
class NuiAutofillPopup : public Dali::ConnectionTracker {
1520
public:
1621
void Show(Dali::Actor* actor);
1722

18-
void SetOnCommit(std::function<void(const std::string&)> callback) {
19-
on_commit_ = callback;
20-
}
23+
void SetOnCommit(OnCommit callback) { on_commit_ = callback; }
2124

2225
private:
23-
void Prepare();
26+
void Prepare(const std::vector<std::unique_ptr<AutofillItem>>& items);
2427

2528
void Hidden();
2629

2730
void OutsideTouched();
2831

2932
bool Touched(Dali::Actor actor, const Dali::TouchEvent& event);
3033

34+
Dali::Toolkit::TableView MakeContent(
35+
const std::vector<std::unique_ptr<AutofillItem>>& items);
36+
3137
Dali::Toolkit::Popup popup_;
32-
std::function<void(const std::string&)> on_commit_;
38+
OnCommit on_commit_;
3339
};
3440

3541
} // namespace flutter
3642

37-
#endif
43+
#endif // EMBEDDER_NUI_AUTOFILL_POPUP_H_

flutter/shell/platform/tizen/tizen_autofill.cc

+29-23
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ std::optional<autofill_hint_e> ConvertAutofillHint(std::string hint) {
4545
return std::nullopt;
4646
}
4747

48-
bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) {
48+
bool StoreFillResponseItem(autofill_fill_response_item_h item,
49+
void* user_data) {
4950
char* id = nullptr;
5051
char* value = nullptr;
5152
char* label = nullptr;
@@ -55,12 +56,12 @@ bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) {
5556
autofill_fill_response_item_get_value(item, &value);
5657
std::unique_ptr<AutofillItem> response_item =
5758
std::make_unique<AutofillItem>();
58-
response_item->id_ = std::string(id);
59-
response_item->value_ = std::string(value);
60-
response_item->label_ = std::string(label);
59+
response_item->id = std::string(id);
60+
response_item->value = std::string(value);
61+
response_item->label = std::string(label);
6162

62-
TizenAutofill* tizen_autofill = static_cast<TizenAutofill*>(data);
63-
tizen_autofill->StoreResponseItem(move(response_item));
63+
TizenAutofill* self = static_cast<TizenAutofill*>(user_data);
64+
self->StoreResponseItem(std::move(response_item));
6465
if (id) {
6566
free(id);
6667
}
@@ -75,17 +76,19 @@ bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) {
7576
return true;
7677
}
7778

78-
bool StoreForeachItem(autofill_fill_response_group_h group, void* data) {
79-
autofill_fill_response_group_foreach_item(group, StoreFillResponseItem, data);
79+
bool StoreForeachItem(autofill_fill_response_group_h group, void* user_data) {
80+
autofill_fill_response_group_foreach_item(group, StoreFillResponseItem,
81+
user_data);
8082
return true;
8183
};
8284

8385
void ResponseReceived(autofill_h autofill,
8486
autofill_fill_response_h fill_response,
85-
void* data) {
86-
autofill_fill_response_foreach_group(fill_response, StoreForeachItem, data);
87-
TizenAutofill* tizen_autofill = static_cast<TizenAutofill*>(data);
88-
tizen_autofill->OnPopup();
87+
void* user_data) {
88+
autofill_fill_response_foreach_group(fill_response, StoreForeachItem,
89+
user_data);
90+
TizenAutofill* self = static_cast<TizenAutofill*>(user_data);
91+
self->OnPopup();
8992
};
9093

9194
autofill_save_item_h CreateSaveItem(const AutofillItem& item) {
@@ -96,11 +99,11 @@ autofill_save_item_h CreateSaveItem(const AutofillItem& item) {
9699
return nullptr;
97100
}
98101

99-
autofill_save_item_set_autofill_hint(save_item, item.hint_);
100-
autofill_save_item_set_id(save_item, item.id_.c_str());
101-
autofill_save_item_set_label(save_item, item.label_.c_str());
102-
autofill_save_item_set_sensitive_data(save_item, item.sensitive_data_);
103-
autofill_save_item_set_value(save_item, item.value_.c_str());
102+
autofill_save_item_set_autofill_hint(save_item, item.hint);
103+
autofill_save_item_set_id(save_item, item.id.c_str());
104+
autofill_save_item_set_label(save_item, item.label.c_str());
105+
autofill_save_item_set_sensitive_data(save_item, item.sensitive_data);
106+
autofill_save_item_set_value(save_item, item.value.c_str());
104107

105108
return save_item;
106109
}
@@ -132,8 +135,8 @@ autofill_save_view_info_h CreateSaveViewInfo(const std::string& view_id,
132135
return save_view_info;
133136
}
134137

135-
void AddItemsToViewInfo(const autofill_view_info_h& view_info,
136-
const std::string id,
138+
void AddItemsToViewInfo(autofill_view_info_h view_info,
139+
const std::string& id,
137140
const std::vector<std::string>& hints) {
138141
for (auto hint : hints) {
139142
std::optional<autofill_hint_e> autofill_hint = ConvertAutofillHint(hint);
@@ -199,17 +202,20 @@ void TizenAutofill::Initialize() {
199202

200203
ret = autofill_connect(
201204
autofill_,
202-
[](autofill_h autofill, autofill_connection_status_e status, void* data) {
203-
TizenAutofill* tizen_autofill = static_cast<TizenAutofill*>(data);
205+
[](autofill_h autofill, autofill_connection_status_e status,
206+
void* user_data) {
207+
TizenAutofill* self = static_cast<TizenAutofill*>(user_data);
204208
if (status == AUTOFILL_CONNECTION_STATUS_CONNECTED) {
205-
tizen_autofill->SetConnected(true);
209+
self->SetConnected(true);
206210
} else {
207-
tizen_autofill->SetConnected(false);
211+
self->SetConnected(false);
208212
}
209213
},
210214
this);
211215
if (ret != AUTOFILL_ERROR_NONE) {
212216
FT_LOG(Error) << "Failed to connect to the autofill daemon.";
217+
autofill_destroy(autofill_);
218+
autofill_ = nullptr;
213219
return;
214220
}
215221

flutter/shell/platform/tizen/tizen_autofill.h

+11-7
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
namespace flutter {
1717

1818
struct AutofillItem {
19-
autofill_hint_e hint_;
20-
bool sensitive_data_;
21-
std::string label_;
22-
std::string id_;
23-
std::string value_;
19+
autofill_hint_e hint;
20+
bool sensitive_data;
21+
std::string label;
22+
std::string id;
23+
std::string value;
2424
};
2525

2626
class TizenAutofill {
@@ -36,7 +36,7 @@ class TizenAutofill {
3636
void RegisterItem(const std::string& view_id, const AutofillItem& item);
3737

3838
void StoreResponseItem(std::unique_ptr<AutofillItem> item) {
39-
response_items_.push_back(move(item));
39+
response_items_.push_back(std::move(item));
4040
}
4141

4242
void SetConnected(bool connected) { is_connected_ = connected; };
@@ -49,7 +49,11 @@ class TizenAutofill {
4949

5050
void OnCommit(const std::string& str) { on_commit_(str); }
5151

52-
void OnPopup() { on_popup_(); }
52+
void OnPopup() {
53+
if (on_popup_) {
54+
on_popup_();
55+
}
56+
}
5357

5458
const std::vector<std::unique_ptr<AutofillItem>>& GetResponseItems() {
5559
return response_items_;

flutter/shell/platform/tizen/tizen_input_method_context.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ void TizenInputMethodContext::SetInputAction(const std::string& input_action) {
284284
Ecore_IMF_Input_Panel_Return_Key_Type return_key_type =
285285
ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
286286

287-
// Not support : none, previous, continueAction, route, emergencycall, newline
287+
// Not supported : none, previous, continueAction, route, emergencyCall,
288+
// newline
288289
if (input_action == "TextInputAction.unspecified") {
289290
return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT;
290291
} else if (input_action == "TextInputAction.done") {
@@ -423,15 +424,12 @@ void TizenInputMethodContext::SetContextOptions() {
423424
FT_ASSERT(imf_context_);
424425
ecore_imf_context_autocapital_type_set(imf_context_,
425426
ECORE_IMF_AUTOCAPITAL_TYPE_NONE);
426-
ecore_imf_context_prediction_allow_set(imf_context_, EINA_FALSE);
427427
}
428428

429429
void TizenInputMethodContext::SetInputPanelOptions() {
430430
FT_ASSERT(imf_context_);
431431
ecore_imf_context_input_panel_layout_set(imf_context_,
432432
ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL);
433-
ecore_imf_context_input_panel_return_key_type_set(
434-
imf_context_, ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT);
435433
ecore_imf_context_input_panel_language_set(
436434
imf_context_, ECORE_IMF_INPUT_PANEL_LANG_AUTOMATIC);
437435
}

flutter/shell/platform/tizen/tizen_input_method_context.h

+3-12
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717

1818
namespace flutter {
1919

20-
using OnCommit = std::function<void(std::string str)>;
21-
using OnPreeditChanged = std::function<void(std::string str, int cursor_pos)>;
20+
using OnCommit = std::function<void(const std::string& str)>;
21+
using OnPreeditChanged =
22+
std::function<void(const std::string& str, int cursor_pos)>;
2223
using OnPreeditStart = std::function<void()>;
2324
using OnPreeditEnd = std::function<void()>;
2425
using OnPopupAutofillContext = std::function<void()>;
@@ -82,16 +83,6 @@ class TizenInputMethodContext {
8283

8384
void SetOnPreeditEnd(OnPreeditEnd callback) { on_preedit_end_ = callback; }
8485

85-
void SetOnPopupAutofillContext(OnPopupAutofillContext callback) {
86-
on_popup_autofill_context_ = callback;
87-
}
88-
89-
void PopupAutofillItems() {
90-
if (on_popup_autofill_context_) {
91-
on_popup_autofill_context_();
92-
}
93-
}
94-
9586
private:
9687
void RegisterEventCallbacks();
9788
void UnregisterEventCallbacks();

0 commit comments

Comments
 (0)