Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement built in updater #6

Merged
merged 37 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
54988e1
implement release check api
qimiko Dec 31, 2023
38172aa
add options for updater
qimiko Dec 31, 2023
067c0e8
fix settings scroll
qimiko Dec 31, 2023
e1f8e8a
minor preference reorganization
qimiko Dec 31, 2023
e55ee7a
implement initial release properties
qimiko Dec 31, 2023
ba6c07e
add downloading code
qimiko Dec 31, 2023
74ee77b
change download api
qimiko Jan 1, 2024
1176779
add extraction code
qimiko Jan 1, 2024
3a03d9e
fix modifier padding
qimiko Jan 1, 2024
4817cd5
update geode status after update
qimiko Jan 1, 2024
b407aa1
set stored release after update
qimiko Jan 1, 2024
a8ef5fb
disable updater by default for armv8
qimiko Jan 1, 2024
d344ec3
add settings toasts
qimiko Jan 1, 2024
e50bbfc
use snackbar instead of toast
qimiko Jan 1, 2024
05e9c46
small cleanup
qimiko Jan 1, 2024
2a28d57
remove unused constant
qimiko Jan 1, 2024
7d5073a
implement stable channel
qimiko Jan 1, 2024
7918fe0
child doesn't require viewmodel
qimiko Jan 1, 2024
30d3c6a
update release format
qimiko Jan 1, 2024
1cf63b5
enable updater by default for all archs
qimiko Jan 1, 2024
65e9e6a
modify updater to be global
qimiko Jan 4, 2024
3c566fc
Merge remote-tracking branch 'origin/main' into autoupdate
qimiko Jan 4, 2024
56b5578
fix copyfile reference
qimiko Jan 4, 2024
950a80a
correct state ordering issue
qimiko Jan 5, 2024
65d6eed
only allow one update at a time
qimiko Jan 6, 2024
6648d61
show message in settings on second update
qimiko Jan 6, 2024
6bf8f75
allow update cancellation and retry
qimiko Jan 6, 2024
39b47b6
disable start until update finished
qimiko Jan 6, 2024
7bd9c39
fix countdown lifecycle
qimiko Jan 6, 2024
88cba69
always sync release state to main activity
qimiko Jan 6, 2024
c15e60d
allow scrolling main activity
qimiko Jan 6, 2024
098cbcd
use a library for internal downloads
qimiko Jan 6, 2024
c4abb0c
show download progress in settings
qimiko Jan 6, 2024
4ac6345
no internet messages
qimiko Jan 6, 2024
bd6cf43
enable api request cache
qimiko Jan 6, 2024
49dcb32
delete old library before extracting
qimiko Jan 6, 2024
1b23bdd
oops....
qimiko Jan 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization'
}

android {
Expand Down Expand Up @@ -65,10 +66,16 @@ dependencies {
implementation 'androidx.compose.material3:material3:1.1.2'
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.2"
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.activity:activity-ktx:1.8.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
implementation "com.squareup.okio:okio:3.7.0"
implementation "com.squareup.okhttp3:okhttp:4.12.0"
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0'
implementation 'org.jetbrains.kotlinx:kotlinx-datetime:0.5.0'
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json-okio:1.6.0"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
}
51 changes: 0 additions & 51 deletions app/src/main/java/com/geode/launcher/DownloadGeode.kt

This file was deleted.

43 changes: 15 additions & 28 deletions app/src/main/java/com/geode/launcher/GeometryDashActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ import androidx.core.view.WindowInsetsControllerCompat
import com.customRobTop.BaseRobTopActivity
import com.customRobTop.JniToCpp
import com.geode.launcher.utils.Constants
import com.geode.launcher.utils.DownloadUtils
import com.geode.launcher.utils.LaunchUtils
import com.geode.launcher.utils.GeodeUtils
import com.geode.launcher.utils.PreferenceUtils
import org.cocos2dx.lib.Cocos2dxEditText
import org.cocos2dx.lib.Cocos2dxGLSurfaceView
import org.cocos2dx.lib.Cocos2dxHelper
Expand All @@ -33,8 +35,6 @@ import org.fmod.FMOD
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.io.InputStream
import java.io.OutputStream


class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperListener {
Expand Down Expand Up @@ -149,7 +149,7 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
// there doesn't seem to be a way to load a library from a file descriptor
val libraryCopy = File(cacheDir, "lib$libraryName.so")
val libraryOutput = libraryCopy.outputStream()
copyFile(libraryFd.createInputStream(), libraryOutput)
DownloadUtils.copyFile(libraryFd.createInputStream(), libraryOutput)

System.load(libraryCopy.path)

Expand Down Expand Up @@ -190,7 +190,8 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
return true
} catch (e: UnsatisfiedLinkError) {
// but users may prefer it stored with data
val geodePath = File(filesDir.path, "launcher/Geode.so")
val geodeFilename = LaunchUtils.getGeodeFilename()
val geodePath = File(filesDir.path, "launcher/$geodeFilename")
if (geodePath.exists()) {
System.load(geodePath.path)
return true
Expand All @@ -211,7 +212,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
val geodePath = File(copiedPath.path, "Geode.so")

if (externalGeodePath.exists()) {
copyFile(FileInputStream(externalGeodePath), FileOutputStream(geodePath))
DownloadUtils.copyFile(
FileInputStream(externalGeodePath),
FileOutputStream(geodePath)
)

if (geodePath.exists()) {
try {
Expand Down Expand Up @@ -395,9 +399,8 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
}

private fun getLoadTesting(): Boolean {
val preferences = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE)

return preferences.getBoolean(getString(R.string.preference_load_testing), false)
val preferences = PreferenceUtils.get(this)
return preferences.getBoolean(PreferenceUtils.Key.LOAD_TESTING)
}

@SuppressLint("UnsafeDynamicallyLoadedCode")
Expand All @@ -416,7 +419,10 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
if (it.isFile) {
// welcome to the world of Android classloader permissions
val outputFile = File(testDirPath.path + File.separator + it.name)
copyFile(FileInputStream(it), FileOutputStream(outputFile))
DownloadUtils.copyFile(
FileInputStream(it),
FileOutputStream(outputFile)
)

try {
println("Loading test library ${outputFile.name}")
Expand All @@ -428,23 +434,4 @@ class GeometryDashActivity : AppCompatActivity(), Cocos2dxHelper.Cocos2dxHelperL
}
}
}

private fun copyFile(inputStream: InputStream, outputStream: OutputStream) {
// gotta love copying
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
FileUtils.copy(inputStream, outputStream)
} else {
inputStream.use { input ->
outputStream.use { output ->
val buffer = ByteArray(4 * 1024)
while (true) {
val byteCount = input.read(buffer)
if (byteCount < 0) break
output.write(buffer, 0, byteCount)
}
output.flush()
}
}
}
}
}
Loading