Skip to content

Commit

Permalink
feat: add text zoom option with openWebView
Browse files Browse the repository at this point in the history
  • Loading branch information
陈泳澄 committed Dec 31, 2024
1 parent f3d1cbc commit 136093b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ public void openWebView(PluginCall call) {
Boolean.TRUE.equals(call.getBoolean("ignoreUntrustedSSLError", false))
);

options.setTextZoom(call.getDouble("textZoom"));

String proxyRequestsStr = call.getString("proxyRequests");
if (proxyRequestsStr != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public int getWidth() {
private boolean ignoreUntrustedSSLError;
private String preShowScript;
private Pattern proxyRequestsPattern = null;
private Double textZoom;

public Pattern getProxyRequestsPattern() {
return proxyRequestsPattern;
Expand All @@ -156,6 +157,14 @@ public void setTitle(String title) {
this.title = title;
}

public Double getTextZoom() {
return textZoom;
}

public void setTextZoom(Double textZoom) {
this.textZoom = textZoom;
}

public boolean getCloseModal() {
return CloseModal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,10 @@ public void presentWebView() {
_webView.getSettings().setAllowFileAccessFromFileURLs(true);
_webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
_webView.getSettings().setMediaPlaybackRequiresUserGesture(false);

//text zoom
int rounded = (int) Math.round(_options.getTextZoom() * 100);
_webView.getSettings().setTextZoom(rounded);

_webView.setWebViewClient(new WebViewClient());

_webView.setWebChromeClient(
Expand Down
4 changes: 4 additions & 0 deletions src/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ export interface OpenWebViewOptions {
height?: number;
};
};
/**
* text zoom in webview, 1.0 is 100%, 1.2 is 120%
*/
textZoom?: number
}

export interface InAppBrowserPlugin {
Expand Down

0 comments on commit 136093b

Please sign in to comment.