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): Added settings value to control 'setUseWideViewPort' #5414

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -424,6 +424,7 @@ private void initWebView() {
settings.setAppCacheEnabled(true);
settings.setMediaPlaybackRequiresUserGesture(false);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setUseWideViewPort(this.config.useWideViewPort());
if (this.config.isMixedContentAllowed()) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
Expand Down
13 changes: 12 additions & 1 deletion android/capacitor/src/main/java/com/getcapacitor/CapConfig.java
Expand Up @@ -41,7 +41,7 @@ public class CapConfig {
private boolean webContentsDebuggingEnabled = false;
private boolean loggingEnabled = true;
private boolean initialFocus = true;

private boolean useWideViewPort = false;
// Embedded
private String startPath;

Expand Down Expand Up @@ -118,6 +118,7 @@ private CapConfig(Builder builder) {
this.webContentsDebuggingEnabled = builder.webContentsDebuggingEnabled;
this.loggingEnabled = builder.loggingEnabled;
this.initialFocus = builder.initialFocus;
this.useWideViewPort = builder.useWideViewPort;

// Embedded
this.startPath = builder.startPath;
Expand Down Expand Up @@ -190,6 +191,7 @@ private void deserializeConfig(@Nullable Context context) {
}

initialFocus = JSONUtils.getBoolean(configJSON, "android.initialFocus", initialFocus);
useWideViewPort = JSONUtils.getBoolean(configJSON, "android.useWideViewPort", useWideViewPort);

// Plugins
pluginsConfiguration = deserializePluginsConfig(JSONUtils.getObject(configJSON, "plugins"));
Expand Down Expand Up @@ -251,6 +253,9 @@ public boolean isInitialFocus() {
return initialFocus;
}

public boolean useWideViewPort() {
return useWideViewPort;
}
public PluginConfig getPluginConfiguration(String pluginId) {
PluginConfig pluginConfig = pluginsConfiguration.get(pluginId);
if (pluginConfig == null) {
Expand Down Expand Up @@ -407,6 +412,7 @@ public static class Builder {
private Boolean webContentsDebuggingEnabled = null;
private boolean loggingEnabled = true;
private boolean initialFocus = false;
private boolean useWideViewPort = false;

// Embedded
private String startPath = null;
Expand Down Expand Up @@ -510,5 +516,10 @@ public Builder setInitialFocus(boolean focus) {
this.initialFocus = focus;
return this;
}

public Builder setUseWideViewPort(boolean useWideViewPort) {
this.useWideViewPort = useWideViewPort;
return this;
}
}
}