forked from geode-sdk/android-launcher
redirect main to launch
This commit is contained in:
5 files changed
+27
-22
No files matched your search
@@ -25,11 +25,11 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:theme="@style/Theme.Geodelauncher"
|
||||
android:theme="@style/Theme.GeodeLauncher"
|
||||
tools:targetApi="31">
|
||||
<activity
|
||||
android:name=".GeometryDashActivity"
|
||||
android:exported="false"
|
||||
android:exported="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
@@ -37,17 +37,16 @@
|
||||
<meta-data
|
||||
android:name="android.app.lib_name"
|
||||
android:value="cocos2dcpp" />
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:theme="@style/Theme.Geodelauncher">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:theme="@style/Theme.GeodeLauncher">
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Geodelauncher" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
<style name="Theme.GeodeLauncher" parent="android:Theme.Material.Light.NoActionBar" />
|
||||
</resources>
|
||||
Reference in new issue
Block a user