explicitly set the max refresh rate

This commit is contained in:
qimiko committed 2024-05-22 18:39:06 -07:00
1 parent b7be446ecd
commit 127fd1bfd1
5 files changed
+29 -2

No files matched your search

@@ -59,6 +59,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
private var mReceiver: BroadcastReceiver? = null
private var displayMode = DisplayMode.DEFAULT
private var forceRefreshRate = false
override fun onCreate(savedInstanceState: Bundle?) {
setupUIState()
@@ -377,6 +378,8 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
PreferenceUtils.get(this).getInt(PreferenceUtils.Key.DISPLAY_MODE)
)
forceRefreshRate = PreferenceUtils.get(this).getBoolean(PreferenceUtils.Key.FORCE_HRR)
if (displayMode == DisplayMode.FULLSCREEN && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
}
@@ -414,6 +417,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
mIsRunning = true
// Cocos2dxHelper.onResume()
mGLSurfaceView?.onResume()
if (forceRefreshRate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
mGLSurfaceView?.updateRefreshRate()
}
}
private fun pauseGame() {
@@ -319,6 +319,12 @@ fun SettingsScreen(
preferenceKey = PreferenceUtils.Key.DISPLAY_MODE,
toLabel = { displayOptionToKey(it) }
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
SettingsCard(
title = context.getString(R.string.preference_force_hrr),
preferenceKey = PreferenceUtils.Key.FORCE_HRR,
)
}
OptionsButton(
title = stringResource(R.string.preferences_open_file_manager),
onClick = { onOpenFileManager(context) }
@@ -135,12 +135,13 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
DISMISSED_GJ_UPDATE,
LAUNCH_ARGUMENTS,
LIMIT_ASPECT_RATIO,
DISPLAY_MODE
DISPLAY_MODE,
FORCE_HRR
}
private fun defaultValueForBooleanKey(key: Key): Boolean {
return when (key) {
Key.UPDATE_AUTOMATICALLY -> true
Key.UPDATE_AUTOMATICALLY, Key.FORCE_HRR -> true
Key.RELEASE_CHANNEL -> BuildConfig.DEBUG
else -> false
}
@@ -166,6 +167,7 @@ class PreferenceUtils(private val sharedPreferences: SharedPreferences) {
Key.LAUNCH_ARGUMENTS -> "PreferenceLaunchArguments"
Key.LIMIT_ASPECT_RATIO -> "PreferenceLimitAspectRatio"
Key.DISPLAY_MODE -> "PreferenceDisplayMode"
Key.FORCE_HRR -> "PreferenceForceHighRefreshRate"
}
}