Split functions
This commit is contained in:
parent
fc9deccad7
commit
b5895e1fd8
2 changed files with 23 additions and 23 deletions
|
@ -514,10 +514,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStorageState(File f) {
|
|
||||||
return EnvironmentCompat.getStorageState(f); //Environment.MEDIA_MOUNTED
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<File> getStorageDirectories() {
|
public ArrayList<File> getStorageDirectories() {
|
||||||
ArrayList<File> list = null;
|
ArrayList<File> list = null;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
|
@ -530,7 +526,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
for (File f : list) {
|
for (File f : list) {
|
||||||
if (f != null) {
|
if (f != null) {
|
||||||
if (getStorageState(f).equals(Environment.MEDIA_MOUNTED))
|
if (EnvironmentCompat.getStorageState(f).equals(Environment.MEDIA_MOUNTED))
|
||||||
res.add(f);
|
res.add(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,24 +171,7 @@ public class BRouterView extends View {
|
||||||
String basedir = baseDir.getAbsolutePath();
|
String basedir = baseDir.getAbsolutePath();
|
||||||
AppLogger.log("using basedir: " + basedir);
|
AppLogger.log("using basedir: " + basedir);
|
||||||
|
|
||||||
String version = "v" + getContext().getString(R.string.app_version);
|
populateBasedir(basedir);
|
||||||
|
|
||||||
// create missing directories
|
|
||||||
assertDirectoryExists("project directory", new File(basedir, "brouter"), null, null);
|
|
||||||
segmentDir = new File(basedir, "/brouter/segments4");
|
|
||||||
if (assertDirectoryExists("data directory", segmentDir, "segments4.zip", null)) {
|
|
||||||
ConfigMigration.tryMigrateStorageConfig(
|
|
||||||
new File(basedir + "/brouter/segments3/storageconfig.txt"),
|
|
||||||
new File(basedir + "/brouter/segments4/storageconfig.txt"));
|
|
||||||
}
|
|
||||||
profileDir = new File(basedir, "brouter/profiles2");
|
|
||||||
assertDirectoryExists("profile directory", profileDir, "profiles2.zip", version);
|
|
||||||
modesDir = new File(basedir, "/brouter/modes");
|
|
||||||
assertDirectoryExists("modes directory", modesDir, "modes.zip", version);
|
|
||||||
assertDirectoryExists("readmes directory", new File(basedir, "brouter/readmes"), "readmes.zip", version);
|
|
||||||
|
|
||||||
File inputDir = new File(basedir, "brouter/import");
|
|
||||||
assertDirectoryExists("input directory", inputDir, null, version);
|
|
||||||
|
|
||||||
// new init is done move old files
|
// new init is done move old files
|
||||||
if (waitingForMigration) {
|
if (waitingForMigration) {
|
||||||
|
@ -294,6 +277,27 @@ public class BRouterView extends View {
|
||||||
waitingForSelection = true;
|
waitingForSelection = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateBasedir(String basedir) {
|
||||||
|
String version = "v" + getContext().getString(R.string.app_version);
|
||||||
|
|
||||||
|
// create missing directories
|
||||||
|
assertDirectoryExists("project directory", new File(basedir, "brouter"), null, null);
|
||||||
|
segmentDir = new File(basedir, "/brouter/segments4");
|
||||||
|
if (assertDirectoryExists("data directory", segmentDir, "segments4.zip", null)) {
|
||||||
|
ConfigMigration.tryMigrateStorageConfig(
|
||||||
|
new File(basedir + "/brouter/segments3/storageconfig.txt"),
|
||||||
|
new File(basedir + "/brouter/segments4/storageconfig.txt"));
|
||||||
|
}
|
||||||
|
profileDir = new File(basedir, "brouter/profiles2");
|
||||||
|
assertDirectoryExists("profile directory", profileDir, "profiles2.zip", version);
|
||||||
|
modesDir = new File(basedir, "/brouter/modes");
|
||||||
|
assertDirectoryExists("modes directory", modesDir, "modes.zip", version);
|
||||||
|
assertDirectoryExists("readmes directory", new File(basedir, "brouter/readmes"), "readmes.zip", version);
|
||||||
|
|
||||||
|
File inputDir = new File(basedir, "brouter/import");
|
||||||
|
assertDirectoryExists("input directory", inputDir, null, version);
|
||||||
|
}
|
||||||
|
|
||||||
private void moveFolders(String oldMigrationPath, String basedir) {
|
private void moveFolders(String oldMigrationPath, String basedir) {
|
||||||
File oldDir = new File(oldMigrationPath);
|
File oldDir = new File(oldMigrationPath);
|
||||||
File[] oldFiles = oldDir.listFiles();
|
File[] oldFiles = oldDir.listFiles();
|
||||||
|
|
Loading…
Reference in a new issue