add safe mode handling

This commit is contained in:
qimiko committed 2024-01-30 00:06:29 -07:00
1 parent f197b45f9e
commit 84657fd6b3
2 files changed
+24 -2

No files matched your search

@@ -46,6 +46,7 @@ import com.geode.launcher.utils.Constants
import com.geode.launcher.utils.LaunchUtils import com.geode.launcher.utils.LaunchUtils
import com.geode.launcher.utils.PreferenceUtils import com.geode.launcher.utils.PreferenceUtils
import com.geode.launcher.updater.ReleaseManager import com.geode.launcher.updater.ReleaseManager
import com.geode.launcher.utils.GeodeUtils
import com.geode.launcher.utils.useCountdownTimer import com.geode.launcher.utils.useCountdownTimer
import java.net.ConnectException import java.net.ConnectException
import java.net.UnknownHostException import java.net.UnknownHostException
@@ -389,7 +390,13 @@ fun UpdateCard(releaseViewModel: ReleaseViewModel, modifier: Modifier = Modifier
} }
} }
fun onLaunch(context: Context) { fun onLaunch(context: Context, safeMode: Boolean = false) {
if (safeMode) {
GeodeUtils.setAdditionalLaunchArguments(GeodeUtils.ARGUMENT_SAFE_MODE)
} else {
GeodeUtils.clearLaunchArguments()
}
val launchIntent = Intent(context, GeometryDashActivity::class.java) val launchIntent = Intent(context, GeometryDashActivity::class.java)
launchIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK launchIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
@@ -347,11 +347,26 @@ object GeodeUtils {
private external fun permissionCallback(granted: Boolean) private external fun permissionCallback(granted: Boolean)
const val ARGUMENT_SAFE_MODE = "--geode:safe-mode"
private var additionalLaunchArguments = arrayListOf<String>()
fun setAdditionalLaunchArguments(vararg args: String) {
additionalLaunchArguments.addAll(args)
}
fun clearLaunchArguments() = setAdditionalLaunchArguments()
@JvmStatic @JvmStatic
fun getLaunchArguments(): String? { fun getLaunchArguments(): String? {
activity.get()?.apply { activity.get()?.apply {
val preferences = PreferenceUtils.get(this) val preferences = PreferenceUtils.get(this)
return preferences.getString(PreferenceUtils.Key.LAUNCH_ARGUMENTS)
val userArgs = preferences.getString(PreferenceUtils.Key.LAUNCH_ARGUMENTS)
val args = if (!userArgs.isNullOrEmpty()) {
listOf(userArgs) + additionalLaunchArguments
} else additionalLaunchArguments
return args.joinToString(" ")
} }
return null return null