mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #106709 from m4gr3d/fix_transparency_flags
Fix transparency background issue on Android
This commit is contained in:
commit
ae33da972b
11 changed files with 61 additions and 14 deletions
|
@ -5,6 +5,7 @@
|
|||
<style name="GodotAppMainTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar">
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
|
||||
<item name="android:windowSwipeToDismiss">false</item>
|
||||
<item name="android:windowIsTranslucent">false</item>
|
||||
</style>
|
||||
|
||||
<!-- GodotAppSplashTheme is auto-generated during export. Manual changes will be overwritten.
|
||||
|
@ -13,5 +14,6 @@
|
|||
<item name="android:windowSplashScreenBackground">@mipmap/icon_background</item>
|
||||
<item name="windowSplashScreenAnimatedIcon">@mipmap/icon_foreground</item>
|
||||
<item name="postSplashScreenTheme">@style/GodotAppMainTheme</item>
|
||||
<item name="android:windowIsTranslucent">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
android:launchMode="singleTask"
|
||||
android:process=":GodotGame"
|
||||
android:autoRemoveFromRecents="true"
|
||||
android:theme="@style/GodotGameTheme"
|
||||
android:supportsPictureInPicture="true"
|
||||
android:screenOrientation="userLandscape">
|
||||
<layout
|
||||
|
|
|
@ -2,10 +2,14 @@
|
|||
<resources>
|
||||
<style name="GodotEditorTheme" parent="@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen">
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name ="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:navigationBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
|
||||
</style>
|
||||
|
||||
<style name="GodotGameTheme" parent="GodotEditorTheme">
|
||||
<item name="android:windowIsTranslucent">true</item>
|
||||
</style>
|
||||
|
||||
<style name="GodotEditorSplashScreenTheme" parent="Theme.SplashScreen.IconBackground">
|
||||
<!-- Set the theme of the Activity that directly follows your splash
|
||||
screen. This is required. -->
|
||||
|
|
|
@ -478,19 +478,24 @@ class Godot(private val context: Context) {
|
|||
editText.setBackgroundColor(Color.TRANSPARENT)
|
||||
// ...add to FrameLayout
|
||||
containerLayout?.addView(editText)
|
||||
|
||||
// Check whether the render view should be made transparent
|
||||
val shouldBeTransparent =
|
||||
!isProjectManagerHint() && !isEditorHint() && java.lang.Boolean.parseBoolean(GodotLib.getGlobal("display/window/per_pixel_transparency/allowed"))
|
||||
Log.d(TAG, "Render view should be transparent: $shouldBeTransparent")
|
||||
renderView = if (usesVulkan()) {
|
||||
if (meetsVulkanRequirements(activity.packageManager)) {
|
||||
GodotVulkanRenderView(host, this, godotInputHandler)
|
||||
GodotVulkanRenderView(host, this, godotInputHandler, shouldBeTransparent)
|
||||
} else if (canFallbackToOpenGL()) {
|
||||
// Fallback to OpenGl.
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl, shouldBeTransparent)
|
||||
} else {
|
||||
throw IllegalStateException(activity.getString(R.string.error_missing_vulkan_requirements_message))
|
||||
}
|
||||
|
||||
} else {
|
||||
// Fallback to OpenGl.
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl, shouldBeTransparent)
|
||||
}
|
||||
|
||||
if (host == primaryHost) {
|
||||
|
|
|
@ -46,7 +46,6 @@ import android.content.res.AssetManager;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -83,7 +82,7 @@ class GodotGLRenderView extends GLSurfaceView implements GodotRenderView {
|
|||
private final GodotRenderer godotRenderer;
|
||||
private final SparseArray<PointerIcon> customPointerIcons = new SparseArray<>();
|
||||
|
||||
public GodotGLRenderView(GodotHost host, Godot godot, GodotInputHandler inputHandler, XRMode xrMode, boolean useDebugOpengl) {
|
||||
public GodotGLRenderView(GodotHost host, Godot godot, GodotInputHandler inputHandler, XRMode xrMode, boolean useDebugOpengl, boolean shouldBeTranslucent) {
|
||||
super(host.getActivity());
|
||||
|
||||
this.host = host;
|
||||
|
@ -91,7 +90,7 @@ class GodotGLRenderView extends GLSurfaceView implements GodotRenderView {
|
|||
this.inputHandler = inputHandler;
|
||||
this.godotRenderer = new GodotRenderer();
|
||||
setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT));
|
||||
init(xrMode, false, useDebugOpengl);
|
||||
init(xrMode, shouldBeTranslucent, useDebugOpengl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ import android.annotation.SuppressLint;
|
|||
import android.content.res.AssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Build;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.SparseArray;
|
||||
import android.view.KeyEvent;
|
||||
|
@ -57,7 +57,7 @@ class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderView {
|
|||
private final VkRenderer mRenderer;
|
||||
private final SparseArray<PointerIcon> customPointerIcons = new SparseArray<>();
|
||||
|
||||
public GodotVulkanRenderView(GodotHost host, Godot godot, GodotInputHandler inputHandler) {
|
||||
public GodotVulkanRenderView(GodotHost host, Godot godot, GodotInputHandler inputHandler, boolean shouldBeTranslucent) {
|
||||
super(host.getActivity());
|
||||
|
||||
this.host = host;
|
||||
|
@ -67,6 +67,10 @@ class GodotVulkanRenderView extends VkSurfaceView implements GodotRenderView {
|
|||
setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_DEFAULT));
|
||||
setFocusableInTouchMode(true);
|
||||
setClickable(false);
|
||||
|
||||
if (shouldBeTranslucent) {
|
||||
this.getHolder().setFormat(PixelFormat.TRANSLUCENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue