Sometimes the Android runtime kills off the Bote process to save memory, and recreates it when the user next opens it. If the user was on an Activity that was not EmailListActivity, then when recreated the I2P system vars would not be set, and the first call to I2PBote.getInstance() would create an instance with invalid paths. This was non-fatal - killing Bote and restarting it would fix the problem - but was bad UX, because from the user's PoV all their emails and data had disappeared.
28 lines
811 B
Java
28 lines
811 B
Java
package i2p.bote.android;
|
|
|
|
import android.content.Context;
|
|
|
|
public class InitActivities {
|
|
private final Context ctx;
|
|
private final String myDir;
|
|
|
|
public InitActivities(Context c) {
|
|
ctx = c;
|
|
// This needs to be changed so that we can have an alternative place
|
|
myDir = c.getFilesDir().getAbsolutePath();
|
|
}
|
|
|
|
public void initialize() {
|
|
// Don't initialize twice
|
|
if (System.getProperty("i2pbote.initialized", "false").equals("true"))
|
|
return;
|
|
|
|
// Set up the locations so settings can find them
|
|
System.setProperty("i2p.dir.base", myDir);
|
|
System.setProperty("i2p.dir.config", myDir);
|
|
System.setProperty("wrapper.logfile", myDir + "/wrapper.log");
|
|
|
|
System.setProperty("i2pbote.initialized", "true");
|
|
}
|
|
}
|