Fix check for file subtype
This commit is contained in:
parent
0c52eeef18
commit
b2cd27f6a2
1 changed files with 30 additions and 14 deletions
|
@ -1010,13 +1010,21 @@ 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)) {
|
||||
switch (subtype) {
|
||||
case UNKNOWN:
|
||||
case OTHER:
|
||||
break;
|
||||
case OBF_MAP:
|
||||
if (name.endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
|
||||
return subtype;
|
||||
}
|
||||
} else if (subtype != UNKNOWN && name.startsWith(subtype.subtypeFolder)) {
|
||||
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,6 +1079,7 @@ public class SettingsHelper {
|
|||
void readFromJson(@NonNull JSONObject json) throws JSONException {
|
||||
super.readFromJson(json);
|
||||
String fileName = getFileName();
|
||||
if (subtype == null) {
|
||||
String subtypeStr = json.has("subtype") ? json.getString("subtype") : null;
|
||||
if (!Algorithms.isEmpty(subtypeStr)) {
|
||||
subtype = FileSubtype.getSubtypeByName(subtypeStr);
|
||||
|
@ -1079,6 +1088,7 @@ public class SettingsHelper {
|
|||
} else {
|
||||
subtype = FileSubtype.UNKNOWN;
|
||||
}
|
||||
}
|
||||
if (!Algorithms.isEmpty(fileName)) {
|
||||
if (subtype == FileSubtype.OTHER) {
|
||||
name = fileName;
|
||||
|
@ -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