launcher setting page

This commit is contained in:
Tungstend 2023-07-14 00:20:09 +08:00
parent 1a7d1f0256
commit b391169ef2
8 changed files with 830 additions and 4 deletions

View File

@ -22,11 +22,14 @@ import com.tungsten.fcl.fragment.EulaFragment;
import com.tungsten.fcl.fragment.RuntimeFragment;
import com.tungsten.fcl.util.RequestCodes;
import com.tungsten.fclauncher.FCLPath;
import com.tungsten.fclcore.util.Logging;
import com.tungsten.fcllibrary.component.FCLActivity;
import com.tungsten.fcllibrary.component.ResultListener;
import com.tungsten.fcllibrary.component.dialog.FCLAlertDialog;
import com.tungsten.fcllibrary.component.theme.ThemeEngine;
import java.io.File;
@SuppressLint("CustomSplashScreen")
public class SplashActivity extends FCLActivity {
@ -84,6 +87,7 @@ public class SplashActivity extends FCLActivity {
private void init() {
FCLPath.loadPaths(this);
Logging.start(new File(FCLPath.FILES_DIR, "logs").toPath());
initFragments();
start();
}

View File

@ -1,18 +1,297 @@
package com.tungsten.fcl.ui.setting;
import static com.tungsten.fcl.setting.ConfigHolder.config;
import static com.tungsten.fclcore.util.Lang.thread;
import static com.tungsten.fclcore.util.Logging.LOG;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CompoundButton;
import android.widget.Toast;
import com.tungsten.fcl.R;
import com.tungsten.fcl.activity.MainActivity;
import com.tungsten.fcl.setting.DownloadProviders;
import com.tungsten.fcl.util.AndroidUtils;
import com.tungsten.fcl.util.FXUtils;
import com.tungsten.fcl.util.RequestCodes;
import com.tungsten.fclauncher.FCLPath;
import com.tungsten.fclcore.fakefx.beans.binding.Bindings;
import com.tungsten.fclcore.task.FetchTask;
import com.tungsten.fclcore.task.Schedulers;
import com.tungsten.fclcore.task.Task;
import com.tungsten.fclcore.util.Logging;
import com.tungsten.fclcore.util.io.FileUtils;
import com.tungsten.fcllibrary.browser.FileBrowser;
import com.tungsten.fcllibrary.browser.options.LibMode;
import com.tungsten.fcllibrary.browser.options.SelectionMode;
import com.tungsten.fcllibrary.component.dialog.FCLAlertDialog;
import com.tungsten.fcllibrary.component.dialog.FCLColorPickerDialog;
import com.tungsten.fcllibrary.component.theme.ThemeEngine;
import com.tungsten.fcllibrary.component.ui.FCLCommonPage;
import com.tungsten.fcllibrary.component.view.FCLButton;
import com.tungsten.fcllibrary.component.view.FCLCheckBox;
import com.tungsten.fcllibrary.component.view.FCLSeekBar;
import com.tungsten.fcllibrary.component.view.FCLSpinner;
import com.tungsten.fcllibrary.component.view.FCLSwitch;
import com.tungsten.fcllibrary.component.view.FCLTextView;
import com.tungsten.fcllibrary.component.view.FCLUILayout;
import com.tungsten.fcllibrary.util.LocaleUtils;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.logging.Level;
public class LauncherSettingPage extends FCLCommonPage implements View.OnClickListener, AdapterView.OnItemSelectedListener, CompoundButton.OnCheckedChangeListener {
private FCLSpinner<String> language;
private FCLButton clearCache;
private FCLButton exportLog;
private FCLButton theme;
private FCLButton ltBackground;
private FCLButton dkBackground;
private FCLButton resetTheme;
private FCLButton resetLtBackground;
private FCLButton resetDkBackground;
private FCLSwitch ignoreNotch;
private FCLCheckBox autoSource;
private FCLSpinner<String> versionList;
private FCLSpinner<String> downloadType;
private FCLCheckBox autoThreads;
private FCLSeekBar threads;
private FCLTextView threadsText;
public class LauncherSettingPage extends FCLCommonPage {
public LauncherSettingPage(Context context, int id, FCLUILayout parent, int resId) {
super(context, id, parent, resId);
}
@Override
public void onCreate() {
super.onCreate();
language = findViewById(R.id.language);
clearCache = findViewById(R.id.clear_cache);
exportLog = findViewById(R.id.export_log);
theme = findViewById(R.id.theme);
ltBackground = findViewById(R.id.background_lt);
dkBackground = findViewById(R.id.background_dk);
resetTheme = findViewById(R.id.reset_theme);
resetLtBackground = findViewById(R.id.reset_background_lt);
resetDkBackground = findViewById(R.id.reset_background_dk);
ignoreNotch = findViewById(R.id.ignore_notch);
autoSource = findViewById(R.id.check_auto_source);
versionList = findViewById(R.id.source_auto);
downloadType = findViewById(R.id.source);
autoThreads = findViewById(R.id.check_auto_threads);
threads = findViewById(R.id.threads);
threadsText = findViewById(R.id.threads_text);
clearCache.setOnClickListener(this);
exportLog.setOnClickListener(this);
theme.setOnClickListener(this);
ltBackground.setOnClickListener(this);
dkBackground.setOnClickListener(this);
resetTheme.setOnClickListener(this);
resetLtBackground.setOnClickListener(this);
resetDkBackground.setOnClickListener(this);
ArrayList<String> languageList = new ArrayList<>();
languageList.add(getContext().getString(R.string.settings_launcher_language_system));
languageList.add(getContext().getString(R.string.settings_launcher_language_english));
languageList.add(getContext().getString(R.string.settings_launcher_language_simplified_chinese));
ArrayAdapter<String> languageAdapter = new ArrayAdapter<>(getContext(), R.layout.item_spinner_auto_tint, languageList);
languageAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown);
language.setAdapter(languageAdapter);
language.setSelection(LocaleUtils.getLanguage(getContext()));
language.setOnItemSelectedListener(this);
ignoreNotch.setChecked(ThemeEngine.getInstance().getTheme().isFullscreen());
ignoreNotch.setOnCheckedChangeListener(this);
autoSource.setChecked(config().autoChooseDownloadTypeProperty().get());
autoSource.addCheckedChangeListener();
autoSource.checkProperty().bindBidirectional(config().autoChooseDownloadTypeProperty());
versionList.visibilityProperty().bind(autoSource.checkProperty());
downloadType.visibilityProperty().bind(autoSource.checkProperty().not());
versionList.setDataList(new ArrayList<>(DownloadProviders.providersById.keySet()));
ArrayList<String> versionListSourceList = new ArrayList<>();
versionListSourceList.add(getContext().getString(R.string.download_provider_official));
versionListSourceList.add(getContext().getString(R.string.download_provider_balanced));
versionListSourceList.add(getContext().getString(R.string.download_provider_mirror));
ArrayAdapter<String> versionListAdapter = new ArrayAdapter<>(getContext(), R.layout.item_spinner_auto_tint, versionListSourceList);
versionListAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown);
versionList.setAdapter(versionListAdapter);
versionList.setSelection(getSourcePosition(config().versionListSourceProperty().get()));
FXUtils.bindSelection(versionList, config().versionListSourceProperty());
downloadType.setDataList(new ArrayList<>(DownloadProviders.rawProviders.keySet()));
ArrayList<String> downloadTypeList = new ArrayList<>();
downloadTypeList.add(getContext().getString(R.string.download_provider_mojang));
downloadTypeList.add(getContext().getString(R.string.download_provider_bmclapi));
downloadTypeList.add(getContext().getString(R.string.download_provider_mcbbs));
ArrayAdapter<String> downloadTypeAdapter = new ArrayAdapter<>(getContext(), R.layout.item_spinner_auto_tint, downloadTypeList);
downloadTypeAdapter.setDropDownViewResource(R.layout.item_spinner_dropdown);
downloadType.setAdapter(downloadTypeAdapter);
downloadType.setSelection(getSourcePosition(config().downloadTypeProperty().get()));
FXUtils.bindSelection(downloadType, config().downloadTypeProperty());
autoThreads.setChecked(config().getAutoDownloadThreads());
autoThreads.addCheckedChangeListener();
autoThreads.checkProperty().bindBidirectional(config().autoDownloadThreadsProperty());
autoThreads.checkProperty().addListener(observable -> {
if (autoThreads.isChecked()) {
config().downloadThreadsProperty().set(FetchTask.DEFAULT_CONCURRENCY);
}
});
threads.setProgress(config().getDownloadThreads());
threads.addProgressListener();
threads.progressProperty().bindBidirectional(config().downloadThreadsProperty());
threadsText.stringProperty().bind(Bindings.createStringBinding(() -> threads.getProgress() + "", threads.progressProperty()));
}
private int getSourcePosition(String source) {
switch (source) {
case "official":
case "mojang":
return 0;
case "mirror":
case "mcbbs":
return 2;
default:
return 1;
}
}
@Override
public Task<?> refresh(Object... param) {
return null;
}
@Override
public void onClick(View v) {
if (v == clearCache) {
FileUtils.cleanDirectoryQuietly(new File(FCLPath.CACHE_DIR).getParentFile());
}
if (v == exportLog) {
thread(() -> {
Path logFile = new File(new File(FCLPath.SHARED_COMMON_DIR).getParent(), "fcl-exported-logs-" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH-mm-ss")) + ".log").toPath().toAbsolutePath();
LOG.info("Exporting logs to " + logFile);
try {
Files.write(logFile, Logging.getRawLogs());
} catch (IOException e) {
Schedulers.androidUIThread().execute(() -> {
FCLAlertDialog.Builder builder = new FCLAlertDialog.Builder(getContext());
builder.setCancelable(false);
builder.setAlertLevel(FCLAlertDialog.AlertLevel.ALERT);
builder.setMessage(getContext().getString(R.string.settings_launcher_launcher_log_export_failed) + "\n" + e);
builder.setNegativeButton(getContext().getString(com.tungsten.fcllibrary.R.string.dialog_positive), null);
builder.create().show();
});
LOG.log(Level.WARNING, "Failed to export logs", e);
return;
}
Schedulers.androidUIThread().execute(() -> {
FCLAlertDialog.Builder builder = new FCLAlertDialog.Builder(getContext());
builder.setCancelable(false);
builder.setAlertLevel(FCLAlertDialog.AlertLevel.INFO);
builder.setMessage(AndroidUtils.getLocalizedText(getContext(), "settings_launcher_launcher_log_export_success", logFile));
builder.setNegativeButton(getContext().getString(com.tungsten.fcllibrary.R.string.dialog_positive), null);
builder.create().show();
});
});
}
if (v == theme) {
FCLColorPickerDialog dialog = new FCLColorPickerDialog(getContext(), ThemeEngine.getInstance().getTheme().getColor(), new FCLColorPickerDialog.Listener() {
@Override
public void onColorChanged(int color) {
ThemeEngine.getInstance().applyColor(color);
}
@Override
public void onPositive(int destColor) {
ThemeEngine.getInstance().applyAndSave(getContext(), destColor);
}
@Override
public void onNegative(int initColor) {
ThemeEngine.getInstance().applyColor(initColor);
}
});
dialog.show();
}
if (v == ltBackground) {
FileBrowser.Builder builder = new FileBrowser.Builder(getContext());
builder.setLibMode(LibMode.FILE_CHOOSER);
builder.setSelectionMode(SelectionMode.SINGLE_SELECTION);
ArrayList<String> suffix = new ArrayList<>();
suffix.add(".png");
builder.setSuffix(suffix);
builder.create().browse(getActivity(), RequestCodes.SELECT_LAUNCHER_BACKGROUND_CODE, ((requestCode, resultCode, data) -> {
if (requestCode == RequestCodes.SELECT_LAUNCHER_BACKGROUND_CODE && resultCode == Activity.RESULT_OK && data != null) {
String path = FileBrowser.getSelectedFiles(data).get(0);
ThemeEngine.getInstance().applyAndSave(getContext(), ((MainActivity) getActivity()).background, path, null);
}
}));
}
if (v == dkBackground) {
FileBrowser.Builder builder = new FileBrowser.Builder(getContext());
builder.setLibMode(LibMode.FILE_CHOOSER);
builder.setSelectionMode(SelectionMode.SINGLE_SELECTION);
ArrayList<String> suffix = new ArrayList<>();
suffix.add(".png");
builder.setSuffix(suffix);
builder.create().browse(getActivity(), RequestCodes.SELECT_LAUNCHER_BACKGROUND_CODE, ((requestCode, resultCode, data) -> {
if (requestCode == RequestCodes.SELECT_LAUNCHER_BACKGROUND_CODE && resultCode == Activity.RESULT_OK && data != null) {
String path = FileBrowser.getSelectedFiles(data).get(0);
ThemeEngine.getInstance().applyAndSave(getContext(), ((MainActivity) getActivity()).background, null, path);
}
}));
}
if (v == resetTheme) {
ThemeEngine.getInstance().applyAndSave(getContext(), getContext().getColor(R.color.default_theme_color));
}
if (v == resetLtBackground) {
new Thread(() -> {
if (!new File(FCLPath.LT_BACKGROUND_PATH).delete() && new File(FCLPath.LT_BACKGROUND_PATH).exists())
Schedulers.androidUIThread().execute(() -> Toast.makeText(getContext(), getContext().getString(R.string.message_failed), Toast.LENGTH_SHORT).show());
Schedulers.androidUIThread().execute(() -> ThemeEngine.getInstance().applyAndSave(getContext(), ((MainActivity) getActivity()).background, null, null));
}).start();
}
if (v == resetDkBackground) {
new Thread(() -> {
if (!new File(FCLPath.DK_BACKGROUND_PATH).delete() && new File(FCLPath.DK_BACKGROUND_PATH).exists())
Schedulers.androidUIThread().execute(() -> Toast.makeText(getContext(), getContext().getString(R.string.message_failed), Toast.LENGTH_SHORT).show());
Schedulers.androidUIThread().execute(() -> ThemeEngine.getInstance().applyAndSave(getContext(), ((MainActivity) getActivity()).background, null, null));
}).start();
}
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if (parent == language) {
LocaleUtils.changeLanguage(getContext(), position);
LocaleUtils.setLanguage(getContext());
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (buttonView == ignoreNotch) {
ThemeEngine.getInstance().applyAndSave(getContext(), getActivity().getWindow(), isChecked);
getActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
}
}
}

View File

@ -33,4 +33,6 @@ public class RequestCodes {
public static final int SELECT_WORLD_EXPORT_CODE = 700;
public static final int SELECT_DATAPACK_CODE = 750;
public static final int SELECT_LAUNCHER_BACKGROUND_CODE = 800;
}

View File

@ -1,10 +1,457 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@color/ui_bg_color"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:paddingTop="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:auto_linear_background_tint="true"
android:background="@drawable/bg_container_white"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_language"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/language"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_cache"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:text="@string/settings_launcher_clear_cache"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/clear_cache"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_debug"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:text="@string/settings_launcher_launcher_log_export"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/export_log"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:auto_linear_background_tint="true"
android:layout_marginTop="10dp"
android:background="@drawable/bg_container_white"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_theme"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:text="@string/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/reset_theme"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:layout_marginStart="10dp"
android:text="@string/button_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/theme"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_background_lt"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:text="@string/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/reset_background_lt"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:layout_marginStart="10dp"
android:text="@string/button_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/background_lt"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_background_dk"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:text="@string/button_reset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/reset_background_dk"/>
<com.tungsten.fcllibrary.component.view.FCLButton
app:ripple="true"
android:layout_marginStart="10dp"
android:text="@string/button_set"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/background_dk"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:minHeight="48dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="8dp"
android:paddingBottom="8dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_ignore_notch"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLSwitch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/ignore_notch"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
<com.tungsten.fcllibrary.component.view.FCLLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:auto_linear_background_tint="true"
android:layout_marginTop="10dp"
android:background="@drawable/bg_container_white"
android:orientation="vertical">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="15dp"
android:paddingBottom="15dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:singleLine="true"
android:text="@string/settings_launcher_download_source"/>
<com.tungsten.fcllibrary.component.view.FCLCheckBox
android:layout_marginTop="10dp"
app:auto_hint_tint="true"
android:text="@string/settings_launcher_download_source_auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/check_auto_source"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_marginTop="10dp"
android:layout_marginStart="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_download_source"/>
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
<com.tungsten.fcllibrary.component.view.FCLSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/source_auto"/>
<com.tungsten.fcllibrary.component.view.FCLSpinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/source"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/darker_gray"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="15dp"
android:paddingBottom="15dp">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:singleLine="true"
android:text="@string/settings_launcher_download"/>
<com.tungsten.fcllibrary.component.view.FCLCheckBox
android:layout_marginTop="10dp"
app:auto_hint_tint="true"
android:text="@string/settings_launcher_download_threads_auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/check_auto_threads"/>
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_marginTop="10dp"
android:layout_marginStart="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<com.tungsten.fcllibrary.component.view.FCLTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:auto_text_tint="true"
android:layout_gravity="center"
android:singleLine="true"
android:text="@string/settings_launcher_download_threads"/>
<com.tungsten.fcllibrary.component.view.FCLSeekBar
android:layout_marginStart="10dp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center"
android:min="1"
android:max="128"
android:id="@+id/threads"/>
<com.tungsten.fcllibrary.component.view.FCLTextView
app:auto_text_tint="true"
android:singleLine="true"
android:layout_marginStart="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="@+id/threads_text"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>
</com.tungsten.fcllibrary.component.view.FCLLinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -99,6 +99,8 @@
<string name="button_remove">删除</string>
<string name="button_remove_confirm">您确定要删除吗?此操作无法撤销!</string>
<string name="button_select_all">全选</string>
<string name="button_set">设置</string>
<string name="button_reset">重置</string>
<string name="community">社区</string>
<string name="community_hint">加入社区以获取最新版本,反馈 bug 等。如果你要加入社区,请遵守社区规定。\n注由于 QQ 群聊人数有限,加入 QQ 群需先赞助10元或以上金额赞助方式见关于页面。</string>
@ -240,6 +242,13 @@
<string name="download_failed">下载失败: %1$s错误码%2$d</string>
<string name="download_failed_empty">没有可供选择的版本</string>
<string name="download_provider_mcbbs">我的世界中文论坛 (https://www.mcbbs.net/)</string>
<string name="download_provider_bmclapi">BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)</string>
<string name="download_provider_mojang">官方 (OptiFine 自动安装使用 BMCLAPI 下载源)</string>
<string name="download_provider_official">尽量使用官方源</string>
<string name="download_provider_balanced">选择加载速度快的下载源</string>
<string name="download_provider_mirror">尽量使用镜像源</string>
<string name="edit_view_clone">复制控件</string>
<string name="edit_view_event">控件事件</string>
<string name="edit_view_info">控件基本信息</string>
@ -664,7 +673,24 @@
<string name="settings_icon">版本图标</string>
<string name="settings_launcher">启动器设置</string>
<string name="settings_launcher_debug">调试</string>
<string name="settings_launcher_cache">缓存文件夹</string>
<string name="settings_launcher_clear_cache">清理缓存</string>
<string name="settings_launcher_download">下载</string>
<string name="settings_launcher_download_threads">并发数</string>
<string name="settings_launcher_download_threads_auto">自动选择并发数</string>
<string name="settings_launcher_download_source">下载源</string>
<string name="settings_launcher_download_source_auto">自动选择下载源</string>
<string name="settings_launcher_language">语言</string>
<string name="settings_launcher_language_system">跟随系统语言</string>
<string name="settings_launcher_launcher_log_export">导出启动器日志</string>
<string name="settings_launcher_launcher_log_export_failed">无法导出日志</string>
<string name="settings_launcher_launcher_log_export_success">日志已被导出至 %s</string>
<string name="settings_launcher_theme">主题</string>
<string name="settings_launcher_background_lt">亮色模式启动器背景图片</string>
<string name="settings_launcher_background_dk">暗色模式启动器背景图片</string>
<string name="settings_launcher_ignore_notch">忽略刘海屏</string>
<string name="settings_launcher_animation_speed">动画速度</string>
<string name="settings_memory">游戏内存</string>
<string name="settings_memory_allocate_auto">最低分配 %1$.1f GB / 实际分配 %2$.1f GB</string>

View File

@ -112,6 +112,8 @@
<string name="button_remove">Remove</string>
<string name="button_remove_confirm">Are you sure you want to permanently remove it? This action cannot be undone!</string>
<string name="button_select_all">Select All</string>
<string name="button_set">Set</string>
<string name="button_reset">Reset</string>
<string name="community">Community</string>
<string name="community_hint">Join our community to get latest version, report bugs, etc. Please follow the community rules if you join.</string>
@ -254,6 +256,13 @@
<string name="download_failed">Failed to download %1$s, response code: %2$d</string>
<string name="download_failed_empty">No versions are available</string>
<string name="download_provider_mcbbs">MCBBS (https://www.mcbbs.net/)</string>
<string name="download_provider_bmclapi">BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)</string>
<string name="download_provider_mojang">Mojang (OptiFine is provided by BMCLAPI)</string>
<string name="download_provider_official">From Official Sources</string>
<string name="download_provider_balanced">From Fastest Available</string>
<string name="download_provider_mirror">From Mirror</string>
<string name="edit_view_clone">Clone View</string>
<string name="edit_view_event">View Event</string>
<string name="edit_view_info">Base View Info</string>
@ -690,7 +699,26 @@
<string name="settings_icon">Icon</string>
<string name="settings_launcher">Launcher Settings</string>
<string name="settings_launcher_debug">Debug</string>
<string name="settings_launcher_cache">Cache Directory</string>
<string name="settings_launcher_clear_cache">Clear cache</string>
<string name="settings_launcher_download">Download</string>
<string name="settings_launcher_download_threads">Threads</string>
<string name="settings_launcher_download_threads_auto">Automatically Determine</string>
<string name="settings_launcher_download_source">Download Source</string>
<string name="settings_launcher_download_source_auto">Auto Choose Download Mirror</string>
<string name="settings_launcher_language">Language</string>
<string name="settings_launcher_language_system">Use System Language</string>
<string name="settings_launcher_language_english" translatable="false">English</string>
<string name="settings_launcher_language_simplified_chinese" translatable="false">简体中文</string>
<string name="settings_launcher_launcher_log_export">Export launcher logs</string>
<string name="settings_launcher_launcher_log_export_failed">Unable to export logs</string>
<string name="settings_launcher_launcher_log_export_success">Logs have been exported to %s</string>
<string name="settings_launcher_theme">Theme</string>
<string name="settings_launcher_background_lt">Light Mode Launcher Background</string>
<string name="settings_launcher_background_dk">Dark Mode Launcher Background</string>
<string name="settings_launcher_ignore_notch">Ignore Notch</string>
<string name="settings_launcher_animation_speed">Animation Speed</string>
<string name="settings_memory">Memory</string>
<string name="settings_memory_allocate_auto">%1$.1f GB Minimum / %2$.1f GB Allocated</string>

View File

@ -10,6 +10,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatSpinner;
import com.tungsten.fclcore.fakefx.beans.property.BooleanProperty;
import com.tungsten.fclcore.fakefx.beans.property.BooleanPropertyBase;
import com.tungsten.fclcore.fakefx.beans.property.ObjectProperty;
import com.tungsten.fclcore.fakefx.beans.property.ObjectPropertyBase;
import com.tungsten.fclcore.task.Schedulers;
@ -21,6 +23,7 @@ public class FCLSpinner<T> extends AppCompatSpinner {
private boolean fromUserOrSystem = false;
private ArrayList<T> dataList;
private ObjectProperty<T> selectedItemProperty;
private BooleanProperty visibilityProperty;
public void addSelectListener() {
setOnItemSelectedListener(new OnItemSelectedListener() {
@ -101,4 +104,36 @@ public class FCLSpinner<T> extends AppCompatSpinner {
return selectedItemProperty;
}
public final void setVisibilityValue(boolean visibility) {
visibilityProperty().set(visibility);
}
public final boolean getVisibilityValue() {
return visibilityProperty == null || visibilityProperty.get();
}
public final BooleanProperty visibilityProperty() {
if (visibilityProperty == null) {
visibilityProperty = new BooleanPropertyBase() {
public void invalidated() {
Schedulers.androidUIThread().execute(() -> {
boolean visible = get();
setVisibility(visible ? VISIBLE : GONE);
});
}
public Object getBean() {
return this;
}
public String getName() {
return "visibility";
}
};
}
return visibilityProperty;
}
}

View File

@ -24,6 +24,11 @@ public class LocaleUtils {
return lang == 2 || (lang == 0 && getSystemLocale().toString().equals(Locale.CHINA.toString()));
}
public static int getLanguage(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences("launcher", Context.MODE_PRIVATE);
return sharedPreferences.getInt("lang", 0);
}
public static Context setLanguage(Context context) {
SharedPreferences sharedPreferences = context.getSharedPreferences("launcher", Context.MODE_PRIVATE);
return updateResources(context, sharedPreferences.getInt("lang", 0));