From 161b1207c90d4577a4d471fd6b6a9a601a8b00bb Mon Sep 17 00:00:00 2001 From: dgis Date: Thu, 3 Sep 2020 00:12:42 +0200 Subject: [PATCH] - Prevent app not responding (ANR) in NativeLib.buttonUp(). - Fix a KML folder issue. --- ReadMe.txt | 6 ++---- app/build.gradle | 16 ++++++++-------- app/src/main/assets/ReadMe.txt | 9 +++++++++ app/src/main/cpp/win32-layer.c | 2 +- .../org/emulator/calculator/MainScreenView.java | 4 +++- .../org/emulator/forty/eight/MainActivity.java | 4 ++-- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index 1f88950..db7aa74 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -69,6 +69,7 @@ Version 1.9 (2020-09-XX) - If the memory card file for the port 2 cannot be found, prompt the user to choose a new memory card file. - Move the KML folder in the JSON settings embedded in the state file because Windows cannot open the state file with KML url longer than 256 byte. - Prevent to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc... +- Prevent app not responding (ANR) in NativeLib.buttonUp(). Version 1.8 (2020-05-24) @@ -204,13 +205,10 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp/png") are embedded in this a TODO -- Android 11 new storage issues :-( -- ANR in NativeLib.buttonUp(), should make Win32::InvalidateRect() asynchronous (may be the cause of the lag and freeze). -- Add the name of the file in the toast "State saved". +- The render pixels are very nice. A solution to obtain uniform pixel size could be a preset (a multiplier, auto) so the user could decide and upscale/downscale (Michael P). - Bug: In Xiaomi mi A3 under Android10, the haptic feedback does not work (add an intensity setting). - Somehow LEFT (Shift on the keyboard) + 7 activates the DIVIDE-key (z-Key)..., but with the NUM-Key it can make it work without problems... I think it might have something to do with the "/" sign on the Shifted-7-key. -- The render pixels are very nice. A solution to obtain uniform pixel size could be a preset (a multiplier, auto) so the user could decide and upscale/downscale (Michael P). - The clock seems unsynchronized sometimes (Michael P). - Retain a key by right clicking if it is from a mouse. - Add the possibility to load and save the flash in another file. diff --git a/app/build.gradle b/app/build.gradle index f1a1621..6ea5eb3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,8 +33,8 @@ android { applicationId "org.emulator.forty.eight" minSdkVersion 19 targetSdkVersion 29 - versionCode 15 - versionName "1.8" + versionCode 16 + versionName "1.9" setProperty("archivesBaseName", "Emu48-v$versionName") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { @@ -80,12 +80,12 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.2.0-beta01' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.constraintlayout:constraintlayout:2.0.1' implementation 'androidx.preference:preference:1.1.1' - implementation 'com.google.android.material:material:1.1.0' + implementation 'com.google.android.material:material:1.2.1' implementation 'androidx.documentfile:documentfile:1.0.1' - testImplementation 'junit:junit:4.13-beta-3' - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02' + testImplementation 'junit:junit:4.13' + androidTestImplementation 'androidx.test:runner:1.3.0' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' } diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index 2b9802d..f69688b 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -63,6 +63,15 @@ LINKS CHANGES +Version 1.9 (2020-09-XX) + +- If the KML folder does not exist (like the first time), prompt the user to choose a new KML folder. +- If the memory card file for the port 2 cannot be found, prompt the user to choose a new memory card file. +- Move the KML folder in the JSON settings embedded in the state file because Windows cannot open the state file with KML url longer than 256 byte. +- Prevent to auto save before launching the "Open...", "Save As...", "Load Object...", "Save Object...", etc... +- Prevent app not responding (ANR) in NativeLib.buttonUp(). + + Version 1.8 (2020-05-24) - Intercept the ESC keyboard key to allow the use of the BACK soft key. diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index b0c308b..e81161d 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -125,7 +125,7 @@ HANDLE CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, BOOL foundDocumentScheme = _tcsncmp(lpFileName, documentScheme, documentSchemeLength) == 0; BOOL urlContentSchemeFound = _tcsncmp(lpFileName, contentScheme, contentSchemeLength) == 0; - if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN /*|| chooseCurrentKmlMode == ChooseKmlMode_CHANGE_KML*/) { + if(chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN || chooseCurrentKmlMode == ChooseKmlMode_FILE_OPEN_WITH_FOLDER) { // A E48 state file can contain a path to the KML script. if(foundDocumentScheme) { // Keep for compatibility: diff --git a/app/src/main/java/org/emulator/calculator/MainScreenView.java b/app/src/main/java/org/emulator/calculator/MainScreenView.java index 09c93b1..dd530c8 100644 --- a/app/src/main/java/org/emulator/calculator/MainScreenView.java +++ b/app/src/main/java/org/emulator/calculator/MainScreenView.java @@ -215,7 +215,9 @@ public class MainScreenView extends PanAndScaleView { break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: - NativeLib.buttonUp((int) ((event.getX(actionIndex) - viewPanOffsetX) / viewScaleFactorX), (int) ((event.getY(actionIndex) - viewPanOffsetY) / viewScaleFactorY)); + post(() -> { + NativeLib.buttonUp((int) ((event.getX(actionIndex) - viewPanOffsetX) / viewScaleFactorX), (int) ((event.getY(actionIndex) - viewPanOffsetY) / viewScaleFactorY)); + }); currentButtonTouched.remove(actionIndex); preventToScroll = currentButtonTouched.size() > 0; if (debug) Log.d(TAG, "onTouchEvent() ACTION_UP, actionIndex: " + actionIndex + ", currentButtonTouched: " + currentButtonTouched.size() + ", preventToScroll: " + preventToScroll); 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 a8fd06b..3de94d3 100644 --- a/app/src/main/java/org/emulator/forty/eight/MainActivity.java +++ b/app/src/main/java/org/emulator/forty/eight/MainActivity.java @@ -1322,11 +1322,11 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On // Copy the port1 settings from the state file to the settings (for the UI). setPort1Settings(NativeLib.getPort1Plugged(), NativeLib.getPort1Writable()); // State file successfully opened. - if(kmlScriptFolder == null) { + String currentKml = NativeLib.getCurrentKml(); + if(kmlScriptFolder == null || currentKml.startsWith("document:")) { // Needed for compatibility: // The KML folder is not in the JSON settings embedded in the state file, // so, we need to extract it and change the variable szCurrentKml. - String currentKml = NativeLib.getCurrentKml(); Pattern patternKMLDocumentURL = Pattern.compile("document:([^|]+)\\|(.+)"); Matcher m = patternKMLDocumentURL.matcher(currentKml); if (m.find() && m.groupCount() == 2) {