Fix to my prev commit

This commit is contained in:
pelya
2012-02-14 18:50:43 +02:00
parent 5ad654500f
commit a9e742b7b6

View File

@@ -285,26 +285,29 @@ class Settings
Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt(); Globals.TouchscreenKeyboardDrawSize = settingsFile.readInt();
int cfgVersion = settingsFile.readInt(); int cfgVersion = settingsFile.readInt();
System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion()); System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion());
if( Globals.ResetSdlConfigForThisVersion && cfgVersion < p.getApplicationVersion() ) if( cfgVersion < p.getApplicationVersion() )
{ {
System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file"); DeleteFilesOnUpgrade();
// Delete settings file, and restart the application if( Globals.ResetSdlConfigForThisVersion )
settingsFile.close(); {
ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE )); System.out.println("libSDL: old cfg version " + cfgVersion + ", our version " + p.getApplicationVersion() + " and we need to clean up config file");
out.writeInt(-1); // Delete settings file, and restart the application
out.close(); settingsFile.close();
new File( p.getFilesDir() + "/" + SettingsFileName ).delete(); ObjectOutputStream out = new ObjectOutputStream(p.openFileOutput( SettingsFileName, p.MODE_WORLD_READABLE ));
PendingIntent intent = PendingIntent.getActivity(p, 0, new Intent(p.getIntent()), p.getIntent().getFlags()); out.writeInt(-1);
AlarmManager mgr = (AlarmManager) p.getSystemService(Context.ALARM_SERVICE); out.close();
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent); new File( p.getFilesDir() + "/" + SettingsFileName ).delete();
System.exit(0); PendingIntent intent = PendingIntent.getActivity(p, 0, new Intent(p.getIntent()), p.getIntent().getFlags());
AlarmManager mgr = (AlarmManager) p.getSystemService(Context.ALARM_SERVICE);
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, intent);
System.exit(0);
}
} }
settingsLoaded = true; settingsLoaded = true;
System.out.println("libSDL: Settings.Load(): loaded settings successfully"); System.out.println("libSDL: Settings.Load(): loaded settings successfully");
settingsFile.close(); settingsFile.close();
DeleteFilesOnUpgrade();
return; return;
} catch( FileNotFoundException e ) { } catch( FileNotFoundException e ) {
@@ -315,7 +318,7 @@ class Settings
Globals.DataDir = Globals.DownloadToSdcard ? Globals.DataDir = Globals.DownloadToSdcard ?
Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() : Environment.getExternalStorageDirectory().getAbsolutePath() + "/app-data/" + Globals.class.getPackage().getName() :
p.getFilesDir().getAbsolutePath(); p.getFilesDir().getAbsolutePath();
DeleteFilesOnUpgrade();
// This code fails for both of my phones! // This code fails for both of my phones!
/* /*
Configuration c = new Configuration(); Configuration c = new Configuration();