Skip to content

Commit

Permalink
Merge branch 'master' of github.com:buggins/coolreader
Browse files Browse the repository at this point in the history
  • Loading branch information
buggins committed Feb 4, 2021
2 parents 2e1b3e8 + 6e49afe commit ff652e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 28 deletions.
5 changes: 3 additions & 2 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:host="*" />
<data android:scheme="content" />
<data android:mimeType="application/octet-stream" />
<data android:pathPattern=".*\\.fb2\\.zip"/>
<data android:pathPattern=".*\\..*\\.fb2\\.zip"/>
<data android:pathPattern=".*\\..*\\..*\\.fb2\\.zip"/>
Expand Down Expand Up @@ -152,7 +151,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" android:host="*" />
<data android:scheme="content" />
<data android:scheme="content" android:host="*"/>
<data android:mimeType="text/plain"/>
<data android:mimeType="text/html"/>
<data android:mimeType="text/richtext"/>
Expand Down Expand Up @@ -182,6 +181,8 @@
<data android:mimeType="application/x-msword"/>
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document"/>
<data android:mimeType="application/vnd.oasis.opendocument.text"/>
<data android:mimeType="application/vnd.ms-htmlhelp"/>
<data android:mimeType="application/octet-stream" />
</intent-filter>
</activity>

Expand Down
46 changes: 22 additions & 24 deletions android/src/org/coolreader/crengine/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -327,7 +326,7 @@ public boolean isSmartphone() {
}

private int densityDpi = 160;
private float diagonalInches = 4;
private float diagonalInches = 5;


private InterfaceTheme currentTheme = null;
Expand Down Expand Up @@ -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;
Expand All @@ -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();
}

Expand Down
7 changes: 6 additions & 1 deletion crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion thirdparty-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

top_srcdir=`pwd`

Expand Down

0 comments on commit ff652e6

Please sign in to comment.