Skip to content

Commit eafd944

Browse files
committed
merge with upstream, ext doc dialog
1 parent aebdaa8 commit eafd944

File tree

105 files changed

+26237
-4293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+26237
-4293
lines changed

android/jni/Android.mk

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ CRFLAGS := -DLINUX=1 -D_LINUX=1 -DFOR_ANDROID=1 -DCR3_PATCH \
1313
-DENABLE_CACHE_FILE_CONTENTS_VALIDATION=1 \
1414
-DLDOM_USE_OWN_MEM_MAN=0 \
1515
-DCR3_ANTIWORD_PATCH=1 -DENABLE_ANTIWORD=1 \
16-
-DMAX_IMAGE_SCALE_MUL=2
16+
-DMAX_IMAGE_SCALE_MUL=2 \
17+
-DUSE_NANOSVG=1
1718

1819
CR3_ROOT := $(LOCAL_PATH)/../..
1920

@@ -26,7 +27,8 @@ LOCAL_C_INCLUDES := \
2627
$(CR3_ROOT)/thirdparty/harfbuzz/src \
2728
$(CR3_ROOT)/thirdparty/libjpeg \
2829
$(CR3_ROOT)/thirdparty/antiword \
29-
$(CR3_ROOT)/thirdparty/chmlib/src
30+
$(CR3_ROOT)/thirdparty/chmlib/src \
31+
$(CR3_ROOT)/thirdparty/nanosvg/src
3032

3133

3234
LOCAL_CFLAGS += $(CRFLAGS)
@@ -80,6 +82,7 @@ CRENGINE_SRC_FILES := \
8082
../../crengine/src/wolutil.cpp \
8183
../../crengine/src/crconcurrent.cpp \
8284
../../crengine/src/hist.cpp \
85+
../../crengine/src/xxhash.c \
8386
../../crengine/src/private/lvfontglyphcache.cpp \
8487
../../crengine/src/private/lvfontboldtransform.cpp \
8588
../../crengine/src/private/lvfontcache.cpp \

