(AndroidAdapter adapter, HWInfo hwInfo, boolean permissiongranted, boolean isTabletDevice)
| 520 | } |
| 521 | |
| 522 | private void initForge(AndroidAdapter adapter, HWInfo hwInfo, boolean permissiongranted, boolean isTabletDevice) { |
| 523 | int totalRAM = hwInfo.getTotalRam(); |
| 524 | |
| 525 | AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); |
| 526 | config.useAccelerometer = false; |
| 527 | config.useCompass = false; |
| 528 | config.useGyroscope = false; |
| 529 | config.useRotationVectorSensor = false; |
| 530 | config.useImmersiveMode = false; |
| 531 | config.nativeLoader = () -> ReLinker.loadLibrary(getContext(), "gdx"); |
| 532 | |
| 533 | if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { |
| 534 | String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't access external storage"; |
| 535 | Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation); |
| 536 | loadGame(hwInfo, "", "", false, adapter, permissiongranted, isTabletDevice, config, true, message); |
| 537 | return; |
| 538 | } |
| 539 | ASSETS_DIR = Build.VERSION.SDK_INT > Build.VERSION_CODES.Q ? getContext().getObbDir() + "/Forge/" : Environment.getExternalStorageDirectory() + "/Forge/"; |
| 540 | if (!FileUtil.ensureDirectoryExists(ASSETS_DIR)) { |
| 541 | String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't access external storage\nPath: " + ASSETS_DIR; |
| 542 | Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation); |
| 543 | loadGame(hwInfo, "", "", false, adapter, permissiongranted, isTabletDevice, config, true, message); |
| 544 | return; |
| 545 | } |
| 546 | //ensure .nomedia file exists in Forge directory so its images |
| 547 | //and other media files don't appear in Gallery or other apps |
| 548 | String noMediaFile = ASSETS_DIR + ".nomedia"; |
| 549 | if (!FileUtil.doesFileExist(noMediaFile)) { |
| 550 | try { |
| 551 | FileUtil.writeFile(noMediaFile, ""); |
| 552 | } catch (Exception e) { |
| 553 | String message = getDeviceName() + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB" + "\n" + "LibGDX " + Version.VERSION + "\n" + "Can't read/write to storage"; |
| 554 | Main.this.setRequestedOrientation(Main.this.getResources().getConfiguration().orientation); |
| 555 | loadGame(hwInfo, "", "", false, adapter, permissiongranted, isTabletDevice, config, true, message); |
| 556 | return; |
| 557 | } |
| 558 | } |
| 559 | //enforce orientation based on whether device is a tablet and user preference |
| 560 | adapter.switchOrientationFile = ASSETS_DIR + "switch_orientation.ini"; |
| 561 | boolean landscapeMode = adapter.isTablet == !FileUtil.doesFileExist(adapter.switchOrientationFile); |
| 562 | |
| 563 | String info = totalRAM < 3500 || Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? "Device Specification Check\n" + getDeviceName() |
| 564 | + "\n" + "Android " + Build.VERSION.RELEASE + "\n" + "RAM " + totalRAM + "MB\n\nRecommended API:" : ""; |
| 565 | // Even though Forge runs on Android 8 as minimum, just show indicator that Android 11 is recommended |
| 566 | String lowV = Build.VERSION.SDK_INT < Build.VERSION_CODES.R ? "\nAPI: Android 11 or higher" : ""; |
| 567 | // also show minimum Device RAM |
| 568 | String lowM = totalRAM < 3500 ? "\nRAM: 4GB RAM or higher" : ""; |
| 569 | if (landscapeMode && Build.VERSION.SDK_INT > Build.VERSION_CODES.Q) { //Android 11 onwards |
| 570 | Main.this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); |
| 571 | } |
| 572 | loadGame(hwInfo, info, lowV + lowM, landscapeMode, adapter, permissiongranted, isTabletDevice, config, false, ""); |
| 573 | } |
| 574 | |
| 575 | @Override |
| 576 | protected void onDestroy() { |
no test coverage detected