Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): enable loading of assets outside of the content web asset directory #6301

Merged
merged 4 commits into from
Feb 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ProcessedRoute {

private String path;
private boolean isAsset;
private boolean ignoreAssetPath;

public String getPath() {
return path;
Expand All @@ -25,4 +26,12 @@ public boolean isAsset() {
public void setAsset(boolean asset) {
isAsset = asset;
}

public boolean isIgnoreAssetPath() {
return ignoreAssetPath;
}

public void setIgnoreAssetPath(boolean ignoreAssetPath) {
this.ignoreAssetPath = ignoreAssetPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ public InputStream handle(Uri url) {

// Pass path to routeProcessor if present
RouteProcessor routeProcessor = bridge.getRouteProcessor();
boolean ignoreAssetPath = false;
if (routeProcessor != null) {
ProcessedRoute processedRoute = bridge.getRouteProcessor().process("", path);
path = processedRoute.getPath();
isAsset = processedRoute.isAsset();
ignoreAssetPath = processedRoute.isIgnoreAssetPath();
}

try {
Expand All @@ -501,6 +503,8 @@ public InputStream handle(Uri url) {
}

stream = protocolHandler.openFile(path);
} else if (ignoreAssetPath) {
stream = protocolHandler.openAsset(path);
} else {
stream = protocolHandler.openAsset(assetPath + path);
}
Expand Down