Fix check for file subtype
This commit is contained in:
parent
0c52eeef18
commit
b2cd27f6a2
1 changed files with 30 additions and 14 deletions
|
@ -1010,12 +1010,20 @@ public class SettingsHelper {
|
||||||
name = fileName.substring(1);
|
name = fileName.substring(1);
|
||||||
}
|
}
|
||||||
for (FileSubtype subtype : FileSubtype.values()) {
|
for (FileSubtype subtype : FileSubtype.values()) {
|
||||||
if (subtype == ROUTING_CONFIG || subtype == RENDERING_STYLE) {
|
switch (subtype) {
|
||||||
if (name.startsWith(subtype.subtypeFolder) || name.startsWith(subtype.subtypeName)) {
|
case UNKNOWN:
|
||||||
return subtype;
|
case OTHER:
|
||||||
}
|
break;
|
||||||
} else if (subtype != UNKNOWN && name.startsWith(subtype.subtypeFolder)) {
|
case OBF_MAP:
|
||||||
return subtype;
|
if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||||
|
return subtype;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (name.startsWith(subtype.subtypeFolder)) {
|
||||||
|
return subtype;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return UNKNOWN;
|
return UNKNOWN;
|
||||||
|
@ -1029,7 +1037,7 @@ public class SettingsHelper {
|
||||||
|
|
||||||
protected File file;
|
protected File file;
|
||||||
private File appPath;
|
private File appPath;
|
||||||
private FileSubtype subtype;
|
protected FileSubtype subtype;
|
||||||
|
|
||||||
public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException {
|
public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException {
|
||||||
super(app, file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
super(app, file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
||||||
|
@ -1071,13 +1079,15 @@ public class SettingsHelper {
|
||||||
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
||||||
super.readFromJson(json);
|
super.readFromJson(json);
|
||||||
String fileName = getFileName();
|
String fileName = getFileName();
|
||||||
String subtypeStr = json.has("subtype") ? json.getString("subtype") : null;
|
if (subtype == null) {
|
||||||
if (!Algorithms.isEmpty(subtypeStr)) {
|
String subtypeStr = json.has("subtype") ? json.getString("subtype") : null;
|
||||||
subtype = FileSubtype.getSubtypeByName(subtypeStr);
|
if (!Algorithms.isEmpty(subtypeStr)) {
|
||||||
} else if (!Algorithms.isEmpty(fileName)) {
|
subtype = FileSubtype.getSubtypeByName(subtypeStr);
|
||||||
subtype = FileSubtype.getSubtypeByFileName(fileName);
|
} else if (!Algorithms.isEmpty(fileName)) {
|
||||||
} else {
|
subtype = FileSubtype.getSubtypeByFileName(fileName);
|
||||||
subtype = FileSubtype.UNKNOWN;
|
} else {
|
||||||
|
subtype = FileSubtype.UNKNOWN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!Algorithms.isEmpty(fileName)) {
|
if (!Algorithms.isEmpty(fileName)) {
|
||||||
if (subtype == FileSubtype.OTHER) {
|
if (subtype == FileSubtype.OTHER) {
|
||||||
|
@ -1188,6 +1198,12 @@ public class SettingsHelper {
|
||||||
return SettingsItemType.RESOURCES;
|
return SettingsItemType.RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
||||||
|
subtype = FileSubtype.OTHER;
|
||||||
|
super.readFromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applyFileName(@NonNull String fileName) {
|
public boolean applyFileName(@NonNull String fileName) {
|
||||||
if (fileName.endsWith(File.separator)) {
|
if (fileName.endsWith(File.separator)) {
|
||||||
|
|
Loading…
Reference in a new issue