From 9b6ca65d9fca7bd2e36bfb0c5ab41096fd311669 Mon Sep 17 00:00:00 2001 From: Boram Bae Date: Wed, 14 Sep 2022 18:26:58 +0900 Subject: [PATCH] Support TextCapitalization * Contribute #195 Signed-off-by: Boram Bae --- .../platform/tizen/channels/text_input_channel.cc | 9 +++++++++ .../platform/tizen/channels/text_input_channel.h | 4 ++++ .../platform/tizen/tizen_input_method_context.cc | 15 +++++++++++++++ shell/platform/tizen/tizen_input_method_context.h | 2 ++ 4 files changed, 30 insertions(+) diff --git a/shell/platform/tizen/channels/text_input_channel.cc b/shell/platform/tizen/channels/text_input_channel.cc index 52a9c0f411690..84f9e143b3f44 100644 --- a/shell/platform/tizen/channels/text_input_channel.cc +++ b/shell/platform/tizen/channels/text_input_channel.cc @@ -168,6 +168,15 @@ void TextInputChannel::HandleMethodCall( input_action_ = input_action_iter->value.GetString(); } + text_capitalization_ = ""; + auto text_capitalization_iter = + client_config.FindMember("textCapitalization"); + if (text_capitalization_iter != client_config.MemberEnd() && + text_capitalization_iter->value.IsString()) { + text_capitalization_ = text_capitalization_iter->value.GetString(); + input_method_context_->SetAutocapitalType(text_capitalization_); + } + input_type_ = ""; auto input_type_info_iter = client_config.FindMember(kTextInputType); if (input_type_info_iter != client_config.MemberEnd() && diff --git a/shell/platform/tizen/channels/text_input_channel.h b/shell/platform/tizen/channels/text_input_channel.h index 33904e7e05e59..11d3aa35f08dd 100644 --- a/shell/platform/tizen/channels/text_input_channel.h +++ b/shell/platform/tizen/channels/text_input_channel.h @@ -75,6 +75,10 @@ class TextInputChannel { // Keyboard type of the client. See available options: // https://api.flutter.dev/flutter/services/TextInputType-class.html std::string input_type_; + + // Automatic text capitalization type. See available options: + // https://api.flutter.dev/flutter/services/TextCapitalization.html + std::string text_capitalization_ = ""; }; } // namespace flutter diff --git a/shell/platform/tizen/tizen_input_method_context.cc b/shell/platform/tizen/tizen_input_method_context.cc index 8202e27bda771..79ad734d3db49 100644 --- a/shell/platform/tizen/tizen_input_method_context.cc +++ b/shell/platform/tizen/tizen_input_method_context.cc @@ -256,6 +256,21 @@ void TizenInputMethodContext::SetInputPanelLayoutVariation(bool is_signed, ecore_imf_context_input_panel_layout_variation_set(imf_context_, variation); } +void TizenInputMethodContext::SetAutocapitalType(const std::string& type) { + Ecore_IMF_Autocapital_Type autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE; + + if (type == "TextCapitalization.characters") { + autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_ALLCHARACTER; + } else if (type == "TextCapitalization.words") { + autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_WORD; + } else if (type == "TextCapitalization.sentences") { + autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_SENTENCE; + } else if (type == "TextCapitalization.none") { + autocapital_type = ECORE_IMF_AUTOCAPITAL_TYPE_NONE; + } + ecore_imf_context_autocapital_type_set(imf_context_, autocapital_type); +} + void TizenInputMethodContext::RegisterEventCallbacks() { FT_ASSERT(imf_context_); diff --git a/shell/platform/tizen/tizen_input_method_context.h b/shell/platform/tizen/tizen_input_method_context.h index 55dd4a960c310..ff9913605a25e 100644 --- a/shell/platform/tizen/tizen_input_method_context.h +++ b/shell/platform/tizen/tizen_input_method_context.h @@ -49,6 +49,8 @@ class TizenInputMethodContext { void SetInputPanelLayoutVariation(bool is_signed, bool is_decimal); + void SetAutocapitalType(const std::string& type); + void SetOnCommit(OnCommit callback) { on_commit_ = callback; } void SetOnPreeditChanged(OnPreeditChanged callback) {