android/jni/cr3engine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@ jbyteArray scanBookCoverInternal
623623
// extract coverpage from epub
624624
res = GetEpubCoverpage(arc);
625625
}
626+
if (DetectFb3Format(stream)) {
627+
// FB3
628+
// extract coverpage from FB3
629+
res = GetFb3Coverpage(arc);
630+
}
626631
} else {
627632
res = GetFB2Coverpage(stream);
628633
if (res.isNull()) {
@@ -1103,6 +1108,7 @@ static JNINativeMethod sDocViewMethods[] = {
11031108
{"destroyInternal", "()V", (void*)Java_org_coolreader_crengine_DocView_destroyInternal},
11041109
{"getPageImageInternal", "(Landroid/graphics/Bitmap;I)V", (void*)Java_org_coolreader_crengine_DocView_getPageImageInternal},
11051110
{"loadDocumentInternal", "(Ljava/lang/String;)Z", (void*)Java_org_coolreader_crengine_DocView_loadDocumentInternal},
1111+
{"loadDocumentFromMemoryInternal", "([BLjava/lang/String;)Z", (void*)Java_org_coolreader_crengine_DocView_loadDocumentFromMemoryInternal},
11061112
{"getSettingsInternal", "()Ljava/util/Properties;", (void*)Java_org_coolreader_crengine_DocView_getSettingsInternal},
11071113
{"applySettingsInternal", "(Ljava/util/Properties;)Z", (void*)Java_org_coolreader_crengine_DocView_applySettingsInternal},
11081114
{"setStylesheetInternal", "(Ljava/lang/String;)V", (void*)Java_org_coolreader_crengine_DocView_setStylesheetInternal},

android/jni/docview.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,25 @@ bool DocViewNative::loadDocument( lString16 filename )
891891
return res;
892892
}
893893

894+
bool DocViewNative::loadDocument( LVStreamRef stream, lString16 contentPath )
895+
{
896+
CRLog::info("Loading document from memory stream, content path: %s", LCSTR(contentPath));
897+
bool res = _docview->LoadDocument(stream, contentPath.c_str(), false);
898+
if (res)
899+
CRLog::info("Document %s is loaded successfully", LCSTR(contentPath));
900+
else {
901+
CRLog::info("Document %s not is loaded due to error", LCSTR(contentPath));
902+
if (_docview->getDocument() == NULL) {
903+
// _docview->LoadDocument() can return false with _docview->m_doc == NULL when:
904+
// 1. I/O error - failed to open file
905+
// 2. open archive without supported files
906+
CRLog::error("Document is NULL, inserting stub.");
907+
_docview->createDefaultDocument(lString16::empty_str, Utf8ToUnicode("Error while opening file!"));
908+
}
909+
}
910+
return res;
911+
}
912+
894913
bool DocViewNative::openRecentBook()
895914
{
896915
CRLog::debug("DocViewNative::openRecentBook()");
@@ -1331,6 +1350,27 @@ JNIEXPORT jboolean JNICALL Java_org_coolreader_crengine_DocView_loadDocumentInte
13311350
return res ? JNI_TRUE : JNI_FALSE;
13321351
}
13331352

1353+
/*
1354+
* Class: org_coolreader_crengine_DocView
1355+
* Method: loadDocumentFromMemoryInternal
1356+
* Signature: ([BLjava/lang/String;)Z
1357+
*/
1358+
JNIEXPORT jboolean JNICALL Java_org_coolreader_crengine_DocView_loadDocumentFromMemoryInternal
1359+
(JNIEnv * _env, jobject _this, jbyteArray buf, jstring contentPath)
1360+
{
1361+
CRJNIEnv env(_env);
1362+
DocViewNative * p = getNative(_env, _this);
1363+
if (!p) {
1364+
CRLog::error("Cannot get native view");
1365+
return JNI_FALSE;
1366+
}
1367+
DocViewCallback callback( _env, p->_docview, _this );
1368+
LVStreamRef stream = env.jbyteArrayToStream(buf);
1369+
lString16 contentPath16 = env.fromJavaString(contentPath);
1370+
bool res = p->loadDocument(stream, contentPath16);
1371+
return res ? JNI_TRUE : JNI_FALSE;
1372+
}
1373+
13341374
/*
13351375
* Class: org_coolreader_crengine_DocView
13361376
* Method: getSettings

android/jni/docview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class DocViewNative {
3030
bool saveHistory( lString16 filename );
3131
void createDefaultDocument( lString16 title, lString16 message );
3232
bool loadDocument( lString16 filename );
33+
bool loadDocument( LVStreamRef stream, lString16 contentPath );
3334
int doCommand( int cmd, int param );
3435
bool findText( lString16 pattern, int origin, bool reverse, bool caseInsensitive );
3536
void clearSelection();

android/jni/org_coolreader_crengine_DocView.h

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/res/drawable/button_bg_dashed_border.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<selector xmlns:android="http://schemas.android.com/apk/res/android">
33
<item>
44
<shape android:shape="rectangle">
5+
<solid android:color="?attr/colorThemeGray2Contrast" />
56
<stroke
67
android:color="?attr/colorIcon"
78
android:width="2dp"

android/res/layout-v21/line_edit_dlg.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
android:id="@+id/lbl_prompt"
1515
style="@style/TextAppearance.Medium"
1616
android:singleLine="false"
17-
android:maxLines="3"
17+
android:maxLines="5"
1818
android:layout_margin="5dip"
1919
android:text="Page 34/1024 (25%) Chapter 1"
2020
android:layout_width="wrap_content"
21+
android:textColor="?attr/colorIcon"
2122
android:layout_height="wrap_content"/>
2223
<EditText
2324
android:id="@+id/input_field"

android/res/layout/book_info_edit_dialog.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,47 @@
366366
android:layout_weight="10"
367367
android:layout_margin="2dp"
368368
>
369+
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
370+
android:layout_margin="2dip"
371+
android:layout_width="fill_parent"
372+
android:layout_height="wrap_content"
373+
android:layout_weight="1"
374+
>
375+
<LinearLayout
376+
android:layout_width="0dip"
377+
android:layout_height="fill_parent"
378+
android:gravity="left|center_vertical"
379+
android:layout_weight="1"
380+
android:orientation="horizontal">
381+
<TextView
382+
android:id="@+id/lbl_file_name"
383+
style="@style/TextAppearance.Small"
384+
android:singleLine="false"
385+
android:maxLines="3"
386+
android:text="@string/book_info_file_name"
387+
android:textColor="?attr/colorIcon"
388+
android:layout_width="wrap_content"
389+
android:layout_height="wrap_content"/>
390+
</LinearLayout>
391+
<LinearLayout
392+
android:layout_width="0dip"
393+
android:layout_height="fill_parent"
394+
android:gravity="left"
395+
android:layout_weight="3"
396+
android:orientation="horizontal">
397+
<TextView
398+
android:id="@+id/file_name"
399+
android:layout_width="fill_parent"
400+
android:layout_height="wrap_content"
401+
android:text="file name"
402+
android:maxLines="5"
403+
android:ellipsize="middle"
404+
style="@style/TextAppearance.Small"
405+
android:textColor="?attr/colorIcon"
406+
android:singleLine="false"
407+
/>
408+
</LinearLayout>
409+
</TableRow>
369410
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
370411
android:layout_margin="2dip"
371412
android:layout_width="fill_parent"
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_marginRight="?android:attr/scrollbarSize"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
android:stretchColumns="*" >
7+
8+
<LinearLayout
9+
android:orientation="vertical"
10+
android:layout_width="fill_parent"
11+
android:layout_height="wrap_content"
12+
android:layout_margin="3dip">
13+
14+
<TableLayout
15+
android:id="@+id/table"
16+
style="@style/TextAppearance.Small"
17+
android:layout_width="fill_parent"
18+
android:layout_height="wrap_content"
19+
android:stretchColumns="1"
20+
android:layout_weight="10"
21+
android:layout_margin="2dp"
22+
>
23+
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
24+
android:layout_margin="2dip"
25+
android:layout_width="fill_parent"
26+
android:layout_height="wrap_content"
27+
android:layout_weight="1"
28+
>
29+
<LinearLayout
30+
android:layout_width="0dip"
31+
android:layout_height="fill_parent"
32+
android:gravity="left"
33+
android:layout_weight="3"
34+
android:orientation="horizontal">
35+
<TextView
36+
android:id="@+id/conv_doc_path"
37+
android:layout_width="fill_parent"
38+
android:layout_height="wrap_content"
39+
android:text="file name"
40+
android:maxLines="5"
41+
android:ellipsize="middle"
42+
style="@style/TextAppearance.Small"
43+
android:textColor="?attr/colorIcon"
44+
android:singleLine="false"
45+
/>
46+
</LinearLayout>
47+
</TableRow>
48+
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
49+
android:layout_margin="2dip"
50+
android:layout_width="fill_parent"
51+
android:layout_height="wrap_content"
52+
android:background="#60808080"
53+
>
54+
<TextView
55+
android:layout_margin="5dp"
56+
style="@style/TextAppearance.Small"
57+
android:text="@string/conv_doc_option1"
58+
android:textStyle="bold"
59+
android:singleLine="false"
60+
android:maxLines="3"
61+
android:layout_width="wrap_content"
62+
android:layout_height="wrap_content"
63+
android:textColor="?attr/colorIcon"
64+
/>
65+
</TableRow>
66+
<TableRow>
67+
<LinearLayout
68+
android:layout_width="0dip"
69+
android:layout_height="fill_parent"
70+
android:gravity="left"
71+
android:layout_weight="2"
72+
android:orientation="vertical">
73+
<Button
74+
android:id="@+id/btn_conv"
75+
android:layout_width="fill_parent"
76+
android:layout_height="wrap_content"
77+
android:text="@string/convert_odf_and_open"
78+
android:layout_margin="3dip"
79+
android:textColor="?attr/colorIcon"
80+
style="@style/TextAppearance.Widget.EditText"
81+
/>
82+
<TextView
83+
android:layout_width="fill_parent"
84+
android:layout_height="wrap_content"
85+
android:text="@string/convert_odf_and_open_add_info"
86+
android:maxLines="5"
87+
android:ellipsize="middle"
88+
style="@style/TextAppearance.Small"
89+
android:textColor="?attr/colorIcon"
90+
android:singleLine="false"
91+
/>
92+
</LinearLayout>
93+
</TableRow>
94+
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
95+
android:id="@+id/trow_conv_path"
96+
android:layout_margin="2dip"
97+
android:layout_width="fill_parent"
98+
android:layout_height="wrap_content"
99+
android:layout_weight="1"
100+
>
101+
<LinearLayout
102+
android:layout_width="0dip"
103+
android:layout_height="fill_parent"
104+
android:gravity="left|center_vertical"
105+
android:layout_weight="1"
106+
android:orientation="horizontal">
107+
<TextView
108+
android:id="@+id/lbl_conv_path"
109+
style="@style/TextAppearance.Small"
110+
android:singleLine="false"
111+
android:maxLines="3"
112+
android:text="@string/converted_path"
113+
android:textStyle="bold"
114+
android:textColor="?attr/colorIcon"
115+
android:layout_width="wrap_content"
116+
android:layout_height="wrap_content"/>
117+
</LinearLayout>
118+
<LinearLayout
119+
android:layout_width="0dip"
120+
android:layout_height="fill_parent"
121+
android:gravity="left"
122+
android:layout_weight="3"
123+
android:orientation="horizontal">
124+
<TextView
125+
android:id="@+id/conv_path"
126+
android:layout_width="fill_parent"
127+
android:layout_height="wrap_content"
128+
android:text="download path"
129+
android:maxLines="5"
130+
android:ellipsize="middle"
131+
style="@style/TextAppearance.Small"
132+
android:textColor="?attr/colorIcon"
133+
android:singleLine="false"
134+
/>
135+
</LinearLayout>
136+
</TableRow>
137+
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
138+
android:id="@+id/trow_conv_file_exists1"
139+
android:layout_margin="2dip"
140+
android:layout_width="fill_parent"
141+
android:layout_height="wrap_content"
142+
android:background="#60808080"
143+
>
144+
<TextView
145+
android:layout_margin="5dp"
146+
style="@style/TextAppearance.Small"
147+
android:text="@string/conv_doc_option2"
148+
android:textStyle="bold"
149+
android:singleLine="false"
150+
android:maxLines="3"
151+
android:layout_width="wrap_content"
152+
android:layout_height="wrap_content"
153+
android:textColor="?attr/colorIcon"
154+
/>
155+
</TableRow>
156+
<TableRow android:id="@+id/trow_conv_file_exists2"
157+
>
158+
<LinearLayout
159+
android:layout_width="0dip"
160+
android:layout_height="fill_parent"
161+
android:gravity="left"
162+
android:layout_weight="2"
163+
android:orientation="vertical">
164+
<Button
165+
android:id="@+id/btn_open_existing"
166+
android:layout_width="fill_parent"
167+
android:layout_height="wrap_content"
168+
android:text="@string/open_existing"
169+
android:layout_margin="3dip"
170+
android:textColor="?attr/colorIcon"
171+
style="@style/TextAppearance.Widget.EditText"
172+
/>
173+
<TextView
174+
android:layout_width="fill_parent"
175+
android:layout_height="wrap_content"
176+
android:text="@string/odf_open_previously_converted"
177+
android:maxLines="5"
178+
android:ellipsize="middle"
179+
style="@style/TextAppearance.Small"
180+
android:textColor="?attr/colorIcon"
181+
android:singleLine="false"
182+
/>
183+
</LinearLayout>
184+
</TableRow>
185+
</TableLayout>
186+
</LinearLayout>
187+
</ScrollView>

0 commit comments

Comments
 (0)