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

Embedded Capacitor: Pass urlPath to Bridge #3405

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 7 additions & 3 deletions android/capacitor/src/main/java/com/getcapacitor/Bridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public Bridge(
CordovaInterfaceImpl cordovaInterface,
PluginManager pluginManager,
CordovaPreferences preferences,
JSONObject config
JSONObject config,
String urlPath
) {
this.context = context;
this.webView = webView;
Expand Down Expand Up @@ -163,10 +164,10 @@ public Bridge(
// Register our core plugins
this.registerAllPlugins();

this.loadWebView();
this.loadWebView(urlPath);
}

private void loadWebView() {
private void loadWebView(String urlPath) {
appUrlConfig = this.config.getString("server.url");
String[] appAllowNavigationConfig = this.config.getArray("server.allowNavigation");

Expand Down Expand Up @@ -200,6 +201,9 @@ private void loadWebView() {
appUrl += "/";
}
}
if (urlPath != null) {
appUrl += urlPath;
}

final boolean html5mode = this.config.getBoolean("server.html5mode", true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected void load(Bundle savedInstanceState) {

pluginManager = mockWebView.getPluginManager();
cordovaInterface.onCordovaInit(pluginManager);
bridge = new Bridge(this, webView, initialPlugins, cordovaInterface, pluginManager, preferences, this.config);
bridge = new Bridge(this, webView, initialPlugins, cordovaInterface, pluginManager, preferences, this.config, null);

Splash.showOnLaunch(this, bridge.getConfig());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public class BridgeFragment extends Fragment {
private PluginManager pluginManager;
private CordovaPreferences preferences;
private MockCordovaWebViewImpl mockWebView;
private int activityDepth = 0;
private String bridgeStartDir;
private String urlPath;

private String lastActivityPlugin;

Expand Down Expand Up @@ -80,11 +79,15 @@ public void addPlugin(Class<? extends Plugin> plugin) {
this.initialPlugins.add(plugin);
}

public void setUrlPath(String urlPath) {
this.urlPath = urlPath;
}

/**
* Load the WebView and create the Bridge
*/
protected void load(Bundle savedInstanceState) {
Logger.debug("Starting BridgeActivity");
Logger.debug("Starting BridgeFragment");

Bundle args = getArguments();
String startDir = null;
Expand All @@ -109,7 +112,7 @@ protected void load(Bundle savedInstanceState) {
preferences = new CordovaPreferences();
}

bridge = new Bridge(this.getActivity(), webView, initialPlugins, cordovaInterface, pluginManager, preferences, config);
bridge = new Bridge(this.getActivity(), webView, initialPlugins, cordovaInterface, pluginManager, preferences, config, urlPath);

if (startDir != null) {
bridge.setServerAssetPath(startDir);
Expand Down