diff --git a/flutter/shell/platform/tizen/channels/text_input_channel.cc b/flutter/shell/platform/tizen/channels/text_input_channel.cc index 84becfc..92a65d7 100644 --- a/flutter/shell/platform/tizen/channels/text_input_channel.cc +++ b/flutter/shell/platform/tizen/channels/text_input_channel.cc @@ -7,7 +7,6 @@ #include "flutter/shell/platform/common/json_method_codec.h" #include "flutter/shell/platform/tizen/flutter_tizen_engine.h" #include "flutter/shell/platform/tizen/logger.h" - #ifndef WEARABLE_PROFILE #include "flutter/shell/platform/tizen/tizen_autofill.h" #endif @@ -27,7 +26,9 @@ constexpr char kMultilineInputType[] = "TextInputType.multiline"; constexpr char kUpdateEditingStateMethod[] = "TextInputClient.updateEditingState"; constexpr char kPerformActionMethod[] = "TextInputClient.performAction"; +#ifndef WEARABLE_PROFILE constexpr char kRequestAutofillMethod[] = "TextInput.requestAutofill"; +#endif constexpr char kSetPlatformViewClient[] = "TextInput.setPlatformViewClient"; constexpr char kTextCapitalization[] = "textCapitalization"; constexpr char kTextEnableSuggestions[] = "enableSuggestions"; @@ -69,11 +70,12 @@ TextInputChannel::TextInputChannel( std::unique_ptr> result) { HandleMethodCall(call, std::move(result)); }); + #ifndef WEARABLE_PROFILE - TizenAutofill& instance = TizenAutofill::GetInstance(); - instance.SetOnPopup( + TizenAutofill& autofill = TizenAutofill::GetInstance(); + autofill.SetOnPopup( [this]() { input_method_context_->PopupAutofillItems(); }); - instance.SetOnCommit([this](std::string value) { OnCommit(value); }); + autofill.SetOnCommit([this](std::string value) { OnCommit(value); }); #endif } @@ -249,9 +251,9 @@ void TextInputChannel::HandleMethodCall( auto hints_iter = autofill_iter->value.FindMember(kHints); if (hints_iter != autofill_iter->value.MemberEnd() && hints_iter->value.IsArray()) { + autofill_hints_.clear(); for (auto hint = hints_iter->value.GetArray().Begin(); hint != hints_iter->value.GetArray().End(); hint++) { - autofill_hints_.clear(); autofill_hints_.push_back(hint->GetString()); } } @@ -319,12 +321,9 @@ void TextInputChannel::HandleMethodCall( cursor_offset); } SendStateUpdate(); - } else if (method.compare(kRequestAutofillMethod) == 0) { #ifndef WEARABLE_PROFILE - TizenAutofill& instance = TizenAutofill::GetInstance(); - instance.RequestAutofill(autofill_hints_, autofill_id_); -#else - result->NotImplemented(); + } else if (method.compare(kRequestAutofillMethod) == 0) { + TizenAutofill::GetInstance().RequestAutofill(autofill_hints_, autofill_id_); #endif } else { result->NotImplemented(); diff --git a/flutter/shell/platform/tizen/channels/text_input_channel.h b/flutter/shell/platform/tizen/channels/text_input_channel.h index 152872e..769a112 100644 --- a/flutter/shell/platform/tizen/channels/text_input_channel.h +++ b/flutter/shell/platform/tizen/channels/text_input_channel.h @@ -81,9 +81,10 @@ class TextInputChannel { // https://api.flutter.dev/flutter/services/TextCapitalization.html std::string text_capitalization_ = ""; + // The active autofill client id. std::string autofill_id_; - // Hints for request autofill. See availabel options: + // A list of autofill hint strings. See available options: // https://api.flutter.dev/flutter/services/AutofillHints-class.html std::vector autofill_hints_; }; diff --git a/flutter/shell/platform/tizen/nui_autofill_popup.cc b/flutter/shell/platform/tizen/nui_autofill_popup.cc index 4780a6a..4010da8 100644 --- a/flutter/shell/platform/tizen/nui_autofill_popup.cc +++ b/flutter/shell/platform/tizen/nui_autofill_popup.cc @@ -11,28 +11,34 @@ #include "flutter/shell/platform/tizen/tizen_autofill.h" namespace flutter { -bool NuiAutofillPopup::OnTouch(Dali::Actor actor, + +bool NuiAutofillPopup::Touched(Dali::Actor actor, const Dali::TouchEvent& event) { const Dali::PointState::Type state = event.GetState(0); if (Dali::PointState::DOWN == state) { - auto t = actor.GetProperty(Dali::Actor::Property::NAME).Get(); - on_commit_(t); - OnHide(); + std::string text = + actor.GetProperty(Dali::Actor::Property::NAME).Get(); + on_commit_(text); + Hide(); } return true; } -void NuiAutofillPopup::OnHide() { - // TODO : There is a phenomenon where white traces remain for a while when - // popup disappears. +void NuiAutofillPopup::Hide() { + // TODO(Swanseo0) : There is a phenomenon where white traces remain for a + // while when popup disappears. popup_.SetDisplayState(Dali::Toolkit::Popup::HIDDEN); } -void NuiAutofillPopup::OnHidden() { +void NuiAutofillPopup::Hidden() { popup_.Unparent(); popup_.Reset(); } +void NuiAutofillPopup::OutsideTouched() { + Hide(); +} + void NuiAutofillPopup::PrepareAutofill() { popup_ = Dali::Toolkit::Popup::New(); popup_.SetProperty(Dali::Actor::Property::NAME, "popup"); @@ -42,8 +48,9 @@ void NuiAutofillPopup::PrepareAutofill() { Dali::AnchorPoint::TOP_LEFT); popup_.SetProperty(Dali::Toolkit::Popup::Property::TAIL_VISIBILITY, false); popup_.SetBackgroundColor(Dali::Color::WHITE_SMOKE); - popup_.OutsideTouchedSignal().Connect(this, &NuiAutofillPopup::OnHide); - popup_.HiddenSignal().Connect(this, &NuiAutofillPopup::OnHidden); + popup_.OutsideTouchedSignal().Connect(this, + &NuiAutofillPopup::OutsideTouched); + 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); } @@ -66,7 +73,7 @@ void NuiAutofillPopup::PopupAutofill(Dali::Actor* actor) { 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::OnTouch); + label.TouchedSignal().Connect(this, &NuiAutofillPopup::Touched); content.AddChild(label, Dali::Toolkit::TableView::CellPosition(i, 0)); content.SetFitHeight(i); } diff --git a/flutter/shell/platform/tizen/nui_autofill_popup.h b/flutter/shell/platform/tizen/nui_autofill_popup.h index f1ecf78..78b6d14 100644 --- a/flutter/shell/platform/tizen/nui_autofill_popup.h +++ b/flutter/shell/platform/tizen/nui_autofill_popup.h @@ -16,11 +16,11 @@ using OnRendering = std::function; class NuiAutofillPopup : public Dali::ConnectionTracker { public: - bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event); + void Hide(); - void OnHide(); + void Hidden(); - void OnHidden(); + void OutsideTouched(); void PrepareAutofill(); @@ -28,6 +28,8 @@ class NuiAutofillPopup : public Dali::ConnectionTracker { void SetOnCommit(OnCommit callback) { on_commit_ = callback; } + bool Touched(Dali::Actor actor, const Dali::TouchEvent& event); + private: Dali::Toolkit::Popup popup_; OnCommit on_commit_; diff --git a/flutter/shell/platform/tizen/tizen_autofill.cc b/flutter/shell/platform/tizen/tizen_autofill.cc index 0aee365..33a6271 100644 --- a/flutter/shell/platform/tizen/tizen_autofill.cc +++ b/flutter/shell/platform/tizen/tizen_autofill.cc @@ -133,7 +133,7 @@ void TizenAutofill::RegisterAutofillItem(std::string view_id, autofill_save_item_set_sensitive_data(save_item, item.sensitive_data_); autofill_save_item_set_value(save_item, item.value_.c_str()); - char* app_id; + char* app_id = nullptr; app_get_id(&app_id); autofill_save_view_info_h save_view_info = nullptr; diff --git a/flutter/shell/platform/tizen/tizen_autofill.h b/flutter/shell/platform/tizen/tizen_autofill.h index 2a30d42..7c1ce02 100644 --- a/flutter/shell/platform/tizen/tizen_autofill.h +++ b/flutter/shell/platform/tizen/tizen_autofill.h @@ -45,7 +45,7 @@ class TizenAutofill { void OnCommit(std::string str) { on_commit_(str); } void OnPopup() { on_popup_(); } -# + const std::vector>& GetAutofillItems() { return response_items_; } @@ -57,7 +57,6 @@ class TizenAutofill { void InitailizeAutofill(); - // TODO : implement convert flutter hint to tizen hint function std::optional ConvertAutofillHint(std::string hint); autofill_h autofill_; diff --git a/flutter/shell/platform/tizen/tizen_view_elementary.cc b/flutter/shell/platform/tizen/tizen_view_elementary.cc index eb9287b..daf5df0 100644 --- a/flutter/shell/platform/tizen/tizen_view_elementary.cc +++ b/flutter/shell/platform/tizen/tizen_view_elementary.cc @@ -385,7 +385,7 @@ void TizenViewElementary::PrepareInputMethod() { item.get()); } } - // TODO : Change ctxpopup's position to focused input field. + // TODO(Swanseo0) : Change ctxpopup's position to focused input field. evas_object_move(ctxpopup_, 0, 0); evas_object_show(ctxpopup_); }); diff --git a/flutter/shell/platform/tizen/tizen_window_elementary.cc b/flutter/shell/platform/tizen/tizen_window_elementary.cc index e6ed8b9..d5d8e40 100644 --- a/flutter/shell/platform/tizen/tizen_window_elementary.cc +++ b/flutter/shell/platform/tizen/tizen_window_elementary.cc @@ -464,7 +464,7 @@ void TizenWindowElementary::PrepareInputMethod() { item.get()); } } - // TODO : Change ctxpopup's position to focused input field. + // TODO(Swanseo0) : Change ctxpopup's position to focused input field. evas_object_move(ctxpopup_, initial_geometry_.left, initial_geometry_.top); evas_object_show(ctxpopup_); });