forked from geode-sdk/android-launcher
add safe mode handling
This commit is contained in:
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.PreferenceUtils
|
||||
import com.geode.launcher.updater.ReleaseManager
|
||||
import com.geode.launcher.utils.GeodeUtils
|
||||
import com.geode.launcher.utils.useCountdownTimer
|
||||
import java.net.ConnectException
|
||||
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)
|
||||
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)
|
||||
|
||||
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
|
||||
fun getLaunchArguments(): String? {
|
||||
activity.get()?.apply {
|
||||
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
|
||||
|
||||
Reference in new issue
Block a user