Skip to content

Commit

Permalink
feat(android): add configurable app path for embedded capacitor (#4264)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlpoole authored Mar 3, 2021
1 parent c36104d commit e433691
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
Expand Down Expand Up @@ -203,6 +202,11 @@ private void loadWebView() {
}
}

String appUrlPath = this.config.getStartPath();
if (appUrlPath != null && !appUrlPath.trim().isEmpty()) {
appUrl += appUrlPath;
}

final boolean html5mode = this.config.isHTML5Mode();

// Start the local web server
Expand Down
18 changes: 18 additions & 0 deletions android/capacitor/src/main/java/com/getcapacitor/CapConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class CapConfig {
private boolean webContentsDebuggingEnabled = false;
private boolean hideLogs = false;

// Embedded
private String startPath;

// Plugins
private Map<String, PluginConfig> pluginsConfiguration = null;

Expand Down Expand Up @@ -109,6 +112,9 @@ private CapConfig(Builder builder) {
this.webContentsDebuggingEnabled = builder.webContentsDebuggingEnabled;
this.hideLogs = builder.hideLogs;

// Embedded
this.startPath = builder.startPath;

// Plugins Config
this.pluginsConfiguration = builder.pluginsConfiguration;
}
Expand Down Expand Up @@ -172,6 +178,10 @@ public String getHostname() {
return hostname;
}

public String getStartPath() {
return startPath;
}

public String getAndroidScheme() {
return androidScheme;
}
Expand Down Expand Up @@ -364,6 +374,9 @@ public static class Builder {
private Boolean webContentsDebuggingEnabled = null;
private boolean hideLogs = false;

// Embedded
private String startPath = null;

// Plugins Config Object
private Map<String, PluginConfig> pluginsConfiguration = new HashMap<>();

Expand Down Expand Up @@ -409,6 +422,11 @@ public Builder setHostname(String hostname) {
return this;
}

public Builder setStartPath(String path) {
this.startPath = path;
return this;
}

public Builder setAndroidScheme(String androidScheme) {
this.androidScheme = androidScheme;
return this;
Expand Down

0 comments on commit e433691

Please sign in to comment.