diff --git a/SPD-classes/src/main/java/com/watabou/noosa/Game.java b/SPD-classes/src/main/java/com/watabou/noosa/Game.java index a85b8762a..56381bfd1 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/Game.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/Game.java @@ -46,6 +46,7 @@ import com.watabou.input.Touchscreen; import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.BitmapCache; +import com.watabou.utils.DeviceCompat; import com.watabou.utils.SystemTime; import java.util.ArrayList; @@ -133,10 +134,10 @@ public class Game extends Activity implements GLSurfaceView.Renderer, View.OnTou view = new GLSurfaceView( this ); view.setEGLContextClientVersion( 2 ); - //Versions of android below 4.1 are forced to RGB 565 for performance reasons. + //Older devices are forced to RGB 565 for performance reasons. //Otherwise try to use RGB888 for best quality, but use RGB565 if it is what's available. view.setEGLConfigChooser( new ScreenConfigChooser( - Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN, + DeviceCompat.legacyDevice(), false )); view.setRenderer( this ); diff --git a/SPD-classes/src/main/java/com/watabou/noosa/audio/Music.java b/SPD-classes/src/main/java/com/watabou/noosa/audio/Music.java index 570eabe0f..ff9f19dcb 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/audio/Music.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/audio/Music.java @@ -21,9 +21,11 @@ package com.watabou.noosa.audio; +import android.app.Activity; import android.content.res.AssetFileDescriptor; import android.media.AudioManager; import android.media.MediaPlayer; +import android.os.Build; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; @@ -158,4 +160,13 @@ public enum Music implements MediaPlayer.OnPreparedListener, MediaPlayer.OnError super.onCallStateChanged(state, incomingNumber); } }; + + public static void setMuteListener(){ + //versions lower than this require READ_PHONE_STATE permission + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + TelephonyManager mgr = + (TelephonyManager) Game.instance.getSystemService(Activity.TELEPHONY_SERVICE); + mgr.listen(Music.callMute, PhoneStateListener.LISTEN_CALL_STATE); + } + } } diff --git a/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java new file mode 100644 index 000000000..9047f48fb --- /dev/null +++ b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java @@ -0,0 +1,44 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2017 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.watabou.utils; + +import android.os.Build; + +public class DeviceCompat { + + public static boolean supportsFullScreen(){ + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; + } + + public static boolean legacyDevice(){ + return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN; + } + + public static boolean supportsGamesServices(){ + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH; + } + + public static boolean usesISO_8859_1(){ + return Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO; + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Preferences.java b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java similarity index 55% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Preferences.java rename to SPD-classes/src/main/java/com/watabou/utils/GameSettings.java index be6f46ad3..fb308b3d0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/Preferences.java +++ b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java @@ -19,58 +19,33 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon; +package com.watabou.utils; import android.content.SharedPreferences; import android.os.Build; import com.watabou.noosa.Game; -import com.watabou.utils.GameMath; -enum Preferences { - - INSTANCE; +public class GameSettings { - public static final String KEY_LANDSCAPE = "landscape"; - public static final String KEY_IMMERSIVE = "immersive"; - public static final String KEY_POWER_SAVER = "power_saver"; - public static final String KEY_SCALE = "scale"; - public static final String KEY_MUSIC = "music"; - public static final String KEY_MUSIC_VOL = "music_vol"; - public static final String KEY_SOUND_FX = "soundfx"; - public static final String KEY_SFX_VOL = "sfx_vol"; - public static final String KEY_ZOOM = "zoom"; - public static final String KEY_LAST_CLASS = "last_class"; - public static final String KEY_CHALLENGES = "challenges"; - public static final String KEY_QUICKSLOTS = "quickslots"; - public static final String KEY_FLIPTOOLBAR = "flipped_ui"; - public static final String KEY_FLIPTAGS = "flip_tags"; - public static final String KEY_BARMODE = "toolbar_mode"; - public static final String KEY_LANG = "language"; - public static final String KEY_CLASSICFONT = "classic_font"; - public static final String KEY_INTRO = "intro"; - public static final String KEY_BRIGHTNESS = "brightness"; - public static final String KEY_GRID = "visual_grid"; - public static final String KEY_VERSION = "version"; + private static SharedPreferences prefs; - private SharedPreferences prefs; - - private SharedPreferences get() { + private static SharedPreferences get() { if (prefs == null) { prefs = Game.instance.getPreferences( Game.MODE_PRIVATE ); } return prefs; } - - boolean contains( String key ){ + + public static boolean contains( String key ){ return get().contains( key ); } - - int getInt( String key, int defValue ) { + + public static int getInt( String key, int defValue ) { return getInt(key, defValue, Integer.MIN_VALUE, Integer.MAX_VALUE); } - int getInt( String key, int defValue, int min, int max ) { + public static int getInt( String key, int defValue, int min, int max ) { try { int i = get().getInt( key, defValue ); if (i < min || i > max){ @@ -81,27 +56,27 @@ enum Preferences { return i; } } catch (ClassCastException e) { - ShatteredPixelDungeon.reportException(e); + //ShatteredPixelDungeon.reportException(e); put(key, defValue); return defValue; } } - boolean getBoolean( String key, boolean defValue ) { + public static boolean getBoolean( String key, boolean defValue ) { try { return get().getBoolean(key, defValue); } catch (ClassCastException e) { - ShatteredPixelDungeon.reportException(e); + //ShatteredPixelDungeon.reportException(e); put(key, defValue); return defValue; } } - - String getString( String key, String defValue ) { + + public static String getString( String key, String defValue ) { return getString(key, defValue, Integer.MAX_VALUE); } - String getString( String key, String defValue, int maxLength ) { + public static String getString( String key, String defValue, int maxLength ) { try { String s = get().getString( key, defValue ); if (s != null && s.length() > maxLength) { @@ -111,7 +86,7 @@ enum Preferences { return s; } } catch (ClassCastException e) { - ShatteredPixelDungeon.reportException(e); + //ShatteredPixelDungeon.reportException(e); put(key, defValue); return defValue; } @@ -119,7 +94,7 @@ enum Preferences { //android 2.3+ supports apply, which is asyncronous, much nicer - void put( String key, int value ) { + public static void put( String key, int value ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { get().edit().putInt(key, value).apply(); } else { @@ -127,7 +102,7 @@ enum Preferences { } } - void put( String key, boolean value ) { + public static void put( String key, boolean value ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { get().edit().putBoolean(key, value).apply(); } else { @@ -135,11 +110,12 @@ enum Preferences { } } - void put( String key, String value ) { + public static void put( String key, String value ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { get().edit().putString(key, value).apply(); } else { get().edit().putString(key, value).commit(); } } + } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java new file mode 100644 index 000000000..273e189bc --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/SPDSettings.java @@ -0,0 +1,50 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2017 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon; + +import com.watabou.utils.GameSettings; + +public class SPDSettings extends GameSettings { + + public static final String KEY_LANDSCAPE = "landscape"; + public static final String KEY_IMMERSIVE = "immersive"; + public static final String KEY_POWER_SAVER = "power_saver"; + public static final String KEY_SCALE = "scale"; + public static final String KEY_MUSIC = "music"; + public static final String KEY_MUSIC_VOL = "music_vol"; + public static final String KEY_SOUND_FX = "soundfx"; + public static final String KEY_SFX_VOL = "sfx_vol"; + public static final String KEY_ZOOM = "zoom"; + public static final String KEY_LAST_CLASS = "last_class"; + public static final String KEY_CHALLENGES = "challenges"; + public static final String KEY_QUICKSLOTS = "quickslots"; + public static final String KEY_FLIPTOOLBAR = "flipped_ui"; + public static final String KEY_FLIPTAGS = "flip_tags"; + public static final String KEY_BARMODE = "toolbar_mode"; + public static final String KEY_LANG = "language"; + public static final String KEY_CLASSICFONT = "classic_font"; + public static final String KEY_INTRO = "intro"; + public static final String KEY_BRIGHTNESS = "brightness"; + public static final String KEY_GRID = "visual_grid"; + public static final String KEY_VERSION = "version"; + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index a8050f5b0..33f4db642 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -24,8 +24,6 @@ package com.shatteredpixel.shatteredpixeldungeon; import android.content.pm.ActivityInfo; import android.os.Build; import android.os.Bundle; -import android.telephony.PhoneStateListener; -import android.telephony.TelephonyManager; import android.util.DisplayMetrics; import android.util.Log; import android.view.View; @@ -39,6 +37,7 @@ import com.watabou.noosa.Game; import com.watabou.noosa.RenderedText; import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.DeviceCompat; import java.util.Locale; @@ -134,8 +133,8 @@ public class ShatteredPixelDungeon extends Game { updateSystemUI(); - if (Preferences.INSTANCE.contains( Preferences.KEY_LANDSCAPE )){ - landscape ( Preferences.INSTANCE.getBoolean( Preferences.KEY_LANDSCAPE, false)); + if (SPDSettings.contains( SPDSettings.KEY_LANDSCAPE )){ + landscape ( SPDSettings.getBoolean( SPDSettings.KEY_LANDSCAPE, false)); } else { DisplayMetrics metrics = new DisplayMetrics(); @@ -153,11 +152,7 @@ public class ShatteredPixelDungeon extends Game { Sample.INSTANCE.enable( soundFx() ); Sample.INSTANCE.volume( SFXVol()/10f ); - //versions lower than this require READ_PHONE_STATE permission - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); - mgr.listen(Music.callMute, PhoneStateListener.LISTEN_CALL_STATE); - } + Music.setMuteListener(); Sample.INSTANCE.load( Assets.SND_CLICK, @@ -238,9 +233,11 @@ public class ShatteredPixelDungeon extends Game { } /* - * ---> Prefernces + * ---> Settings */ + //TODO migrate some of these to SPDSettings, no reason to clutter up Shattered Pixel Dungeon + public static void landscape( boolean value ) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { Game.instance.setRequestedOrientation(value ? @@ -251,7 +248,7 @@ public class ShatteredPixelDungeon extends Game { ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } - Preferences.INSTANCE.put( Preferences.KEY_LANDSCAPE, value ); + SPDSettings.put( SPDSettings.KEY_LANDSCAPE, value ); ((ShatteredPixelDungeon)instance).updateDisplaySize(); } @@ -260,13 +257,11 @@ public class ShatteredPixelDungeon extends Game { } public static void scale( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_SCALE, value ); + SPDSettings.put( SPDSettings.KEY_SCALE, value ); } - private static boolean immersiveModeChanged = false; - public static void immerse( boolean value ) { - Preferences.INSTANCE.put( Preferences.KEY_IMMERSIVE, value ); + SPDSettings.put( SPDSettings.KEY_IMMERSIVE, value ); instance.runOnUiThread( new Runnable() { @Override @@ -301,7 +296,7 @@ public class ShatteredPixelDungeon extends Game { //force power saver in this case as all devices must run at at least 2x scale. if (dispWidth < renderWidth*2 || dispHeight < renderHeight*2) - Preferences.INSTANCE.put( Preferences.KEY_POWER_SAVER, true ); + SPDSettings.put( SPDSettings.KEY_POWER_SAVER, true ); if (powerSaver()){ @@ -351,7 +346,7 @@ public class ShatteredPixelDungeon extends Game { WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ + if (DeviceCompat.supportsFullScreen()){ if (fullscreen && immersed()) { instance.getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | @@ -367,88 +362,88 @@ public class ShatteredPixelDungeon extends Game { } public static boolean immersed() { - return Preferences.INSTANCE.getBoolean( Preferences.KEY_IMMERSIVE, false ); + return SPDSettings.getBoolean( SPDSettings.KEY_IMMERSIVE, false ); } public static boolean powerSaver(){ - return Preferences.INSTANCE.getBoolean( Preferences.KEY_POWER_SAVER, false ); + return SPDSettings.getBoolean( SPDSettings.KEY_POWER_SAVER, false ); } public static void powerSaver( boolean value ){ - Preferences.INSTANCE.put( Preferences.KEY_POWER_SAVER, value ); + SPDSettings.put( SPDSettings.KEY_POWER_SAVER, value ); ((ShatteredPixelDungeon)instance).updateDisplaySize(); } public static int scale() { - return Preferences.INSTANCE.getInt( Preferences.KEY_SCALE, 0 ); + return SPDSettings.getInt( SPDSettings.KEY_SCALE, 0 ); } public static void zoom( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_ZOOM, value ); + SPDSettings.put( SPDSettings.KEY_ZOOM, value ); } public static int zoom() { - return Preferences.INSTANCE.getInt( Preferences.KEY_ZOOM, 0 ); + return SPDSettings.getInt( SPDSettings.KEY_ZOOM, 0 ); } public static void music( boolean value ) { Music.INSTANCE.enable( value ); - Preferences.INSTANCE.put( Preferences.KEY_MUSIC, value ); + SPDSettings.put( SPDSettings.KEY_MUSIC, value ); } public static boolean music() { - return Preferences.INSTANCE.getBoolean( Preferences.KEY_MUSIC, true ); + return SPDSettings.getBoolean( SPDSettings.KEY_MUSIC, true ); } public static void musicVol( int value ){ - Preferences.INSTANCE.put( Preferences.KEY_MUSIC_VOL, value ); + SPDSettings.put( SPDSettings.KEY_MUSIC_VOL, value ); } public static int musicVol(){ - return Preferences.INSTANCE.getInt( Preferences.KEY_MUSIC_VOL, 10, 0, 10 ); + return SPDSettings.getInt( SPDSettings.KEY_MUSIC_VOL, 10, 0, 10 ); } public static void soundFx( boolean value ) { Sample.INSTANCE.enable( value ); - Preferences.INSTANCE.put( Preferences.KEY_SOUND_FX, value ); + SPDSettings.put( SPDSettings.KEY_SOUND_FX, value ); } public static boolean soundFx() { - return Preferences.INSTANCE.getBoolean( Preferences.KEY_SOUND_FX, true ); + return SPDSettings.getBoolean( SPDSettings.KEY_SOUND_FX, true ); } public static void SFXVol( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_SFX_VOL, value ); + SPDSettings.put( SPDSettings.KEY_SFX_VOL, value ); } public static int SFXVol() { - return Preferences.INSTANCE.getInt( Preferences.KEY_SFX_VOL, 10, 0, 10 ); + return SPDSettings.getInt( SPDSettings.KEY_SFX_VOL, 10, 0, 10 ); } public static void brightness( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_BRIGHTNESS, value ); + SPDSettings.put( SPDSettings.KEY_BRIGHTNESS, value ); GameScene.updateFog(); } public static int brightness() { - return Preferences.INSTANCE.getInt( Preferences.KEY_BRIGHTNESS, 0, -2, 2 ); + return SPDSettings.getInt( SPDSettings.KEY_BRIGHTNESS, 0, -2, 2 ); } public static void visualGrid( int value ){ - Preferences.INSTANCE.put( Preferences.KEY_GRID, value ); + SPDSettings.put( SPDSettings.KEY_GRID, value ); GameScene.updateMap(); } public static int visualGrid() { - return Preferences.INSTANCE.getInt( Preferences.KEY_GRID, 0, -1, 3 ); + return SPDSettings.getInt( SPDSettings.KEY_GRID, 0, -1, 3 ); } public static void language(Languages lang) { - Preferences.INSTANCE.put( Preferences.KEY_LANG, lang.code()); + SPDSettings.put( SPDSettings.KEY_LANG, lang.code()); } public static Languages language() { - String code = Preferences.INSTANCE.getString(Preferences.KEY_LANG, null); + String code = SPDSettings.getString(SPDSettings.KEY_LANG, null); if (code == null){ return Languages.matchLocale(Locale.getDefault()); } else { @@ -457,7 +452,7 @@ public class ShatteredPixelDungeon extends Game { } public static void classicFont(boolean classic){ - Preferences.INSTANCE.put(Preferences.KEY_CLASSICFONT, classic); + SPDSettings.put(SPDSettings.KEY_CLASSICFONT, classic); if (classic) { RenderedText.setFont("pixelfont.ttf"); } else { @@ -466,68 +461,68 @@ public class ShatteredPixelDungeon extends Game { } public static boolean classicFont(){ - return Preferences.INSTANCE.getBoolean(Preferences.KEY_CLASSICFONT, + return SPDSettings.getBoolean(SPDSettings.KEY_CLASSICFONT, (language() != Languages.KOREAN && language() != Languages.CHINESE)); } public static void lastClass( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_LAST_CLASS, value ); + SPDSettings.put( SPDSettings.KEY_LAST_CLASS, value ); } public static int lastClass() { - return Preferences.INSTANCE.getInt( Preferences.KEY_LAST_CLASS, 0, 0, 3 ); + return SPDSettings.getInt( SPDSettings.KEY_LAST_CLASS, 0, 0, 3 ); } public static void challenges( int value ) { - Preferences.INSTANCE.put( Preferences.KEY_CHALLENGES, value ); + SPDSettings.put( SPDSettings.KEY_CHALLENGES, value ); } public static int challenges() { - return Preferences.INSTANCE.getInt( Preferences.KEY_CHALLENGES, 0, 0, Challenges.MAX_VALUE ); + return SPDSettings.getInt( SPDSettings.KEY_CHALLENGES, 0, 0, Challenges.MAX_VALUE ); } - public static void quickSlots( int value ){ Preferences.INSTANCE.put( Preferences.KEY_QUICKSLOTS, value ); } + public static void quickSlots( int value ){ SPDSettings.put( SPDSettings.KEY_QUICKSLOTS, value ); } - public static int quickSlots(){ return Preferences.INSTANCE.getInt( Preferences.KEY_QUICKSLOTS, 4, 0, 4); } + public static int quickSlots(){ return SPDSettings.getInt( SPDSettings.KEY_QUICKSLOTS, 4, 0, 4); } public static void flipToolbar( boolean value) { - Preferences.INSTANCE.put(Preferences.KEY_FLIPTOOLBAR, value ); + SPDSettings.put(SPDSettings.KEY_FLIPTOOLBAR, value ); } - public static boolean flipToolbar(){ return Preferences.INSTANCE.getBoolean(Preferences.KEY_FLIPTOOLBAR, false); } + public static boolean flipToolbar(){ return SPDSettings.getBoolean(SPDSettings.KEY_FLIPTOOLBAR, false); } public static void flipTags( boolean value) { - Preferences.INSTANCE.put(Preferences.KEY_FLIPTAGS, value ); + SPDSettings.put(SPDSettings.KEY_FLIPTAGS, value ); } - public static boolean flipTags(){ return Preferences.INSTANCE.getBoolean(Preferences.KEY_FLIPTAGS, false); } + public static boolean flipTags(){ return SPDSettings.getBoolean(SPDSettings.KEY_FLIPTAGS, false); } public static void toolbarMode( String value ) { - Preferences.INSTANCE.put( Preferences.KEY_BARMODE, value ); + SPDSettings.put( SPDSettings.KEY_BARMODE, value ); } public static String toolbarMode() { - return Preferences.INSTANCE.getString(Preferences.KEY_BARMODE, !landscape() ? "SPLIT" : "GROUP"); + return SPDSettings.getString(SPDSettings.KEY_BARMODE, !landscape() ? "SPLIT" : "GROUP"); } public static void intro( boolean value ) { - Preferences.INSTANCE.put( Preferences.KEY_INTRO, value ); + SPDSettings.put( SPDSettings.KEY_INTRO, value ); } public static boolean intro() { - return Preferences.INSTANCE.getBoolean( Preferences.KEY_INTRO, true ); + return SPDSettings.getBoolean( SPDSettings.KEY_INTRO, true ); } public static void version( int value) { - Preferences.INSTANCE.put( Preferences.KEY_VERSION, value ); + SPDSettings.put( SPDSettings.KEY_VERSION, value ); } public static int version() { - return Preferences.INSTANCE.getInt( Preferences.KEY_VERSION, 0 ); + return SPDSettings.getInt( SPDSettings.KEY_VERSION, 0 ); } /* - * <--- Preferences + * <--- Settings */ public static void reportException( Throwable tr ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java index 89c2956c8..d08a29adf 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.messages; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.watabou.utils.DeviceCompat; import java.util.Arrays; import java.util.Enumeration; @@ -86,9 +87,8 @@ public class Messages { while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = bundle.getString(key); - - //android 2.2 doesn't use UTF-8 by default, need to force it. - if (android.os.Build.VERSION.SDK_INT == android.os.Build.VERSION_CODES.FROYO) { + + if (DeviceCompat.usesISO_8859_1()) { try { value = new String(value.getBytes("ISO-8859-1"), "UTF-8"); } catch (Exception e) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java index 23914dc2d..38166d9ab 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndSettings.java @@ -21,8 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; -import android.os.Build; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -37,6 +35,7 @@ import com.watabou.noosa.Group; import com.watabou.noosa.RenderedText; import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.DeviceCompat; public class WndSettings extends WndTabbed { @@ -287,7 +286,7 @@ public class WndSettings extends WndTabbed { }; chkImmersive.setRect( 0, slots.bottom() + GAP_SML, WIDTH, BTN_HEIGHT ); chkImmersive.checked(ShatteredPixelDungeon.immersed()); - chkImmersive.enable(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT); + chkImmersive.enable(DeviceCompat.supportsFullScreen()); add(chkImmersive); CheckBox chkFont = new CheckBox(Messages.get(this, "system_font")){