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;
|
package com.erroratline0.infinipaint;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -7,6 +8,7 @@ import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
import org.libsdl.app.SDLActivity;
|
import org.libsdl.app.SDLActivity;
|
||||||
|
import org.libsdl.app.SDLSurface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sample wrapper class that just calls SDLActivity
|
* 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)
|
//if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
|
||||||
// window.setNavigationBarContrastEnforced(false);
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -382,6 +382,7 @@ void FileSelectScreen::edit_title_bar() {
|
||||||
CLAY_AUTO_ID({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_FIT(0)},
|
||||||
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
||||||
.childGap = gui.io.theme->childGap1,
|
.childGap = gui.io.theme->childGap1,
|
||||||
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
.childAlignment = { .x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER },
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
.layoutDirection = CLAY_LEFT_TO_RIGHT,
|
||||||
|
|
@ -407,6 +408,7 @@ void FileSelectScreen::title_bar() {
|
||||||
CLAY_AUTO_ID({
|
CLAY_AUTO_ID({
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
.sizing = {.width = CLAY_SIZING_GROW(0), .height = CLAY_SIZING_GROW(0)},
|
||||||
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
||||||
.childGap = gui.io.theme->childGap1,
|
.childGap = gui.io.theme->childGap1,
|
||||||
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
.childAlignment = {.x = CLAY_ALIGN_X_LEFT, .y = CLAY_ALIGN_Y_CENTER},
|
||||||
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
.layoutDirection = CLAY_LEFT_TO_RIGHT
|
||||||
|
|
@ -527,6 +529,7 @@ void FileSelectScreen::main_menu() {
|
||||||
CLAY(lId, {
|
CLAY(lId, {
|
||||||
.layout = {
|
.layout = {
|
||||||
.sizing = {.width = CLAY_SIZING_FIXED(300.0f * mainMenuOpenAnim->get_val()), .height = CLAY_SIZING_GROW(0)},
|
.sizing = {.width = CLAY_SIZING_FIXED(300.0f * mainMenuOpenAnim->get_val()), .height = CLAY_SIZING_GROW(0)},
|
||||||
|
.padding = CLAY_PADDING_ALL(gui.io.theme->padding1),
|
||||||
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
.layoutDirection = CLAY_TOP_TO_BOTTOM,
|
||||||
},
|
},
|
||||||
}) {
|
}) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue