mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2025-09-13 23:00:45 -04:00
Fix offset on-screen controls on desktop mode.
This commit is contained in:
parent
b32123ba58
commit
6ba6ea2db7
@ -317,6 +317,7 @@ public class PojavLauncherActivity extends BaseLauncherActivity
|
|||||||
PREF_NOTCH_SIZE = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout().getBoundingRects().get(0).width();
|
PREF_NOTCH_SIZE = getWindow().getDecorView().getRootWindowInsets().getDisplayCutout().getBoundingRects().get(0).width();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
Log.i("NOTCH DETECTION", "No notch detected, or the device if in split screen mode");
|
Log.i("NOTCH DETECTION", "No notch detected, or the device if in split screen mode");
|
||||||
|
PREF_NOTCH_SIZE = -1;
|
||||||
}
|
}
|
||||||
Tools.updateWindowSize(this);
|
Tools.updateWindowSize(this);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@ import org.lwjgl.glfw.*;
|
|||||||
import android.view.*;
|
import android.view.*;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static android.os.Build.VERSION_CODES.P;
|
import static android.os.Build.VERSION_CODES.P;
|
||||||
|
import static android.os.Build.VERSION_CODES.Q;
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;
|
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_IGNORE_NOTCH;
|
||||||
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_NOTCH_SIZE;
|
||||||
|
|
||||||
@ -79,7 +81,7 @@ public final class Tools {
|
|||||||
public static void initContextConstants(Context ctx){
|
public static void initContextConstants(Context ctx){
|
||||||
DIR_DATA = ctx.getFilesDir().getParent();
|
DIR_DATA = ctx.getFilesDir().getParent();
|
||||||
MULTIRT_HOME = DIR_DATA+"/runtimes";
|
MULTIRT_HOME = DIR_DATA+"/runtimes";
|
||||||
if(Build.VERSION.SDK_INT >= 29) {
|
if(SDK_INT >= 29) {
|
||||||
DIR_GAME_HOME = ctx.getExternalFilesDir(null).getAbsolutePath();
|
DIR_GAME_HOME = ctx.getExternalFilesDir(null).getAbsolutePath();
|
||||||
}else{
|
}else{
|
||||||
DIR_GAME_HOME = new File(Environment.getExternalStorageDirectory(),"games/PojavLauncher").getAbsolutePath();
|
DIR_GAME_HOME = new File(Environment.getExternalStorageDirectory(),"games/PojavLauncher").getAbsolutePath();
|
||||||
@ -338,11 +340,12 @@ public final class Tools {
|
|||||||
public static DisplayMetrics getDisplayMetrics(Activity ctx) {
|
public static DisplayMetrics getDisplayMetrics(Activity ctx) {
|
||||||
DisplayMetrics displayMetrics = new DisplayMetrics();
|
DisplayMetrics displayMetrics = new DisplayMetrics();
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && (ctx.isInMultiWindowMode() || ctx.isInPictureInPictureMode())){
|
if(SDK_INT >= Build.VERSION_CODES.N && (ctx.isInMultiWindowMode() || ctx.isInPictureInPictureMode())
|
||||||
|
|| PREF_NOTCH_SIZE == -1 ){
|
||||||
//For devices with free form/split screen, we need window size, not screen size.
|
//For devices with free form/split screen, we need window size, not screen size.
|
||||||
displayMetrics = ctx.getResources().getDisplayMetrics();
|
displayMetrics = ctx.getResources().getDisplayMetrics();
|
||||||
}else{
|
}else{
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
if (SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
ctx.getDisplay().getRealMetrics(displayMetrics);
|
ctx.getDisplay().getRealMetrics(displayMetrics);
|
||||||
} else {
|
} else {
|
||||||
ctx.getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
|
ctx.getWindowManager().getDefaultDisplay().getRealMetrics(displayMetrics);
|
||||||
@ -828,7 +831,7 @@ public final class Tools {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ignoreNotch(boolean shouldIgnore, Activity ctx){
|
public static void ignoreNotch(boolean shouldIgnore, Activity ctx){
|
||||||
if (Build.VERSION.SDK_INT >= P) {
|
if (SDK_INT >= P) {
|
||||||
if (shouldIgnore) {
|
if (shouldIgnore) {
|
||||||
ctx.getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
ctx.getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user