diff options
Diffstat (limited to 'platform/android/java')
14 files changed, 45 insertions, 57 deletions
diff --git a/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java b/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java index 0572cf3589..b12844702a 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Dictionary.java @@ -43,10 +43,10 @@ public class Dictionary extends HashMap<String, Object> { for (String key : keys) { ret[i] = key; i++; - }; + } return ret; - }; + } public Object[] get_values() { Object[] ret = new Object[size()]; @@ -55,21 +55,21 @@ public class Dictionary extends HashMap<String, Object> { for (String key : keys) { ret[i] = get(key); i++; - }; + } return ret; - }; + } public void set_keys(String[] keys) { keys_cache = keys; - }; + } public void set_values(Object[] vals) { int i = 0; for (String key : keys_cache) { put(key, vals[i]); i++; - }; + } keys_cache = null; - }; -}; + } +} diff --git a/platform/android/java/lib/src/org/godotengine/godot/Godot.java b/platform/android/java/lib/src/org/godotengine/godot/Godot.java index 0c16214c8a..d66d7fde4b 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/lib/src/org/godotengine/godot/Godot.java @@ -70,10 +70,8 @@ import android.os.VibrationEffect; import android.os.Vibrator; import android.provider.Settings.Secure; import android.view.Display; -import android.view.InputDevice; import android.view.KeyEvent; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.ViewGroup; @@ -175,7 +173,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC public static GodotNetUtils netUtils; public interface ResultCallback { - public void callback(int requestCode, int resultCode, Intent data); + void callback(int requestCode, int resultCode, Intent data); } public ResultCallback result_callback; @@ -220,7 +218,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC for (int i = 0; i < permissions.length; i++) { GodotLib.requestPermissionResult(permissions[i], grantResults[i] == PackageManager.PERMISSION_GRANTED); } - }; + } /** * Invoked on the render thread when the Godot setup is complete. @@ -534,7 +532,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC String main_pack_md5 = null; String main_pack_key = null; - List<String> new_args = new LinkedList<String>(); + List<String> new_args = new LinkedList<>(); for (int i = 0; i < command_line.length; i++) { boolean has_extra = i < command_line.length - 1; @@ -780,7 +778,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC int displayRotation = display.getRotation(); float[] adjustedValues = new float[3]; - final int axisSwap[][] = { + final int[][] axisSwap = { { 1, -1, 0, 1 }, // ROTATION_0 { -1, -1, 1, 0 }, // ROTATION_90 { -1, 1, 0, 1 }, // ROTATION_180 @@ -897,7 +895,7 @@ public class Godot extends Fragment implements SensorEventListener, IDownloaderC byte[] messageDigest = complete.digest(); // Create Hex String - StringBuffer hexString = new StringBuffer(); + StringBuilder hexString = new StringBuilder(); for (int i = 0; i < messageDigest.length; i++) { String s = Integer.toHexString(0xFF & messageDigest[i]); diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java index 12a8bdb90b..071872dff8 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotIO.java @@ -34,11 +34,9 @@ import org.godotengine.godot.input.*; import android.app.Activity; import android.content.*; -import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.AssetManager; import android.graphics.Point; -import android.media.*; import android.net.Uri; import android.os.*; import android.util.DisplayMetrics; @@ -323,8 +321,8 @@ public class GodotIO { am = p_activity.getAssets(); activity = p_activity; //streams = new HashMap<Integer, AssetData>(); - streams = new SparseArray<AssetData>(); - dirs = new SparseArray<AssetDir>(); + streams = new SparseArray<>(); + dirs = new SparseArray<>(); } ///////////////////////// @@ -386,7 +384,7 @@ public class GodotIO { Point size = new Point(); display.getRealSize(size); - int result[] = { 0, 0, size.x, size.y }; + int[] result = { 0, 0, size.x, size.y }; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { WindowInsets insets = activity.getWindow().getDecorView().getRootWindowInsets(); DisplayCutout cutout = insets.getDisplayCutout(); @@ -408,12 +406,12 @@ public class GodotIO { //InputMethodManager inputMgr = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE); //inputMgr.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); - }; + } public void hideKeyboard() { if (edit != null) edit.hideKeyboard(); - }; + } public void setScreenOrientation(int p_orientation) { switch (p_orientation) { diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java index 8108118388..95870acda1 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotLib.java @@ -34,7 +34,6 @@ import android.app.Activity; import android.hardware.SensorEvent; import android.view.Surface; -import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.opengles.GL10; /** diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java index ac333dd827..79007764a7 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderView.java @@ -35,18 +35,18 @@ import org.godotengine.godot.input.GodotInputHandler; import android.view.SurfaceView; public interface GodotRenderView { - abstract public SurfaceView getView(); + SurfaceView getView(); - abstract public void initInputDevices(); + void initInputDevices(); - abstract public void queueOnRenderThread(Runnable event); + void queueOnRenderThread(Runnable event); - abstract public void onActivityPaused(); - abstract public void onActivityResumed(); + void onActivityPaused(); + void onActivityResumed(); - abstract public void onBackPressed(); + void onBackPressed(); - abstract public GodotInputHandler getInputHandler(); + GodotInputHandler getInputHandler(); - abstract public void setPointerIcon(int pointerType); + void setPointerIcon(int pointerType); } diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java index 59bdbf7f8d..878a119c5c 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotRenderer.java @@ -34,7 +34,6 @@ import org.godotengine.godot.plugin.GodotPlugin; import org.godotengine.godot.plugin.GodotPluginRegistry; import org.godotengine.godot.utils.GLUtils; -import android.content.Context; import android.opengl.GLSurfaceView; import javax.microedition.khronos.egl.EGLConfig; diff --git a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java index 169c6cf770..356ad7c770 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java +++ b/platform/android/java/lib/src/org/godotengine/godot/GodotVulkanRenderView.java @@ -39,7 +39,6 @@ import android.annotation.SuppressLint; import android.content.Context; import android.os.Build; import android.view.GestureDetector; -import android.view.InputDevice; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.PointerIcon; diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index 435b8b325f..e8dcc5a4bc 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -45,13 +45,9 @@ import android.view.InputDevice.MotionRange; import android.view.KeyEvent; import android.view.MotionEvent; -import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; import java.util.HashSet; -import java.util.List; -import java.util.Map; import java.util.Set; /** @@ -64,7 +60,7 @@ public class GodotInputHandler implements InputDeviceListener { private final String tag = this.getClass().getSimpleName(); private final SparseIntArray mJoystickIds = new SparseIntArray(4); - private final SparseArray<Joystick> mJoysticksDevices = new SparseArray<Joystick>(4); + private final SparseArray<Joystick> mJoysticksDevices = new SparseArray<>(4); public GodotInputHandler(GodotRenderView godotView) { mRenderView = godotView; @@ -333,7 +329,7 @@ public class GodotInputHandler implements InputDeviceListener { //Helps with creating new joypad mappings. Log.i(tag, "=== New Input Device: " + joystick.name); - Set<Integer> already = new HashSet<Integer>(); + Set<Integer> already = new HashSet<>(); for (InputDevice.MotionRange range : device.getMotionRanges()) { boolean isJoystick = range.isFromSource(InputDevice.SOURCE_JOYSTICK); boolean isGamepad = range.isFromSource(InputDevice.SOURCE_GAMEPAD); diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java index 62810ad3a4..21fdc658bb 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerCompat.java @@ -28,14 +28,14 @@ public interface InputManagerCompat { * @param id The device id * @return The input device or null if not found */ - public InputDevice getInputDevice(int id); + InputDevice getInputDevice(int id); /** * Gets the ids of all input devices in the system. * * @return The input device ids. */ - public int[] getInputDeviceIds(); + int[] getInputDeviceIds(); /** * Registers an input device listener to receive notifications about when @@ -46,7 +46,7 @@ public interface InputManagerCompat { * null if the listener should be invoked on the calling thread's * looper. */ - public void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener, + void registerInputDeviceListener(InputManagerCompat.InputDeviceListener listener, Handler handler); /** @@ -54,7 +54,7 @@ public interface InputManagerCompat { * * @param listener The listener to unregister. */ - public void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener); + void unregisterInputDeviceListener(InputManagerCompat.InputDeviceListener listener); /* * The following three calls are to simulate V16 behavior on pre-Jellybean @@ -69,7 +69,7 @@ public interface InputManagerCompat { * * @param event the motion event from the app */ - public void onGenericMotionEvent(MotionEvent event); + void onGenericMotionEvent(MotionEvent event); /** * Tell the V9 input manager that it should stop polling for disconnected @@ -77,7 +77,7 @@ public interface InputManagerCompat { * might want to call it whenever your game is not active (or whenever you * don't care about being notified of new input devices) */ - public void onPause(); + void onPause(); /** * Tell the V9 input manager that it should start polling for disconnected @@ -85,9 +85,9 @@ public interface InputManagerCompat { * might want to call it less often (only when the gameplay is actually * active) */ - public void onResume(); + void onResume(); - public interface InputDeviceListener { + interface InputDeviceListener { /** * Called whenever the input manager detects that a device has been * added. This will only be called in the V9 version when a motion event @@ -119,7 +119,7 @@ public interface InputManagerCompat { /** * Use this to construct a compatible InputManager. */ - public static class Factory { + class Factory { /** * Constructs and returns a compatible InputManger * diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java index 61828dccae..0dbc13c77b 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/InputManagerV16.java @@ -34,7 +34,7 @@ public class InputManagerV16 implements InputManagerCompat { public InputManagerV16(Context context) { mInputManager = (InputManager)context.getSystemService(Context.INPUT_SERVICE); - mListeners = new HashMap<InputManagerCompat.InputDeviceListener, V16InputDeviceListener>(); + mListeners = new HashMap<>(); } @Override diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/Joystick.java b/platform/android/java/lib/src/org/godotengine/godot/input/Joystick.java index 095fa9bd2a..bff90d7ce9 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/Joystick.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/Joystick.java @@ -41,12 +41,12 @@ import java.util.List; class Joystick { int device_id; String name; - List<Integer> axes = new ArrayList<Integer>(); + List<Integer> axes = new ArrayList<>(); protected boolean hasAxisHat = false; /* * Keep track of values so we can prevent flooding the engine with useless events. */ - protected final SparseArray<Float> axesValues = new SparseArray<Float>(4); + protected final SparseArray<Float> axesValues = new SparseArray<>(4); protected int hatX; protected int hatY; } diff --git a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java index 6c8a3d4219..2dc8359615 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java +++ b/platform/android/java/lib/src/org/godotengine/godot/plugin/GodotPlugin.java @@ -136,7 +136,7 @@ public abstract class GodotPlugin { nativeRegisterSingleton(pluginName, pluginObject); Set<Method> filteredMethods = new HashSet<>(); - Class clazz = pluginObject.getClass(); + Class<?> clazz = pluginObject.getClass(); Method[] methods = clazz.getDeclaredMethods(); for (Method method : methods) { @@ -157,8 +157,8 @@ public abstract class GodotPlugin { for (Method method : filteredMethods) { List<String> ptr = new ArrayList<>(); - Class[] paramTypes = method.getParameterTypes(); - for (Class c : paramTypes) { + Class<?>[] paramTypes = method.getParameterTypes(); + for (Class<?> c : paramTypes) { ptr.add(c.getName()); } diff --git a/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java b/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java index d6e49bb635..2b6e4ad2be 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java +++ b/platform/android/java/lib/src/org/godotengine/godot/utils/Crypt.java @@ -39,10 +39,10 @@ public class Crypt { // Create MD5 Hash MessageDigest digest = java.security.MessageDigest.getInstance("MD5"); digest.update(input.getBytes()); - byte messageDigest[] = digest.digest(); + byte[] messageDigest = digest.digest(); // Create Hex String - StringBuffer hexString = new StringBuffer(); + StringBuilder hexString = new StringBuilder(); for (int i = 0; i < messageDigest.length; i++) hexString.append(Integer.toHexString(0xFF & messageDigest[i])); return hexString.toString(); diff --git a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularContextFactory.java b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularContextFactory.java index 71610d2d00..c852e8759a 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularContextFactory.java +++ b/platform/android/java/lib/src/org/godotengine/godot/xr/regular/RegularContextFactory.java @@ -30,7 +30,6 @@ package org.godotengine.godot.xr.regular; -import org.godotengine.godot.GodotLib; import org.godotengine.godot.utils.GLUtils; import android.opengl.GLSurfaceView; |