implement Uri.Builder with hack for content:// URIs

This commit is contained in:
Julian Winkler
2024-03-20 22:21:09 +01:00
parent e0b3975eb7
commit e8dc6e2f0d

View File

@@ -1,6 +1,8 @@
package android.net;
import java.net.URI;
import java.net.URISyntaxException;
import libcore.net.UriCodec;
import java.io.File;
@@ -147,9 +149,39 @@ public class Uri implements Parcelable {
}
public static final class Builder {
private String scheme;
private String authority;
private String path;
public Builder appendQueryParameter(String key, String value) {
return this;
}
public Builder scheme(String scheme) {
this.scheme = scheme;
return this;
}
public Builder authority(String authority) {
this.authority = authority;
return this;
}
public Builder encodedPath(String encodedPath) {
this.path = decode(encodedPath);
return this;
}
public Uri build() throws URISyntaxException {
if ("content".equals(scheme)) { // hack: content providers not yet supported
scheme = "file";
authority = null;
path = path.substring(path.indexOf("/"));
}
Uri ret = new Uri();
ret.uri = new URI(scheme, authority, path, null, null);
return ret;
}
}
public String getScheme() {