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);
|
||||
}
|
||||
for (FileSubtype subtype : FileSubtype.values()) {
|
||||
if (subtype == ROUTING_CONFIG || subtype == RENDERING_STYLE) {
|
||||
if (name.startsWith(subtype.subtypeFolder) || name.startsWith(subtype.subtypeName)) {
|
||||
return subtype;
|
||||
}
|
||||
} else if (subtype != UNKNOWN && name.startsWith(subtype.subtypeFolder)) {
|
||||
return subtype;
|
||||
switch (subtype) {
|
||||
case UNKNOWN:
|
||||
case OTHER:
|
||||
break;
|
||||
case OBF_MAP:
|
||||
if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
return subtype;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (name.startsWith(subtype.subtypeFolder)) {
|
||||
return subtype;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return UNKNOWN;
|
||||
|
@ -1029,7 +1037,7 @@ public class SettingsHelper {
|
|||
|
||||
protected File file;
|
||||
private File appPath;
|
||||
private FileSubtype subtype;
|
||||
protected FileSubtype subtype;
|
||||
|
||||
public FileSettingsItem(@NonNull OsmandApplication app, @NonNull File file) throws IllegalArgumentException {
|
||||
super(app, file.getPath().replace(app.getAppPath(null).getPath(), ""));
|
||||
|
@ -1071,13 +1079,15 @@ public class SettingsHelper {
|
|||
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
||||
super.readFromJson(json);
|
||||
String fileName = getFileName();
|
||||
String subtypeStr = json.has("subtype") ? json.getString("subtype") : null;
|
||||
if (!Algorithms.isEmpty(subtypeStr)) {
|
||||
subtype = FileSubtype.getSubtypeByName(subtypeStr);
|
||||
} else if (!Algorithms.isEmpty(fileName)) {
|
||||
subtype = FileSubtype.getSubtypeByFileName(fileName);
|
||||
} else {
|
||||
subtype = FileSubtype.UNKNOWN;
|
||||
if (subtype == null) {
|
||||
String subtypeStr = json.has("subtype") ? json.getString("subtype") : null;
|
||||
if (!Algorithms.isEmpty(subtypeStr)) {
|
||||
subtype = FileSubtype.getSubtypeByName(subtypeStr);
|
||||
} else if (!Algorithms.isEmpty(fileName)) {
|
||||
subtype = FileSubtype.getSubtypeByFileName(fileName);
|
||||
} else {
|
||||
subtype = FileSubtype.UNKNOWN;
|
||||
}
|
||||
}
|
||||
if (!Algorithms.isEmpty(fileName)) {
|
||||
if (subtype == FileSubtype.OTHER) {
|
||||
|
@ -1188,6 +1198,12 @@ public class SettingsHelper {
|
|||
return SettingsItemType.RESOURCES;
|
||||
}
|
||||
|
||||
@Override
|
||||
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
||||
subtype = FileSubtype.OTHER;
|
||||
super.readFromJson(json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applyFileName(@NonNull String fileName) {
|
||||
if (fileName.endsWith(File.separator)) {
|
||||
|
|
Loading…
Reference in a new issue