Skip to content

Commit

Permalink
set zoom of webview content via webview textZoom feature
Browse files Browse the repository at this point in the history
Signed-off-by: David Luhmer <[email protected]>
  • Loading branch information
David-Development committed Feb 15, 2025
1 parent cfb9dd2 commit e8e6d4c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
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

0 comments on commit e8e6d4c

Please sign in to comment.