Skip to content

Commit

Permalink
Android-Gui: Allow setting the DecorView to transparent color
Browse files Browse the repository at this point in the history
Sony TVs have a long standing firmware bug. Allow a user to configure
the background color to workaround this.

Usage:
<advancedsettings>
  <gui>
   <transparentguilayout>true</transparentguilayout>
 </gui>
</advancedsettings>
  • Loading branch information
fritsch committed May 11, 2024
1 parent 161ccd0 commit 65db38b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
38 changes: 38 additions & 0 deletions xbmc/platform/android/activity/XBMCApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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, ...)
Expand Down Expand Up @@ -1669,6 +1683,30 @@ std::shared_ptr<CNativeWindow> CXBMCApp::GetNativeWindow(int timeout) const
return m_window;
}

void CXBMCApp::SetDecorViewBackgroundColorCallback(void* colorVariant)
{
CVariant* colorV = static_cast<CVariant*>(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)
Expand Down
2 changes: 2 additions & 0 deletions xbmc/platform/android/activity/XBMCApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions xbmc/settings/AdvancedSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 65db38b

Please sign in to comment.