Commit 8ccaf9c4 authored by kenan's avatar kenan

fix click

parent 93677f44
...@@ -81,8 +81,8 @@ public class GameSize { ...@@ -81,8 +81,8 @@ public class GameSize {
public GameSize(int width, int height, int touchX, int touchY) { public GameSize(int width, int height, int touchX, int touchY) {
this.width = width; this.width = width;
this.height = height; this.height = height;
this.touchX = touchX; this.touchX = touchX < 0 ? 0 : touchX;
this.touchY = touchY; this.touchY = touchY < 0 ? 0 : touchY;
} }
@Override @Override
......
...@@ -16,6 +16,7 @@ import com.yuyh.library.imgsel.common.ImageLoader; ...@@ -16,6 +16,7 @@ import com.yuyh.library.imgsel.common.ImageLoader;
import cn.garymb.ygomobile.interfaces.GameConfig; import cn.garymb.ygomobile.interfaces.GameConfig;
import cn.garymb.ygomobile.interfaces.GameHost; import cn.garymb.ygomobile.interfaces.GameHost;
import cn.garymb.ygomobile.utils.CrashHandler; import cn.garymb.ygomobile.utils.CrashHandler;
import cn.garymb.ygomobile.utils.ScreenUtil;
import libwindbot.windbot.WindBot; import libwindbot.windbot.WindBot;
public class App extends GameApplication { public class App extends GameApplication {
......
...@@ -141,7 +141,8 @@ class LocalGameHost extends GameHost { ...@@ -141,7 +141,8 @@ class LocalGameHost extends GameHost {
} }
maxW = Math.max(w1, h1); maxW = Math.max(w1, h1);
maxH = Math.min(w1, h1); maxH = Math.min(w1, h1);
if(immerSiveMode){ boolean hasNotouch = ScreenUtil.hasNotchInformation(activity);
if(hasNotouch && immerSiveMode){
maxW -= config.getNotouchHeight(); maxW -= config.getNotouchHeight();
} }
Log.i("kk", "real=" + fullW + "x" + fullH + ",cur=" + actW + "x" + actH + ",use=" + maxW + "x" + maxH); Log.i("kk", "real=" + fullW + "x" + fullH + ",cur=" + actW + "x" + actH + ",use=" + maxW + "x" + maxH);
...@@ -161,7 +162,7 @@ class LocalGameHost extends GameHost { ...@@ -161,7 +162,7 @@ class LocalGameHost extends GameHost {
//fix touch point //fix touch point
int left = (maxW - gw) / 2; int left = (maxW - gw) / 2;
int top = (maxH - gh) / 2; int top = (maxH - gh) / 2;
if(!immerSiveMode){ if(hasNotouch && !immerSiveMode){
//fix touch //fix touch
left = (maxW - gw - config.getNotouchHeight()) / 2; left = (maxW - gw - config.getNotouchHeight()) / 2;
} }
......
...@@ -46,7 +46,11 @@ public class ScreenUtil { ...@@ -46,7 +46,11 @@ public class ScreenUtil {
} else { } else {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
DisplayCutout cutout = activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout(); DisplayCutout cutout = activity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
return cutout != null; if (cutout == null) {
return false;
}
List<Rect> rects = cutout.getBoundingRects();
return rects != null && rects.size() > 0;
} else { } else {
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment