mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 08:42:38 +00:00
explicitly set the max refresh rate
This commit is contained in:
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"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,9 @@ import android.os.Message
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.MotionEvent
|
||||
import android.view.Surface
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.customRobTop.BaseRobTopActivity
|
||||
import com.geode.launcher.utils.GeodeUtils
|
||||
|
||||
@@ -113,6 +115,15 @@ class Cocos2dxGLSurfaceView(context: Context) : GLSurfaceView(context) {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
fun updateRefreshRate() {
|
||||
val maxRefreshRate = display.supportedModes.maxBy { it.refreshRate }
|
||||
holder.surface.setFrameRate(
|
||||
maxRefreshRate.refreshRate,
|
||||
Surface.FRAME_RATE_COMPATIBILITY_DEFAULT
|
||||
)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
queueEvent { cocos2dxRenderer.handleOnPause() }
|
||||
super.onPause()
|
||||
|
||||
@@ -101,6 +101,7 @@
|
||||
<string name="preference_theme_light">Light</string>
|
||||
<string name="preference_theme_dark">Dark</string>
|
||||
<string name="preference_black_background_name">Black background in dark theme</string>
|
||||
<string name="preference_force_hrr">Force maximum refresh rate</string>
|
||||
|
||||
<string name="preference_display_mode_name">Screen scale</string>
|
||||
<string name="preference_display_mode_select">Select screen scale</string>
|
||||
|
||||
Reference in new issue
Block a user