|
12 | 12 | import android.content.SharedPreferences.Editor; |
13 | 13 | import android.content.pm.PackageInfo; |
14 | 14 | import android.content.pm.PackageManager; |
| 15 | +import android.content.res.Configuration; |
15 | 16 | import android.graphics.Color; |
16 | 17 | import android.graphics.PixelFormat; |
17 | 18 | import android.hardware.display.DisplayManager; |
|
31 | 32 | import android.widget.RelativeLayout.LayoutParams; |
32 | 33 | import android.widget.Toast; |
33 | 34 |
|
| 35 | +import androidx.annotation.NonNull; |
34 | 36 | import androidx.core.content.PermissionChecker; |
35 | 37 | import androidx.preference.PreferenceManager; |
36 | 38 |
|
|
51 | 53 | import com.osudroid.ui.v2.multi.LobbyScene; |
52 | 54 |
|
53 | 55 | import com.osudroid.ui.v2.modmenu.ModMenu; |
| 56 | +import com.reco1l.osu.ui.MessageDialog; |
54 | 57 | import com.rian.osu.difficulty.BeatmapDifficultyCalculator; |
55 | 58 | import net.lingala.zip4j.ZipFile; |
56 | 59 |
|
@@ -109,6 +112,7 @@ public class MainActivity extends BaseGameActivity implements |
109 | 112 | private DisplayManager.DisplayListener displayListener; |
110 | 113 | private float currentRefreshRate = 60; |
111 | 114 | private float maxRefreshRate = 60; |
| 115 | + private MessageDialog multiWindowAlert; |
112 | 116 |
|
113 | 117 | // Multiplayer |
114 | 118 | private Uri roomInviteLink; |
@@ -635,6 +639,11 @@ public void onResume() { |
635 | 639 | return; |
636 | 640 | } |
637 | 641 |
|
| 642 | + if (isInMultiWindowMode()) { |
| 643 | + showMultiModeWindowAlert(); |
| 644 | + return; |
| 645 | + } |
| 646 | + |
638 | 647 | var gameScene = GlobalManager.getInstance().getGameScene(); |
639 | 648 |
|
640 | 649 | if (gameScene != null && mEngine.getScene() == gameScene.getScene()) { |
@@ -725,6 +734,17 @@ public void onWindowFocusChanged(boolean hasFocus) { |
725 | 734 | | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); |
726 | 735 | } |
727 | 736 |
|
| 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 | + |
728 | 748 | @Override |
729 | 749 | public void onAccelerometerChanged(final AccelerometerData arg0) { |
730 | 750 | if (this.mEngine == null) { |
@@ -931,4 +951,24 @@ private boolean checkPermissions() { |
931 | 951 | } |
932 | 952 | } |
933 | 953 |
|
| 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 | + } |
934 | 974 | } |
0 commit comments