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

set zoom of webview content via webview textZoom feature #1497

Merged
merged 1 commit into from
Feb 15, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ private void openInBrowser(int currentPosition) {
link = rssItem.getLink();
}

if (link.length() > 0) {
if (!link.isEmpty()) {
newsDetailFragment.loadURL(link);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ public class NewsDetailFragment extends Fragment implements RssItemToHtmlTask.Li

private int section_number;
protected String html;
private String title = "";
private String baseUrl = null;
// private String title = "";
// private String baseUrl = null;
private final float scalingFactor = Float.parseFloat(mPrefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
// private GestureDetector mGestureDetector;


Expand Down Expand Up @@ -254,8 +255,7 @@ protected void startLoadRssItemToWebViewTask(NewsDetailActivity ndActivity) {

init_webView();
RssItem rssItem = ndActivity.rssItems.get(section_number);
title = rssItem.getTitle();
Log.d(TAG, "startLoadRssItemToWebViewTask: " + title);
Log.d(TAG, "startLoadRssItemToWebViewTask: " + rssItem.getTitle());
RssItemToHtmlTask task = new RssItemToHtmlTask(ndActivity, rssItem, this, mPrefs);
AsyncTaskHelper.StartAsyncTask(task);
}
Expand Down Expand Up @@ -306,6 +306,8 @@ private void applyWebSettings() {
webSettings.setSupportZoom(false);
webSettings.setMediaPlaybackRequiresUserGesture(true);

webSettings.setTextZoom(Math.round(scalingFactor * 100));

syncIncognitoState();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,14 @@
import com.bumptech.glide.request.target.Target;

import java.io.File;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import de.luhmer.owncloudnewsreader.R;
import de.luhmer.owncloudnewsreader.SettingsActivity;
import de.luhmer.owncloudnewsreader.database.model.Feed;
import de.luhmer.owncloudnewsreader.database.model.RssItem;
import de.luhmer.owncloudnewsreader.helper.ImageHandler;
Expand Down Expand Up @@ -127,9 +123,9 @@ public static String getHtmlPage(RequestManager glide, RssItem rssItem, boolean
builder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"web.css\" />");

// font size scaling
builder.append("<style type=\"text/css\">");
builder.append(getFontSizeScalingCss(mPrefs));
builder.append("</style>");
// builder.append("<style type=\"text/css\">");
// builder.append(getFontSizeScalingCss(mPrefs));
// builder.append("</style>");

builder.append(String.format("</head><body class=\"%s %s\">", body_id, rtlClass));

Expand Down Expand Up @@ -278,6 +274,7 @@ private static String getCachedFavIcon(RequestManager glide, String favIconUrl)
}
}

/*
private static String getFontSizeScalingCss(SharedPreferences mPrefs) {
// font size scaling
double scalingFactor = Float.parseFloat(mPrefs.getString(SettingsActivity.SP_FONT_SIZE, "1.0"));
Expand All @@ -296,6 +293,7 @@ private static String getFontSizeScalingCss(SharedPreferences mPrefs) {
fontFormat.format(scalingFactor * SUBSCRIPT_FONT_SIZE)
);
}
*/

private static String getDescriptionWithCachedImages(RequestManager glide, String articleUrl, String text) {
List<String> links = ImageHandler.getImageLinksFromText(articleUrl, text);
Expand Down Expand Up @@ -328,7 +326,7 @@ private static String getDescriptionWithCachedImages(RequestManager glide, Strin
return text;
}

private static RequestListener<File> rl = new RequestListener<>() {
private static final RequestListener<File> rl = new RequestListener<>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<File> target, boolean isFirstResource) {
// Log the GlideException here (locally or with a remote logging framework):
Expand Down
Loading