From 65db38bc45e419473e8c4a4221e16869eba603fb Mon Sep 17 00:00:00 2001 From: fritsch Date: Thu, 9 May 2024 11:41:46 +0200 Subject: [PATCH] Android-Gui: Allow setting the DecorView to transparent color Sony TVs have a long standing firmware bug. Allow a user to configure the background color to workaround this. Usage: true --- xbmc/platform/android/activity/XBMCApp.cpp | 38 ++++++++++++++++++++++ xbmc/platform/android/activity/XBMCApp.h | 2 ++ xbmc/settings/AdvancedSettings.cpp | 1 + xbmc/settings/AdvancedSettings.h | 1 + 4 files changed, 42 insertions(+) diff --git a/xbmc/platform/android/activity/XBMCApp.cpp b/xbmc/platform/android/activity/XBMCApp.cpp index 437c7371d9dc9..1cce04bccf871 100644 --- a/xbmc/platform/android/activity/XBMCApp.cpp +++ b/xbmc/platform/android/activity/XBMCApp.cpp @@ -266,6 +266,13 @@ void CXBMCApp::onStart() m_inputHandler.setDPI(GetDPI()); runNativeOnUiThread(RegisterDisplayListenerCallback, nullptr); } + + CLog::Log(LOGINFO, "XBMCApp: Setting Decorview Color 1"); + if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiLayoutTransparent) + { + CLog::Log(LOGINFO, "XBMCApp: Value was set 1"); + SetDecorViewBackgroundColor(0); + } } namespace @@ -732,6 +739,13 @@ void CXBMCApp::SetDisplayMode(int mode, float rate) runNativeOnUiThread(SetDisplayModeCallback, variant); if (g_application.IsInitialized()) m_displayChangeEvent.Wait(5000ms); + + CLog::Log(LOGINFO, "XBMCApp: Setting decorview 2"); + if (CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_guiLayoutTransparent) + { + CLog::Log(LOGINFO, "XBMCApp: Value was set 2"); + SetDecorViewBackgroundColor(0); + } } int CXBMCApp::android_printf(const char* format, ...) @@ -1669,6 +1683,30 @@ std::shared_ptr CXBMCApp::GetNativeWindow(int timeout) const return m_window; } +void CXBMCApp::SetDecorViewBackgroundColorCallback(void* colorVariant) +{ + CVariant* colorV = static_cast(colorVariant); + const int color = colorV->asInteger(); + delete colorV; + + CJNIWindow window = getWindow(); + if (window) + { + CJNIView view = window.getDecorView(); + if (view) + { + view.setBackgroundColor(color); + } + } +} + +void CXBMCApp::SetDecorViewBackgroundColor(const int color) +{ + // this object is deallocated in the callback + CVariant* variant = new CVariant(color); + runNativeOnUiThread(SetDecorViewBackgroundColorCallback, variant); +} + void CXBMCApp::RegisterInputDeviceCallbacks(IInputDeviceCallbacks* handler) { if (handler != nullptr) diff --git a/xbmc/platform/android/activity/XBMCApp.h b/xbmc/platform/android/activity/XBMCApp.h index 2e2d8670a0797..d149a5417c41d 100644 --- a/xbmc/platform/android/activity/XBMCApp.h +++ b/xbmc/platform/android/activity/XBMCApp.h @@ -181,6 +181,7 @@ class CXBMCApp : public IActivityHandler, void SetDisplayMode(int mode, float rate); int GetDPI() const; + void SetDecorViewBackgroundColor(const int color); CRect MapRenderToDroid(const CRect& srcRect); @@ -243,6 +244,7 @@ class CXBMCApp : public IActivityHandler, void SetupEnv(); static void SetDisplayModeCallback(void* modeVariant); static void KeepScreenOnCallback(void* onVariant); + static void SetDecorViewBackgroundColorCallback(void* onVariant); static void RegisterDisplayListenerCallback(void*); void UnregisterDisplayListener(); diff --git a/xbmc/settings/AdvancedSettings.cpp b/xbmc/settings/AdvancedSettings.cpp index 7b78c322997bc..591ea579525a1 100644 --- a/xbmc/settings/AdvancedSettings.cpp +++ b/xbmc/settings/AdvancedSettings.cpp @@ -1226,6 +1226,7 @@ void CAdvancedSettings::ParseSettingsFile(const std::string &file) XMLUtils::GetInt(pElement, "anisotropicfiltering", m_guiAnisotropicFiltering); XMLUtils::GetBoolean(pElement, "fronttobackrendering", m_guiFrontToBackRendering); XMLUtils::GetBoolean(pElement, "geometryclear", m_guiGeometryClear); + XMLUtils::GetBoolean(pElement, "transparentguilayout", m_guiLayoutTransparent); } std::string seekSteps; diff --git a/xbmc/settings/AdvancedSettings.h b/xbmc/settings/AdvancedSettings.h index e9adb76b61d9f..69c324c67dc1c 100644 --- a/xbmc/settings/AdvancedSettings.h +++ b/xbmc/settings/AdvancedSettings.h @@ -336,6 +336,7 @@ class CAdvancedSettings : public ISettingCallback, public ISettingsHandler int32_t m_guiAnisotropicFiltering{0}; bool m_guiFrontToBackRendering{false}; bool m_guiGeometryClear{true}; + bool m_guiLayoutTransparent = false; unsigned int m_addonPackageFolderSize; bool m_jsonOutputCompact;