Added option to remove specified file from SD card on upgrade
This commit is contained in:
@@ -444,6 +444,16 @@ if [ -n "$var" ] ; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DeleteFilesOnUpgrade" -o -z "$AUTO" ]; then
|
||||||
|
echo
|
||||||
|
echo -n "Delete application data files when upgrading (specify file/dir paths separated by spaces): ($DeleteFilesOnUpgrade): "
|
||||||
|
read var
|
||||||
|
if [ -n "$var" ] ; then
|
||||||
|
DeleteFilesOnUpgrade="$var"
|
||||||
|
CHANGED=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$CustomBuildScript" -o -z "$AUTO" ]; then
|
if [ -z "$CustomBuildScript" -o -z "$AUTO" ]; then
|
||||||
echo
|
echo
|
||||||
echo -n "Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) ($CustomBuildScript): "
|
echo -n "Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n) ($CustomBuildScript): "
|
||||||
@@ -575,6 +585,7 @@ echo MultiABI=$MultiABI >> AndroidAppSettings.cfg
|
|||||||
echo AppVersionCode=$AppVersionCode >> AndroidAppSettings.cfg
|
echo AppVersionCode=$AppVersionCode >> AndroidAppSettings.cfg
|
||||||
echo AppVersionName=\"$AppVersionName\" >> AndroidAppSettings.cfg
|
echo AppVersionName=\"$AppVersionName\" >> AndroidAppSettings.cfg
|
||||||
echo ResetSdlConfigForThisVersion=$ResetSdlConfigForThisVersion >> AndroidAppSettings.cfg
|
echo ResetSdlConfigForThisVersion=$ResetSdlConfigForThisVersion >> AndroidAppSettings.cfg
|
||||||
|
echo DeleteFilesOnUpgrade=\"$DeleteFilesOnUpgrade\" >> AndroidAppSettings.cfg
|
||||||
echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
|
echo CompiledLibraries=\"$CompiledLibraries\" >> AndroidAppSettings.cfg
|
||||||
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
|
echo CustomBuildScript=$CustomBuildScript >> AndroidAppSettings.cfg
|
||||||
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
|
echo AppCflags=\'$AppCflags\' >> AndroidAppSettings.cfg
|
||||||
@@ -808,6 +819,7 @@ cat project/src/Globals.java | \
|
|||||||
sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \
|
sed "s/public static boolean AppUsesMultitouch = .*;/public static boolean AppUsesMultitouch = $AppUsesMultitouch;/" | \
|
||||||
sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \
|
sed "s/public static boolean NonBlockingSwapBuffers = .*;/public static boolean NonBlockingSwapBuffers = $NonBlockingSwapBuffers;/" | \
|
||||||
sed "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \
|
sed "s/public static boolean ResetSdlConfigForThisVersion = .*;/public static boolean ResetSdlConfigForThisVersion = $ResetSdlConfigForThisVersion;/" | \
|
||||||
|
sed "s|public static String DeleteFilesOnUpgrade = .*;|public static String DeleteFilesOnUpgrade = \"$DeleteFilesOnUpgrade\";|" | \
|
||||||
sed "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" | \
|
sed "s/public static int AppTouchscreenKeyboardKeysAmount = .*;/public static int AppTouchscreenKeyboardKeysAmount = $AppTouchscreenKeyboardKeysAmount;/" | \
|
||||||
sed "s/public static int AppTouchscreenKeyboardKeysAmountAutoFire = .*;/public static int AppTouchscreenKeyboardKeysAmountAutoFire = $AppTouchscreenKeyboardKeysAmountAutoFire;/" | \
|
sed "s/public static int AppTouchscreenKeyboardKeysAmountAutoFire = .*;/public static int AppTouchscreenKeyboardKeysAmountAutoFire = $AppTouchscreenKeyboardKeysAmountAutoFire;/" | \
|
||||||
sed "s/public static int StartupMenuButtonTimeout = .*;/public static int StartupMenuButtonTimeout = $StartupMenuButtonTimeout;/" | \
|
sed "s/public static int StartupMenuButtonTimeout = .*;/public static int StartupMenuButtonTimeout = $StartupMenuButtonTimeout;/" | \
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class Globals {
|
|||||||
public static boolean AppUsesMultitouch = false;
|
public static boolean AppUsesMultitouch = false;
|
||||||
public static boolean NonBlockingSwapBuffers = false;
|
public static boolean NonBlockingSwapBuffers = false;
|
||||||
public static boolean ResetSdlConfigForThisVersion = false;
|
public static boolean ResetSdlConfigForThisVersion = false;
|
||||||
|
public static String DeleteFilesOnUpgrade = "";
|
||||||
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
public static int AppTouchscreenKeyboardKeysAmount = 4;
|
||||||
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
public static int AppTouchscreenKeyboardKeysAmountAutoFire = 1;
|
||||||
public static int StartupMenuButtonTimeout = 3000;
|
public static int StartupMenuButtonTimeout = 3000;
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ class Settings
|
|||||||
|
|
||||||
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 ) {
|
||||||
@@ -314,7 +315,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();
|
||||||
@@ -2418,6 +2419,29 @@ class Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean deleteRecursively(File dir)
|
||||||
|
{
|
||||||
|
if (dir.isDirectory()) {
|
||||||
|
String[] children = dir.list();
|
||||||
|
for (int i=0; i<children.length; i++) {
|
||||||
|
boolean success = deleteRecursively(new File(dir, children[i]));
|
||||||
|
if (!success)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dir.delete();
|
||||||
|
}
|
||||||
|
public static void DeleteFilesOnUpgrade()
|
||||||
|
{
|
||||||
|
String [] files = Globals.DeleteFilesOnUpgrade.split(" ");
|
||||||
|
for(String path: files) {
|
||||||
|
File f = new File( Globals.DataDir + "/" + path );
|
||||||
|
if( !f.exists() )
|
||||||
|
continue;
|
||||||
|
deleteRecursively(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===============================================================================================
|
// ===============================================================================================
|
||||||
|
|
||||||
static void Apply(Activity p)
|
static void Apply(Activity p)
|
||||||
|
|||||||
Reference in New Issue
Block a user