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

+6 -7
View File
@@ -25,11 +25,11 @@
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/Theme.Geodelauncher" android:theme="@style/Theme.GeodeLauncher"
tools:targetApi="31"> tools:targetApi="31">
<activity <activity
android:name=".GeometryDashActivity" android:name=".GeometryDashActivity"
android:exported="false" android:exported="true"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
@@ -37,17 +37,16 @@
<meta-data <meta-data
android:name="android.app.lib_name" android:name="android.app.lib_name"
android:value="cocos2dcpp" /> android:value="cocos2dcpp" />
</activity>
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.Geodelauncher">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".MainActivity"
android:theme="@style/Theme.GeodeLauncher">
</activity>
</application> </application>
</manifest> </manifest>
@@ -1,5 +1,6 @@
package com.robtopx.geometryjump package com.robtopx.geometryjump
import android.content.pm.PackageManager
import dalvik.system.BaseDexClassLoader import dalvik.system.BaseDexClassLoader
import java.io.File 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 package dev.xyze.geodelauncher
import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Environment import android.os.Environment
import android.util.Log
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
@@ -32,6 +31,14 @@ class GeometryDashActivity : ComponentActivity(), Cocos2dxHelper.Cocos2dxHelperL
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
setupUIState() 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 gdPackageInfo = packageManager.getPackageInfo(GJConstants.PACKAGE_NAME, 0)
val gdNativeLibraryPath = "${gdPackageInfo.applicationInfo.nativeLibraryDir}/" val gdNativeLibraryPath = "${gdPackageInfo.applicationInfo.nativeLibraryDir}/"
@@ -2,7 +2,6 @@ package dev.xyze.geodelauncher
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import android.widget.Toast import android.widget.Toast
import androidx.activity.ComponentActivity 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.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import com.robtopx.geometryjump.GJConstants import com.robtopx.geometryjump.LaunchUtils
import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme import dev.xyze.geodelauncher.ui.theme.GeodeLauncherTheme
@@ -29,7 +28,7 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val gdInstalled = isGeometryDashInstalled(packageManager) val gdInstalled = LaunchUtils.isGeometryDashInstalled(packageManager)
setContent { setContent {
GeodeLauncherTheme { GeodeLauncherTheme {
@@ -52,15 +51,6 @@ fun onSettings(context: Context) {
Toast.makeText(context, "Settings are not implemented yet!", Toast.LENGTH_SHORT).show() 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 @Composable
fun MainScreen(gdInstalled: Boolean = true) { fun MainScreen(gdInstalled: Boolean = true) {
val context = LocalContext.current val context = LocalContext.current
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<style name="Theme.Geodelauncher" parent="android:Theme.Material.Light.NoActionBar" /> <style name="Theme.GeodeLauncher" parent="android:Theme.Material.Light.NoActionBar" />
</resources> </resources>