mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-21 02:09:05 +02:00
Android: Preparation for future cutout (notch) support
This commit is contained in:
1 parent
ccda27edcf
commit
d5f2d74257
4 files changed
+42
-5
No files matched your search
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="black">#FF000000</color>
|
||||
<style name="ppsspp_style">
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:navigationBarColor">@color/black</item>
|
||||
<!-- TODO: Our rendering is not ready for these yet.
|
||||
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
|
||||
<item name="android:windowTranslucentStatus">true</item>
|
||||
<item name="android:windowTranslucentNavigation">true</item> -->
|
||||
</style>
|
||||
</resources>
|
||||
@@ -31,6 +31,7 @@ import android.text.InputType;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Display;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.Gravity;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.InputDevice;
|
||||
@@ -119,6 +120,11 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
private int pixelWidth;
|
||||
private int pixelHeight;
|
||||
|
||||
private int safeInsetLeft = 0;
|
||||
private int safeInsetRight = 0;
|
||||
private int safeInsetTop = 0;
|
||||
private int safeInsetBottom = 0;
|
||||
|
||||
private static final String[] permissionsForStorage = {
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
};
|
||||
@@ -673,7 +679,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
void setupSystemUiCallback() {
|
||||
View decorView = getWindow().peekDecorView();
|
||||
final View decorView = getWindow().peekDecorView();
|
||||
if (decorView == null || decorView == navigationCallbackView) {
|
||||
return;
|
||||
}
|
||||
@@ -688,6 +694,7 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
navigationHidden = ((visibility & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0);
|
||||
// TODO: Check here if it's the state we want.
|
||||
Log.i(TAG, "SystemUiVisibilityChange! visibility=" + visibility + " navigationHidden: " + navigationHidden);
|
||||
Log.i(TAG, "decorView: " + decorView.getWidth() + "x" + decorView.getHeight());
|
||||
updateDisplayMeasurements();
|
||||
}
|
||||
});
|
||||
@@ -813,6 +820,27 @@ public abstract class NativeActivity extends Activity implements SurfaceHolder.C
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
Log.i(TAG, "onAttachedToWindow");
|
||||
DisplayCutout cutout = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
|
||||
if (cutout != null) {
|
||||
safeInsetLeft = cutout.getSafeInsetLeft();
|
||||
safeInsetRight = cutout.getSafeInsetRight();
|
||||
safeInsetTop = cutout.getSafeInsetTop();
|
||||
safeInsetBottom = cutout.getSafeInsetBottom();
|
||||
Log.i(TAG, "Safe insets: left: " + safeInsetLeft + " right: " + safeInsetRight + " top: " + safeInsetTop + " bottom: " + safeInsetBottom);
|
||||
} else {
|
||||
Log.i(TAG, "Cutout was null");
|
||||
safeInsetLeft = 0;
|
||||
safeInsetRight = 0;
|
||||
safeInsetTop = 0;
|
||||
safeInsetBottom = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
Log.i(TAG, "onConfigurationChanged");
|
||||
|
||||
@@ -125,7 +125,6 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
Log.i(TAG, "onResume");
|
||||
super.onResume();
|
||||
mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
|
||||
if (mController != null) {
|
||||
@@ -136,7 +135,6 @@ public class NativeGLView extends GLSurfaceView implements SensorEventListener,
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "onDestroy");
|
||||
if (mController != null) {
|
||||
mController.exit();
|
||||
}
|
||||
|
||||
@@ -116,7 +116,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
Log.i(TAG, "onPause");
|
||||
mSensorManager.unregisterListener(this);
|
||||
if (mController != null) {
|
||||
mController.onPause();
|
||||
@@ -133,7 +132,6 @@ public class NativeSurfaceView extends SurfaceView implements SensorEventListene
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
Log.i(TAG, "onDestroy");
|
||||
if (mController != null) {
|
||||
mController.exit();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user