redirect main to launch

This commit is contained in:
qimiko committed 2022-05-23 11:45:58 -07:00
1 parent 5cb05795f1
commit 6e770d3827
5 files changed
+27 -22

No files matched your search

@@ -1,5 +1,6 @@
package com.robtopx.geometryjump
import android.content.pm.PackageManager
import dalvik.system.BaseDexClassLoader
import java.io.File
@@ -41,4 +42,12 @@ object LaunchUtils {
}
}
fun isGeometryDashInstalled(packageManager: PackageManager): Boolean {
return try {
packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
true
} catch (e: PackageManager.NameNotFoundException) {
false
}
}
}
@@ -1,10 +1,9 @@
package dev.xyze.geodelauncher
import android.content.Intent
import android.content.pm.ActivityInfo
import android.os.Build
import android.os.Bundle
import android.os.Environment
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
@@ -32,6 +31,14 @@ class GeometryDashActivity : ComponentActivity(), Cocos2dxHelper.Cocos2dxHelperL
override fun onCreate(savedInstanceState: Bundle?) {
setupUIState()
// return back to main if Geometry Dash isn't found
if (!LaunchUtils.isGeometryDashInstalled(packageManager)) {
val launchIntent = Intent(this, MainActivity::class.java)
launchIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(launchIntent)
}
val gdPackageInfo = packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
val gdNativeLibraryPath = "${gdPackageInfo.applicationInfo.nativeLibraryDir}/"
@@ -2,7 +2,6 @@ package dev.xyze.geodelauncher
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.widget.Toast
import androidx.activity.ComponentActivity
@@ -21,7 +20,7 @@ import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.robtopx.geometryjump.GJConstants
import com.robtopx.geometryjump.LaunchUtils
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
@@ -29,7 +28,7 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val gdInstalled = isGeometryDashInstalled(packageManager)
val gdInstalled = LaunchUtils.isGeometryDashInstalled(packageManager)
setContent {
GeodeLauncherTheme {
@@ -52,15 +51,6 @@ fun onSettings(context: Context) {
Toast.makeText(context, "Settings are not implemented yet!", Toast.LENGTH_SHORT).show()
}
fun isGeometryDashInstalled(packageManager: PackageManager): Boolean {
return try {
packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
true
} catch (e: PackageManager.NameNotFoundException) {
false
}
}
@Composable
fun MainScreen(gdInstalled: Boolean = true) {
val context = LocalContext.current