v0.9.4: added an opt-in for betas in the update checker
This commit is contained in:
@@ -34,7 +34,10 @@ public abstract class UpdateService {
|
||||
//whether the app is updateable via an ingame prompt (e.g. not a demo or an android instant app)
|
||||
public abstract boolean isUpdateable();
|
||||
|
||||
public abstract void checkForUpdate( boolean useMetered, UpdateResultCallback callback );
|
||||
//whether the service supports an opt-in channel for betas
|
||||
public abstract boolean supportsBetaChannel();
|
||||
|
||||
public abstract void checkForUpdate( boolean useMetered, boolean includeBetas, UpdateResultCallback callback );
|
||||
|
||||
public abstract void initializeUpdate( AvailableUpdateData update );
|
||||
|
||||
|
||||
@@ -35,7 +35,12 @@ public class DebugUpdates extends UpdateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
|
||||
public boolean supportsBetaChannel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(boolean useMetered, boolean includeBetas, UpdateResultCallback callback) {
|
||||
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
|
||||
@@ -44,7 +44,12 @@ public class GitHubUpdates extends UpdateService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(boolean useMetered, UpdateResultCallback callback) {
|
||||
public boolean supportsBetaChannel() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkForUpdate(boolean useMetered, boolean includeBetas, UpdateResultCallback callback) {
|
||||
|
||||
if (!useMetered && !Game.platform.connectedToUnmeteredNetwork()){
|
||||
callback.onConnectionFailed();
|
||||
@@ -62,15 +67,13 @@ public class GitHubUpdates extends UpdateService {
|
||||
Bundle latestRelease = null;
|
||||
int latestVersionCode = Game.versionCode;
|
||||
|
||||
boolean includePrereleases = Game.version.contains("-BETA-") || Game.version.contains("-RC-");
|
||||
|
||||
for (Bundle b : Bundle.read( httpResponse.getResultAsStream() ).getBundleArray()){
|
||||
Matcher m = versionCodePattern.matcher(b.getString("body"));
|
||||
|
||||
if (m.find()){
|
||||
int releaseVersion = Integer.parseInt(m.group(1));
|
||||
if (releaseVersion > latestVersionCode
|
||||
&& (includePrereleases || !b.getBoolean("prerelease"))){
|
||||
&& (includeBetas || !b.getBoolean("prerelease"))){
|
||||
latestRelease = b;
|
||||
latestVersionCode = releaseVersion;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user