From 9e3510231bf771bad26fd32ae7e55dce409fdd76 Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Tue, 22 Aug 2023 12:48:33 +0800 Subject: [PATCH] fixed 315a0ac from https://gitee.com/fupengfei001/tools_previewer/pulls/107 change 2in1 default device Signed-off-by: fupengfei001 --- jsapp/rich/JsAppImpl.cpp | 15 +++++++++++++-- jsapp/rich/JsAppImpl.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/jsapp/rich/JsAppImpl.cpp b/jsapp/rich/JsAppImpl.cpp index feafadf..18e0ee5 100644 --- a/jsapp/rich/JsAppImpl.cpp +++ b/jsapp/rich/JsAppImpl.cpp @@ -450,13 +450,20 @@ void JsAppImpl::AdaptDeviceType(Platform::AceRunArgs& args, const std::string ty args.deviceConfig.density = args.deviceWidth / adaptWidthTv; return; } - if (type == "phone" || type == "2in1" || type == "default") { + if (type == "phone" || type == "default") { args.deviceConfig.deviceType = DeviceType::PHONE; double density = screenDendity > 0 ? screenDendity : phoneScreenDensity; double adaptWidthPhone = realDeviceWidth * BASE_SCREEN_DENSITY / density; args.deviceConfig.density = args.deviceWidth / adaptWidthPhone; return; } + if (type == "2in1") { + args.deviceConfig.deviceType = DeviceType::TABLET; + double density = screenDendity > 0 ? screenDendity : twoInOneScreenDensity; + double adaptWidthPhone = realDeviceWidth * BASE_SCREEN_DENSITY / density; + args.deviceConfig.density = args.deviceWidth / adaptWidthPhone; + return; + } if (type == "tablet") { args.deviceConfig.deviceType = DeviceType::TABLET; double density = screenDendity > 0 ? screenDendity : tabletScreenDensity; @@ -715,10 +722,14 @@ void JsAppImpl::SetDeviceScreenDensity(const int32_t screenDensity, const std::s tvScreenDensity = screenDensity; return; } - if ((type == "phone" || type == "2in1" || type == "default") && screenDensity != 0) { + if ((type == "phone" || type == "default") && screenDensity != 0) { phoneScreenDensity = screenDensity; return; } + if (type == "2in1" && screenDensity != 0) { + twoInOneScreenDensity = screenDensity; + return; + } if (type == "tablet" && screenDensity != 0) { tabletScreenDensity = screenDensity; return; diff --git a/jsapp/rich/JsAppImpl.h b/jsapp/rich/JsAppImpl.h index 0b19c2b..3c9233b 100644 --- a/jsapp/rich/JsAppImpl.h +++ b/jsapp/rich/JsAppImpl.h @@ -91,6 +91,7 @@ protected: double tvScreenDensity = 320; // TV Screen Density double tabletScreenDensity = 400; // Tablet Screen Density double carScreenDensity = 320; // Car Screen Density + double twoInOneScreenDensity = 240; // Car Screen Density private: void SetAssetPath(OHOS::Ace::Platform::AceRunArgs& args, const std::string) const;