Skip to content

Commit dec5380

Browse files
committed
Disable multi-window mode
As per Android manifest, the game does not support resizing (for good reasons). However, Android 12 may force multi-window mode in large screens or bypass the manifest setting entirely. This change aims to prevent that.
1 parent a6f885b commit dec5380

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

res/values/strings_temporary_for_locals.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,7 @@
7878

7979
<string name="opt_prefer_no_video_downloads_title">Prefer downloads without video</string>
8080
<string name="opt_prefer_no_video_downloads_summary">Prefer downloading beatmaps without video in beatmap downloader if the selected beatmap mirror supports it</string>
81+
82+
<string name="multi_mode_window_alert_title">Multi-window Mode</string>
83+
<string name="multi_mode_window_alert_message">osu!droid does not support multi-window mode. Please switch back to single-window mode to continue playing.</string>
8184
</resources>

src/ru/nsu/ccfit/zuev/osu/MainActivity.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import android.content.SharedPreferences.Editor;
1313
import android.content.pm.PackageInfo;
1414
import android.content.pm.PackageManager;
15+
import android.content.res.Configuration;
1516
import android.graphics.Color;
1617
import android.graphics.PixelFormat;
1718
import android.hardware.display.DisplayManager;
@@ -31,6 +32,7 @@
3132
import android.widget.RelativeLayout.LayoutParams;
3233
import android.widget.Toast;
3334

35+
import androidx.annotation.NonNull;
3436
import androidx.core.content.PermissionChecker;
3537
import androidx.preference.PreferenceManager;
3638

@@ -51,6 +53,7 @@
5153
import com.osudroid.ui.v2.multi.LobbyScene;
5254

5355
import com.osudroid.ui.v2.modmenu.ModMenu;
56+
import com.reco1l.osu.ui.MessageDialog;
5457
import com.rian.osu.difficulty.BeatmapDifficultyCalculator;
5558
import net.lingala.zip4j.ZipFile;
5659

@@ -109,6 +112,7 @@ public class MainActivity extends BaseGameActivity implements
109112
private DisplayManager.DisplayListener displayListener;
110113
private float currentRefreshRate = 60;
111114
private float maxRefreshRate = 60;
115+
private MessageDialog multiWindowAlert;
112116

113117
// Multiplayer
114118
private Uri roomInviteLink;
@@ -635,6 +639,11 @@ public void onResume() {
635639
return;
636640
}
637641

642+
if (isInMultiWindowMode()) {
643+
showMultiModeWindowAlert();
644+
return;
645+
}
646+
638647
var gameScene = GlobalManager.getInstance().getGameScene();
639648

640649
if (gameScene != null && mEngine.getScene() == gameScene.getScene()) {
@@ -725,6 +734,17 @@ public void onWindowFocusChanged(boolean hasFocus) {
725734
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
726735
}
727736

737+
@Override
738+
public void onMultiWindowModeChanged(boolean isInMultiWindowMode, @NonNull Configuration newConfig) {
739+
super.onMultiWindowModeChanged(isInMultiWindowMode, newConfig);
740+
741+
if (isInMultiWindowMode) {
742+
showMultiModeWindowAlert();
743+
} else {
744+
hideMultiModeWindowAlert();
745+
}
746+
}
747+
728748
@Override
729749
public void onAccelerometerChanged(final AccelerometerData arg0) {
730750
if (this.mEngine == null) {
@@ -931,4 +951,24 @@ private boolean checkPermissions() {
931951
}
932952
}
933953

954+
private void showMultiModeWindowAlert() {
955+
if (multiWindowAlert == null) {
956+
multiWindowAlert = new MessageDialog()
957+
.setTitle(getString(R.string.multi_mode_window_alert_title))
958+
.setMessage(getString(R.string.multi_mode_window_alert_message))
959+
.setAllowDismiss(false)
960+
.addButton(getString(com.osudroid.resources.R.string.accessibility_detector_exit), (d) -> {
961+
finish();
962+
return null;
963+
});
964+
}
965+
966+
multiWindowAlert.show();
967+
}
968+
969+
private void hideMultiModeWindowAlert() {
970+
if (multiWindowAlert != null) {
971+
multiWindowAlert.dismiss();
972+
}
973+
}
934974
}

0 commit comments

Comments
 (0)