Files
AVA2/android/app/src/main/java/com/metin2/ava2/Ava2Activity.java
T
shenleiandClaude Opus 5.5 c132891aef Mobile HUD: minimap radar in its frame, top row at the screen edge
Preview radar drew at the fixed PC spot; it now follows the uiminimap
window (CPythonMiniMap::GetScreenPosition) and its open state. On
Android the top safe inset came from the hidden status bar's gesture
zone; Ava2Surface takes the top only from the cutout and visible bars.
The preview keyboard-hint header is skipped in touch mode, and
--game-script also runs with --preview-data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 11:15:37 +09:00

69 lines
2.9 KiB
Java

package com.metin2.ava2;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.graphics.Insets;
import android.os.Build;
import android.view.View;
import android.view.WindowInsets;
import org.libsdl.app.SDLActivity;
import org.libsdl.app.SDLSurface;
/**
* SDLActivity with command-line arguments for development runs:
* {@code adb shell "am start -n com.metin2.ava2/.Ava2Activity --es args '--phase game --preview-data'"}.
* A normal launch (no extra) passes none, as before.
*/
public class Ava2Activity extends SDLActivity {
@Override
protected String[] getArguments() {
String args = getIntent() != null ? getIntent().getStringExtra("args") : null;
if (args == null || args.trim().isEmpty()) return new String[0];
return args.trim().split("\\s+");
}
/**
* The game is landscape-only. SDL re-requests an orientation whenever a window is created or
* resized (FULL_USER for a resizable window without SDL_HINT_ORIENTATIONS), which would override
* the manifest's sensorLandscape; keep both landscape directions regardless of the hint.
*/
@Override
public void setOrientationBis(int w, int h, boolean resizable, String hint) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
}
@Override
protected SDLSurface createSDLSurface(Context context) {
return new Ava2Surface(context);
}
/**
* SDL folds the system-gesture insets into the safe area. In landscape fullscreen the status bar
* is hidden, but its swipe-down gesture zone still reported a 120 px top inset, which pushed the
* top HUD row down. Keep SDL's left/right/bottom; take the top only from what really covers the
* screen there (display cutout and visible system bars).
*/
static class Ava2Surface extends SDLSurface {
Ava2Surface(Context context) {
super(context);
}
@Override
public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) {
WindowInsets result = super.onApplyWindowInsets(v, insets);
if (Build.VERSION.SDK_INT >= 30 /* Android 11 (R) */) {
Insets combined = insets.getInsets(WindowInsets.Type.systemBars() |
WindowInsets.Type.systemGestures() |
WindowInsets.Type.mandatorySystemGestures() |
WindowInsets.Type.tappableElement() |
WindowInsets.Type.displayCutout());
Insets covering = insets.getInsets(WindowInsets.Type.systemBars() |
WindowInsets.Type.displayCutout());
SDLActivity.onNativeInsetsChanged(combined.left, combined.right, covering.top, combined.bottom);
}
return result;
}
}
}