New option: sustained performance

This commit is contained in:
SerpentSpirale 2021-11-14 14:51:36 +01:00
parent 154fb36cb0
commit 14529f109b
5 changed files with 24 additions and 0 deletions

View File

@ -14,6 +14,7 @@ import net.kdt.pojavlaunch.utils.MCOptionUtils;
import java.io.*; import java.io.*;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF; import static net.kdt.pojavlaunch.prefs.LauncherPreferences.DEFAULT_PREF;
import static net.kdt.pojavlaunch.prefs.LauncherPreferences.PREF_SUSTAINED_PERFORMANCE;
public class MainActivity extends BaseMainActivity { public class MainActivity extends BaseMainActivity {
public static ControlLayout mControlLayout; public static ControlLayout mControlLayout;
@ -24,6 +25,11 @@ public class MainActivity extends BaseMainActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
initLayout(R.layout.main_with_customctrl); initLayout(R.layout.main_with_customctrl);
// Set the sustained performance mode for available APIs
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
getWindow().setSustainedPerformanceMode(PREF_SUSTAINED_PERFORMANCE);
super.ingameControlsEditorListener = menuItem -> { super.ingameControlsEditorListener = menuItem -> {
switch (menuItem.getItemId()) { switch (menuItem.getItemId()) {
case R.id.menu_ctrl_load: case R.id.menu_ctrl_load:

View File

@ -33,6 +33,7 @@ public class LauncherPreferences
public static int PREF_CONTROL_RIGHT_OFFSET = 0; public static int PREF_CONTROL_RIGHT_OFFSET = 0;
public static int PREF_CONTROL_BOTTOM_OFFSET = 0; public static int PREF_CONTROL_BOTTOM_OFFSET = 0;
public static int PREF_CONTROL_LEFT_OFFSET = 0; public static int PREF_CONTROL_LEFT_OFFSET = 0;
public static boolean PREF_SUSTAINED_PERFORMANCE = false;
public static void loadPreferences(Context ctx) { public static void loadPreferences(Context ctx) {
@ -61,6 +62,7 @@ public class LauncherPreferences
PREF_CONTROL_RIGHT_OFFSET = DEFAULT_PREF.getInt("controlRightOffset", 0); PREF_CONTROL_RIGHT_OFFSET = DEFAULT_PREF.getInt("controlRightOffset", 0);
PREF_CONTROL_BOTTOM_OFFSET = DEFAULT_PREF.getInt("controlBottomOffset", 0); PREF_CONTROL_BOTTOM_OFFSET = DEFAULT_PREF.getInt("controlBottomOffset", 0);
PREF_CONTROL_LEFT_OFFSET = DEFAULT_PREF.getInt("controlTopOffset", 0); PREF_CONTROL_LEFT_OFFSET = DEFAULT_PREF.getInt("controlTopOffset", 0);
PREF_SUSTAINED_PERFORMANCE = DEFAULT_PREF.getBoolean("sustainedPerformance", false);
/* /*
if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) { if (PREF_CUSTOM_JAVA_ARGS.isEmpty()) {

View File

@ -1,12 +1,19 @@
package net.kdt.pojavlaunch.prefs.screens; package net.kdt.pojavlaunch.prefs.screens;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.preference.SwitchPreference;
import net.kdt.pojavlaunch.R; import net.kdt.pojavlaunch.R;
public class LauncherPreferenceMiscellaneousFragment extends LauncherPreferenceFragment { public class LauncherPreferenceMiscellaneousFragment extends LauncherPreferenceFragment {
@Override @Override
public void onCreatePreferences(Bundle b, String str) { public void onCreatePreferences(Bundle b, String str) {
addPreferencesFromResource(R.xml.pref_misc); addPreferencesFromResource(R.xml.pref_misc);
// Sustained performance is only available since Nougat
SwitchPreference sustainedPerfSwitch = findPreference("sustainedPerformance");
sustainedPerfSwitch.setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N);
} }
} }

View File

@ -274,6 +274,8 @@
<string name="preference_misc_description">Version list, and libs checks</string> <string name="preference_misc_description">Version list, and libs checks</string>
<string name="preference_experimental_title">Experimental Stuff</string> <string name="preference_experimental_title">Experimental Stuff</string>
<string name="preference_experimental_description">Use things there with consideration, no support.</string> <string name="preference_experimental_description">Use things there with consideration, no support.</string>
<string name="preference_sustained_performance_title">Enable sustained performance mode</string>
<string name="preference_sustained_performance_description">Limit thermal throttling by limiting peak performance</string>
<string name="preference_back_title">Back to the last screen</string> <string name="preference_back_title">Back to the last screen</string>

View File

@ -6,6 +6,13 @@
<PreferenceCategory android:title="Miscellaneous settings"> <PreferenceCategory android:title="Miscellaneous settings">
<SwitchPreference
android:title="@string/preference_sustained_performance_title"
android:summary="@string/preference_sustained_performance_description"
android:key="sustainedPerformance"
android:defaultValue="false"
/>
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="hideSidebar" android:key="hideSidebar"