【toast】修复深色模式下系统回退中toast颜色异常的问题

Signed-off-by: huzhanjiang <huzhanjiang@huawei.com>
Change-Id: I5722d34ff5fab3e2562c0f20aca4c567b172fdf5
This commit is contained in:
huzhanjiang 2024-10-11 18:09:43 +08:00
parent bdf87b2835
commit 2b4d36f7d3
3 changed files with 22 additions and 4 deletions

View File

@ -1217,7 +1217,12 @@ bool SubwindowOhos::InitToastDialogWindow(int32_t width, int32_t height, int32_t
windowOption->SetFocusable(!isToast);
int32_t dialogId = gToastDialogId.fetch_add(1, std::memory_order_relaxed);
std::string windowName = "ARK_APP_SUBWINDOW_TOAST_DIALOG_" + std::to_string(dialogId);
dialogWindow_ = OHOS::Rosen::Window::Create(windowName, windowOption);
if (isToast) {
auto context = OHOS::AbilityRuntime::Context::GetApplicationContext();
dialogWindow_ = OHOS::Rosen::Window::Create(windowName, windowOption, context);
} else {
dialogWindow_ = OHOS::Rosen::Window::Create(windowName, windowOption);
}
CHECK_NULL_RETURN(dialogWindow_, false);
dialogWindow_->SetLayoutFullScreen(true);
return true;

View File

@ -2792,10 +2792,22 @@ void UIContentImpl::DumpInfo(const std::vector<std::string>& params, std::vector
}
}
void UIContentImpl::UpdateDialogResourceConfiguration(RefPtr<Container>& container)
void UIContentImpl::UpdateDialogResourceConfiguration(RefPtr<Container>& container,
const std::shared_ptr<OHOS::AbilityRuntime::Context>& context)
{
auto dialogContainer = AceType::DynamicCast<Platform::DialogContainer>(container);
if (dialogContainer) {
std::unique_ptr<Global::Resource::ResConfig> resConfig(Global::Resource::CreateResConfig());
CHECK_NULL_VOID(context);
auto resourceManager = context->GetResourceManager();
if (resourceManager != nullptr) {
resourceManager->GetResConfig(*resConfig);
if (resConfig->GetColorMode() == OHOS::Global::Resource::ColorMode::DARK) {
SystemProperties::SetColorMode(ColorMode::DARK);
} else {
SystemProperties::SetColorMode(ColorMode::LIGHT);
}
}
auto aceResCfg = dialogContainer->GetResourceConfiguration();
aceResCfg.SetOrientation(SystemProperties::GetDeviceOrientation());
aceResCfg.SetDensity(SystemProperties::GetResolution());
@ -2836,7 +2848,7 @@ void UIContentImpl::InitializeSubWindow(OHOS::Rosen::Window* window, bool isDial
icu::Locale locale = icu::Locale::forLanguageTag(Global::I18n::LocaleConfig::GetSystemLanguage(), status);
AceApplicationInfo::GetInstance().SetLocale(locale.getLanguage(), locale.getCountry(), locale.getScript(), "");
container = AceType::MakeRefPtr<Platform::DialogContainer>(instanceId_, FrontendType::DECLARATIVE_JS);
UpdateDialogResourceConfiguration(container);
UpdateDialogResourceConfiguration(container, context);
} else {
#ifdef NG_BUILD
container = AceType::MakeRefPtr<Platform::AceContainer>(instanceId_, frontendType,

View File

@ -83,7 +83,8 @@ public:
// UI content event process
bool ProcessBackPressed() override;
void UpdateDialogResourceConfiguration(RefPtr<Container>& container);
void UpdateDialogResourceConfiguration(RefPtr<Container>& container,
const std::shared_ptr<OHOS::AbilityRuntime::Context>& context);
bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) override;
bool ProcessPointerEventWithCallback(
const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent, const std::function<void()>& callback) override;