I’m working on improving my plugin and I want to create my own IPlatformTextField to use my own runtime text keyboard by disabling the default Android system keyboard. But on Android I’m running into issues where it still wants to use the AndroidPlatformTextField. And I want to do it without modifying the engine code.
I’m targetting the Pico platform before they don’t know how to do it with their platform plugin so I was looking for some way to override it.
I actually managed to fix it another way. The IPlatformTextField really isn’t great for mixing between different Android devices, despite there being a custom implementation.
I found a way to prevent the keyboard from appearing by using a custom UPL.xml file and added the following to it.
<gameActivityClassAdditions>
<insert>
public class HiddenVirtualKeyboardInput extends VirtualKeyboardInput
{
public HiddenVirtualKeyboardInput(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
}
public HiddenVirtualKeyboardInput(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public HiddenVirtualKeyboardInput(Context context)
{
super(context);
}
public void setVisibility(int visibility)
{
// 8 is the number for hidden, probably could use View.GONE instead
super.setVisibility(8);
}
}
</insert>
</gameActivityClassAdditions>
<!-- optional additions to GameActivity onCreate in GameActivity.java -->
<gameActivityOnCreateAdditions>
<insert>
newVirtualKeyboardInput = new HiddenVirtualKeyboardInput(this);
newVirtualKeyboardInput.setVisibility(View.GONE);
</insert>
</gameActivityOnCreateAdditions>
You could wrap these inserts for the appropriate conditions to make them more easily toggled on and off, but this does work and it works fantastically.
1 Like