diff --git a/SPD-classes/build.gradle b/SPD-classes/build.gradle index 2dee8e68f..48d1ac3ca 100644 --- a/SPD-classes/build.gradle +++ b/SPD-classes/build.gradle @@ -3,35 +3,9 @@ apply plugin: 'com.android.library' android { compileSdkVersion 28 - task ndkBuild(type: Exec){ - description "builds JNI libs from source. " + - "This requires the Android NDK and is optional as precompiled libs are provided." - - def root = project(':SPD-classes').projectDir - def ndkDir = android.ndkDirectory - - //Need to execute through cmd on windows systems - if (System.properties["os.name"].toLowerCase().contains("windows")){ - executable "cmd" - args "/c", "$ndkDir${File.separator}ndk-build", - "NDK_PROJECT_PATH=$root/src/main/jniSources", - "NDK_APPLICATION_MK=$root/src/main/jniSources/Application.mk", - "APP_BUILD_SCRIPT=$root/src/main/jniSources/Android.mk", - "NDK_LIBS_OUT=$root/src/main/jniLibs" - - } else { - executable "$ndkDir/ndk-build" - args "NDK_PROJECT_PATH=$root/src/main/jniSources", - "NDK_APPLICATION_MK=$root/src/main/jniSources/Application.mk", - "APP_BUILD_SCRIPT=$root/src/main/jniSources/Android.mk", - "NDK_LIBS_OUT=$root/src/main/jniLibs" - - } - } - defaultConfig { //noinspection MinSdkTooLow - minSdkVersion 8 + minSdkVersion 9 } } diff --git a/SPD-classes/src/main/java/com/watabou/glwrap/Attribute.java b/SPD-classes/src/main/java/com/watabou/glwrap/Attribute.java index 12220c222..bc1e06f3d 100644 --- a/SPD-classes/src/main/java/com/watabou/glwrap/Attribute.java +++ b/SPD-classes/src/main/java/com/watabou/glwrap/Attribute.java @@ -51,10 +51,6 @@ public class Attribute { } public void vertexBuffer( int size, int stride, int offset) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - GLES20.glVertexAttribPointer(location, size, GLES20.GL_FLOAT, false, stride * 4, offset * 4); - } else { - FroyoGLES20Fix.glVertexAttribPointer(location, size, GLES20.GL_FLOAT, false, stride * 4, offset * 4); - } + GLES20.glVertexAttribPointer(location, size, GLES20.GL_FLOAT, false, stride * 4, offset * 4); } } diff --git a/SPD-classes/src/main/java/com/watabou/glwrap/FroyoGLES20Fix.java b/SPD-classes/src/main/java/com/watabou/glwrap/FroyoGLES20Fix.java deleted file mode 100644 index 1e54aa892..000000000 --- a/SPD-classes/src/main/java/com/watabou/glwrap/FroyoGLES20Fix.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 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.glwrap; - -//This class exists because the back-end OpenGL implementation (written in C) -// supports VBO operations (along with the rest of GLES 2.0) since android 2.2 (Froyo, api 8), -// but for some reason the Java calls for these methods were only added in 2.3 (Gingerbread, api 9) - -//So this class is here specifically to reference an armabi/x86 compiled binary -// which gives us Java hooks for VBOs on android 2.2 - -//...I don't know what google engineer forgot to put the java hooks in android 2.2 back in 2010, -// but you know who you are and this class is your fault. - -//Compiled binaries for the FroyoGLES20Fix lib are included in this project, which means that -// the android NDK is not required for building Shattered Pixel Dungeon. -// see SPD-classes/src/main/jniSources/README.txt for more details. - -//DO NOT REFERENCE THIS CLASS ON DEVICES API 9 AND ABOVE, use android.opengl.GLES20 instead. -@SuppressWarnings("JniMissingFunction") -public class FroyoGLES20Fix { - - static - { - System.loadLibrary("FroyoGLES20Fix"); - } - - native public static void glVertexAttribPointer(int index, int size, int type, boolean normalized, int stride, int offset); - - native public static void glDrawElements(int mode, int count, int type, int offset); - -} diff --git a/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java b/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java index bbdbb4b84..e36f883bc 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/NoosaScript.java @@ -22,11 +22,9 @@ package com.watabou.noosa; import android.opengl.GLES20; -import android.os.Build; import com.watabou.glscripts.Script; import com.watabou.glwrap.Attribute; -import com.watabou.glwrap.FroyoGLES20Fix; import com.watabou.glwrap.Quad; import com.watabou.glwrap.Uniform; import com.watabou.glwrap.Vertexbuffer; @@ -95,12 +93,7 @@ public class NoosaScript extends Script { vertices.position( 2 ); aUV.vertexPointer( 2, 4, vertices ); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); - } else { - FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); - } - + GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); } public void drawQuad( Vertexbuffer buffer ) { @@ -114,11 +107,7 @@ public class NoosaScript extends Script { buffer.release(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); - } else { - FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); - } + GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE, GLES20.GL_UNSIGNED_SHORT, 0 ); } public void drawQuadSet( FloatBuffer vertices, int size ) { @@ -133,12 +122,7 @@ public class NoosaScript extends Script { vertices.position( 2 ); aUV.vertexPointer( 2, 4, vertices ); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 ); - } else { - FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 ); - } - + GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * size, GLES20.GL_UNSIGNED_SHORT, 0 ); } public void drawQuadSet( Vertexbuffer buffer, int length, int offset ){ @@ -156,11 +140,7 @@ public class NoosaScript extends Script { buffer.release(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset ); - } else { - FroyoGLES20Fix.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset ); - } + GLES20.glDrawElements( GLES20.GL_TRIANGLES, Quad.SIZE * length, GLES20.GL_UNSIGNED_SHORT, Quad.SIZE * Short.SIZE/8 * offset ); } public void lighting( float rm, float gm, float bm, float am, float ra, float ga, float ba, float aa ) { diff --git a/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java index affc8648a..d774b542c 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java +++ b/SPD-classes/src/main/java/com/watabou/utils/DeviceCompat.java @@ -39,10 +39,6 @@ public class DeviceCompat { return Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN; } - public static boolean usesISO_8859_1(){ - return Build.VERSION.SDK_INT == Build.VERSION_CODES.FROYO; - } - public static boolean isDebug(){ return BuildConfig.DEBUG; } diff --git a/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java index 05317d769..911adad9e 100644 --- a/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java +++ b/SPD-classes/src/main/java/com/watabou/utils/GameSettings.java @@ -92,30 +92,16 @@ public class GameSettings { } } - //android 2.3+ supports apply, which is asyncronous, much nicer - public static void put( String key, int value ) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - get().edit().putInt(key, value).apply(); - } else { - get().edit().putInt(key, value).commit(); - } + get().edit().putInt(key, value).apply(); } public static void put( String key, boolean value ) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - get().edit().putBoolean(key, value).apply(); - } else { - get().edit().putBoolean(key, value).commit(); - } + get().edit().putBoolean(key, value).apply(); } 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(); - } + get().edit().putString(key, value).apply(); } } diff --git a/SPD-classes/src/main/jniLibs/armeabi/libFroyoGLES20Fix.so b/SPD-classes/src/main/jniLibs/armeabi/libFroyoGLES20Fix.so deleted file mode 100644 index 6f232486e..000000000 Binary files a/SPD-classes/src/main/jniLibs/armeabi/libFroyoGLES20Fix.so and /dev/null differ diff --git a/SPD-classes/src/main/jniLibs/x86/libFroyoGLES20Fix.so b/SPD-classes/src/main/jniLibs/x86/libFroyoGLES20Fix.so deleted file mode 100644 index 0cf1eced0..000000000 Binary files a/SPD-classes/src/main/jniLibs/x86/libFroyoGLES20Fix.so and /dev/null differ diff --git a/SPD-classes/src/main/jniSources/Android.mk b/SPD-classes/src/main/jniSources/Android.mk deleted file mode 100644 index 37ca2d8ca..000000000 --- a/SPD-classes/src/main/jniSources/Android.mk +++ /dev/null @@ -1,9 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := FroyoGLES20Fix -LOCAL_SRC_FILES := FroyoGLES20Fix.c -LOCAL_LDLIBS := -lGLESv2 - -include $(BUILD_SHARED_LIBRARY) diff --git a/SPD-classes/src/main/jniSources/Application.mk b/SPD-classes/src/main/jniSources/Application.mk deleted file mode 100644 index e40f0baf5..000000000 --- a/SPD-classes/src/main/jniSources/Application.mk +++ /dev/null @@ -1,3 +0,0 @@ -APP_ABI := armeabi x86 -APP_OPTIM := release -APP_PLATFORM := android-8 \ No newline at end of file diff --git a/SPD-classes/src/main/jniSources/FroyoGLES20Fix.c b/SPD-classes/src/main/jniSources/FroyoGLES20Fix.c deleted file mode 100644 index 87525f12c..000000000 --- a/SPD-classes/src/main/jniSources/FroyoGLES20Fix.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Pixel Dungeon - * Copyright (C) 2012-2015 Oleg Dolya - * - * Shattered Pixel Dungeon - * Copyright (C) 2014-2019 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 - */ - -#include -#include - -void Java_com_watabou_glwrap_FroyoGLES20Fix_glVertexAttribPointer - (JNIEnv *env, jclass c, jint index, jint size, jint type, jboolean normalized, jint stride, jint offset) -{ - glVertexAttribPointer(index, size, type, normalized, stride, (const void*)offset); -} - -void Java_com_watabou_glwrap_FroyoGLES20Fix_glDrawElements - (JNIEnv *env, jclass c, jint mode, jint count, jint type, jint offset) -{ - glDrawElements(mode, count, type, (const void*)offset); -} diff --git a/SPD-classes/src/main/jniSources/README.txt b/SPD-classes/src/main/jniSources/README.txt deleted file mode 100644 index 4f94706b0..000000000 --- a/SPD-classes/src/main/jniSources/README.txt +++ /dev/null @@ -1,11 +0,0 @@ -These sources are provided for FOSS completeness, but compiling them is optional. - -The folder jniLibs already contains compiled versions of FroyoGLES20Fix.c, and makes compiling -The sources here an optional step in building Shattered Pixel Dungeon. This is done so that -The Android NDK is not required for project compilation, but those who want to ensure they are 100% -building from source can still do so. - -There is no functional difference between using the provided .so files, and compiling your own. - -These sources can be compiled through the gradle task SPD-classes:ndkBuild on a system with the -Android NDK installed and configured. \ No newline at end of file diff --git a/core/build.gradle b/core/build.gradle index 3d5498770..39651e8c7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,7 +7,7 @@ android { resConfigs "en_US", "cs", "tr", "ca", "ko", "pl", "it", "eo", "ru", "zh_CN", "de", "fr", "es", "pt", "fi", "hu", "in" //noinspection MinSdkTooLow - minSdkVersion 8 + minSdkVersion 9 targetSdkVersion 28 } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index 651e38942..f97485282 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -247,15 +247,9 @@ public class ShatteredPixelDungeon extends Game { public void updateDisplaySize(){ boolean landscape = SPDSettings.landscape(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { - instance.setRequestedOrientation(landscape ? - ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); - } else { - instance.setRequestedOrientation(landscape ? - ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE : - ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); - } + instance.setRequestedOrientation(landscape ? + ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE : + ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0) return; 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 9522cf837..68bab0e43 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/messages/Messages.java @@ -89,14 +89,6 @@ public class Messages { while (keys.hasMoreElements()) { String key = keys.nextElement(); String value = bundle.getString(key); - - if (DeviceCompat.usesISO_8859_1()) { - try { - value = new String(value.getBytes("ISO-8859-1"), "UTF-8"); - } catch (Exception e) { - ShatteredPixelDungeon.reportException(e); - } - } strings.put(key, value); }