Android: remove old code after Android-16 has been set as minimum requirement
authorSylvain Becker <sylvain.becker@gmail.com>
Wed, 16 Jan 2019 09:11:13 +0100
changeset 12549787e86a461f5
parent 12548 1ae839748d02
child 12550 08ef17bb974a
Android: remove old code after Android-16 has been set as minimum requirement
android-project/app/build.gradle
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java
     1.1 --- a/android-project/app/build.gradle	Mon Jan 14 19:43:25 2019 -0500
     1.2 +++ b/android-project/app/build.gradle	Wed Jan 16 09:11:13 2019 +0100
     1.3 @@ -13,13 +13,13 @@
     1.4          if (buildAsApplication) {
     1.5              applicationId "org.libsdl.app"
     1.6          }
     1.7 -        minSdkVersion 14
     1.8 +        minSdkVersion 16
     1.9          targetSdkVersion 26
    1.10          versionCode 1
    1.11          versionName "1.0"
    1.12          externalNativeBuild {
    1.13              ndkBuild {
    1.14 -                arguments "APP_PLATFORM=android-14"
    1.15 +                arguments "APP_PLATFORM=android-16"
    1.16                  abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
    1.17              }
    1.18          }
     2.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Mon Jan 14 19:43:25 2019 -0500
     2.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Wed Jan 16 09:11:13 2019 +0100
     2.3 @@ -245,12 +245,7 @@
     2.4          mSingleton = this;
     2.5          SDL.setContext(this);
     2.6  
     2.7 -        if (Build.VERSION.SDK_INT >= 11) {
     2.8 -            mClipboardHandler = new SDLClipboardHandler_API11();
     2.9 -        } else {
    2.10 -            /* Before API 11, no clipboard notification (eg no SDL_CLIPBOARDUPDATE) */
    2.11 -            mClipboardHandler = new SDLClipboardHandler_Old();
    2.12 -        }
    2.13 +        mClipboardHandler = new SDLClipboardHandler_API11();
    2.14  
    2.15          mHIDDeviceManager = HIDDeviceManager.acquire(this);
    2.16  
    2.17 @@ -1035,10 +1030,8 @@
    2.18      public static boolean isTextInputEvent(KeyEvent event) {
    2.19        
    2.20          // Key pressed with Ctrl should be sent as SDL_KEYDOWN/SDL_KEYUP and not SDL_TEXTINPUT
    2.21 -        if (Build.VERSION.SDK_INT >= 11) {
    2.22 -            if (event.isCtrlPressed()) {
    2.23 -                return false;
    2.24 -            }  
    2.25 +        if (event.isCtrlPressed()) {
    2.26 +            return false;
    2.27          }
    2.28  
    2.29          return event.isPrintingKey() || event.getKeyCode() == KeyEvent.KEYCODE_SPACE;
    2.30 @@ -1557,9 +1550,7 @@
    2.31          mDisplay = ((WindowManager)context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    2.32          mSensorManager = (SensorManager)context.getSystemService(Context.SENSOR_SERVICE);
    2.33  
    2.34 -        if (Build.VERSION.SDK_INT >= 12) {
    2.35 -            setOnGenericMotionListener(SDLActivity.getMotionListener());
    2.36 -        }
    2.37 +        setOnGenericMotionListener(SDLActivity.getMotionListener());
    2.38  
    2.39          // Some arbitrary defaults to avoid a potential division by zero
    2.40          mWidth = 1.0f;
    2.41 @@ -1776,17 +1767,12 @@
    2.42          int i = -1;
    2.43          float x,y,p;
    2.44  
    2.45 -        // !!! FIXME: dump this SDK check after 2.0.4 ships and require API14.
    2.46          // 12290 = Samsung DeX mode desktop mouse
    2.47          if ((event.getSource() == InputDevice.SOURCE_MOUSE || event.getSource() == 12290) && SDLActivity.mSeparateMouseAndTouch) {
    2.48 -            if (Build.VERSION.SDK_INT < 14) {
    2.49 -                mouseButton = 1; // all mouse buttons are the left button
    2.50 -            } else {
    2.51 -                try {
    2.52 -                    mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
    2.53 -                } catch(Exception e) {
    2.54 -                    mouseButton = 1;    // oh well.
    2.55 -                }
    2.56 +            try {
    2.57 +                mouseButton = (Integer) event.getClass().getMethod("getButtonState").invoke(event);
    2.58 +            } catch(Exception e) {
    2.59 +                mouseButton = 1;    // oh well.
    2.60              }
    2.61  
    2.62              // We need to check if we're in relative mouse mode and get the axis offset rather than the x/y values
    2.63 @@ -2164,33 +2150,3 @@
    2.64  
    2.65  }
    2.66  
    2.67 -class SDLClipboardHandler_Old implements
    2.68 -    SDLClipboardHandler {
    2.69 -   
    2.70 -    protected android.text.ClipboardManager mClipMgrOld;
    2.71 -  
    2.72 -    SDLClipboardHandler_Old() {
    2.73 -       mClipMgrOld = (android.text.ClipboardManager) SDL.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
    2.74 -    }
    2.75 -
    2.76 -    @Override
    2.77 -    public boolean clipboardHasText() {
    2.78 -       return mClipMgrOld.hasText();
    2.79 -    }
    2.80 -
    2.81 -    @Override
    2.82 -    public String clipboardGetText() {
    2.83 -       CharSequence text;
    2.84 -       text = mClipMgrOld.getText();
    2.85 -       if (text != null) {
    2.86 -          return text.toString();
    2.87 -       }
    2.88 -       return null;
    2.89 -    }
    2.90 -
    2.91 -    @Override
    2.92 -    public void clipboardSetText(String string) {
    2.93 -       mClipMgrOld.setText(string);
    2.94 -    }
    2.95 -}
    2.96 -
     3.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Mon Jan 14 19:43:25 2019 -0500
     3.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLControllerManager.java	Wed Jan 16 09:11:13 2019 +0100
     3.3 @@ -39,12 +39,8 @@
     3.4          if (mJoystickHandler == null) {
     3.5              if (Build.VERSION.SDK_INT >= 19) {
     3.6                  mJoystickHandler = new SDLJoystickHandler_API19();
     3.7 -            } else if (Build.VERSION.SDK_INT >= 16) {
     3.8 +            } else {
     3.9                  mJoystickHandler = new SDLJoystickHandler_API16();
    3.10 -            } else if (Build.VERSION.SDK_INT >= 12) {
    3.11 -                mJoystickHandler = new SDLJoystickHandler_API12();
    3.12 -            } else {
    3.13 -                mJoystickHandler = new SDLJoystickHandler();
    3.14              }
    3.15          }
    3.16  
    3.17 @@ -482,21 +478,18 @@
    3.18          // so the first controller seen by SDL matches what the receiver
    3.19          // considers to be the first controller
    3.20  
    3.21 -        if (Build.VERSION.SDK_INT >= 16)
    3.22 -        {
    3.23 -            for (int i = deviceIds.length - 1; i > -1; i--) {
    3.24 -                SDLHaptic haptic = getHaptic(deviceIds[i]);
    3.25 -                if (haptic == null) {
    3.26 -                    InputDevice device = InputDevice.getDevice(deviceIds[i]);
    3.27 -                    Vibrator vib = device.getVibrator();
    3.28 -                    if (vib.hasVibrator()) {
    3.29 -                        haptic = new SDLHaptic();
    3.30 -                        haptic.device_id = deviceIds[i];
    3.31 -                        haptic.name = device.getName();
    3.32 -                        haptic.vib = vib;
    3.33 -                        mHaptics.add(haptic);
    3.34 -                        SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
    3.35 -                    }
    3.36 +        for (int i = deviceIds.length - 1; i > -1; i--) {
    3.37 +            SDLHaptic haptic = getHaptic(deviceIds[i]);
    3.38 +            if (haptic == null) {
    3.39 +                InputDevice device = InputDevice.getDevice(deviceIds[i]);
    3.40 +                Vibrator vib = device.getVibrator();
    3.41 +                if (vib.hasVibrator()) {
    3.42 +                    haptic = new SDLHaptic();
    3.43 +                    haptic.device_id = deviceIds[i];
    3.44 +                    haptic.name = device.getName();
    3.45 +                    haptic.vib = vib;
    3.46 +                    mHaptics.add(haptic);
    3.47 +                    SDLControllerManager.nativeAddHaptic(haptic.device_id, haptic.name);
    3.48                  }
    3.49              }
    3.50          }
    3.51 @@ -504,11 +497,7 @@
    3.52          /* Check VIBRATOR_SERVICE */
    3.53          Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);
    3.54          if (vib != null) {
    3.55 -            if (Build.VERSION.SDK_INT >= 11) {
    3.56 -                hasVibratorService = vib.hasVibrator();
    3.57 -            } else {
    3.58 -                hasVibratorService = true;
    3.59 -            }
    3.60 +            hasVibratorService = vib.hasVibrator();
    3.61  
    3.62              if (hasVibratorService) {
    3.63                  SDLHaptic haptic = getHaptic(deviceId_VIBRATOR_SERVICE);
    3.64 @@ -843,4 +832,4 @@
    3.65          // Relative mouse in capture mode will only have relative for X/Y
    3.66          return event.getY(0);
    3.67      }
    3.68 -}
    3.69 \ No newline at end of file
    3.70 +}