Change how safe window area is calculated on android
This commit is contained in:
parent
59a9d04d6f
commit
56cd0c920f
3 changed files with 46 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package com.erroratline0.infinipaint;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
|
@ -7,6 +8,7 @@ import android.view.Window;
|
|||
import android.view.WindowManager;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
import org.libsdl.app.SDLSurface;
|
||||
|
||||
/**
|
||||
* A sample wrapper class that just calls SDLActivity
|
||||
|
|
@ -25,4 +27,12 @@ public class InfiniPaint extends SDLActivity {
|
|||
//if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||
// window.setNavigationBarContrastEnforced(false);
|
||||
}
|
||||
|
||||
protected void get_window_insets() {
|
||||
Window window = this.getWindow();
|
||||
}
|
||||
|
||||
protected SDLSurface createSDLSurface(Context context) {
|
||||
return new InfiniPaintSurface(context);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.erroratline0.infinipaint;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Insets;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.WindowInsets;
|
||||
|
||||
import org.libsdl.app.SDLActivity;
|
||||
import org.libsdl.app.SDLSurface;
|
||||
|
||||
public class InfiniPaintSurface extends SDLSurface {
|
||||
protected InfiniPaintSurface(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
// Window inset calculations are different from SDL defaults
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
|
||||
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
|
||||
Insets combined = insets.getInsets(WindowInsets.Type.systemBars() |
|
||||
//WindowInsets.Type.systemGestures() |
|
||||
//WindowInsets.Type.mandatorySystemGestures() |
|
||||
WindowInsets.Type.tappableElement() |
|
||||
WindowInsets.Type.displayCutout());
|
||||
|
||||
SDLActivity.onNativeInsetsChanged(combined.left, combined.right, combined.top, combined.bottom);
|
||||
}
|
||||
|
||||
// Pass these to any child views in case they need them
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue