From 80b4b3f68e364f4c27e99c19481a385486e3f895 Mon Sep 17 00:00:00 2001 From: U7484052 Date: Sat, 28 Oct 2023 12:11:35 +1100 Subject: [PATCH] Implemented API 31+ vibration service code to replace depreciated code --- CodenameOne/CodenameOne.iml | 20 -- CodenameOneDesigner/CodenameOneDesigner.iml | 41 ---- Ports/Android/CompatLibs/CompatLibs.iml | 20 -- .../impl/android/AndroidImplementation.java | 13 +- Ports/BlackBerryOS_5/BlackBerryOS_5.iml | 43 ---- Ports/J2ME/J2ME.iml | 43 ---- .../JavaSEWithSVGSupport.iml | 20 -- Ports/retro/retro.iml | 23 --- .../SampleProjectTemplate.iml | 43 ---- Samples/Samples.iml | 20 -- Samples/samples/samples.iml | 191 ------------------ .../TestNativeInterfaces.iml | 44 ---- tests/TestNativeInterfaces/native/native.iml | 24 --- 13 files changed, 12 insertions(+), 533 deletions(-) delete mode 100644 CodenameOne/CodenameOne.iml delete mode 100644 CodenameOneDesigner/CodenameOneDesigner.iml delete mode 100644 Ports/Android/CompatLibs/CompatLibs.iml delete mode 100644 Ports/BlackBerryOS_5/BlackBerryOS_5.iml delete mode 100644 Ports/J2ME/J2ME.iml delete mode 100644 Ports/JavaSEWithSVGSupport/JavaSEWithSVGSupport.iml delete mode 100644 Ports/retro/retro.iml delete mode 100644 Samples/SampleProjectTemplate/SampleProjectTemplate.iml delete mode 100644 Samples/Samples.iml delete mode 100644 Samples/samples/samples.iml delete mode 100644 tests/TestNativeInterfaces/TestNativeInterfaces.iml delete mode 100644 tests/TestNativeInterfaces/native/native.iml diff --git a/CodenameOne/CodenameOne.iml b/CodenameOne/CodenameOne.iml deleted file mode 100644 index 0708b640f8..0000000000 --- a/CodenameOne/CodenameOne.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/CodenameOneDesigner/CodenameOneDesigner.iml b/CodenameOneDesigner/CodenameOneDesigner.iml deleted file mode 100644 index 2c160ddf08..0000000000 --- a/CodenameOneDesigner/CodenameOneDesigner.iml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Ports/Android/CompatLibs/CompatLibs.iml b/Ports/Android/CompatLibs/CompatLibs.iml deleted file mode 100644 index 0708b640f8..0000000000 --- a/Ports/Android/CompatLibs/CompatLibs.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java b/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java index bef52e0456..e6439b6138 100644 --- a/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java +++ b/Ports/Android/src/com/codename1/impl/android/AndroidImplementation.java @@ -2610,7 +2610,18 @@ public int getSoftkeyCount() { public void vibrate(int duration) { if (!this.vibrateInitialized) { try { - v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); + /** + * Implementation takes into account for retrocompatability if the + * SDK ever needs to be reverted to pre 31 for some reason? + */ + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + // SDK >= 31 + VibratorManager vibratorManager = (VibratorManager) getSystemService(Context.VIBRATOR_MANAGER_SERVICE); + v = vibratorManager.getDefaultVibrator(); + } else { + // Backward compatability for SDK < 31 + v = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE); + } } catch (Throwable e) { Log.e("Codename One", "problem with virbrator(0)", e); } finally { diff --git a/Ports/BlackBerryOS_5/BlackBerryOS_5.iml b/Ports/BlackBerryOS_5/BlackBerryOS_5.iml deleted file mode 100644 index 3b2dd56502..0000000000 --- a/Ports/BlackBerryOS_5/BlackBerryOS_5.iml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Ports/J2ME/J2ME.iml b/Ports/J2ME/J2ME.iml deleted file mode 100644 index 3b2dd56502..0000000000 --- a/Ports/J2ME/J2ME.iml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Ports/JavaSEWithSVGSupport/JavaSEWithSVGSupport.iml b/Ports/JavaSEWithSVGSupport/JavaSEWithSVGSupport.iml deleted file mode 100644 index 0708b640f8..0000000000 --- a/Ports/JavaSEWithSVGSupport/JavaSEWithSVGSupport.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Ports/retro/retro.iml b/Ports/retro/retro.iml deleted file mode 100644 index 4139b4f84b..0000000000 --- a/Ports/retro/retro.iml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/SampleProjectTemplate/SampleProjectTemplate.iml b/Samples/SampleProjectTemplate/SampleProjectTemplate.iml deleted file mode 100644 index 3b2dd56502..0000000000 --- a/Samples/SampleProjectTemplate/SampleProjectTemplate.iml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/Samples.iml b/Samples/Samples.iml deleted file mode 100644 index 0708b640f8..0000000000 --- a/Samples/Samples.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/samples/samples.iml b/Samples/samples/samples.iml deleted file mode 100644 index 3a78ec2caf..0000000000 --- a/Samples/samples/samples.iml +++ /dev/null @@ -1,191 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/TestNativeInterfaces/TestNativeInterfaces.iml b/tests/TestNativeInterfaces/TestNativeInterfaces.iml deleted file mode 100644 index d6bffb43d0..0000000000 --- a/tests/TestNativeInterfaces/TestNativeInterfaces.iml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/TestNativeInterfaces/native/native.iml b/tests/TestNativeInterfaces/native/native.iml deleted file mode 100644 index 1fb8188b1b..0000000000 --- a/tests/TestNativeInterfaces/native/native.iml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file