diff --git a/flutter/shell/platform/tizen/channels/text_input_channel.cc b/flutter/shell/platform/tizen/channels/text_input_channel.cc index 1b56107..7153b10 100644 --- a/flutter/shell/platform/tizen/channels/text_input_channel.cc +++ b/flutter/shell/platform/tizen/channels/text_input_channel.cc @@ -73,8 +73,6 @@ TextInputChannel::TextInputChannel( #ifndef WEARABLE_PROFILE TizenAutofill& autofill = TizenAutofill::GetInstance(); - autofill.SetOnPopup( - [this]() { input_method_context_->PopupAutofillItems(); }); autofill.SetOnCommit([this](std::string value) { OnCommit(value); }); #endif } diff --git a/flutter/shell/platform/tizen/nui_autofill_popup.cc b/flutter/shell/platform/tizen/nui_autofill_popup.cc index d723900..268be41 100644 --- a/flutter/shell/platform/tizen/nui_autofill_popup.cc +++ b/flutter/shell/platform/tizen/nui_autofill_popup.cc @@ -5,11 +5,8 @@ #include "flutter/shell/platform/tizen/nui_autofill_popup.h" #include -#include #include -#include "flutter/shell/platform/tizen/tizen_autofill.h" - namespace flutter { bool NuiAutofillPopup::Touched(Dali::Actor actor, @@ -35,7 +32,32 @@ void NuiAutofillPopup::OutsideTouched() { popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); } -void NuiAutofillPopup::Prepare() { +Dali::Toolkit::TableView NuiAutofillPopup::MakeContent( + const std::vector>& items) { + Dali::Toolkit::TableView content = + Dali::Toolkit::TableView::New(items.size(), 1); + content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, + Dali::Dimension::ALL_DIMENSIONS); + content.SetProperty(Dali::Actor::Property::PADDING, + Dali::Vector4(10, 10, 0, 0)); + for (uint32_t i = 0; i < items.size(); ++i) { + Dali::Toolkit::TextLabel label = + Dali::Toolkit::TextLabel::New(items[i]->label); + label.SetProperty(Dali::Actor::Property::NAME, items[i]->value); + label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY, + Dali::Dimension::HEIGHT); + label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR, + Dali::Color::WHITE_SMOKE); + label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f); + label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched); + content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0)); + content.SetFitHeight(i); + } + return content; +} + +void NuiAutofillPopup::Prepare( + const std::vector>& items) { popup_ = Dali::Toolkit::Popup::New(); popup_.SetProperty(Dali::Actor::Property::NAME, "popup"); popup_.SetProperty(Dali::Actor::Property::PARENT_ORIGIN, @@ -49,6 +71,11 @@ void NuiAutofillPopup::Prepare() { popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::Hidden); popup_.SetProperty(Dali::Toolkit::Popup::Property::BACKING_ENABLED, false); popup_.SetProperty(Dali::Toolkit::Popup::Property::AUTO_HIDE_DELAY, 2500); + popup_.SetProperty(Dali::Actor::Property::SIZE, + Dali::Vector2(140.0f, 35.0f * items.size())); + + Dali::Toolkit::TableView content = MakeContent(items); + popup_.SetContent(content); } void NuiAutofillPopup::Show(Dali::Actor* actor) { @@ -58,29 +85,8 @@ void NuiAutofillPopup::Show(Dali::Actor* actor) { return; } - Prepare(); - Dali::Toolkit::TableView content = - Dali::Toolkit::TableView::New(items.size(), 1); - content.SetResizePolicy(Dali::ResizePolicy::FILL_TO_PARENT, - Dali::Dimension::ALL_DIMENSIONS); - content.SetProperty(Dali::Actor::Property::PADDING, - Dali::Vector4(10, 10, 0, 0)); - for (uint32_t i = 0; i < items.size(); ++i) { - Dali::Toolkit::TextLabel label = - Dali::Toolkit::TextLabel::New(items[i]->label_); - label.SetProperty(Dali::Actor::Property::NAME, items[i]->value_); - label.SetResizePolicy(Dali::ResizePolicy::DIMENSION_DEPENDENCY, - Dali::Dimension::HEIGHT); - label.SetProperty(Dali::Toolkit::TextLabel::Property::TEXT_COLOR, - Dali::Color::WHITE_SMOKE); - label.SetProperty(Dali::Toolkit::TextLabel::Property::POINT_SIZE, 7.0f); - label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched); - content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0)); - content.SetFitHeight(i); - } - popup_.SetProperty(Dali::Actor::Property::SIZE, - Dali::Vector2(140.0f, 35.0f * items.size())); - popup_.SetContent(content); + Prepare(items); + popup_.SetDisplayState(Dali::Toolkit::Popup::SHOWN); actor->Add(popup_); } diff --git a/flutter/shell/platform/tizen/nui_autofill_popup.h b/flutter/shell/platform/tizen/nui_autofill_popup.h index 1295d42..37a6531 100644 --- a/flutter/shell/platform/tizen/nui_autofill_popup.h +++ b/flutter/shell/platform/tizen/nui_autofill_popup.h @@ -6,21 +6,24 @@ #define EMBEDDER_NUI_AUTOFILL_POPUP_H_ #include +#include #include +#include "flutter/shell/platform/tizen/tizen_autofill.h" + +using OnCommit = std::function; + namespace flutter { class NuiAutofillPopup : public Dali::ConnectionTracker { public: void Show(Dali::Actor* actor); - void SetOnCommit(std::function callback) { - on_commit_ = callback; - } + void SetOnCommit(OnCommit callback) { on_commit_ = callback; } private: - void Prepare(); + void Prepare(const std::vector>& items); void Hidden(); @@ -28,10 +31,13 @@ class NuiAutofillPopup : public Dali::ConnectionTracker { bool Touched(Dali::Actor actor, const Dali::TouchEvent& event); + Dali::Toolkit::TableView MakeContent( + const std::vector>& items); + Dali::Toolkit::Popup popup_; - std::function on_commit_; + OnCommit on_commit_; }; } // namespace flutter -#endif +#endif // EMBEDDER_NUI_AUTOFILL_POPUP_H_ diff --git a/flutter/shell/platform/tizen/tizen_autofill.cc b/flutter/shell/platform/tizen/tizen_autofill.cc index b3e27dd..9443e1c 100644 --- a/flutter/shell/platform/tizen/tizen_autofill.cc +++ b/flutter/shell/platform/tizen/tizen_autofill.cc @@ -45,7 +45,8 @@ std::optional ConvertAutofillHint(std::string hint) { return std::nullopt; } -bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) { +bool StoreFillResponseItem(autofill_fill_response_item_h item, + void* user_data) { char* id = nullptr; char* value = nullptr; char* label = nullptr; @@ -55,12 +56,12 @@ bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) { autofill_fill_response_item_get_value(item, &value); std::unique_ptr response_item = std::make_unique(); - response_item->id_ = std::string(id); - response_item->value_ = std::string(value); - response_item->label_ = std::string(label); + response_item->id = std::string(id); + response_item->value = std::string(value); + response_item->label = std::string(label); - TizenAutofill* tizen_autofill = static_cast(data); - tizen_autofill->StoreResponseItem(move(response_item)); + TizenAutofill* self = static_cast(user_data); + self->StoreResponseItem(std::move(response_item)); if (id) { free(id); } @@ -75,17 +76,19 @@ bool StoreFillResponseItem(autofill_fill_response_item_h item, void* data) { return true; } -bool StoreForeachItem(autofill_fill_response_group_h group, void* data) { - autofill_fill_response_group_foreach_item(group, StoreFillResponseItem, data); +bool StoreForeachItem(autofill_fill_response_group_h group, void* user_data) { + autofill_fill_response_group_foreach_item(group, StoreFillResponseItem, + user_data); return true; }; void ResponseReceived(autofill_h autofill, autofill_fill_response_h fill_response, - void* data) { - autofill_fill_response_foreach_group(fill_response, StoreForeachItem, data); - TizenAutofill* tizen_autofill = static_cast(data); - tizen_autofill->OnPopup(); + void* user_data) { + autofill_fill_response_foreach_group(fill_response, StoreForeachItem, + user_data); + TizenAutofill* self = static_cast(user_data); + self->OnPopup(); }; autofill_save_item_h CreateSaveItem(const AutofillItem& item) { @@ -96,11 +99,11 @@ autofill_save_item_h CreateSaveItem(const AutofillItem& item) { return nullptr; } - autofill_save_item_set_autofill_hint(save_item, item.hint_); - autofill_save_item_set_id(save_item, item.id_.c_str()); - autofill_save_item_set_label(save_item, item.label_.c_str()); - autofill_save_item_set_sensitive_data(save_item, item.sensitive_data_); - autofill_save_item_set_value(save_item, item.value_.c_str()); + autofill_save_item_set_autofill_hint(save_item, item.hint); + autofill_save_item_set_id(save_item, item.id.c_str()); + autofill_save_item_set_label(save_item, item.label.c_str()); + autofill_save_item_set_sensitive_data(save_item, item.sensitive_data); + autofill_save_item_set_value(save_item, item.value.c_str()); return save_item; } @@ -132,8 +135,8 @@ autofill_save_view_info_h CreateSaveViewInfo(const std::string& view_id, return save_view_info; } -void AddItemsToViewInfo(const autofill_view_info_h& view_info, - const std::string id, +void AddItemsToViewInfo(autofill_view_info_h view_info, + const std::string& id, const std::vector& hints) { for (auto hint : hints) { std::optional autofill_hint = ConvertAutofillHint(hint); @@ -199,17 +202,20 @@ void TizenAutofill::Initialize() { ret = autofill_connect( autofill_, - [](autofill_h autofill, autofill_connection_status_e status, void* data) { - TizenAutofill* tizen_autofill = static_cast(data); + [](autofill_h autofill, autofill_connection_status_e status, + void* user_data) { + TizenAutofill* self = static_cast(user_data); if (status == AUTOFILL_CONNECTION_STATUS_CONNECTED) { - tizen_autofill->SetConnected(true); + self->SetConnected(true); } else { - tizen_autofill->SetConnected(false); + self->SetConnected(false); } }, this); if (ret != AUTOFILL_ERROR_NONE) { FT_LOG(Error) << "Failed to connect to the autofill daemon."; + autofill_destroy(autofill_); + autofill_ = nullptr; return; } diff --git a/flutter/shell/platform/tizen/tizen_autofill.h b/flutter/shell/platform/tizen/tizen_autofill.h index 103ed92..718487a 100644 --- a/flutter/shell/platform/tizen/tizen_autofill.h +++ b/flutter/shell/platform/tizen/tizen_autofill.h @@ -16,11 +16,11 @@ namespace flutter { struct AutofillItem { - autofill_hint_e hint_; - bool sensitive_data_; - std::string label_; - std::string id_; - std::string value_; + autofill_hint_e hint; + bool sensitive_data; + std::string label; + std::string id; + std::string value; }; class TizenAutofill { @@ -36,7 +36,7 @@ class TizenAutofill { void RegisterItem(const std::string& view_id, const AutofillItem& item); void StoreResponseItem(std::unique_ptr item) { - response_items_.push_back(move(item)); + response_items_.push_back(std::move(item)); } void SetConnected(bool connected) { is_connected_ = connected; }; @@ -49,7 +49,11 @@ class TizenAutofill { void OnCommit(const std::string& str) { on_commit_(str); } - void OnPopup() { on_popup_(); } + void OnPopup() { + if (on_popup_) { + on_popup_(); + } + } const std::vector>& GetResponseItems() { return response_items_; diff --git a/flutter/shell/platform/tizen/tizen_input_method_context.cc b/flutter/shell/platform/tizen/tizen_input_method_context.cc index ff01eaf..ba4aea6 100644 --- a/flutter/shell/platform/tizen/tizen_input_method_context.cc +++ b/flutter/shell/platform/tizen/tizen_input_method_context.cc @@ -284,7 +284,8 @@ void TizenInputMethodContext::SetInputAction(const std::string& input_action) { Ecore_IMF_Input_Panel_Return_Key_Type return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; - // Not support : none, previous, continueAction, route, emergencycall, newline + // Not supported : none, previous, continueAction, route, emergencyCall, + // newline if (input_action == "TextInputAction.unspecified") { return_key_type = ECORE_IMF_INPUT_PANEL_RETURN_KEY_TYPE_DEFAULT; } else if (input_action == "TextInputAction.done") { diff --git a/flutter/shell/platform/tizen/tizen_input_method_context.h b/flutter/shell/platform/tizen/tizen_input_method_context.h index 8fb7ce9..315dfb1 100644 --- a/flutter/shell/platform/tizen/tizen_input_method_context.h +++ b/flutter/shell/platform/tizen/tizen_input_method_context.h @@ -17,8 +17,9 @@ namespace flutter { -using OnCommit = std::function; -using OnPreeditChanged = std::function; +using OnCommit = std::function; +using OnPreeditChanged = + std::function; using OnPreeditStart = std::function; using OnPreeditEnd = std::function; using OnPopupAutofillContext = std::function; @@ -82,16 +83,6 @@ class TizenInputMethodContext { void SetOnPreeditEnd(OnPreeditEnd callback) { on_preedit_end_ = callback; } - void SetOnPopupAutofillContext(OnPopupAutofillContext callback) { - on_popup_autofill_context_ = callback; - } - - void PopupAutofillItems() { - if (on_popup_autofill_context_) { - on_popup_autofill_context_(); - } - } - private: void RegisterEventCallbacks(); void UnregisterEventCallbacks(); diff --git a/flutter/shell/platform/tizen/tizen_view_elementary.cc b/flutter/shell/platform/tizen/tizen_view_elementary.cc index c3366fb..677e029 100644 --- a/flutter/shell/platform/tizen/tizen_view_elementary.cc +++ b/flutter/shell/platform/tizen/tizen_view_elementary.cc @@ -55,6 +55,9 @@ TizenViewElementary::TizenViewElementary(int32_t width, } RegisterEventHandlers(); +#ifndef WEARABLE_PROFILE + PrepareAutofill(); +#endif PrepareInputMethod(); Show(); } @@ -97,6 +100,7 @@ bool TizenViewElementary::CreateView() { evas_object_image_size_set(image_, initial_width_, initial_height_); evas_object_image_alpha_set(image_, EINA_TRUE); elm_object_part_content_set(container_, "overlay", image_); + #ifndef WEARABLE_PROFILE ctxpopup_ = elm_ctxpopup_add(container_); #endif @@ -360,30 +364,19 @@ void TizenViewElementary::Show() { evas_object_show(image_); } -void TizenViewElementary::PrepareInputMethod() { - input_method_context_ = - std::make_unique(GetWindowId()); - - // Set input method callbacks. - input_method_context_->SetOnPreeditStart( - [this]() { view_delegate_->OnComposeBegin(); }); - input_method_context_->SetOnPreeditChanged( - [this](std::string str, int cursor_pos) { - view_delegate_->OnComposeChange(str, cursor_pos); - }); - input_method_context_->SetOnPreeditEnd( - [this]() { view_delegate_->OnComposeEnd(); }); - input_method_context_->SetOnCommit( - [this](std::string str) { view_delegate_->OnCommit(str); }); #ifndef WEARABLE_PROFILE - input_method_context_->SetOnPopupAutofillContext([this]() { +void TizenViewElementary::PrepareAutofill() { + TizenAutofill& autofill = TizenAutofill::GetInstance(); + autofill.SetOnPopup([this]() { if (!TizenAutofill::GetInstance().GetResponseItems().empty()) { - for (auto& item : TizenAutofill::GetInstance().GetResponseItems()) { + const std::vector>& items = + TizenAutofill::GetInstance().GetResponseItems(); + for (const auto& item : items) { elm_ctxpopup_item_append( - ctxpopup_, item->label_.c_str(), nullptr, + ctxpopup_, item->label.c_str(), nullptr, [](void* data, Evas_Object* obj, void* event_info) { AutofillItem* item = static_cast(data); - TizenAutofill::GetInstance().OnCommit(item->value_); + TizenAutofill::GetInstance().OnCommit(item->value); evas_object_hide(obj); }, item.get()); @@ -393,7 +386,24 @@ void TizenViewElementary::PrepareInputMethod() { evas_object_move(ctxpopup_, 0, 0); evas_object_show(ctxpopup_); }); +} #endif + +void TizenViewElementary::PrepareInputMethod() { + input_method_context_ = + std::make_unique(GetWindowId()); + + // Set input method callbacks. + input_method_context_->SetOnPreeditStart( + [this]() { view_delegate_->OnComposeBegin(); }); + input_method_context_->SetOnPreeditChanged( + [this](std::string str, int cursor_pos) { + view_delegate_->OnComposeChange(str, cursor_pos); + }); + input_method_context_->SetOnPreeditEnd( + [this]() { view_delegate_->OnComposeEnd(); }); + input_method_context_->SetOnCommit( + [this](std::string str) { view_delegate_->OnCommit(str); }); } } // namespace flutter diff --git a/flutter/shell/platform/tizen/tizen_view_elementary.h b/flutter/shell/platform/tizen/tizen_view_elementary.h index dca149d..7a761ab 100644 --- a/flutter/shell/platform/tizen/tizen_view_elementary.h +++ b/flutter/shell/platform/tizen/tizen_view_elementary.h @@ -46,6 +46,10 @@ class TizenViewElementary : public TizenView { void UnregisterEventHandlers(); +#ifndef WEARABLE_PROFILE + void PrepareAutofill(); +#endif + void PrepareInputMethod(); Evas_Object* parent_ = nullptr; diff --git a/flutter/shell/platform/tizen/tizen_view_nui.cc b/flutter/shell/platform/tizen/tizen_view_nui.cc index a0ff223..65e87cb 100644 --- a/flutter/shell/platform/tizen/tizen_view_nui.cc +++ b/flutter/shell/platform/tizen/tizen_view_nui.cc @@ -23,6 +23,7 @@ TizenViewNui::TizenViewNui(int32_t width, native_image_queue_(native_image_queue), default_window_id_(default_window_id) { RegisterEventHandlers(); + PrepareAutofill(); PrepareInputMethod(); Show(); } @@ -97,6 +98,14 @@ void TizenViewNui::OnKey(const char* device_name, } } +void TizenViewNui::PrepareAutofill() { + TizenAutofill& autofill = TizenAutofill::GetInstance(); + autofill.SetOnPopup([this]() { autofill_.Show(image_view_); }); + + autofill_.SetOnCommit( + [this](std::string str) { view_delegate_->OnCommit(str); }); +} + void TizenViewNui::PrepareInputMethod() { input_method_context_ = std::make_unique(GetWindowId()); @@ -112,12 +121,6 @@ void TizenViewNui::PrepareInputMethod() { [this]() { view_delegate_->OnComposeEnd(); }); input_method_context_->SetOnCommit( [this](std::string str) { view_delegate_->OnCommit(str); }); - - input_method_context_->SetOnPopupAutofillContext( - [this]() { autofill_.Show(image_view_); }); - - autofill_.SetOnCommit( - [this](std::string str) { view_delegate_->OnCommit(str); }); } void TizenViewNui::RenderOnce() { diff --git a/flutter/shell/platform/tizen/tizen_view_nui.h b/flutter/shell/platform/tizen/tizen_view_nui.h index fef63be..81b73be 100644 --- a/flutter/shell/platform/tizen/tizen_view_nui.h +++ b/flutter/shell/platform/tizen/tizen_view_nui.h @@ -59,6 +59,8 @@ class TizenViewNui : public TizenView { void UnregisterEventHandlers(); + void PrepareAutofill(); + void PrepareInputMethod(); void RenderOnce(); diff --git a/flutter/shell/platform/tizen/tizen_window_elementary.cc b/flutter/shell/platform/tizen/tizen_window_elementary.cc index c2caaa6..5a2eae5 100644 --- a/flutter/shell/platform/tizen/tizen_window_elementary.cc +++ b/flutter/shell/platform/tizen/tizen_window_elementary.cc @@ -61,6 +61,9 @@ TizenWindowElementary::TizenWindowElementary( SetWindowOptions(); RegisterEventHandlers(); +#ifndef WEARABLE_PROFILE + PrepareAutofill(); +#endif PrepareInputMethod(); Show(); } @@ -438,31 +441,19 @@ void TizenWindowElementary::Show() { evas_object_show(elm_win_); } -void TizenWindowElementary::PrepareInputMethod() { - input_method_context_ = - std::make_unique(GetWindowId()); - - // Set input method callbacks. - input_method_context_->SetOnPreeditStart( - [this]() { view_delegate_->OnComposeBegin(); }); - input_method_context_->SetOnPreeditChanged( - [this](std::string str, int cursor_pos) { - view_delegate_->OnComposeChange(str, cursor_pos); - }); - input_method_context_->SetOnPreeditEnd( - [this]() { view_delegate_->OnComposeEnd(); }); - input_method_context_->SetOnCommit( - [this](std::string str) { view_delegate_->OnCommit(str); }); - #ifndef WEARABLE_PROFILE - input_method_context_->SetOnPopupAutofillContext([this]() { +void TizenWindowElementary::PrepareAutofill() { + TizenAutofill& autofill = TizenAutofill::GetInstance(); + autofill.SetOnPopup([this]() { if (!TizenAutofill::GetInstance().GetResponseItems().empty()) { - for (auto& item : TizenAutofill::GetInstance().GetResponseItems()) { + const std::vector>& items = + TizenAutofill::GetInstance().GetResponseItems(); + for (const auto& item : items) { elm_ctxpopup_item_append( - ctxpopup_, item->label_.c_str(), nullptr, + ctxpopup_, item->label.c_str(), nullptr, [](void* data, Evas_Object* obj, void* event_info) { AutofillItem* item = static_cast(data); - TizenAutofill::GetInstance().OnCommit(item->value_); + TizenAutofill::GetInstance().OnCommit(item->value); evas_object_hide(obj); }, item.get()); @@ -472,7 +463,24 @@ void TizenWindowElementary::PrepareInputMethod() { evas_object_move(ctxpopup_, initial_geometry_.left, initial_geometry_.top); evas_object_show(ctxpopup_); }); +} #endif + +void TizenWindowElementary::PrepareInputMethod() { + input_method_context_ = + std::make_unique(GetWindowId()); + + // Set input method callbacks. + input_method_context_->SetOnPreeditStart( + [this]() { view_delegate_->OnComposeBegin(); }); + input_method_context_->SetOnPreeditChanged( + [this](std::string str, int cursor_pos) { + view_delegate_->OnComposeChange(str, cursor_pos); + }); + input_method_context_->SetOnPreeditEnd( + [this]() { view_delegate_->OnComposeEnd(); }); + input_method_context_->SetOnCommit( + [this](std::string str) { view_delegate_->OnCommit(str); }); } int32_t TizenWindowElementary::GetExternalOutputId() { diff --git a/flutter/shell/platform/tizen/tizen_window_elementary.h b/flutter/shell/platform/tizen/tizen_window_elementary.h index 78d64f7..989321c 100644 --- a/flutter/shell/platform/tizen/tizen_window_elementary.h +++ b/flutter/shell/platform/tizen/tizen_window_elementary.h @@ -68,6 +68,10 @@ class TizenWindowElementary : public TizenWindow { void UnregisterEventHandlers(); +#ifndef WEARABLE_PROFILE + void PrepareAutofill(); +#endif + void PrepareInputMethod(); Evas_Object* elm_win_ = nullptr; diff --git a/tools/generate_sysroot.py b/tools/generate_sysroot.py index 9b8dbb7..67ae2d9 100755 --- a/tools/generate_sysroot.py +++ b/tools/generate_sysroot.py @@ -159,7 +159,6 @@ def generate_sysroot(sysroot: Path, api_version: float, arch: str, quiet=False): existing_rpms = [f for f in download_path.iterdir() if f.suffix == '.rpm'] packages = base_packages + unified_packages - if api_version >= 6.5: packages += dali_packages