Skip to content

Commit 256f112

Browse files
committed
feat: 启动游戏后关闭启动器 #1235
1 parent 75a96b0 commit 256f112

File tree

5 files changed

+34
-2
lines changed

5 files changed

+34
-2
lines changed

FCL/src/main/java/com/tungsten/fcl/game/LauncherHelper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
*/
1818
package com.tungsten.fcl.game;
1919

20+
import static android.content.Context.MODE_PRIVATE;
2021
import static com.tungsten.fcl.util.AndroidUtils.getLocalizedText;
2122
import static com.tungsten.fcl.util.AndroidUtils.hasStringId;
2223
import static com.tungsten.fclcore.util.Logging.LOG;
2324

25+
import android.app.Activity;
2426
import android.content.Context;
2527
import android.content.Intent;
2628
import android.os.Bundle;
@@ -33,6 +35,7 @@
3335
import com.mio.manager.RendererManager;
3436
import com.mio.minecraft.ModCheckException;
3537
import com.mio.minecraft.ModChecker;
38+
import com.tungsten.fcl.FCLApplication;
3639
import com.tungsten.fcl.R;
3740
import com.tungsten.fcl.activity.JVMActivity;
3841
import com.tungsten.fcl.control.MenuType;
@@ -196,6 +199,11 @@ private void launch0() {
196199
intent.putExtras(bundle);
197200
LOG.log(Level.INFO, "Start JVMActivity!");
198201
context.startActivity(intent);
202+
if (context.getSharedPreferences("launcher", MODE_PRIVATE).getBoolean("autoExitLauncher", false)) {
203+
Activity activity = FCLApplication.getCurrentActivity();
204+
if (activity != null)
205+
activity.finish();
206+
}
199207
}))
200208
.withStage("launch.state.waiting_launching"))
201209
.withStagesHint(Lang.immutableListOf(

FCL/src/main/java/com/tungsten/fcl/ui/setting/LauncherSettingPage.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public class LauncherSettingPage extends FCLCommonPage implements View.OnClickLi
7878
private FCLButton clearCache;
7979
private FCLButton exportLog;
8080
private FCLButton requestAudioRecord;
81+
private FCLSwitch autoExitLauncher;
8182
private FCLButton theme;
8283
private FCLButton theme2;
8384
private FCLButton ltBackground;
@@ -112,11 +113,13 @@ public LauncherSettingPage(Context context, int id, FCLUILayout parent, int resI
112113
@Override
113114
public void onCreate() {
114115
super.onCreate();
116+
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("launcher", MODE_PRIVATE);
115117
language = findViewById(R.id.language);
116118
checkUpdate = findViewById(R.id.check_update);
117119
clearCache = findViewById(R.id.clear_cache);
118120
exportLog = findViewById(R.id.export_log);
119121
requestAudioRecord = findViewById(R.id.request_audio_record);
122+
autoExitLauncher = findViewById(R.id.auto_exit_launcher);
120123
theme = findViewById(R.id.theme);
121124
theme2 = findViewById(R.id.theme2);
122125
ltBackground = findViewById(R.id.background_lt);
@@ -184,6 +187,9 @@ public void onCreate() {
184187
language.setSelection(LocaleUtils.getLanguage(getContext()));
185188
language.setOnItemSelectedListener(this);
186189

190+
autoExitLauncher.setChecked(sharedPreferences.getBoolean("autoExitLauncher", false));
191+
autoExitLauncher.setOnCheckedChangeListener(this);
192+
187193
ignoreNotch.setChecked(ThemeEngine.getInstance().getTheme().isFullscreen());
188194
ignoreNotch.setOnCheckedChangeListener(this);
189195

@@ -195,7 +201,6 @@ public void onCreate() {
195201
animationSpeed.progressProperty().bindBidirectional(ThemeEngine.getInstance().getTheme().animationSpeedProperty());
196202
ThemeEngine.getInstance().getTheme().animationSpeedProperty().addListener(observable -> Theme.saveTheme(getContext(), ThemeEngine.getInstance().getTheme()));
197203

198-
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("launcher", MODE_PRIVATE);
199204
vibrationDuration.setProgress(sharedPreferences.getInt("vibrationDuration", 100));
200205
vibrationDuration.addProgressListener();
201206
vibrationDuration.progressProperty().addListener(observable -> {
@@ -529,15 +534,17 @@ public void onNothingSelected(AdapterView<?> parent) {
529534

530535
@Override
531536
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
537+
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("launcher", MODE_PRIVATE);
532538
if (buttonView == ignoreNotch) {
533539
ThemeEngine.getInstance().applyAndSave(getContext(), getActivity().getWindow(), isChecked);
534540
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
535541
} else if (buttonView == closeSkinModel) {
536542
ThemeEngine.getInstance().getTheme().setiIgnoreSkinContainer(isChecked);
537543
Theme.saveTheme(getContext(), ThemeEngine.getInstance().getTheme());
538544
} else if (buttonView == disableFullscreenInput) {
539-
SharedPreferences sharedPreferences = getActivity().getSharedPreferences("launcher", MODE_PRIVATE);
540545
sharedPreferences.edit().putBoolean("disableFullscreenInput", isChecked).apply();
546+
} else if (buttonView == autoExitLauncher) {
547+
sharedPreferences.edit().putBoolean("autoExitLauncher", isChecked).apply();
541548
}
542549
}
543550
}

FCL/src/main/res/layout/page_setting_launcher.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,21 @@
204204

205205
</androidx.appcompat.widget.LinearLayoutCompat>
206206

207+
<View
208+
android:layout_width="match_parent"
209+
android:layout_height="1dp"
210+
android:background="@android:color/darker_gray" />
211+
212+
<com.tungsten.fcllibrary.component.view.FCLSwitch
213+
android:id="@+id/auto_exit_launcher"
214+
android:text="@string/settings_launcher_exit_after_launching"
215+
android:paddingStart="12dp"
216+
android:paddingTop="8dp"
217+
android:paddingEnd="12dp"
218+
android:paddingBottom="8dp"
219+
android:layout_width="match_parent"
220+
android:layout_height="wrap_content"/>
221+
207222
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
208223

209224
<com.tungsten.fcllibrary.component.view.FCLLinearLayout

FCL/src/main/res/values-zh/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@
838838
<string name="settings_launcher_animation_speed">动画速度</string>
839839
<string name="settings_launcher_vibrate_duration">震动时长(用于TouchController模组)</string>
840840
<string name="settings_disable_fullscreen_input">禁用全屏输入(用于TouchController模组)</string>
841+
<string name="settings_launcher_exit_after_launching">启动器启动后自动关闭</string>
841842

842843
<string name="settings_memory">游戏内存</string>
843844
<string name="settings_memory_allocate_auto">最低分配 %1$.1f GB / 实际分配 %2$.1f GB</string>

FCL/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@
898898
<string name="settings_launcher_animation_speed">Animation Speed</string>
899899
<string name="settings_launcher_vibrate_duration">Vibration Duration (For TouchController mod)</string>
900900
<string name="settings_disable_fullscreen_input">Disable fullscreen input (For TouchController mod)</string>
901+
<string name="settings_launcher_exit_after_launching">Launcher exits after launching</string>
901902

902903
<string name="settings_memory">Memory</string>
903904
<string name="settings_memory_allocate_auto">%1$.1f GB Minimum / %2$.1f GB Allocated</string>

0 commit comments

Comments
 (0)