From dbbdfaef00a3c7635500d3b7c10751687788b7bf Mon Sep 17 00:00:00 2001 From: ourairquality Date: Tue, 2 Feb 2021 11:25:34 +1100 Subject: [PATCH 1/4] parse_number_value: round to nearest --- crengine/src/lvstsheet.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crengine/src/lvstsheet.cpp b/crengine/src/lvstsheet.cpp index da34d78f1a..20adb52c41 100644 --- a/crengine/src/lvstsheet.cpp +++ b/crengine/src/lvstsheet.cpp @@ -597,7 +597,12 @@ static bool parse_number_value( const char * & str, css_length_t & value, // allow unspecified unit (for line-height) // else // return false; - value.value = n * 256 + 256 * frac / frac_div; // *256 + + // The largest frac here is 999999, limited above, with a frac_div of + // 1000000, and even scaling it by 256 it does not overflow a 32 bit + // integer. The frac_div is a power of 10 so always divisible by 2 without + // loss when frac is non-zero. + value.value = n * 256 + (256 * frac + frac_div / 2 ) / frac_div; // *256 if (negative) value.value = -value.value; return true; From 18157543218579ea399c13b052c6d9e716c2f6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Fern=C3=A1ndez?= <975883+pazos@users.noreply.github.com> Date: Tue, 2 Feb 2021 22:17:41 +0100 Subject: [PATCH 2/4] Update thirdparty-deploy.sh As it contains Bash-isms (or posix-isms) that are not compatible with some shells, like fish. Pinging @virxkane --- thirdparty-deploy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/thirdparty-deploy.sh b/thirdparty-deploy.sh index 9bfe937326..13aa01f521 100755 --- a/thirdparty-deploy.sh +++ b/thirdparty-deploy.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash top_srcdir=`pwd` From 894b4026b21546d7437995a5ffe587adf1102c94 Mon Sep 17 00:00:00 2001 From: Edward259 Date: Wed, 3 Feb 2021 19:24:27 +0800 Subject: [PATCH 3/4] Adjust and add mimeType to support chm,fb2,fb3 --- android/app/src/main/AndroidManifest.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 31f0b5c6b7..cad865175b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -89,7 +89,6 @@ - @@ -152,7 +151,7 @@ - + @@ -182,6 +181,8 @@ + + From 53d3297f474674f18236743df2ce6d82aaa349a0 Mon Sep 17 00:00:00 2001 From: ourairquality Date: Tue, 2 Feb 2021 22:36:48 +1100 Subject: [PATCH 4/4] android: fix DPI initialization The DPI was not being initialized correctly leaving it at the default of 96 dpi, but the intention appears to have been to increase the CSS DPI for higher DPI devices. The SettingsManager() was being initialized early, before initializing the display DPI, and was pushing the initial default DPI of 96 to the crengine when calling loadSettings(). Move the initialization of the display DPI earlier to address this. --- .../org/coolreader/crengine/BaseActivity.java | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/android/src/org/coolreader/crengine/BaseActivity.java b/android/src/org/coolreader/crengine/BaseActivity.java index 4684f7b946..b630759718 100644 --- a/android/src/org/coolreader/crengine/BaseActivity.java +++ b/android/src/org/coolreader/crengine/BaseActivity.java @@ -102,6 +102,26 @@ public Properties settings() { private SettingsManager mSettingsManager; protected void startServices() { + DisplayMetrics dm = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(dm); + + try { + Field fld = dm.getClass().getField("densityDpi"); + if (fld != null) { + Object v = fld.get(dm); + if (v != null && v instanceof Integer) { + densityDpi = ((Integer) v).intValue(); + log.i("Screen density detected: " + densityDpi + "DPI"); + } + } + } catch (Exception e) { + log.e("Cannot find field densityDpi, using default value"); + } + float widthInches = (float)dm.widthPixels / (float)densityDpi; + float heightInches = (float)dm.heightPixels / (float)densityDpi; + diagonalInches = (float) Math.sqrt(widthInches * widthInches + heightInches * heightInches); + log.i("diagonal=" + diagonalInches + " isSmartphone=" + isSmartphone()); + // create settings mSettingsManager = new SettingsManager(this); // create rest of settings @@ -136,27 +156,6 @@ protected void onCreate(Bundle savedInstanceState) { // ignore } log.i("CoolReader version : " + getVersion()); - - Display d = getWindowManager().getDefaultDisplay(); - DisplayMetrics m = new DisplayMetrics(); - d.getMetrics(m); - try { - Field fld = m.getClass().getField("densityDpi"); - if (fld != null) { - Object v = fld.get(m); - if (v != null && v instanceof Integer) { - densityDpi = ((Integer) v).intValue(); - log.i("Screen density detected: " + densityDpi + "DPI"); - } - } - } catch (Exception e) { - log.e("Cannot find field densityDpi, using default value"); - } - float widthInches = m.widthPixels / densityDpi; - float heightInches = m.heightPixels / densityDpi; - diagonalInches = (float) Math.sqrt(widthInches * widthInches + heightInches * heightInches); - - log.i("diagonal=" + diagonalInches + " isSmartphone=" + isSmartphone()); //log.i("CoolReader.window=" + getWindow()); if (!DeviceInfo.EINK_SCREEN) { WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); @@ -327,7 +326,7 @@ public boolean isSmartphone() { } private int densityDpi = 160; - private float diagonalInches = 4; + private float diagonalInches = 5; private InterfaceTheme currentTheme = null; @@ -1455,7 +1454,6 @@ private static class SettingsManager { private BaseActivity mActivity; private Properties mSettings; - private boolean isSmartphone; private final DisplayMetrics displayMetrics = new DisplayMetrics(); private final File defaultSettingsDir; @@ -1464,7 +1462,7 @@ public SettingsManager(BaseActivity activity) { this.mActivity = activity; activity.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); defaultSettingsDir = activity.getDir("settings", Context.MODE_PRIVATE); - isSmartphone = activity.isSmartphone(); + mSettings = loadSettings(); }