Skip to content

Commit

Permalink
Bump min Android API level to 19 (libgdx#7310)
Browse files Browse the repository at this point in the history
  • Loading branch information
obigu authored Feb 3, 2024
1 parent 7d1a149 commit 6ff5855
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[1.12.2-SNAPSHOT]
- [BREAKING CHANGE] GWT: Updated to 2.10.0. `com.google.jsinterop:jsinterop-annotations:2.0.2:sources` must be added as a dependency to your html project dependencies.
- [BREAKING CHANGE] Android: Minimum API level is now level 19 (Android 4.4)
- Fixed GlyphLayout for fixed width glyph offsets at the start and end of lines.
- Fixed scene2d.ui layout for fractional positions and sizes.
- libGDX is now built using Java 17 due to Gradle 8 requirements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package com.badlogic.gdx.backends.android;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.os.Debug;
import android.os.Handler;
Expand Down Expand Up @@ -167,7 +165,7 @@ public void dispose () {

createWakeLock(config.useWakelock);
useImmersiveMode(this.useImmersiveMode);
if (this.useImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) {
if (this.useImmersiveMode) {
AndroidVisibilityListener vlistener = new AndroidVisibilityListener();
vlistener.createListener(this);
}
Expand Down Expand Up @@ -214,10 +212,9 @@ public void onWindowFocusChanged (boolean hasFocus) {
}
}

@TargetApi(19)
@Override
public void useImmersiveMode (boolean use) {
if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return;
if (!use) return;

View view = getWindow().getDecorView();
int code = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @author davebaol */
public interface AndroidApplicationBase extends Application {

static final int MINIMUM_SDK = 14;
static final int MINIMUM_SDK = 19;

/** The application or activity context
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@

package com.badlogic.gdx.backends.android;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.opengl.GLSurfaceView;
import android.os.Build;
import android.os.Debug;
import android.os.Handler;
import android.os.Looper;
Expand All @@ -43,7 +41,6 @@
* for the {@link GLSurfaceView}.
*
* @author mzechner */
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public class AndroidDaydream extends DreamService implements AndroidApplicationBase {

protected AndroidGraphics graphics;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

package com.badlogic.gdx.backends.android;

import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Debug;
import android.os.Handler;
import android.util.Log;
Expand Down Expand Up @@ -86,10 +84,9 @@ protected void createWakeLock (boolean use) {
}
}

@TargetApi(19)
@Override
public void useImmersiveMode (boolean use) {
if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return;
if (!use) return;

View view = this.graphics.getView();

Expand Down Expand Up @@ -168,7 +165,7 @@ public void dispose () {
Gdx.net = this.getNet();
createWakeLock(config.useWakelock);
useImmersiveMode(config.useImmersiveMode);
if (config.useImmersiveMode && getVersion() >= Build.VERSION_CODES.KITKAT) {
if (config.useImmersiveMode) {
AndroidVisibilityListener vlistener = new AndroidVisibilityListener();
vlistener.createListener(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

package com.badlogic.gdx.backends.android;

import android.annotation.TargetApi;
import android.opengl.GLES30;

import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.utils.GdxRuntimeException;

@TargetApi(18)
public class AndroidGL30 extends AndroidGL20 implements GL30 {
@Override
public void glReadBuffer (int mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,14 +723,9 @@ public DisplayMode getDisplayMode () {
Display display;
DisplayMetrics metrics = new DisplayMetrics();

if (Build.VERSION.SDK_INT >= 17) {
DisplayManager displayManager = (DisplayManager)app.getContext().getSystemService(Context.DISPLAY_SERVICE);
display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
display.getRealMetrics(metrics); // Deprecated but no direct equivalent
} else {
display = app.getWindowManager().getDefaultDisplay();
display.getMetrics(metrics); // Excludes system UI!
}
DisplayManager displayManager = (DisplayManager)app.getContext().getSystemService(Context.DISPLAY_SERVICE);
display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
display.getRealMetrics(metrics); // Deprecated but no direct equivalent

int width = metrics.widthPixels;
int height = metrics.heightPixels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.PixelFormat;
import android.opengl.GLSurfaceView;
Expand Down Expand Up @@ -86,21 +85,17 @@ public InputConnection onCreateInputConnection (EditorInfo outAttrs) {
BaseInputConnection connection = new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText (int beforeLength, int afterLength) {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion >= 16) {
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
return super.deleteSurroundingText(beforeLength, afterLength);
}

@TargetApi(16)
private void sendDownUpKeyEventForBackwardCompatibility (final int code) {
final long eventTime = SystemClock.uptimeMillis();
super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class DependencyBank {
static String roboVMVersion = "2.3.20";
static String buildToolsVersion = "33.0.2";
static String androidAPILevel = "33";
static String androidMinAPILevel = "14";
static String androidMinAPILevel = "19";
static String gwtVersion = "2.10.0";

// Repositories
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ versions.androidPlugin = "8.1.2"
versions.multiDex = "2.0.1"
versions.androidCompileSdk = 33
versions.androidTargetSdk = 33
versions.androidMinSdk = 14
versions.androidMinSdk = 19
versions.androidBuildTools = "33.0.2"
versions.androidFragment = "1.5.7"
versions.javaparser = "2.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@

package com.badlogic.gdx.tests.android;

import android.annotation.TargetApi;
import android.util.Log;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.badlogic.gdx.backends.android.AndroidDaydream;
import com.badlogic.gdx.tests.MeshShaderTest;

@TargetApi(17)
public class Daydream extends AndroidDaydream {
@Override
public void onAttachedToWindow () {
Expand Down

0 comments on commit 6ff5855

Please sign in to comment.