mirror of
https://github.com/geode-sdk/android-launcher.git
synced 2026-10-22 16:42:38 +00:00
GEODE_DOWNLOAD_LINK is a nightly link but it works i dont care a single bit finally
This commit is contained in:
1 parent
2c5a8eadc3
commit
e34bfc50a2
5 files changed
+104
-4
No files matched your search
@@ -0,0 +1,51 @@
|
|||||||
|
package com.geode.launcher
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.AsyncTask
|
||||||
|
import android.util.Log
|
||||||
|
import com.geode.launcher.MainActivity
|
||||||
|
import java.io.BufferedInputStream
|
||||||
|
import java.io.File
|
||||||
|
import java.io.FileOutputStream
|
||||||
|
import java.net.HttpURLConnection
|
||||||
|
import java.net.URL
|
||||||
|
import java.util.zip.ZipInputStream
|
||||||
|
|
||||||
|
class DownloadGeode constructor(context: Context) : AsyncTask<String, Int, Boolean>() {
|
||||||
|
private val context: Context = context
|
||||||
|
|
||||||
|
override fun doInBackground(vararg params: String?): Boolean {
|
||||||
|
val url = URL(params[0])
|
||||||
|
val connection = url.openConnection() as HttpURLConnection
|
||||||
|
connection.requestMethod = "GET"
|
||||||
|
connection.connect()
|
||||||
|
// downloads a zip file
|
||||||
|
ZipInputStream(connection.inputStream).use { zip ->
|
||||||
|
var entry = zip.nextEntry
|
||||||
|
while (entry != null) {
|
||||||
|
val file = entry.name
|
||||||
|
context.getExternalFilesDir(null)?.let { dir->
|
||||||
|
val destFile = File(dir, file)
|
||||||
|
destFile.outputStream().use { output ->
|
||||||
|
zip.copyTo(output)
|
||||||
|
Log.d("Geode", "Downloading to $destFile")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry = zip.nextEntry
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPostExecute(result: Boolean) {
|
||||||
|
super.onPostExecute(result)
|
||||||
|
Log.d("Geode", "Downloading Result: $result")
|
||||||
|
|
||||||
|
// update the screen
|
||||||
|
val intent = Intent(context, MainActivity::class.java)
|
||||||
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
context.startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import com.geode.launcher.ui.theme.GeodeLauncherTheme
|
import com.geode.launcher.ui.theme.GeodeLauncherTheme
|
||||||
import com.geode.launcher.ui.theme.Typography
|
import com.geode.launcher.ui.theme.Typography
|
||||||
|
import com.geode.launcher.utils.Constants
|
||||||
import com.geode.launcher.utils.LaunchUtils
|
import com.geode.launcher.utils.LaunchUtils
|
||||||
import com.geode.launcher.utils.useCountdownTimer
|
import com.geode.launcher.utils.useCountdownTimer
|
||||||
import com.geode.launcher.utils.usePreference
|
import com.geode.launcher.utils.usePreference
|
||||||
@@ -31,6 +32,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
val gdInstalled = LaunchUtils.isGeometryDashInstalled(packageManager)
|
val gdInstalled = LaunchUtils.isGeometryDashInstalled(packageManager)
|
||||||
|
val geodeInstalled = LaunchUtils.isGeodeInstalled(this)
|
||||||
|
|
||||||
setContent {
|
setContent {
|
||||||
GeodeLauncherTheme {
|
GeodeLauncherTheme {
|
||||||
@@ -38,19 +40,28 @@ class MainActivity : ComponentActivity() {
|
|||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
color = MaterialTheme.colorScheme.background
|
color = MaterialTheme.colorScheme.background
|
||||||
) {
|
) {
|
||||||
MainScreen(gdInstalled)
|
MainScreen(gdInstalled, geodeInstalled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (gdInstalled) {
|
if (gdInstalled && geodeInstalled) {
|
||||||
intent.getBooleanExtra("restarted", false).let {
|
intent.getBooleanExtra("restarted", false).let {
|
||||||
if (it) {
|
if (it) {
|
||||||
onLaunch(this)
|
onLaunch(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gdInstalled && !geodeInstalled) {
|
||||||
|
downloadGeode(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun downloadGeode(context: Context) {
|
||||||
|
// download geode in the background and update the screen when it's done
|
||||||
|
DownloadGeode(context).execute(Constants.GEODE_DOWNLOAD_LINK)
|
||||||
|
}
|
||||||
|
|
||||||
fun onLaunch(context: Context) {
|
fun onLaunch(context: Context) {
|
||||||
val launchIntent = Intent(context, GeometryDashActivity::class.java)
|
val launchIntent = Intent(context, GeometryDashActivity::class.java)
|
||||||
@@ -65,7 +76,7 @@ fun onSettings(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MainScreen(gdInstalled: Boolean = true) {
|
fun MainScreen(gdInstalled: Boolean = true, geodeInstalled: Boolean = true) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
val shouldAutomaticallyLaunch = usePreference(
|
val shouldAutomaticallyLaunch = usePreference(
|
||||||
@@ -88,7 +99,7 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
fontSize = 32.sp,
|
fontSize = 32.sp,
|
||||||
modifier = Modifier.padding(12.dp)
|
modifier = Modifier.padding(12.dp)
|
||||||
)
|
)
|
||||||
if (gdInstalled) {
|
if (gdInstalled && geodeInstalled) {
|
||||||
if (shouldAutomaticallyLaunch.value) {
|
if (shouldAutomaticallyLaunch.value) {
|
||||||
val countdownTimer = useCountdownTimer(
|
val countdownTimer = useCountdownTimer(
|
||||||
time = 3000,
|
time = 3000,
|
||||||
@@ -129,6 +140,19 @@ fun MainScreen(gdInstalled: Boolean = true) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (gdInstalled && !geodeInstalled) {
|
||||||
|
Text(
|
||||||
|
context.getString(R.string.geode_download_title),
|
||||||
|
modifier = Modifier.padding(12.dp)
|
||||||
|
)
|
||||||
|
OutlinedButton(onClick = { onSettings(context) }) {
|
||||||
|
Icon(
|
||||||
|
Icons.Filled.Settings,
|
||||||
|
contentDescription = context.getString(R.string.launcher_settings_icon_alt)
|
||||||
|
)
|
||||||
|
Spacer(Modifier.size(ButtonDefaults.IconSpacing))
|
||||||
|
Text(context.getString(R.string.launcher_settings))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Text(
|
Text(
|
||||||
context.getString(R.string.game_not_found),
|
context.getString(R.string.game_not_found),
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ object Constants {
|
|||||||
// this value is hardcoded into GD
|
// this value is hardcoded into GD
|
||||||
@SuppressLint("SdCardPath")
|
@SuppressLint("SdCardPath")
|
||||||
const val GJ_DATA_DIR = "/data/data/${PACKAGE_NAME}"
|
const val GJ_DATA_DIR = "/data/data/${PACKAGE_NAME}"
|
||||||
|
|
||||||
|
const val GEODE_DOWNLOAD_LINK = "https://nightly.link/geode-sdk/geode/actions/artifacts/978429662.zip"
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,9 @@ package com.geode.launcher.utils
|
|||||||
import android.content.pm.PackageInfo
|
import android.content.pm.PackageInfo
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.res.AssetManager
|
import android.content.res.AssetManager
|
||||||
|
import android.content.Context
|
||||||
|
import com.geode.launcher.utils.Constants
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
object LaunchUtils {
|
object LaunchUtils {
|
||||||
fun isGeometryDashInstalled(packageManager: PackageManager): Boolean {
|
fun isGeometryDashInstalled(packageManager: PackageManager): Boolean {
|
||||||
@@ -14,6 +17,24 @@ object LaunchUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getInstalledGeodePath(context: Context): File? {
|
||||||
|
val internalGeodePath = File(context.filesDir.path, "launcher/Geode.so")
|
||||||
|
if (internalGeodePath.exists()) {
|
||||||
|
return internalGeodePath
|
||||||
|
}
|
||||||
|
context.getExternalFilesDir(null)?.let { dir->
|
||||||
|
val externalGeodePath = File(dir.path, "Geode.so")
|
||||||
|
if (externalGeodePath.exists()) {
|
||||||
|
return externalGeodePath
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isGeodeInstalled(context: Context): Boolean {
|
||||||
|
return getInstalledGeodePath(context) != null
|
||||||
|
}
|
||||||
|
|
||||||
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
fun addAssetsFromPackage(assetManager: AssetManager, packageInfo: PackageInfo) {
|
||||||
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
// this method is officially marked as deprecated but it is the only method we are allowed to reflect
|
||||||
// (the source recommends replacing with AssetManager.setApkAssets(ApkAssets[], boolean) lol)
|
// (the source recommends replacing with AssetManager.setApkAssets(ApkAssets[], boolean) lol)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
<string name="launcher_logo_alt">geode logo</string>
|
<string name="launcher_logo_alt">geode logo</string>
|
||||||
<string name="launcher_launch_icon_alt">play icon</string>
|
<string name="launcher_launch_icon_alt">play icon</string>
|
||||||
<string name="launcher_settings_icon_alt">settings icon</string>
|
<string name="launcher_settings_icon_alt">settings icon</string>
|
||||||
|
<string name="geode_download_title">Downloading Geode</string>
|
||||||
|
<string name="geode_download_description">Geode is downloading. Please wait.</string>
|
||||||
<plurals name="automatically_load_countdown">
|
<plurals name="automatically_load_countdown">
|
||||||
<item quantity="one">Automatically launching game in %1$d second.</item>
|
<item quantity="one">Automatically launching game in %1$d second.</item>
|
||||||
<item quantity="other">Automatically launching game in %1$d seconds.</item>
|
<item quantity="other">Automatically launching game in %1$d seconds.</item>
|
||||||
|
|||||||
Reference in new issue
Block a user