Commit 7a1a55c5 authored by kenan's avatar kenan

opt fullscreen

parent 8a9d8afd
...@@ -101,6 +101,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -101,6 +101,7 @@ public class YGOMobileActivity extends NativeActivity implements
private SurfaceView mSurfaceView; private SurfaceView mSurfaceView;
private boolean replaced = false; private boolean replaced = false;
private static boolean USE_SURFACE = true; private static boolean USE_SURFACE = true;
private static boolean RESIZE_WINDOW = true;
// public static int notchHeight; // public static int notchHeight;
...@@ -143,10 +144,9 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -143,10 +144,9 @@ public class YGOMobileActivity extends NativeActivity implements
.setPackage(getPackageName())); .setPackage(getPackageName()));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() { getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
@Override @Override
public void onSystemUiVisibilityChange(int visibility) { public void onSystemUiVisibilityChange(int visibility) {
if ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0) { if ((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) {
fullscreen(); fullscreen();
} }
} }
...@@ -169,7 +169,6 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -169,7 +169,6 @@ public class YGOMobileActivity extends NativeActivity implements
mLock = mPM.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG); mLock = mPM.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);
} }
mLock.acquire(); mLock.acquire();
//注册
} }
@Override @Override
...@@ -252,13 +251,12 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -252,13 +251,12 @@ public class YGOMobileActivity extends NativeActivity implements
changeGameSize(); changeGameSize();
} else { } else {
int[] size = getGameSize(); int[] size = getGameSize();
if (app().isKeepScale()) { if(RESIZE_WINDOW) {
getWindow().setLayout(size[0], size[1]); if (app().isKeepScale()) {
getWindow().setLayout(size[0], size[1]);
}
} }
} }
if(USE_SURFACE && mSurfaceView != null) {
mSurfaceView.requestFocus();
}
} }
private int[] getGameSize(){ private int[] getGameSize(){
...@@ -291,6 +289,7 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -291,6 +289,7 @@ public class YGOMobileActivity extends NativeActivity implements
int w = size[0]; int w = size[0];
int h = size[1]; int h = size[1];
mLayout = new FrameLayout(this); mLayout = new FrameLayout(this);
// mLayout.setFitsSystemWindows(true);
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(w, h);
lp.gravity = Gravity.CENTER; lp.gravity = Gravity.CENTER;
if (USE_SURFACE) { if (USE_SURFACE) {
...@@ -298,16 +297,18 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -298,16 +297,18 @@ public class YGOMobileActivity extends NativeActivity implements
mLayout.addView(view, lp); mLayout.addView(view, lp);
super.setContentView(mLayout); super.setContentView(mLayout);
app().attachGame(this); app().attachGame(this);
changeGameSize();
getWindow().takeSurface(null); getWindow().takeSurface(null);
replaced = true; replaced = true;
mSurfaceView.getHolder().addCallback(this); mSurfaceView.getHolder().addCallback(this);
mSurfaceView.requestFocus(); mSurfaceView.requestFocus();
getWindow().setGravity(Gravity.CENTER); getWindow().setGravity(Gravity.CENTER);
changeGameSize();
} else { } else {
mLayout.addView(view, lp); mLayout.addView(view, lp);
getWindow().setLayout(w, h); if (RESIZE_WINDOW) {
getWindow().setGravity(Gravity.CENTER); getWindow().setLayout(w, h);
getWindow().setGravity(Gravity.CENTER);
}
super.setContentView(mLayout); super.setContentView(mLayout);
} }
} }
...@@ -332,12 +333,14 @@ public class YGOMobileActivity extends NativeActivity implements ...@@ -332,12 +333,14 @@ public class YGOMobileActivity extends NativeActivity implements
// Log.i("ygo", "Android command setInputFix2:posX=" + spX + ",posY=" + spY); // Log.i("ygo", "Android command setInputFix2:posX=" + spX + ",posY=" + spY);
IrrlichtBridge.setInputFix(mPositionX, mPositionY); IrrlichtBridge.setInputFix(mPositionX, mPositionY);
} }
if (app().isKeepScale()) { if(RESIZE_WINDOW) {
//设置为屏幕宽高 if (app().isKeepScale()) {
getWindow().setLayout(w, h); //设置为屏幕宽高
} else { getWindow().setLayout(w, h);
//拉伸,画布设置为游戏宽高 } else {
getWindow().setLayout(size[0], size[1]); //拉伸,画布设置为游戏宽高
getWindow().setLayout(size[0], size[1]);
}
} }
} }
......
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