diff --git a/ReadMe.txt b/ReadMe.txt index a7976e9..598e010 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -58,14 +58,13 @@ LINKS CHANGES -Version 2.7 (2024-06-XX) +Version 2.7 (2024-06-12) - Updated source code with Emu48 version 1.65+. This new version improve the serial communication. -- Attempt to fix haptic feedback with Android 13 (API deprecation). -- Patch the ROM files to prevent the calculator to sleep (Fix #22). +- Fix haptic feedback with Android 12 (API deprecation). +- Patch the ROM files to prevent the calculator to sleep, but not for HP 48gII/49G/50g (Fix #22). - Fix a potential crash about the permission to access the files. - Require at least Android 5.0 (4.4 previously). -BUG: In Emu48 with HP49 FlashCard, click on Android RECENT button, and comes back in the APP -> we lost the FlashCard! Version 2.6 (2022-08-19) @@ -269,8 +268,8 @@ FAQ TODO -- Test XSEND. -- Haptic feedback does not seems to work on Android 13, should check (J. Majors). +- NDK 26 does not compile +- Patching 49G to disable 10 min auto off causes a reset when touching the Recent button and coming back to the app. - Add an "haptic" feedback with a sound instead of a vibration (F. Giampietro). - Add a Cancel button to the HP48 memory card creator dialog. - Manage the HP 48 port 2 with the same kind of interface for the memory card. @@ -285,7 +284,7 @@ TODO BUILD -Emu48 for Android is built with Android Studio 2021.1.1 (2022). +Emu48 for Android is built with Android Studio 2023.3.1 (2024). And to generate an installable APK file with a real Android device, it MUST be signed. Either use Android Studio: diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5f61ea0..c7869d9 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -3,7 +3,7 @@ # Sets the minimum version of CMake required to build the native library. -cmake_minimum_required(VERSION 3.4.1) +cmake_minimum_required(VERSION 3.6.0) #add_compile_options(-DDEBUG_DISPLAY) #add_compile_options(-DDEBUG_SOUND) @@ -31,6 +31,10 @@ add_compile_options(-DLODEPNG_NO_COMPILE_CPP) add_compile_options(-DEMUXX=48) +#add_compile_options(-Wno-error=implicit-function-declaration) +add_compile_options(-fpermissive) +add_compile_options(-Wno-error=incompatible-pointer-types) + if(CMAKE_BUILD_TYPE STREQUAL Release) message("RELEASE BUILD") add_compile_options(-Ofast) @@ -103,4 +107,4 @@ target_link_libraries( # Specifies the target library. android jnigraphics OpenSLES - log) + log) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 57629ff..0288189 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,11 +33,24 @@ android { defaultConfig { applicationId "org.emulator.forty.eight" minSdk 21 - //targetSdk 33 + targetSdk 34 versionCode 26 versionName "2.7" setProperty("archivesBaseName", "Emu48-v$versionName") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + externalNativeBuild { + cmake { +// cppFlags '-std=c++11' +// cppFlags '-std=gnu99' +// cppFlags '-std=c99' +// cppFlags '-std=c++11 -std=gnu99' + +// cppFlags '-std=c++11 -Wno-error=implicit-function-declaration' +// add_compile_options(-fpermissive) + cppFlags '-std=c++11 -fpermissive -Wno-error=incompatible-pointer-types' + + } + } } if (canSign) { @@ -75,6 +88,7 @@ android { //version '3.18.1' } } + ndkVersion '25.1.8937393' } dependencies { diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index f0bac64..12f72ab 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -58,11 +58,11 @@ LINKS CHANGES -Version 2.7 (2024-06-09) +Version 2.7 (2024-06-12) - Updated source code with Emu48 version 1.65+. This new version improve the serial communication. - Attempt to fix haptic feedback with Android 13 (API deprecation). -- Patch the ROM files to prevent the calculator to sleep (Fix #22). +- Patch the ROM files to prevent the calculator to sleep, but not for HP 48gII/49G/50g (Fix #22). - Fix a potential crash about the permission to access the files. - Require at least Android 5.0 (4.4 previously). diff --git a/app/src/main/assets/calculators/calypso2k.kml b/app/src/main/assets/calculators/calypso2k.kml index 91587ce..0ea4a12 100644 --- a/app/src/main/assets/calculators/calypso2k.kml +++ b/app/src/main/assets/calculators/calypso2k.kml @@ -11,7 +11,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "calypso2k.png" Color 0 0 0 0 #Scale 3 9 diff --git a/app/src/main/assets/calculators/calypso4k.kml b/app/src/main/assets/calculators/calypso4k.kml index a1a1a96..3318b6d 100644 --- a/app/src/main/assets/calculators/calypso4k.kml +++ b/app/src/main/assets/calculators/calypso4k.kml @@ -11,7 +11,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "calypso4k.png" Color 0 0 0 0 #Scale 3 18 diff --git a/app/src/main/assets/calculators/real48gii-l.kml b/app/src/main/assets/calculators/real48gii-l.kml index 2b97566..5a08136 100644 --- a/app/src/main/assets/calculators/real48gii-l.kml +++ b/app/src/main/assets/calculators/real48gii-l.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "2" Rom "rom.49g" - Patch "patch.49g" Bitmap "real48gii-l.png" Icon "48gii.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real48gii-lc.kml b/app/src/main/assets/calculators/real48gii-lc.kml index a38e3c4..f1355c5 100644 --- a/app/src/main/assets/calculators/real48gii-lc.kml +++ b/app/src/main/assets/calculators/real48gii-lc.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "2" Rom "rom.49g" - Patch "patch.49g" Bitmap "real48gii-lc.png" Icon "48gii.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real49g-l.kml b/app/src/main/assets/calculators/real49g-l.kml index 3fd6d47..a3cb173 100644 --- a/app/src/main/assets/calculators/real49g-l.kml +++ b/app/src/main/assets/calculators/real49g-l.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "X" Rom "rom.49g" - Patch "patch.49g" Bitmap "real49g-l.png" Icon "49g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real49g-lc.kml b/app/src/main/assets/calculators/real49g-lc.kml index a99af4e..c8bbb9c 100644 --- a/app/src/main/assets/calculators/real49g-lc.kml +++ b/app/src/main/assets/calculators/real49g-lc.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "X" Rom "rom.49g" - Patch "patch.49g" Bitmap "real49g-lc.png" Icon "49g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real49gp-l.kml b/app/src/main/assets/calculators/real49gp-l.kml index 76db014..a4e1d2b 100644 --- a/app/src/main/assets/calculators/real49gp-l.kml +++ b/app/src/main/assets/calculators/real49gp-l.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "Q" Rom "rom.49g" - Patch "patch.49g" Bitmap "real49gp-l.png" Icon "49gp.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real49gp-lc.kml b/app/src/main/assets/calculators/real49gp-lc.kml index 5e463f5..1e656cf 100644 --- a/app/src/main/assets/calculators/real49gp-lc.kml +++ b/app/src/main/assets/calculators/real49gp-lc.kml @@ -14,7 +14,6 @@ Global Author "Eric Rechlin" Model "Q" Rom "rom.49g" - Patch "patch.49g" Bitmap "real49gp-lc.png" Icon "49gp.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real50g-blue-l.kml b/app/src/main/assets/calculators/real50g-blue-l.kml index f9ca676..8637564 100644 --- a/app/src/main/assets/calculators/real50g-blue-l.kml +++ b/app/src/main/assets/calculators/real50g-blue-l.kml @@ -14,7 +14,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "real50g-blue-l.png" Icon "50g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real50g-blue-lc.kml b/app/src/main/assets/calculators/real50g-blue-lc.kml index 70bc428..3a40fd5 100644 --- a/app/src/main/assets/calculators/real50g-blue-lc.kml +++ b/app/src/main/assets/calculators/real50g-blue-lc.kml @@ -14,7 +14,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "real50g-blue-lc.png" Icon "50g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real50g-l.kml b/app/src/main/assets/calculators/real50g-l.kml index 7e15fb3..22e59c8 100644 --- a/app/src/main/assets/calculators/real50g-l.kml +++ b/app/src/main/assets/calculators/real50g-l.kml @@ -15,7 +15,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "real50g-l.png" Icon "50g.ico" Color 0 190 190 190 diff --git a/app/src/main/assets/calculators/real50g-lc.kml b/app/src/main/assets/calculators/real50g-lc.kml index a963c92..36140dc 100644 --- a/app/src/main/assets/calculators/real50g-lc.kml +++ b/app/src/main/assets/calculators/real50g-lc.kml @@ -15,7 +15,6 @@ Global Model "Q" Class 50 Rom "rom.49g" - Patch "patch.49g" Bitmap "real50g-lc.png" Icon "50g.ico" Color 0 190 190 190 diff --git a/app/src/main/java/org/emulator/calculator/Serial.java b/app/src/main/java/org/emulator/calculator/Serial.java index f823e26..5d351a1 100644 --- a/app/src/main/java/org/emulator/calculator/Serial.java +++ b/app/src/main/java/org/emulator/calculator/Serial.java @@ -7,6 +7,7 @@ import android.content.Intent; import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbDeviceConnection; import android.hardware.usb.UsbManager; +import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.SystemClock; @@ -156,7 +157,8 @@ public class Serial { } if(usbConnection == null && usbPermission == UsbPermission.Unknown && !usbManager.hasPermission(driver.getDevice())) { usbPermission = UsbPermission.Requested; - PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_GRANT_USB), 0); + int flags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_MUTABLE : 0; + PendingIntent usbPermissionIntent = PendingIntent.getBroadcast(context, 0, new Intent(INTENT_ACTION_GRANT_USB), flags); usbManager.requestPermission(driver.getDevice(), usbPermissionIntent); if(debug) Log.d(TAG, "Request permission"); connectionStatus = "serial_connection_failed_user_has_not_given_permission"; diff --git a/app/src/main/java/org/emulator/calculator/Utils.java b/app/src/main/java/org/emulator/calculator/Utils.java index ab6a8cc..f67fae1 100644 --- a/app/src/main/java/org/emulator/calculator/Utils.java +++ b/app/src/main/java/org/emulator/calculator/Utils.java @@ -220,14 +220,11 @@ public class Utils { public static void vibrate(Vibrator vibrator, int durationInMilliSecond) { if(vibrator != null && durationInMilliSecond > 0) { - if (Build.VERSION.SDK_INT >= 33) - // https://developer.android.com/reference/android/os/Vibrator#vibrate(android.os.VibrationEffect,%20android.os.VibrationAttributes) - vibrator.vibrate(VibrationEffect.createOneShot(durationInMilliSecond, VibrationAttributes.USAGE_TOUCH)); - else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) - // https://developer.android.com/reference/android/os/Vibrator#vibrate(android.os.VibrationEffect,%20android.media.AudioAttributes) - vibrator.vibrate(VibrationEffect.createOneShot(durationInMilliSecond, VibrationEffect.DEFAULT_AMPLITUDE)); + long[] vibratePattern = { 0, durationInMilliSecond, 1000 }; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) + vibrator.vibrate(VibrationEffect.createWaveform(vibratePattern, -1)); else - //deprecated in API 26 + // Deprecated in API 26 vibrator.vibrate(durationInMilliSecond); } } diff --git a/app/src/main/java/org/emulator/forty/eight/MainActivity.java b/app/src/main/java/org/emulator/forty/eight/MainActivity.java index 96f69a2..a88ef9c 100644 --- a/app/src/main/java/org/emulator/forty/eight/MainActivity.java +++ b/app/src/main/java/org/emulator/forty/eight/MainActivity.java @@ -30,6 +30,7 @@ import android.os.Build; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.Vibrator; +import android.os.VibratorManager; import android.util.Log; import android.util.SparseArray; import android.view.LayoutInflater; @@ -165,7 +166,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On settings = EmuApplication.getSettings(); settings.setIsDefaultSettings(true); - vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + vibrator = ((VibratorManager)getSystemService(Context.VIBRATOR_MANAGER_SERVICE)).getDefaultVibrator(); + } else { + // Deprecated in API 31 + vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); + } ViewGroup mainScreenContainer = findViewById(R.id.main_screen_container); mainScreenView = new MainScreenView(this); diff --git a/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java b/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java index 558ac59..07bd8c7 100644 --- a/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java +++ b/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java @@ -20,8 +20,10 @@ import android.content.Context; import android.content.Intent; import android.content.res.Configuration; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.Vibrator; +import android.os.VibratorManager; import android.text.InputType; import android.util.Log; import android.view.LayoutInflater; @@ -214,7 +216,13 @@ public class SettingsFragment extends AppCompatDialogFragment { // Haptic feedback settings - Vibrator vibrator = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE); + Vibrator vibrator; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { + vibrator = ((VibratorManager)requireContext().getSystemService(Context.VIBRATOR_MANAGER_SERVICE)).getDefaultVibrator(); + } else { + vibrator = (Vibrator) requireContext().getSystemService(Context.VIBRATOR_SERVICE); + } + SeekBarPreference preferenceHapticFeedbackDuration = findPreference("settings_haptic_feedback_duration"); if(preferenceHapticFeedbackDuration != null) { preferenceHapticFeedbackDuration.setOnPreferenceChangeListener((preference, newValue) -> { diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index e2078d2..4e676f5 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -88,7 +88,7 @@ android:summary="@string/settings_haptic_feedback_summary" android:defaultValue="25" android:min="0" - android:max="50" + android:max="100" app:showSeekBarValue="true" /> diff --git a/build.gradle b/build.gradle index 242f4a6..48f755b 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.3.2' + classpath 'com.android.tools.build:gradle:8.4.2' // NOTE: Do not place your application dependencies here; they belong diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 12817ef..3f37000 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sat Jan 28 21:16:38 CET 2023 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME