android: Add premium section and Dark Theme setting
This commit is contained in:
parent
a35107b70d
commit
1a925312c0
@ -14,6 +14,7 @@ import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Settings {
|
||||
public static final String SECTION_PREMIUM = "Premium";
|
||||
public static final String SECTION_CORE = "Core";
|
||||
public static final String SECTION_SYSTEM = "System";
|
||||
public static final String SECTION_CONTROLS = "Controls";
|
||||
@ -26,7 +27,7 @@ public class Settings {
|
||||
private static final Map<String, List<String>> configFileSectionsMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_CONFIG, Arrays.asList(SECTION_CORE, SECTION_SYSTEM, SECTION_CONTROLS, SECTION_RENDERER, SECTION_AUDIO, SECTION_DEBUG));
|
||||
configFileSectionsMap.put(SettingsFile.FILE_NAME_CONFIG, Arrays.asList(SECTION_PREMIUM, SECTION_CORE, SECTION_SYSTEM, SECTION_CONTROLS, SECTION_RENDERER, SECTION_AUDIO, SECTION_DEBUG));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,6 +11,7 @@ import org.citra.citra_emu.utils.DirectoryInitialization;
|
||||
import org.citra.citra_emu.utils.DirectoryInitialization.DirectoryInitializationState;
|
||||
import org.citra.citra_emu.utils.DirectoryStateReceiver;
|
||||
import org.citra.citra_emu.utils.Log;
|
||||
import org.citra.citra_emu.utils.ThemeUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@ -108,6 +109,7 @@ public final class SettingsActivityPresenter {
|
||||
if (mSettings != null && finishing && mShouldSave) {
|
||||
Log.debug("[SettingsActivity] Settings activity stopping. Saving settings to INI...");
|
||||
mSettings.saveSettings(mView);
|
||||
ThemeUtil.applyTheme(mSettings);
|
||||
}
|
||||
|
||||
NativeLibrary.ReloadSettings();
|
||||
|
@ -82,6 +82,9 @@ public final class SettingsFragmentPresenter {
|
||||
case SettingsFile.FILE_NAME_CONFIG:
|
||||
addConfigSettings(sl);
|
||||
break;
|
||||
case Settings.SECTION_PREMIUM:
|
||||
addPremiumSettings(sl);
|
||||
break;
|
||||
case Settings.SECTION_CORE:
|
||||
addGeneralSettings(sl);
|
||||
break;
|
||||
@ -112,6 +115,7 @@ public final class SettingsFragmentPresenter {
|
||||
private void addConfigSettings(ArrayList<SettingsItem> sl) {
|
||||
mView.getActivity().setTitle(R.string.preferences_settings);
|
||||
|
||||
sl.add(new SubmenuSetting(null, null, R.string.preferences_premium, 0, Settings.SECTION_PREMIUM));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.preferences_general, 0, Settings.SECTION_CORE));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.preferences_system, 0, Settings.SECTION_SYSTEM));
|
||||
sl.add(new SubmenuSetting(null, null, R.string.preferences_controls, 0, Settings.SECTION_CONTROLS));
|
||||
@ -120,6 +124,15 @@ public final class SettingsFragmentPresenter {
|
||||
sl.add(new SubmenuSetting(null, null, R.string.preferences_debug, 0, Settings.SECTION_DEBUG));
|
||||
}
|
||||
|
||||
private void addPremiumSettings(ArrayList<SettingsItem> sl) {
|
||||
mView.getActivity().setTitle(R.string.preferences_premium);
|
||||
|
||||
SettingSection premiumSection = mSettings.getSection(Settings.SECTION_PREMIUM);
|
||||
Setting design = premiumSection.getSetting(SettingsFile.KEY_DESIGN);
|
||||
|
||||
sl.add(new SingleChoiceSetting(SettingsFile.KEY_DESIGN, Settings.SECTION_PREMIUM, R.string.design, 0, R.array.designNames, R.array.designValues, 0, design));
|
||||
}
|
||||
|
||||
private void addGeneralSettings(ArrayList<SettingsItem> sl) {
|
||||
mView.getActivity().setTitle(R.string.preferences_general);
|
||||
|
||||
|
@ -35,6 +35,8 @@ public final class SettingsFile {
|
||||
|
||||
public static final String KEY_CPU_JIT = "use_cpu_jit";
|
||||
|
||||
public static final String KEY_DESIGN = "design";
|
||||
|
||||
public static final String KEY_HW_RENDERER = "use_hw_renderer";
|
||||
public static final String KEY_HW_SHADER = "use_hw_shader";
|
||||
public static final String KEY_SHADERS_ACCURATE_MUL = "shaders_accurate_mul";
|
||||
@ -148,10 +150,12 @@ public final class SettingsFile {
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.error("[SettingsFile] File not found: " + ini.getAbsolutePath() + e.getMessage());
|
||||
view.onSettingsFileNotFound();
|
||||
if (view != null)
|
||||
view.onSettingsFileNotFound();
|
||||
} catch (IOException e) {
|
||||
Log.error("[SettingsFile] Error reading from: " + ini.getAbsolutePath() + e.getMessage());
|
||||
view.onSettingsFileNotFound();
|
||||
if (view != null)
|
||||
view.onSettingsFileNotFound();
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
|
@ -22,6 +22,7 @@ import org.citra.citra_emu.utils.DirectoryInitialization;
|
||||
import org.citra.citra_emu.utils.FileBrowserHelper;
|
||||
import org.citra.citra_emu.utils.PermissionsHandler;
|
||||
import org.citra.citra_emu.utils.StartupHandler;
|
||||
import org.citra.citra_emu.utils.ThemeUtil;
|
||||
|
||||
/**
|
||||
* The main Activity of the Lollipop style UI. Manages several PlatformGamesFragments, which
|
||||
@ -47,6 +48,7 @@ public final class MainActivity extends AppCompatActivity implements MainView {
|
||||
mPresenter.onCreate();
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
ThemeUtil.applyTheme();
|
||||
StartupHandler.HandleInit(this);
|
||||
if (PermissionsHandler.hasWriteAccess(this)) {
|
||||
mPlatformGamesFragment = new PlatformGamesFragment();
|
||||
|
@ -0,0 +1,42 @@
|
||||
package org.citra.citra_emu.utils;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import org.citra.citra_emu.features.settings.model.Setting;
|
||||
import org.citra.citra_emu.features.settings.model.Settings;
|
||||
import org.citra.citra_emu.features.settings.utils.SettingsFile;
|
||||
|
||||
public class ThemeUtil {
|
||||
|
||||
public static void applyTheme() {
|
||||
Settings settings = new Settings();
|
||||
settings.loadSettings(null);
|
||||
applyTheme(settings);
|
||||
}
|
||||
|
||||
public static void applyTheme(Settings settings) {
|
||||
Setting design = settings.getSection(Settings.SECTION_PREMIUM).getSetting((SettingsFile.KEY_DESIGN));
|
||||
if (design == null) {
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
return;
|
||||
}
|
||||
|
||||
int designValue = Integer.parseInt(design.getValueAsString());
|
||||
switch (designValue) {
|
||||
case 0:
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
|
||||
break;
|
||||
case 1:
|
||||
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
|
||||
break;
|
||||
case 2:
|
||||
AppCompatDelegate.setDefaultNightMode(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q ?
|
||||
AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM :
|
||||
AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,11 @@
|
||||
namespace DefaultINI {
|
||||
|
||||
const char* sdl2_config_file = R"(
|
||||
[Premium]
|
||||
# What Android design to use
|
||||
# 0 (default): Light, 1: Dark, 2: System default
|
||||
design =
|
||||
|
||||
[Controls]
|
||||
# The input devices and parameters for each 3DS native input
|
||||
# It should be in the format of "engine:[engine_name],[param1]:[value1],[param2]:[value2]..."
|
||||
|
@ -12,6 +12,18 @@
|
||||
<item>1</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="designNames" translatable="true">
|
||||
<item>Light</item>
|
||||
<item>Dark</item>
|
||||
<item>System default</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="designValues" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="regionNames">
|
||||
<item>Auto-select</item>
|
||||
<item>Japan</item>
|
||||
|
@ -41,6 +41,7 @@
|
||||
<string name="cpu_jit_description">Uses the Just-in-Time (JIT) compiler for CPU emulation. When enabled, game performance will be significantly improved.</string>
|
||||
<string name="init_clock">System clock type</string>
|
||||
<string name="init_clock_description">Set the emulated 3DS clock to either reflect that of your device or start at a simulated date and time.</string>
|
||||
<string name="design">Design</string>
|
||||
|
||||
<!-- System settings strings -->
|
||||
<string name="init_time">System clock starting time override</string>
|
||||
@ -92,6 +93,7 @@
|
||||
|
||||
<!-- Preferences Screen -->
|
||||
<string name="preferences_settings">Settings</string>
|
||||
<string name="preferences_premium">Premium</string>
|
||||
<string name="preferences_general">General</string>
|
||||
<string name="preferences_system">System</string>
|
||||
<string name="preferences_controls">Gamepad</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user