From a11044e872542dbad08685b132970cf4a0035ee8 Mon Sep 17 00:00:00 2001 From: openharmony_ci <120357966@qq.com> Date: Thu, 20 Jul 2023 16:50:06 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!16120?= =?UTF-8?q?=20:=20(weekly)=E5=85=A8=E5=B1=80map=E6=87=92=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frameworks/base/resource/ace_res_config.cpp | 217 +++++++++--------- frameworks/core/event/key_event.cpp | 50 +--- frameworks/core/event/key_event.h | 30 ++- .../drag_controller/js_drag_controller.cpp | 2 +- 4 files changed, 149 insertions(+), 150 deletions(-) diff --git a/frameworks/base/resource/ace_res_config.cpp b/frameworks/base/resource/ace_res_config.cpp index d232dc52d00c..581fb1ae288f 100644 --- a/frameworks/base/resource/ace_res_config.cpp +++ b/frameworks/base/resource/ace_res_config.cpp @@ -32,6 +32,110 @@ namespace OHOS::Ace { namespace { +const std::unordered_map LOCALE_PARENTS { + { "ar-DZ", "ar-015" }, + { "ar-EH", "ar-015" }, + { "ar-LY", "ar-015" }, + { "ar-MA", "ar-015" }, + { "ar-TN", "ar-015" }, + { "zh-MO", "zh-HK" }, + { "en-150", "en-001" }, + { "en-AG", "en-001" }, + { "en-AI", "en-001" }, + { "en-AU", "en-001" }, + { "en-BB", "en-001" }, + { "en-BE", "en-001" }, + { "en-BM", "en-001" }, + { "en-BS", "en-001" }, + { "en-BZ", "en-001" }, + { "en-CC", "en-001" }, + { "en-CK", "en-001" }, + { "en-CX", "en-001" }, + { "en-DG", "en-001" }, + { "en-ER", "en-001" }, + { "en-FK", "en-001" }, + { "en-FM", "en-001" }, + { "en-GB", "en-001" }, + { "en-GD", "en-001" }, + { "en-GG", "en-001" }, + { "en-GI", "en-001" }, + { "en-GY", "en-001" }, + { "en-HK", "en-001" }, + { "en-IE", "en-001" }, + { "en-IM", "en-001" }, + { "en-IN", "en-001" }, + { "en-IO", "en-001" }, + { "en-JE", "en-001" }, + { "en-KI", "en-001" }, + { "en-KN", "en-001" }, + { "en-KY", "en-001" }, + { "en-LC", "en-001" }, + { "en-LR", "en-001" }, + { "en-LS", "en-001" }, + { "en-MM", "en-001" }, + { "en-MO", "en-001" }, + { "en-MS", "en-001" }, + { "en-MT", "en-001" }, + { "en-MY", "en-001" }, + { "en-NF", "en-001" }, + { "en-NR", "en-001" }, + { "en-NU", "en-001" }, + { "en-NZ", "en-001" }, + { "en-PG", "en-001" }, + { "en-PK", "en-001" }, + { "en-PN", "en-001" }, + { "en-PW", "en-001" }, + { "en-SB", "en-001" }, + { "en-SC", "en-001" }, + { "en-SD", "en-001" }, + { "en-SG", "en-001" }, + { "en-SH", "en-001" }, + { "en-SL", "en-001" }, + { "en-SS", "en-001" }, + { "en-SX", "en-001" }, + { "en-SZ", "en-001" }, + { "en-TC", "en-001" }, + { "en-TK", "en-001" }, + { "en-TT", "en-001" }, + { "en-TV", "en-001" }, + { "en-VC", "en-001" }, + { "en-VG", "en-001" }, + { "en-WS", "en-001" }, + { "en-ZG", "en-001" }, + { "es-AR", "es-419" }, + { "es-BO", "es-419" }, + { "es-BR", "es-419" }, + { "es-BZ", "es-419" }, + { "es-CL", "es-419" }, + { "es-CO", "es-419" }, + { "es-CR", "es-419" }, + { "es-CU", "es-419" }, + { "es-DO", "es-419" }, + { "es-EC", "es-419" }, + { "es-GT", "es-419" }, + { "es-HN", "es-419" }, + { "es-MX", "es-419" }, + { "es-NI", "es-419" }, + { "es-PA", "es-419" }, + { "es-PE", "es-419" }, + { "es-PR", "es-419" }, + { "es-PY", "es-419" }, + { "es-SV", "es-419" }, + { "es-US", "es-419" }, + { "es-UY", "es-419" }, + { "es-VE", "es-419" }, + { "pt-AO", "pt-PT" }, + { "pt-CH", "pt-PT" }, + { "pt-CV", "pt-PT" }, + { "pt-GQ", "pt-PT" }, + { "pt-GW", "pt-PT" }, + { "pt-LU", "pt-PT" }, + { "pt-MO", "pt-PT" }, + { "pt-MZ", "pt-PT" }, + { "pt-ST", "pt-PT" }, + { "pt-TL", "pt-PT" }, +}; + const std::unordered_map DEFAULT_LANG { { "es-419", "es-US" }, { "en-Qaag", "en-GB" }, @@ -118,109 +222,6 @@ void MatchLocaleConfig(const std::vector& candidatesLocaleConfig, void FindBacktrackPath( const AceResConfig& localeConfig, std::vector& backtrackPath, const std::string& localeTag) { - static const std::unordered_map LOCALE_PARENTS { - { "ar-DZ", "ar-015" }, - { "ar-EH", "ar-015" }, - { "ar-LY", "ar-015" }, - { "ar-MA", "ar-015" }, - { "ar-TN", "ar-015" }, - { "zh-MO", "zh-HK" }, - { "en-150", "en-001" }, - { "en-AG", "en-001" }, - { "en-AI", "en-001" }, - { "en-AU", "en-001" }, - { "en-BB", "en-001" }, - { "en-BE", "en-001" }, - { "en-BM", "en-001" }, - { "en-BS", "en-001" }, - { "en-BZ", "en-001" }, - { "en-CC", "en-001" }, - { "en-CK", "en-001" }, - { "en-CX", "en-001" }, - { "en-DG", "en-001" }, - { "en-ER", "en-001" }, - { "en-FK", "en-001" }, - { "en-FM", "en-001" }, - { "en-GB", "en-001" }, - { "en-GD", "en-001" }, - { "en-GG", "en-001" }, - { "en-GI", "en-001" }, - { "en-GY", "en-001" }, - { "en-HK", "en-001" }, - { "en-IE", "en-001" }, - { "en-IM", "en-001" }, - { "en-IN", "en-001" }, - { "en-IO", "en-001" }, - { "en-JE", "en-001" }, - { "en-KI", "en-001" }, - { "en-KN", "en-001" }, - { "en-KY", "en-001" }, - { "en-LC", "en-001" }, - { "en-LR", "en-001" }, - { "en-LS", "en-001" }, - { "en-MM", "en-001" }, - { "en-MO", "en-001" }, - { "en-MS", "en-001" }, - { "en-MT", "en-001" }, - { "en-MY", "en-001" }, - { "en-NF", "en-001" }, - { "en-NR", "en-001" }, - { "en-NU", "en-001" }, - { "en-NZ", "en-001" }, - { "en-PG", "en-001" }, - { "en-PK", "en-001" }, - { "en-PN", "en-001" }, - { "en-PW", "en-001" }, - { "en-SB", "en-001" }, - { "en-SC", "en-001" }, - { "en-SD", "en-001" }, - { "en-SG", "en-001" }, - { "en-SH", "en-001" }, - { "en-SL", "en-001" }, - { "en-SS", "en-001" }, - { "en-SX", "en-001" }, - { "en-SZ", "en-001" }, - { "en-TC", "en-001" }, - { "en-TK", "en-001" }, - { "en-TT", "en-001" }, - { "en-TV", "en-001" }, - { "en-VC", "en-001" }, - { "en-VG", "en-001" }, - { "en-WS", "en-001" }, - { "en-ZG", "en-001" }, - { "es-AR", "es-419" }, - { "es-BO", "es-419" }, - { "es-BR", "es-419" }, - { "es-BZ", "es-419" }, - { "es-CL", "es-419" }, - { "es-CO", "es-419" }, - { "es-CR", "es-419" }, - { "es-CU", "es-419" }, - { "es-DO", "es-419" }, - { "es-EC", "es-419" }, - { "es-GT", "es-419" }, - { "es-HN", "es-419" }, - { "es-MX", "es-419" }, - { "es-NI", "es-419" }, - { "es-PA", "es-419" }, - { "es-PE", "es-419" }, - { "es-PR", "es-419" }, - { "es-PY", "es-419" }, - { "es-SV", "es-419" }, - { "es-US", "es-419" }, - { "es-UY", "es-419" }, - { "es-VE", "es-419" }, - { "pt-AO", "pt-PT" }, - { "pt-CH", "pt-PT" }, - { "pt-CV", "pt-PT" }, - { "pt-GQ", "pt-PT" }, - { "pt-GW", "pt-PT" }, - { "pt-LU", "pt-PT" }, - { "pt-MO", "pt-PT" }, - { "pt-MZ", "pt-PT" }, - { "pt-ST", "pt-PT" }, - { "pt-TL", "pt-PT" }, - }; if (LOCALE_PARENTS.find(localeTag) != LOCALE_PARENTS.end()) { std::string curTag = LOCALE_PARENTS.find(localeTag)->second; backtrackPath.emplace_back(curTag); @@ -734,9 +735,8 @@ std::string AceResConfig::GetCurrentDeviceResTag() ResolutionType resolutionType = AceResConfig::GetResolutionType(SystemProperties::GetResolution()); AceResConfig deviceResConfig = AceResConfig(SystemProperties::GetMcc(), SystemProperties::GetMnc(), SystemProperties::GetDeviceOrientation(), SystemProperties::GetColorMode(), - (SystemProperties::GetParamDeviceType() == "tablet" || SystemProperties::GetParamDeviceType() == "2in1") - ? DeviceType::TABLET - : SystemProperties::GetDeviceType(), + (SystemProperties::GetParamDeviceType() == "tablet" || SystemProperties::GetParamDeviceType() == "2in1") ? + DeviceType::TABLET : SystemProperties::GetDeviceType(), resolutionType); return AceResConfig::ConvertResConfigToTag(deviceResConfig, false); } @@ -753,9 +753,8 @@ std::string AceResConfig::GetCurrentDeviceDeclarativeResTag() deviceResConfig = AceResConfig(language, script, region, longScreenType, SystemProperties::GetScreenShape(), SystemProperties::GetDeviceOrientation(), SystemProperties::GetColorMode(), - (SystemProperties::GetParamDeviceType() == "tablet" || SystemProperties::GetParamDeviceType() == "2in1") - ? DeviceType::TABLET - : SystemProperties::GetDeviceType(), + (SystemProperties::GetParamDeviceType() == "tablet" || SystemProperties::GetParamDeviceType() == "2in1") ? + DeviceType::TABLET : SystemProperties::GetDeviceType(), resolutionType); return AceResConfig::ConvertDeclarativeResConfigToTag(deviceResConfig); diff --git a/frameworks/core/event/key_event.cpp b/frameworks/core/event/key_event.cpp index 3661383a20e3..3af7b3a94dba 100644 --- a/frameworks/core/event/key_event.cpp +++ b/frameworks/core/event/key_event.cpp @@ -21,14 +21,15 @@ namespace { // key : define aosp key event code, value : define ace key string constexpr int32_t KEYCODE_SIZE = 289; -const char* g_aospKeycode2String[KEYCODE_SIZE] = { "Unknown", "SoftLeft", "SoftRight", "Home", "Back", "Call", - "EndCall", "Digit0", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", - "Star", "Pound", "DpadUp", "DpadDown", "DpadLeft", "DpadRight", "DpadCenter", "VolumeUp", "VolumeDown", "Power", - "Camera", "Clear", "KeyA", "KeyB", "KeyC", "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", - "KeyM", "KeyN", "KeyO", "KeyP", "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ", - "Comma", "Period", "AltLeft", "AltRight", "ShiftLeft", "ShiftRight", "Tab", "Space", "Sym", "Explorer", "Envelope", - "Enter", "Del", "Grave", "Minus", "Equals", "LeftBracket", "RightBracket", "BackSlash", "Semicolon", "Apostrophe", - "Slash", "At", "Num", "HeadsetHook", "Focus", "Plus", "Menu", "Notification", "Search", "MediaPlayPause", +const char* g_aospKeycode2String[KEYCODE_SIZE] = { + "Unknown", "SoftLeft", "SoftRight", "Home", "Back", "Call", "EndCall", "Digit0", "Digit1", "Digit2", "Digit3", + "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9", "Star", "Pound", "DpadUp", "DpadDown", "DpadLeft", + "DpadRight", "DpadCenter", "VolumeUp", "VolumeDown", "Power", "Camera", "Clear", "KeyA", "KeyB", "KeyC", + "KeyD", "KeyE", "KeyF", "KeyG", "KeyH", "KeyI", "KeyJ", "KeyK", "KeyL", "KeyM", "KeyN", "KeyO", "KeyP", + "KeyQ", "KeyR", "KeyS", "KeyT", "KeyU", "KeyV", "KeyW", "KeyX", "KeyY", "KeyZ", "Comma", "Period", "AltLeft", + "AltRight", "ShiftLeft", "ShiftRight", "Tab", "Space", "Sym", "Explorer", "Envelope", "Enter", "Del", "Grave", + "Minus", "Equals", "LeftBracket", "RightBracket", "BackSlash", "Semicolon", "Apostrophe", "Slash", "At", + "Num", "HeadsetHook", "Focus", "Plus", "Menu", "Notification", "Search", "MediaPlayPause", "MediaStop", "MediaNext", "MediaPrevious", "MediaRewind", "MediaFastForward", "Mute", "PageUp", "PageDown", "PictSymbols", "SwitchCharset", "ButtonA", "ButtonB", "ButtonC", "ButtonX", "ButtonY", "ButtonZ", "ButtonL1", "ButtonR1", "ButtonL2", "ButtonR2", "ButtonThumbl", "ButtonThumbr", "ButtonStart", "ButtonSelect", "ButtonMode", @@ -53,7 +54,8 @@ const char* g_aospKeycode2String[KEYCODE_SIZE] = { "Unknown", "SoftLeft", "SoftR "StemPrimary", "Stem1", "Stem2", "Stem3", "DpadUpLeft", "DpadDownLeft", "DpadUpRight", "DpadDownRight", "MediaSkipForward", "MediaSkipBackward", "MediaStepForward", "MediaStepBackward", "SoftSleep", "Cut", "Copy", "Paste", "SystemNavigationUp", "SystemNavigationDown", "SystemNavigationLeft", "SystemNavigationRight", "AllApps", - "Refresh", "ThumbsUp", "ThumbsDown", "ProfileSwitch" }; + "Refresh", "ThumbsUp", "ThumbsDown", "ProfileSwitch" +}; } // namespace @@ -66,34 +68,4 @@ const char* KeyToString(int32_t code) } } -std::string KeyEvent::ConvertInputCodeToString() const -{ - static const std::map VISIBILITY_CODE = { { KeyCode::KEY_0, "0)" }, { KeyCode::KEY_1, "1!" }, - { KeyCode::KEY_2, "2@" }, { KeyCode::KEY_3, "3#" }, { KeyCode::KEY_4, "4$" }, { KeyCode::KEY_5, "5%" }, - { KeyCode::KEY_6, "6^" }, { KeyCode::KEY_7, "7&" }, { KeyCode::KEY_8, "8*" }, { KeyCode::KEY_9, "9(" }, - { KeyCode::KEY_COMMA, ",<" }, { KeyCode::KEY_PERIOD, ".>" }, { KeyCode::KEY_GRAVE, "`~" }, - { KeyCode::KEY_MINUS, "-_" }, { KeyCode::KEY_EQUALS, "=+" }, { KeyCode::KEY_LEFT_BRACKET, "[{" }, - { KeyCode::KEY_RIGHT_BRACKET, "]}" }, { KeyCode::KEY_BACKSLASH, "\\|" }, { KeyCode::KEY_SEMICOLON, ";:" }, - { KeyCode::KEY_APOSTROPHE, "\'\"" }, { KeyCode::KEY_SLASH, "/?" }, { KeyCode::KEY_AT, "@" }, - { KeyCode::KEY_PLUS, "+=" }, { KeyCode::KEY_NUMPAD_DIVIDE, "/" }, { KeyCode::KEY_NUMPAD_MULTIPLY, "*" }, - { KeyCode::KEY_NUMPAD_SUBTRACT, "-" }, { KeyCode::KEY_NUMPAD_ADD, "+" }, { KeyCode::KEY_NUMPAD_DOT, "." }, - { KeyCode::KEY_NUMPAD_COMMA, "," }, { KeyCode::KEY_NUMPAD_EQUALS, "=" }, { KeyCode::KEY_TAB, "\t" }, - { KeyCode::KEY_SPACE, " " }, { KeyCode::KEY_ESCAPE, "ESC" }, { KeyCode::KEY_F1, "F1" }, - { KeyCode::KEY_F2, "F2" }, { KeyCode::KEY_F3, "F3" }, { KeyCode::KEY_F4, "F4" }, { KeyCode::KEY_F5, "F5" }, - { KeyCode::KEY_F6, "F6" }, { KeyCode::KEY_F7, "F7" }, { KeyCode::KEY_F8, "F8" }, { KeyCode::KEY_F9, "F9" }, - { KeyCode::KEY_F10, "F10" }, { KeyCode::KEY_F11, "F11" }, { KeyCode::KEY_F12, "F12" } }; - if (KeyCode::KEY_NUMPAD_0 <= code && code <= KeyCode::KEY_NUMPAD_9) { - return std::to_string(static_cast(code) - static_cast(KeyCode::KEY_NUMPAD_0)); - } - if (IsLetterKey()) { - int32_t codeValue = static_cast(code) - static_cast(KeyCode::KEY_A); - return std::string(1, static_cast(codeValue + ASCII_START_UPPER_CASE_LETTER)); - } - auto iter = VISIBILITY_CODE.find(code); - if (iter != VISIBILITY_CODE.end()) { - return iter->second; - } - return ""; -} - } // namespace OHOS::Ace \ No newline at end of file diff --git a/frameworks/core/event/key_event.h b/frameworks/core/event/key_event.h index 81eecf7dff35..fb8ae58fa320 100644 --- a/frameworks/core/event/key_event.h +++ b/frameworks/core/event/key_event.h @@ -473,6 +473,20 @@ enum class KeyIntention : int32_t { constexpr int32_t ASCII_START_UPPER_CASE_LETTER = 65; constexpr int32_t ASCII_START_LOWER_CASE_LETTER = 97; +const std::map VISIBILITY_CODE = { { KeyCode::KEY_0, "0)" }, { KeyCode::KEY_1, "1!" }, + { KeyCode::KEY_2, "2@" }, { KeyCode::KEY_3, "3#" }, { KeyCode::KEY_4, "4$" }, { KeyCode::KEY_5, "5%" }, + { KeyCode::KEY_6, "6^" }, { KeyCode::KEY_7, "7&" }, { KeyCode::KEY_8, "8*" }, { KeyCode::KEY_9, "9(" }, + { KeyCode::KEY_COMMA, ",<" }, { KeyCode::KEY_PERIOD, ".>" }, { KeyCode::KEY_GRAVE, "`~" }, + { KeyCode::KEY_MINUS, "-_" }, { KeyCode::KEY_EQUALS, "=+" }, { KeyCode::KEY_LEFT_BRACKET, "[{" }, + { KeyCode::KEY_RIGHT_BRACKET, "]}" }, { KeyCode::KEY_BACKSLASH, "\\|" }, { KeyCode::KEY_SEMICOLON, ";:" }, + { KeyCode::KEY_APOSTROPHE, "\'\"" }, { KeyCode::KEY_SLASH, "/?" }, { KeyCode::KEY_AT, "@" }, + { KeyCode::KEY_PLUS, "+=" }, { KeyCode::KEY_NUMPAD_DIVIDE, "/" }, { KeyCode::KEY_NUMPAD_MULTIPLY, "*" }, + { KeyCode::KEY_NUMPAD_SUBTRACT, "-" }, { KeyCode::KEY_NUMPAD_ADD, "+" }, { KeyCode::KEY_NUMPAD_DOT, "." }, + { KeyCode::KEY_NUMPAD_COMMA, "," }, { KeyCode::KEY_NUMPAD_EQUALS, "=" }, { KeyCode::KEY_TAB, "\t" }, + { KeyCode::KEY_SPACE, " " }, { KeyCode::KEY_ESCAPE, "ESC" }, { KeyCode::KEY_F1, "F1" }, { KeyCode::KEY_F2, "F2" }, + { KeyCode::KEY_F3, "F3" }, { KeyCode::KEY_F4, "F4" }, { KeyCode::KEY_F5, "F5" }, { KeyCode::KEY_F6, "F6" }, + { KeyCode::KEY_F7, "F7" }, { KeyCode::KEY_F8, "F8" }, { KeyCode::KEY_F9, "F9" }, { KeyCode::KEY_F10, "F10" }, + { KeyCode::KEY_F11, "F11" }, { KeyCode::KEY_F12, "F12" } }; ACE_FORCE_EXPORT const char* KeyToString(int32_t code); @@ -560,7 +574,21 @@ struct KeyEvent final { return ""; } - std::string ConvertInputCodeToString() const; + std::string ConvertInputCodeToString() const + { + if (KeyCode::KEY_NUMPAD_0 <= code && code <= KeyCode::KEY_NUMPAD_9) { + return std::to_string(static_cast(code) - static_cast(KeyCode::KEY_NUMPAD_0)); + } + if (IsLetterKey()) { + int32_t codeValue = static_cast(code) - static_cast(KeyCode::KEY_A); + return std::string(1, static_cast(codeValue + ASCII_START_UPPER_CASE_LETTER)); + } + auto iter = VISIBILITY_CODE.find(code); + if (iter != VISIBILITY_CODE.end()) { + return iter->second; + } + return ""; + } KeyCode code { KeyCode::KEY_UNKNOWN }; const char* key = ""; diff --git a/interfaces/napi/kits/drag_controller/js_drag_controller.cpp b/interfaces/napi/kits/drag_controller/js_drag_controller.cpp index 47a8dbb94dfd..6e23e5cb326e 100644 --- a/interfaces/napi/kits/drag_controller/js_drag_controller.cpp +++ b/interfaces/napi/kits/drag_controller/js_drag_controller.cpp @@ -21,12 +21,12 @@ #include "interfaces/napi/kits/utils/napi_utils.h" #include "js_native_api.h" #include "js_native_api_types.h" +#include "jsnapi.h" #include "napi/native_common.h" #include "native_value.h" #include "node_api.h" #if defined(ENABLE_DRAG_FRAMEWORK) && defined(PIXEL_MAP_SUPPORTED) -#include "jsnapi.h" #include "pixel_map.h" #include "pixel_map_napi.h" -- Gitee