v0.9.4: added an opt-in for betas in the update checker
This commit is contained in:
@@ -186,6 +186,7 @@ windows.wndsettings$uitab.key_bindings=Key Bindings
|
||||
windows.wndsettings$datatab.title=Connectivity Settings
|
||||
windows.wndsettings$datatab.news=Check for news
|
||||
windows.wndsettings$datatab.updates=Check for updates
|
||||
windows.wndsettings$datatab.betas=Include beta updates
|
||||
windows.wndsettings$datatab.wifi=Only check on WiFi
|
||||
windows.wndsettings$audiotab.title=Audio Settings
|
||||
windows.wndsettings$audiotab.music_vol=Music Volume
|
||||
|
||||
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.GameSettings;
|
||||
@@ -268,6 +269,7 @@ public class SPDSettings extends GameSettings {
|
||||
|
||||
public static final String KEY_NEWS = "news";
|
||||
public static final String KEY_UPDATES = "updates";
|
||||
public static final String KEY_BETAS = "betas";
|
||||
public static final String KEY_WIFI = "wifi";
|
||||
|
||||
public static final String KEY_NEWS_LAST_READ = "news_last_read";
|
||||
@@ -288,6 +290,14 @@ public class SPDSettings extends GameSettings {
|
||||
return getBoolean(KEY_UPDATES, true);
|
||||
}
|
||||
|
||||
public static void betas(boolean value){
|
||||
put(KEY_BETAS, value);
|
||||
}
|
||||
|
||||
public static boolean betas(){
|
||||
return getBoolean(KEY_BETAS, Game.version.contains("BETA") || Game.version.contains("RC"));
|
||||
}
|
||||
|
||||
public static void WiFi(boolean value){
|
||||
put(KEY_WIFI, value);
|
||||
}
|
||||
|
||||
+10
-1
@@ -41,11 +41,20 @@ public class Updates {
|
||||
return supportsUpdates() && service.isUpdateable();
|
||||
}
|
||||
|
||||
public static boolean supportsBetaChannel(){
|
||||
return supportsUpdates() && service.supportsBetaChannel();
|
||||
}
|
||||
|
||||
public static void checkForUpdate(){
|
||||
if (!isUpdateable()) return;
|
||||
if (lastCheck != null && (new Date().getTime() - lastCheck.getTime()) < CHECK_DELAY) return;
|
||||
|
||||
service.checkForUpdate(!SPDSettings.WiFi(), new UpdateService.UpdateResultCallback() {
|
||||
//We do this so that automatically enabled beta checking (for users who DLed a beta) persists afterward
|
||||
if (SPDSettings.betas()){
|
||||
SPDSettings.betas(true);
|
||||
}
|
||||
|
||||
service.checkForUpdate(!SPDSettings.WiFi(), SPDSettings.betas(), new UpdateService.UpdateResultCallback() {
|
||||
@Override
|
||||
public void onUpdateAvailable(AvailableUpdateData update) {
|
||||
lastCheck = new Date();
|
||||
|
||||
@@ -528,6 +528,7 @@ public class WndSettings extends WndTabbed {
|
||||
ColorBlock sep1;
|
||||
CheckBox chkNews;
|
||||
CheckBox chkUpdates;
|
||||
CheckBox chkBetas;
|
||||
CheckBox chkWifi;
|
||||
|
||||
@Override
|
||||
@@ -561,6 +562,19 @@ public class WndSettings extends WndTabbed {
|
||||
};
|
||||
chkUpdates.checked(SPDSettings.updates());
|
||||
add(chkUpdates);
|
||||
|
||||
if (Updates.supportsBetaChannel()){
|
||||
chkBetas = new CheckBox(Messages.get(this, "betas")) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
SPDSettings.updates(checked());
|
||||
Updates.clearUpdate();
|
||||
}
|
||||
};
|
||||
chkBetas.checked(SPDSettings.betas());
|
||||
add(chkBetas);
|
||||
}
|
||||
}
|
||||
|
||||
if (!DeviceCompat.isDesktop()){
|
||||
@@ -596,6 +610,11 @@ public class WndSettings extends WndTabbed {
|
||||
}
|
||||
}
|
||||
|
||||
if (chkBetas != null){
|
||||
chkBetas.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
pos = chkBetas.bottom();
|
||||
}
|
||||
|
||||
if (chkWifi != null){
|
||||
chkWifi.setRect(0, pos + GAP, width, BTN_HEIGHT);
|
||||
pos = chkWifi.bottom();
|
||||
|
||||
Reference in New Issue
Block a user