Skip to content
This repository has been archived by the owner on Feb 18, 2022. It is now read-only.

Commit

Permalink
Fixed bugs with choosing release
Browse files Browse the repository at this point in the history
  • Loading branch information
fruzyna committed Nov 27, 2021
1 parent b61412a commit 0730bdb
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.wildstang.wildrank.android"
minSdkVersion 21
targetSdkVersion 30
versionCode 5
versionName "rc4"
versionCode 6
versionName "rc5"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class MainActivity : AppCompatActivity() {
if (page.contains(relStr)) {
var latest = page.substring(page.indexOf(relStr) + relStr.length)
latest = latest.substring(0, latest.indexOf("\""))
if (latest.contains("&")) {
latest = latest.substring(0, latest.indexOf("&"))
}
println("[FETCH] Found release $latest")
useRelease(latest)
return
Expand All @@ -299,11 +302,14 @@ class MainActivity : AppCompatActivity() {
}

// if the desired release does not exist
if (!isReleaseCached(release) || release == "master") {
if ((!isReleaseCached(release) && release != "master-cached") || release == "master") {
// download it
fetchRelease(release)
}
else {
if (release == "master-cached") {
release = "master"
}
// otherwise, start app with release
startRelease(release)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class POSTServer(directory: String, apiKey: String) : NanoHTTPD(8080) {
println("Request: $request")

// get upload directory
val uploadDir = File(directory, "uploads")
var uploadDir = File(directory, "uploads")
uploadDir.mkdirs()

// save posted files to /uploads
Expand Down Expand Up @@ -67,6 +67,12 @@ class POSTServer(directory: String, apiKey: String) : NanoHTTPD(8080) {
file += ".json"
}

// handle incoming configs by backing up
if (file.endsWith("config.json")) {
uploadDir = File(directory, "config")
File(uploadDir, file).renameTo(File(uploadDir, "$file.bkp"))
}

// write JSON to file
val writer = FileWriter(File(uploadDir, file))
writer.write(content)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class ReleaseDialog : DialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val mainActivity = (activity as MainActivity)
val lastUsed = mainActivity.getLastRelease()
var lastUsed = mainActivity.getLastRelease()
if (lastUsed == "master") {
lastUsed = "master-cached"
}

// create base list of releases
val releases = ArrayList<String>()
Expand Down Expand Up @@ -48,7 +51,7 @@ class ReleaseDialog : DialogFragment() {
1 -> "latest"
2 -> "master"
releases.size - 1 -> "manual"
else -> releases[which - 3].substring(8)
else -> releases[which].substring(8)
}

if (release != "manual") {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip

0 comments on commit 0730bdb

Please sign in to comment.