- Fix an issue which prevents to save all the settings (Save in onPause instead of onStop).

This commit is contained in:
dgis 2020-11-23 13:03:47 +01:00
parent 23184e86d2
commit 288bffd5ec
7 changed files with 32 additions and 24 deletions

View file

@ -63,6 +63,12 @@ LINKS
CHANGES CHANGES
Version 2.1 (2020-11-23)
- Fix an issue which prevents to save all the settings (Save in onPause instead of onStop).
Version 2.0 (2020-11-15) Version 2.0 (2020-11-15)
- Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63. - Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63.
@ -218,6 +224,9 @@ The Eric's Real scripts ("real*.kml" and "real*.bmp/png") are embedded in this a
TODO TODO
- Bug: Sometimes the haptic feedback is reset to its default! Actually, the full settings are gone!!! Searching a scenario to reproduce...
- Show KML log on request.
- Serial port support (via USB OTG and maybe Bluetooth).
- Manage the HP 48 port 2 with the same kind of interface for the memory card. - Manage the HP 48 port 2 with the same kind of interface for the memory card.
- 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 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).
- 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... - 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...

View file

@ -33,8 +33,8 @@ android {
applicationId "org.emulator.forty.eight" applicationId "org.emulator.forty.eight"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 29 targetSdkVersion 29
versionCode 17 versionCode 18
versionName "2.0" versionName "2.1"
setProperty("archivesBaseName", "Emu48-v$versionName") setProperty("archivesBaseName", "Emu48-v$versionName")
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild { externalNativeBuild {
@ -81,7 +81,7 @@ android {
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.2' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.preference:preference:1.1.1' implementation 'androidx.preference:preference:1.1.1'
implementation 'com.google.android.material:material:1.2.1' implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.documentfile:documentfile:1.0.1'

View file

@ -63,6 +63,12 @@ LINKS
CHANGES CHANGES
Version 2.1 (2020-11-23)
- Fix an issue which prevents to save all the settings (Save in onPause instead of onStop).
Version 2.0 (2020-11-15) Version 2.0 (2020-11-15)
- Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63. - Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63.

View file

@ -1020,7 +1020,7 @@ JNIEXPORT jboolean JNICALL Java_org_emulator_calculator_NativeLib_onLoadFlashROM
BOOL result = MapRom(filenameUTF8); BOOL result = MapRom(filenameUTF8);
cCurrentRomType = cCurrentRomTypeBackup; cCurrentRomType = cCurrentRomTypeBackup;
if(result) { if(result) {
UpdatePatches(true); // Apply the patch again if needed (not tested!) UpdatePatches(TRUE); // Apply the patch again if needed (not tested!)
if (!CrcRom(&wRomCrc)) // build patched ROM fingerprint and check for unpacked data if (!CrcRom(&wRomCrc)) // build patched ROM fingerprint and check for unpacked data
result = FALSE; result = FALSE;
if (result && bDocumentAvail) { if (result && bDocumentAvail) {

View file

@ -251,10 +251,10 @@ public class Settings extends PreferenceDataStore {
for (int i = 0; i < magic.length(); i++) { for (int i = 0; i < magic.length(); i++) {
fileOutputStream.write(magic.charAt(i)); fileOutputStream.write(magic.charAt(i));
} }
fileOutputStream.flush();
fileOutputStream.close(); fileOutputStream.close();
} }
} catch (IOException e) { } catch (IOException e) {
if(debug) Log.d(TAG, "saveInStateFile() Error");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -398,8 +398,8 @@ public class Settings extends PreferenceDataStore {
@Nullable @Nullable
@Override @Override
public String getString(String key, @Nullable String defValue) { public String getString(String key, @Nullable String defValue) {
if(debug) Log.d(TAG, "getString(key: '" + key + "')");
Object result = getValue(key); Object result = getValue(key);
if(debug) Log.d(TAG, "getString(key: '" + key + "') -> " + result);
if(result instanceof String) if(result instanceof String)
return (String) result; return (String) result;
return defValue; return defValue;
@ -420,8 +420,8 @@ public class Settings extends PreferenceDataStore {
@Override @Override
public int getInt(String key, int defValue) { public int getInt(String key, int defValue) {
if(debug) Log.d(TAG, "getInt(key: '" + key + "')");
Object result = getValue(key); Object result = getValue(key);
if(debug) Log.d(TAG, "getInt(key: '" + key + "') -> " + result);
if(result != null) if(result != null)
try { try {
return ((Number) result).intValue(); return ((Number) result).intValue();
@ -431,8 +431,8 @@ public class Settings extends PreferenceDataStore {
@Override @Override
public long getLong(String key, long defValue) { public long getLong(String key, long defValue) {
if(debug) Log.d(TAG, "getLong(key: '" + key + "')");
Object result = getValue(key); Object result = getValue(key);
if(debug) Log.d(TAG, "getLong(key: '" + key + "') -> " + result);
if(result != null) if(result != null)
try { try {
return ((Number) result).longValue(); return ((Number) result).longValue();
@ -442,8 +442,8 @@ public class Settings extends PreferenceDataStore {
@Override @Override
public float getFloat(String key, float defValue) { public float getFloat(String key, float defValue) {
if(debug) Log.d(TAG, "getFloat(key: '" + key + "')");
Object result = getValue(key); Object result = getValue(key);
if(debug) Log.d(TAG, "getFloat(key: '" + key + "') -> " + result);
if(result != null) if(result != null)
try { try {
return ((Number) result).floatValue(); return ((Number) result).floatValue();
@ -453,8 +453,8 @@ public class Settings extends PreferenceDataStore {
@Override @Override
public boolean getBoolean(String key, boolean defValue) { public boolean getBoolean(String key, boolean defValue) {
if(debug) Log.d(TAG, "getBoolean(key: '" + key + "')");
Object result = getValue(key); Object result = getValue(key);
if(debug) Log.d(TAG, "getBoolean(key: '" + key + "') -> " + result);
if(result != null) if(result != null)
try { try {
return (Boolean) result; return (Boolean) result;

View file

@ -273,19 +273,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
} }
@Override
protected void onResume() {
super.onResume();
}
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); // Following the Activity lifecycle (https://developer.android.com/reference/android/app/Activity),
} // the data must be saved in the onPause() event instead of onStop() simply because the onStop
// method is killable and may lead to the data half saved!
@Override if(saveWhenLaunchingActivity) {
protected void onStop() {
if(saveWhenLaunchingActivity) {
settings.putStringSet("MRU", mruLinkedHashMap.keySet()); settings.putStringSet("MRU", mruLinkedHashMap.keySet());
if (lcdOverlappingView != null) if (lcdOverlappingView != null)
lcdOverlappingView.saveViewLayout(); lcdOverlappingView.saveViewLayout();
@ -301,7 +294,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
clearFolderCache(); clearFolderCache();
} }
super.onStop(); super.onPause();
} }
@Override @Override
@ -1483,7 +1476,7 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
} }
private void migrateDeprecatedSettings() { private void migrateDeprecatedSettings() {
if(settings.hasValue("settings_haptic_feedback")) { if(!settings.hasValue("settings_haptic_feedback_duration") && settings.hasValue("settings_haptic_feedback")) {
settings.removeValue("settings_haptic_feedback"); settings.removeValue("settings_haptic_feedback");
settings.putInt("settings_haptic_feedback_duration", 25); settings.putInt("settings_haptic_feedback_duration", 25);
} }

View file

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.1.0' classpath 'com.android.tools.build:gradle:4.1.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong