fix android updater, add fallback to android check

- copy build.txt to assets (gdx.files.internal looks only inside assets folder)
This commit is contained in:
Anthony Calosa
2024-10-29 16:44:29 +08:00
parent b70df0d422
commit 1ef0656495
2 changed files with 21 additions and 1 deletions

View File

@@ -425,6 +425,23 @@
</dependency>
</dependencies>
<executions>
<execution>
<id>android-additional-asset</id>
<phase>test</phase>
<configuration>
<target>
<delete file="${basedir}/assets/build.txt"/>
<copy todir="${basedir}/assets">
<fileset dir="${project.build.directory}/classes">
<include name="build.txt" />
</fileset>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>android-release-packaging</id>
<phase>package</phase>

View File

@@ -58,7 +58,7 @@ public class AssetsDownloader {
final String versionText = isSnapshots ? snapsURL + "version.txt" : releaseURL + "maven-metadata.xml";
FileHandle assetsDir = Gdx.files.absolute(ASSETS_DIR);
FileHandle resDir = Gdx.files.absolute(RES_DIR);
FileHandle buildTxtFileHandle = Gdx.files.classpath("build.txt");
FileHandle buildTxtFileHandle = GuiBase.isAndroid() ? Gdx.files.internal("build.txt") : Gdx.files.classpath("build.txt");
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
boolean verifyUpdatable = false;
boolean mandatory = false;
@@ -101,6 +101,9 @@ public class AssetsDownloader {
buildTimeStamp = format.parse(buildTxtFileHandle.readString());
buildDate = buildTimeStamp.toString();
verifyUpdatable = snapsTimestamp.after(buildTimeStamp);
} else {
//fallback to old version comparison
verifyUpdatable = !StringUtils.isEmpty(version) && !versionString.equals(version);
}
}
} else {