Dil: |
+ 1 dakikadan az.
+ Yükleniyor
+ Yapılandırılıyor
+ Arama
+ Text To Speech
+ %1$d dakika ·
+ %1$d dakika ·
+ 1x
+ %1$d sayfa kaldı
+ %1$d sayfa kaldı
+ Lütfen bir not giriniz.
+ Lütfen bekleyiniz...
+ Lütfen ses tanımlanana kadar bekleyiniz, sonra tekrar deneyiniz.
+ Yayımcı
+ Notu kaydet
+ Sonuç yok.
+ Bir şeyler yanlış gitti.
+ Kitapta ara.
+ Gönder.
+ Paylaş
+ Stil
+ Başlık
+ İçerik Tablosu
+ Çeviri
+ 2x
+ Types
+ Wikipedi
+ Notu sildiniz
+
\ No newline at end of file
diff --git a/folioreader/res/values-vi-rVN/strings.xml b/folioreader/res/values-vi-rVN/strings.xml
new file mode 100644
index 000000000..69d553fa4
--- /dev/null
+++ b/folioreader/res/values-vi-rVN/strings.xml
@@ -0,0 +1,62 @@
+
+
+ Dịch sang
+ Dịch
+ FolioReader
+ Huỷ
+ Chọn hai ngôn ngữ:
+ Đồng ý
+ Kích thước panel trên:
+ <tr><td>Tác giả:</td>
+ Không thể mở ebook, bạn cần kích hoạt quyền truy cập vào bộ nhớ ngoài!
+ Đổi kiểu
+ Đổi Font
+ Màu chữ
+ Chương
+ <tr><td>Người đóng góp:</td>
+ Đã copy
+ Định nghĩa
+ <tr><td>Mô tả:</td>
+ Từ điển
+ Lật ngang
+ Lật dọc
+ Đã lưu ghi chú
+ Không thể đổi kiểu
+ Highlight
+ Highlights
+ <tr><td>Ngôn ngữ:</td><td>
+ Còn dưới 1 phút
+ Đang tải
+ Chỉnh sửa
+ Sao chép
+ Định nghĩa
+ Highlight
+ Tìm kiếm
+ Chia sẻ
+ Đọc
+ %1$d phút ·
+ %1$d phút ·
+ 1x
+ %1$d còn lại
+ %1$d còn lại
+ Nhập vào một ghi chú
+ Xin hãy đợi
+ Vui lòng đợi âm thanh được phân tích, hãy thử lại sau một thời gian.
+ Nhà xuất bản
+ Phải
+ Lưu ghi chú
+ Không có kết quả
+ Có gì đó không đúng xảy ra
+ Tìm kiếm trong sách
+ Gửi tới
+ Chia sẻ
+ Kiểu
+ Nhan đề
+ Mục lục
+ 2x
+ Thể loại:
+ Wikipedia
+ Đã xoá ghi chú
+ Không có kết nối mạng
+ Không tìm thấy từ cần tìm
+
\ No newline at end of file
diff --git a/folioreader/res/values-vi/strings.xml b/folioreader/res/values-vi/strings.xml
new file mode 100644
index 000000000..2c2dbfd48
--- /dev/null
+++ b/folioreader/res/values-vi/strings.xml
@@ -0,0 +1,59 @@
+
+
+ Dịch
+ FolioReader
+ Huỷ
+ Chọn hai ngôn ngữ:
+ Đồng ý
+ Kích thước panel trên:
+ <tr><td>Tác giả:</td>
+ Không thể mở ebook, bạn cần kích hoạt quyền truy cập vào bộ nhớ ngoài!
+ Đổi kiểu
+ Đổi Font
+ Màu chữ
+ Chương
+ <tr><td>Người đóng góp:</td>
+ Đã copy
+ Định nghĩa
+ <tr><td>Mô tả:</td>
+ Từ điển
+ Lật ngang
+ Lật dọc
+ Đã lưu ghi chú
+ Không thể đổi kiểu
+ Highlight
+ Highlights
+ <tr><td>Ngôn ngữ:</td><td>
+ Còn dưới 1 phút
+ Đang tải
+ Chỉnh sửa
+ Sao chép
+ Định nghĩa
+ Highlight
+ Tìm kiếm
+ Chia sẻ
+ Đọc
+ %1$d phút ·
+ %1$d phút ·
+ 1x
+ %1$d còn lại
+ %1$d còn lại
+ Nhập vào một ghi chú
+ Xin hãy đợi
+ Vui lòng đợi âm thanh được phân tích, hãy thử lại sau một thời gian.
+ Nhà xuất bản
+ Phải
+ Lưu ghi chú
+ Không có kết quả
+ Có gì đó không đúng xảy ra
+ Tìm kiếm trong sách
+ Gửi tới
+ Chia sẻ
+ Kiểu
+ Nhan đề
+ Mục lục
+ 2x
+ Thể loại:
+ Wikipedia
+ Đã xoá ghi chú
+
\ No newline at end of file
diff --git a/folioreader/res/values/colors.xml b/folioreader/res/values/colors.xml
index c2bd97086..ab9913c18 100644
--- a/folioreader/res/values/colors.xml
+++ b/folioreader/res/values/colors.xml
@@ -1,11 +1,11 @@
- #008577
+ #03a9f4
#00574B
#D81B60
- #71C951
+ #03a9f4
#80000000
#F1EFF2
#000000
@@ -24,9 +24,23 @@
#AAAAAA
- #FFEB6B
- #C0ED72
- #ADD8FF
- #FFB0CA
+
+
+
+
+
+ #606060
+ #363636
+ #30363636
+ #606061
+ #f44336
+ #ffc107
+ #03a9f4
+ #8bc34a
+ #0000
+ #30f44336
+ #30ffc107
+ #3003a9f4
+ #308bc34a
\ No newline at end of file
diff --git a/folioreader/res/values/strings.xml b/folioreader/res/values/strings.xml
index 9d944130e..e9e1ffde2 100644
--- a/folioreader/res/values/strings.xml
+++ b/folioreader/res/values/strings.xml
@@ -2,15 +2,15 @@
FolioReader
- Andada
+ Arvo
Lato
Lora
- Raleway
+ Ubuntu
- fonts/andada/Andada-Regular.otf
+ fonts/arvo/Arvo-Regular.ttf
fonts/lato/Lato-Regular.ttf
fonts/lora/Lora-Regular.ttf
- fonts/raleway/Raleway-Regular.ttf
+ fonts/ubuntu/Ubuntu-Regular.ttf
%1$d minutes ·
%1$d minute ·
@@ -23,7 +23,8 @@
Share
Define
Highlight
-
+ Translate
+ Translate to
%1$d pages left
%1$d page left
Highlights
@@ -38,8 +39,7 @@
.zip
<html><body><table>
<tr><td>Titles:</td>
- <tr><td>Authors:</td>
- <tr><td>Contributors:</td>
+ <tr><td>Contributor:</td>
<tr><td>Language:</td><td>
<tr><td>Publishers:</td>
<tr><td>Types:</td>
@@ -81,7 +81,8 @@
Save your note
Save note
- please enter a note
+ Please enter a note!
+ You have deleted note
Contents
@@ -90,7 +91,6 @@
Starting unable to drag!
Dictionary
Wikipedia
- Cannot open epub it needs storage access !
Horizontal
Vertical
@@ -115,5 +115,10 @@
javascript:scrollToCfi(\"%s\")
javascript:highlightSearchLocator(\"%s\")
javascript:clearSelection()
+ <tr><td>Authors:</td>
+
+ Unable to open ebook, you need to enable access to external memory!
+ No network connection
+ Work not found
diff --git a/folioreader/search.png b/folioreader/search.png
new file mode 100644
index 000000000..16552c18b
Binary files /dev/null and b/folioreader/search.png differ
diff --git a/folioreader/show.png b/folioreader/show.png
new file mode 100644
index 000000000..44ac39d8f
Binary files /dev/null and b/folioreader/show.png differ
diff --git a/folioreader/src/main/assets/css/Style.css b/folioreader/src/main/assets/css/Style.css
index a1e2c9513..390bb0c38 100755
--- a/folioreader/src/main/assets/css/Style.css
+++ b/folioreader/src/main/assets/css/Style.css
@@ -162,16 +162,16 @@ input, textarea, button, highlight, select, a {
}
/* Highlight styles */
-html .highlight_yellow {background:rgb(255, 235, 107)}
+html .highlight_orange {background:rgb(255, 235, 107)}
html .highlight_green {background:#C0ED72}
html .highlight_blue {background:#ADD8FF}
-html .highlight_pink {background:#FFB0CA}
+html .highlight_red {background:#FFB0CA}
html .highlight_underline {
text-decoration: none;
border-bottom: 2px solid #F02814;
}
-html .highlight_yellow, html .highlight_green, html .highlight_blue, html .highlight_pink, span.epub-media-overlay-playing {
+html .highlight_orange, html .highlight_green, html .highlight_blue, html .highlight_red, span.epub-media-overlay-playing {
border-radius: 3px;
padding: 0 2px;
margin: 0 -2px;
@@ -216,10 +216,10 @@ html.nightMode {
color: #848484 !important;
}
-html.nightMode .highlight_yellow {background:rgba(255, 235, 107, 0.9)}
+html.nightMode .highlight_orange {background:rgba(255, 235, 107, 0.9)}
html.nightMode .highlight_green {background:rgba(192, 237, 114, 0.9)}
html.nightMode .highlight_blue {background:rgba(173, 216, 255, 0.9)}
-html.nightMode .highlight_pink {background:rgba(255, 176, 202, 0.9)}
+html.nightMode .highlight_red {background:rgba(255, 176, 202, 0.9)}
html.nightMode .highlight_underline {border-bottom: 2px solid rgba(240, 40, 20, 0.6)}
@@ -230,13 +230,13 @@ html.nightMode .highlight_underline {border-bottom: 2px solid rgba(240, 40, 20,
*/
@font-face {
- font-family: 'andada';
- src: url('file:///android_asset/fonts/andada/Andada-Regular.otf');
+ font-family: 'arvo';
+ src: url('file:///android_asset/fonts/arvo/Arvo-Regular.ttf');
}
@font-face {
font-family: 'lato';
- src: url('file:///android_asset/fonts/lato/Lato-Regular.ttf');
+ src: url('file:///android_asset/fonts/lato/lato-regular.ttf');
}
@font-face {
@@ -245,12 +245,12 @@ html.nightMode .highlight_underline {border-bottom: 2px solid rgba(240, 40, 20,
}
@font-face {
- font-family: 'raleway';
- src: url('file:///android_asset/fonts/raleway/Raleway-Regular.ttf');
+ font-family: 'ubuntu';
+ src: url('file:///android_asset/fonts/ubuntu/Ubuntu-Regular.ttf');
}
-.andada {
- font-family: "andada", sans-serif;
+.arvo {
+ font-family: "arvo", sans-serif;
}
.lato {
font-family: "lato", serif;
@@ -258,8 +258,8 @@ html.nightMode .highlight_underline {border-bottom: 2px solid rgba(240, 40, 20,
.lora {
font-family: "lora", serif;
}
-.raleway {
- font-family: "raleway", sans-serif;
+.ubuntu {
+ font-family: "ubuntu", sans-serif;
}
html.textSizeOne { font-size: 13px !important; }
diff --git a/folioreader/src/main/assets/databases/VietnameseDictionary.db.sqbpro b/folioreader/src/main/assets/databases/VietnameseDictionary.db.sqbpro
new file mode 100644
index 000000000..ea7301e19
Binary files /dev/null and b/folioreader/src/main/assets/databases/VietnameseDictionary.db.sqbpro differ
diff --git a/folioreader/src/main/assets/fonts/andada/Andada-Bold.otf b/folioreader/src/main/assets/fonts/andada/Andada-Bold.otf
deleted file mode 100755
index 31c0c7f4c..000000000
Binary files a/folioreader/src/main/assets/fonts/andada/Andada-Bold.otf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/andada/Andada-BoldItalic.otf b/folioreader/src/main/assets/fonts/andada/Andada-BoldItalic.otf
deleted file mode 100755
index e8bc4792b..000000000
Binary files a/folioreader/src/main/assets/fonts/andada/Andada-BoldItalic.otf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/andada/Andada-Italic.otf b/folioreader/src/main/assets/fonts/andada/Andada-Italic.otf
deleted file mode 100755
index 38a558d4f..000000000
Binary files a/folioreader/src/main/assets/fonts/andada/Andada-Italic.otf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/andada/Andada-Regular.otf b/folioreader/src/main/assets/fonts/andada/Andada-Regular.otf
deleted file mode 100755
index 0532524c8..000000000
Binary files a/folioreader/src/main/assets/fonts/andada/Andada-Regular.otf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/arvo/Arvo-Bold.ttf b/folioreader/src/main/assets/fonts/arvo/Arvo-Bold.ttf
new file mode 100644
index 000000000..38341b12f
Binary files /dev/null and b/folioreader/src/main/assets/fonts/arvo/Arvo-Bold.ttf differ
diff --git a/folioreader/src/main/assets/fonts/arvo/Arvo-BoldItalic.ttf b/folioreader/src/main/assets/fonts/arvo/Arvo-BoldItalic.ttf
new file mode 100644
index 000000000..b87118bcf
Binary files /dev/null and b/folioreader/src/main/assets/fonts/arvo/Arvo-BoldItalic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/arvo/Arvo-Italic.ttf b/folioreader/src/main/assets/fonts/arvo/Arvo-Italic.ttf
new file mode 100644
index 000000000..1a193372e
Binary files /dev/null and b/folioreader/src/main/assets/fonts/arvo/Arvo-Italic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/arvo/Arvo-Regular.ttf b/folioreader/src/main/assets/fonts/arvo/Arvo-Regular.ttf
new file mode 100644
index 000000000..d8d0ec890
Binary files /dev/null and b/folioreader/src/main/assets/fonts/arvo/Arvo-Regular.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lato/Lato-Bold.ttf b/folioreader/src/main/assets/fonts/lato/Lato-Bold.ttf
deleted file mode 100755
index 74343694e..000000000
Binary files a/folioreader/src/main/assets/fonts/lato/Lato-Bold.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/lato/Lato-BoldItalic.ttf b/folioreader/src/main/assets/fonts/lato/Lato-BoldItalic.ttf
deleted file mode 100755
index 684aacf5b..000000000
Binary files a/folioreader/src/main/assets/fonts/lato/Lato-BoldItalic.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/lato/Lato-Italic.ttf b/folioreader/src/main/assets/fonts/lato/Lato-Italic.ttf
deleted file mode 100755
index 3d3b7a298..000000000
Binary files a/folioreader/src/main/assets/fonts/lato/Lato-Italic.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/lato/Lato-Regular.ttf b/folioreader/src/main/assets/fonts/lato/Lato-Regular.ttf
deleted file mode 100755
index 04ea8efb1..000000000
Binary files a/folioreader/src/main/assets/fonts/lato/Lato-Regular.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/lato/lato-bold.ttf b/folioreader/src/main/assets/fonts/lato/lato-bold.ttf
new file mode 100644
index 000000000..70c4dd92b
Binary files /dev/null and b/folioreader/src/main/assets/fonts/lato/lato-bold.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lato/lato-bolditalic.ttf b/folioreader/src/main/assets/fonts/lato/lato-bolditalic.ttf
new file mode 100644
index 000000000..c0e84bc79
Binary files /dev/null and b/folioreader/src/main/assets/fonts/lato/lato-bolditalic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lato/lato-italic.ttf b/folioreader/src/main/assets/fonts/lato/lato-italic.ttf
new file mode 100644
index 000000000..e7a31ce36
Binary files /dev/null and b/folioreader/src/main/assets/fonts/lato/lato-italic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lato/lato-regular.ttf b/folioreader/src/main/assets/fonts/lato/lato-regular.ttf
new file mode 100644
index 000000000..b536f9558
Binary files /dev/null and b/folioreader/src/main/assets/fonts/lato/lato-regular.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lora/Lora-Bold.ttf b/folioreader/src/main/assets/fonts/lora/Lora-Bold.ttf
index d911f87a1..16ea2bfde 100644
Binary files a/folioreader/src/main/assets/fonts/lora/Lora-Bold.ttf and b/folioreader/src/main/assets/fonts/lora/Lora-Bold.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lora/Lora-BoldItalic.ttf b/folioreader/src/main/assets/fonts/lora/Lora-BoldItalic.ttf
index 80525cb8f..fa18352f7 100644
Binary files a/folioreader/src/main/assets/fonts/lora/Lora-BoldItalic.ttf and b/folioreader/src/main/assets/fonts/lora/Lora-BoldItalic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lora/Lora-Italic.ttf b/folioreader/src/main/assets/fonts/lora/Lora-Italic.ttf
index 7876a231e..104a24570 100644
Binary files a/folioreader/src/main/assets/fonts/lora/Lora-Italic.ttf and b/folioreader/src/main/assets/fonts/lora/Lora-Italic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/lora/Lora-Regular.ttf b/folioreader/src/main/assets/fonts/lora/Lora-Regular.ttf
index 61b39901b..2b42c08fd 100644
Binary files a/folioreader/src/main/assets/fonts/lora/Lora-Regular.ttf and b/folioreader/src/main/assets/fonts/lora/Lora-Regular.ttf differ
diff --git a/folioreader/src/main/assets/fonts/raleway/Raleway-Bold.ttf b/folioreader/src/main/assets/fonts/raleway/Raleway-Bold.ttf
deleted file mode 100755
index 7aa37f014..000000000
Binary files a/folioreader/src/main/assets/fonts/raleway/Raleway-Bold.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/raleway/Raleway-BoldItalic.ttf b/folioreader/src/main/assets/fonts/raleway/Raleway-BoldItalic.ttf
deleted file mode 100755
index 1d1c6dd6c..000000000
Binary files a/folioreader/src/main/assets/fonts/raleway/Raleway-BoldItalic.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/raleway/Raleway-Italic.ttf b/folioreader/src/main/assets/fonts/raleway/Raleway-Italic.ttf
deleted file mode 100755
index e46ac30ba..000000000
Binary files a/folioreader/src/main/assets/fonts/raleway/Raleway-Italic.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/raleway/Raleway-Regular.ttf b/folioreader/src/main/assets/fonts/raleway/Raleway-Regular.ttf
deleted file mode 100755
index c6ec2f0ac..000000000
Binary files a/folioreader/src/main/assets/fonts/raleway/Raleway-Regular.ttf and /dev/null differ
diff --git a/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Bold.ttf b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Bold.ttf
new file mode 100644
index 000000000..b173da274
Binary files /dev/null and b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Bold.ttf differ
diff --git a/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-BoldItalic.ttf b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-BoldItalic.ttf
new file mode 100644
index 000000000..72a5a99ac
Binary files /dev/null and b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-BoldItalic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Italic.ttf b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Italic.ttf
new file mode 100644
index 000000000..4f2d2bc7c
Binary files /dev/null and b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Italic.ttf differ
diff --git a/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Regular.ttf b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Regular.ttf
new file mode 100644
index 000000000..d748728a2
Binary files /dev/null and b/folioreader/src/main/assets/fonts/ubuntu/Ubuntu-Regular.ttf differ
diff --git a/folioreader/src/main/assets/js/Bridge.js b/folioreader/src/main/assets/js/Bridge.js
index 8e91df482..cf01870c2 100755
--- a/folioreader/src/main/assets/js/Bridge.js
+++ b/folioreader/src/main/assets/js/Bridge.js
@@ -225,7 +225,7 @@ $(function () {
this.highlighter = rangy.createHighlighter();
- this.highlighter.addClassApplier(rangy.createClassApplier("highlight_yellow", {
+ this.highlighter.addClassApplier(rangy.createClassApplier("highlight_orange", {
ignoreWhiteSpace: true,
tagNames: ["span", "a"]
}));
@@ -240,7 +240,7 @@ $(function () {
tagNames: ["span", "a"]
}));
- this.highlighter.addClassApplier(rangy.createClassApplier("highlight_pink", {
+ this.highlighter.addClassApplier(rangy.createClassApplier("highlight_red", {
ignoreWhiteSpace: true,
tagNames: ["span", "a"]
}));
@@ -252,8 +252,8 @@ $(function () {
},
- setFontAndada: function () {
- this.setFont("andada");
+ setFontArvo: function () {
+ this.setFont("comfort");
},
setFontLato: function () {
diff --git a/folioreader/src/main/java/com/folioreader/Constants.java b/folioreader/src/main/java/com/folioreader/Constants.java
index d48df8e0d..61b6e6dca 100644
--- a/folioreader/src/main/java/com/folioreader/Constants.java
+++ b/folioreader/src/main/java/com/folioreader/Constants.java
@@ -21,10 +21,10 @@ public class Constants {
public static final String SELECTED_WORD = "selected_word";
public static final String DICTIONARY_BASE_URL = "https://api.pearson.com/v2/dictionaries/entries?headword=";
public static final String WIKIPEDIA_API_URL = "https://en.wikipedia.org/w/api.php?action=opensearch&namespace=0&format=json&search=";
- public static final int FONT_ANDADA = 1;
+ public static final int FONT_ARVO = 1;
public static final int FONT_LATO = 2;
public static final int FONT_LORA = 3;
- public static final int FONT_RALEWAY = 4;
+ public static final int FONT_UBUNTU = 4;
public static final String DATE_FORMAT = "MMM dd, yyyy | HH:mm";
public static final String ASSET = "file:///android_asset/";
public static final int WRITE_EXTERNAL_STORAGE_REQUEST = 102;
diff --git a/folioreader/src/main/java/com/folioreader/FolioReader.java b/folioreader/src/main/java/com/folioreader/FolioReader.java
index d02a16d90..fd0c39092 100644
--- a/folioreader/src/main/java/com/folioreader/FolioReader.java
+++ b/folioreader/src/main/java/com/folioreader/FolioReader.java
@@ -7,6 +7,8 @@
import android.content.IntentFilter;
import android.os.Parcelable;
import androidx.annotation.Nullable;
+import androidx.fragment.app.FragmentManager;
+import androidx.fragment.app.FragmentTransaction;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.folioreader.model.HighLight;
import com.folioreader.model.HighlightImpl;
@@ -14,11 +16,16 @@
import com.folioreader.model.sqlite.DbAdapter;
import com.folioreader.network.QualifiedTypeConverterFactory;
import com.folioreader.network.R2StreamerApi;
+import com.folioreader.ui.activity.ContentHighlightActivity;
import com.folioreader.ui.activity.FolioActivity;
import com.folioreader.ui.base.OnSaveHighlight;
import com.folioreader.ui.base.SaveReceivedHighlightTask;
+import com.folioreader.ui.fragment.HighlightFragment;
import com.folioreader.util.OnHighlightListener;
import com.folioreader.util.ReadLocatorListener;
+
+import org.greenrobot.eventbus.util.ErrorDialogManager;
+
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
@@ -57,6 +64,8 @@ public class FolioReader {
@Nullable
public R2StreamerApi r2StreamerApi;
+
+
public interface OnClosedListener {
/**
* You may call {@link FolioReader#clear()} in this method, if you wouldn't require to open
@@ -295,4 +304,8 @@ private void unregisterListeners() {
localBroadcastManager.unregisterReceiver(readLocatorReceiver);
localBroadcastManager.unregisterReceiver(closedReceiver);
}
+ // FragmentManager fragmentManager, String assetOrSdcardPath
+ public void showContentHighlightFragment(FragmentManager fragmentManager) {
+
+ }
}
diff --git a/folioreader/src/main/java/com/folioreader/model/HighlightImpl.java b/folioreader/src/main/java/com/folioreader/model/HighlightImpl.java
index 3d954912a..49ff2c843 100644
--- a/folioreader/src/main/java/com/folioreader/model/HighlightImpl.java
+++ b/folioreader/src/main/java/com/folioreader/model/HighlightImpl.java
@@ -72,10 +72,10 @@ public class HighlightImpl implements Parcelable, HighLight {
private String note;
public enum HighlightStyle {
- Yellow,
+ Orange,
Green,
Blue,
- Pink,
+ Red,
Underline,
TextColor,
DottetUnderline,
@@ -86,14 +86,14 @@ public enum HighlightStyle {
*/
public static String classForStyle(HighlightStyle style) {
switch (style) {
- case Yellow:
- return "highlight_yellow";
+ case Orange:
+ return "highlight_orange";
case Green:
return "highlight_green";
case Blue:
return "highlight_blue";
- case Pink:
- return "highlight_pink";
+ case Red:
+ return "highlight_red";
case Underline:
return "highlight_underline";
case DottetUnderline:
@@ -185,6 +185,18 @@ public void setType(String type) {
this.type = type;
}
+ public String getTmpColorLabel() {
+ if (type.equalsIgnoreCase("highlight_red"))
+ return "red";
+ if (type.equalsIgnoreCase("highlight_orange"))
+ return "orange";
+ if (type.equalsIgnoreCase("highlight_blue"))
+ return "blur";
+ if (type.equalsIgnoreCase("highlight_green"))
+ return "green";
+ return "old";
+ }
+
public int getPageNumber() {
return pageNumber;
}
diff --git a/folioreader/src/main/java/com/folioreader/model/dictionary/Dictionary.java b/folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionary.java
similarity index 71%
rename from folioreader/src/main/java/com/folioreader/model/dictionary/Dictionary.java
rename to folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionary.java
index 978380121..1a3ba24a9 100644
--- a/folioreader/src/main/java/com/folioreader/model/dictionary/Dictionary.java
+++ b/folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionary.java
@@ -13,20 +13,20 @@
* @author gautam chibde on 4/7/17.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public class Dictionary {
+public class EnglishDictionary {
@JsonProperty
private int status;
@JsonProperty
private String url;
@JsonProperty
- private List results;
+ private List resultsList;
@Override
public String toString() {
- return "Dictionary{" +
+ return "EnglishDictionary{" +
"status=" + status +
", url='" + url + '\'' +
- ", results=" + results +
+ ", results=" + resultsList +
'}';
}
@@ -38,12 +38,12 @@ public void setStatus(int status) {
this.status = status;
}
- public List getResults() {
- return results;
+ public List getResultsList() {
+ return resultsList;
}
- public void setResults(List results) {
- this.results = results;
+ public void setResults(List resultslist) {
+ this.resultsList = resultslist;
}
public String getUrl() {
diff --git a/folioreader/src/main/java/com/folioreader/model/dictionary/DictionaryResults.java b/folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionaryResults.java
similarity index 94%
rename from folioreader/src/main/java/com/folioreader/model/dictionary/DictionaryResults.java
rename to folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionaryResults.java
index ddfe17859..dc1fa779d 100644
--- a/folioreader/src/main/java/com/folioreader/model/dictionary/DictionaryResults.java
+++ b/folioreader/src/main/java/com/folioreader/model/dictionary/EnglishDictionaryResults.java
@@ -9,7 +9,7 @@
* @author gautam chibde on 4/7/17.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
-public class DictionaryResults {
+public class EnglishDictionaryResults {
@JsonProperty
private String headword;
@JsonProperty
@@ -22,7 +22,7 @@ public class DictionaryResults {
@Override
public String toString() {
- return "DictionaryResults{" +
+ return "EnglishDictionaryResults{" +
"headword='" + headword + '\'' +
", partOfSpeech='" + partOfSpeech + '\'' +
", pronunciations=" + pronunciations +
diff --git a/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionary.java b/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionary.java
new file mode 100644
index 000000000..c72825142
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionary.java
@@ -0,0 +1,19 @@
+package com.folioreader.model.dictionary;
+
+import java.util.List;
+
+public class VietnameseDictionary {
+ private List resultsList;
+
+ public VietnameseDictionary(List resultslist) {
+ setResult(resultslist);
+ }
+
+ public List getResultsList() {
+ return resultsList;
+ }
+
+ public void setResult(List resultlist) {
+ this.resultsList = resultlist;
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionaryResult.java b/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionaryResult.java
new file mode 100644
index 000000000..dc58c0238
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/model/dictionary/VietnameseDictionaryResult.java
@@ -0,0 +1,38 @@
+package com.folioreader.model.dictionary;
+
+public class VietnameseDictionaryResult {
+ private String word;
+ private String define;
+ private String example;
+
+
+ public VietnameseDictionaryResult(String word, String define, String example) {
+ this.word = word;
+ this.define = define;
+ this.example = example;
+ }
+
+ public String getWord() {
+ return word;
+ }
+
+ public void setWord(String word) {
+ this.word = word;
+ }
+
+ public String getDefine() {
+ return define;
+ }
+
+ public void setDefine(String define) {
+ this.define = define;
+ }
+
+ public String getExample() {
+ return example;
+ }
+
+ public void setExample(String example) {
+ this.example = example;
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/model/sqlite/HighLightTable.java b/folioreader/src/main/java/com/folioreader/model/sqlite/HighLightTable.java
index 29a4462fc..87aa9bb57 100644
--- a/folioreader/src/main/java/com/folioreader/model/sqlite/HighLightTable.java
+++ b/folioreader/src/main/java/com/folioreader/model/sqlite/HighLightTable.java
@@ -143,7 +143,7 @@ public static Date getDateTime(String date) {
return date1;
}
- public static HighlightImpl updateHighlightStyle(String rangy, String style) {
+ public static HighlightImpl updateHighlightStyle(String rangy, String style) {
String query = "SELECT " + ID + " FROM " + TABLE_NAME + " WHERE " + COL_RANGY + " = \"" + rangy + "\"";
int id = DbAdapter.getIdForQuery(query);
if (id != -1 && update(id, updateRangy(rangy, style), style.replace("highlight_", ""))) {
@@ -157,7 +157,7 @@ public static HighlightImpl getHighlightForRangy(String rangy) {
return getHighlightId(DbAdapter.getIdForQuery(query));
}
- private static String updateRangy(String rangy, String style) {
+ public static String updateRangy(String rangy, String style) {
/*Pattern p = Pattern.compile("\\highlight_\\w+");
Matcher m = p.matcher(rangy);
return m.replaceAll(style);*/
diff --git a/folioreader/src/main/java/com/folioreader/model/sqlite/SQLiteExternalDatabase_VietnameseDictionaryHelper.java b/folioreader/src/main/java/com/folioreader/model/sqlite/SQLiteExternalDatabase_VietnameseDictionaryHelper.java
new file mode 100644
index 000000000..d4adeb3d2
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/model/sqlite/SQLiteExternalDatabase_VietnameseDictionaryHelper.java
@@ -0,0 +1,19 @@
+package com.folioreader.model.sqlite;
+
+import android.content.Context;
+
+import com.readystatesoftware.sqliteasset.SQLiteAssetHelper;
+
+//VietnamseDictionaryDatabase contain a table named VIETNAMESE_DICTIONARY which containt 2 columns:
+//WORD (Primary Key): w_word
+//DEFINE: wdf<1>_define<1> wex<1>_example<1> wdf<2>_define<2> wex<2>_example<2>
+
+public class SQLiteExternalDatabase_VietnameseDictionaryHelper extends SQLiteAssetHelper {
+
+ private static final String DB_NAME = "VietnameseDictionary.db.sqbpro";
+ private static final int DB_VERSION = 1;
+
+ public SQLiteExternalDatabase_VietnameseDictionaryHelper(Context context) {
+ super(context, DB_NAME, null, DB_VERSION);
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/model/sqlite/VietnameseDictionaryDatabaseHelper.java b/folioreader/src/main/java/com/folioreader/model/sqlite/VietnameseDictionaryDatabaseHelper.java
new file mode 100644
index 000000000..73d707d5e
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/model/sqlite/VietnameseDictionaryDatabaseHelper.java
@@ -0,0 +1,61 @@
+package com.folioreader.model.sqlite;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.util.Log;
+
+public class VietnameseDictionaryDatabaseHelper {
+
+ private SQLiteOpenHelper openHelper;
+ private SQLiteDatabase vi_DictionaryDB;
+ private static VietnameseDictionaryDatabaseHelper instance;
+
+ Cursor cursor = null;
+
+ private VietnameseDictionaryDatabaseHelper(Context context) {
+ this.openHelper = new SQLiteExternalDatabase_VietnameseDictionaryHelper(context);
+ }
+
+ public static VietnameseDictionaryDatabaseHelper getInstance(Context context) {
+ if (instance == null) {
+ instance = new VietnameseDictionaryDatabaseHelper(context);
+ Log.e("DBHelper: ", "DB null");
+ }
+ return instance;
+ }
+
+
+ public void openDatabase() {
+ this.vi_DictionaryDB = openHelper.getWritableDatabase();
+ }
+
+ public void closeDatabase() {
+ if (this.vi_DictionaryDB != null) {
+ this.vi_DictionaryDB.close();
+ }
+ }
+
+ public String getDefine(String word) {
+ cursor = vi_DictionaryDB.rawQuery("SELECT DEFINE FROM VIETNAMESE_DICTIONARY WHERE WORD = '" + word+"' ", new String[]{});
+ StringBuffer buffer = new StringBuffer();
+ while (cursor.moveToNext()) {
+ String define = cursor.getString(0);
+ buffer.append(" " + define);
+ }
+ return buffer.toString();
+ }
+
+// public void QueryData(String query)
+// {
+// SQLiteDatabase database = getWritableDatabase();
+// database.execSQL(query);
+// }
+
+// public Cursor GetData(String query)
+// {
+// SQLiteDatabase database = getReadableDatabase();
+// return database.rawQuery(query, null);
+// }
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/activity/ContentHighlightActivity.java b/folioreader/src/main/java/com/folioreader/ui/activity/ContentHighlightActivity.java
index 2c320e731..eb0a4de04 100644
--- a/folioreader/src/main/java/com/folioreader/ui/activity/ContentHighlightActivity.java
+++ b/folioreader/src/main/java/com/folioreader/ui/activity/ContentHighlightActivity.java
@@ -106,7 +106,7 @@ private void loadContentFragment() {
ft.commit();
}
- private void loadHighlightsFragment() {
+ public void loadHighlightsFragment() {
findViewById(R.id.btn_contents).setSelected(false);
findViewById(R.id.btn_highlights).setSelected(true);
String bookId = getIntent().getStringExtra(FolioReader.EXTRA_BOOK_ID);
diff --git a/folioreader/src/main/java/com/folioreader/ui/activity/FolioActivity.kt b/folioreader/src/main/java/com/folioreader/ui/activity/FolioActivity.kt
index 8df26fbe8..de3fcae9b 100644
--- a/folioreader/src/main/java/com/folioreader/ui/activity/FolioActivity.kt
+++ b/folioreader/src/main/java/com/folioreader/ui/activity/FolioActivity.kt
@@ -36,6 +36,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
+import android.widget.ImageButton
import android.widget.Toast
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
@@ -82,6 +83,7 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
private var mFolioPageViewPager: DirectionalViewpager? = null
private var actionBar: ActionBar? = null
private var appBarLayout: FolioAppBarLayout? = null
+ private var bookmarkButton: ImageButton? = null
private var toolbar: Toolbar? = null
private var distractionFreeMode: Boolean = false
private var handler: Handler? = null
@@ -139,7 +141,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
if (action != null && action == FolioReader.ACTION_CLOSE_FOLIOREADER) {
try {
- val activityManager = context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
+ val activityManager =
+ context.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val tasks = activityManager.runningAppProcesses
taskImportance = tasks[0].importance
} catch (e: Exception) {
@@ -147,7 +150,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
}
val closeIntent = Intent(applicationContext, FolioActivity::class.java)
- closeIntent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
+ closeIntent.flags =
+ Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP
closeIntent.action = FolioReader.ACTION_CLOSE_FOLIOREADER
this@FolioActivity.startActivity(closeIntent)
}
@@ -267,11 +271,13 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
if (savedInstanceState != null) {
searchAdapterDataBundle = savedInstanceState.getBundle(SearchAdapter.DATA_BUNDLE)
- searchQuery = savedInstanceState.getCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY)
+ searchQuery =
+ savedInstanceState.getCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY)
}
mBookId = intent.getStringExtra(FolioReader.EXTRA_BOOK_ID)
- mEpubSourceType = intent.extras!!.getSerializable(FolioActivity.INTENT_EPUB_SOURCE_TYPE) as EpubSourceType
+ mEpubSourceType =
+ intent.extras!!.getSerializable(FolioActivity.INTENT_EPUB_SOURCE_TYPE) as EpubSourceType
if (mEpubSourceType == EpubSourceType.RAW) {
mEpubRawId = intent.extras!!.getInt(FolioActivity.INTENT_EPUB_SOURCE_PATH)
} else {
@@ -301,9 +307,12 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
appBarLayout = findViewById(R.id.appBarLayout)
toolbar = findViewById(R.id.toolbar)
+
setSupportActionBar(toolbar)
actionBar = supportActionBar
+ bookmarkButton = findViewById(R.id.btn_bookmark)
+
val config = AppUtil.getSavedConfig(applicationContext)!!
val drawable = ContextCompat.getDrawable(this, R.drawable.ic_drawer)
@@ -403,11 +412,21 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
Log.v(LOG_TAG, "-> onOptionsItemSelected -> " + item.title)
showMediaController()
return true
+ } else if (itemId == R.id.btn_bookmark)
+ {
+ Log.v(LOG_TAG, "-> onOptionsItemSelected -> " + item.title)
+ handlerBookmarkButton()
+ return true
}
return super.onOptionsItemSelected(item)
}
+ fun handlerBookmarkButton()
+ {
+
+ }
+
fun startContentHighlightActivity() {
val intent = Intent(this@FolioActivity, ContentHighlightActivity::class.java)
@@ -485,7 +504,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
}
}
- portNumber = intent.getIntExtra(FolioReader.EXTRA_PORT_NUMBER, Constants.DEFAULT_PORT_NUMBER)
+ portNumber =
+ intent.getIntExtra(FolioReader.EXTRA_PORT_NUMBER, Constants.DEFAULT_PORT_NUMBER)
portNumber = AppUtil.getAvailablePortNumber(portNumber)
r2StreamerServer = Server(portNumber)
@@ -538,7 +558,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
override fun getStreamerUrl(): String {
if (streamerUri == null) {
- streamerUri = Uri.parse(String.format(STREAMER_URL_TEMPLATE, LOCALHOST, portNumber, bookFileName))
+ streamerUri =
+ Uri.parse(String.format(STREAMER_URL_TEMPLATE, LOCALHOST, portNumber, bookFileName))
}
return streamerUri.toString()
}
@@ -575,7 +596,8 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
hideSystemUI()
showSystemUI()
- distractionFreeMode = savedInstanceState != null && savedInstanceState.getBoolean(BUNDLE_DISTRACTION_FREE_MODE)
+ distractionFreeMode =
+ savedInstanceState != null && savedInstanceState.getBoolean(BUNDLE_DISTRACTION_FREE_MODE)
}
override fun onPostCreate(savedInstanceState: Bundle?) {
@@ -855,8 +877,14 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
mFolioPageViewPager = findViewById(R.id.folioPageViewPager)
// Replacing with addOnPageChangeListener(), onPageSelected() is not invoked
- mFolioPageViewPager!!.setOnPageChangeListener(object : DirectionalViewpager.OnPageChangeListener {
- override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
+ mFolioPageViewPager!!.setOnPageChangeListener(object :
+ DirectionalViewpager.OnPageChangeListener {
+ override fun onPageScrolled(
+ position: Int,
+ positionOffset: Float,
+ positionOffsetPixels: Int
+ ) {
+ }
override fun onPageSelected(position: Int) {
Log.v(LOG_TAG, "-> onPageSelected -> DirectionalViewpager -> position = $position")
@@ -879,14 +907,16 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
"position = " + position
)
- var folioPageFragment = mFolioPageFragmentAdapter!!.getItem(position - 1) as FolioPageFragment?
+ var folioPageFragment =
+ mFolioPageFragmentAdapter!!.getItem(position - 1) as FolioPageFragment?
if (folioPageFragment != null) {
folioPageFragment.scrollToLast()
if (folioPageFragment.mWebview != null)
folioPageFragment.mWebview!!.dismissPopupWindow()
}
- folioPageFragment = mFolioPageFragmentAdapter!!.getItem(position + 1) as FolioPageFragment?
+ folioPageFragment =
+ mFolioPageFragmentAdapter!!.getItem(position + 1) as FolioPageFragment?
if (folioPageFragment != null) {
folioPageFragment.scrollToFirst()
if (folioPageFragment.mWebview != null)
@@ -1027,12 +1057,20 @@ class FolioActivity : AppCompatActivity(), FolioActivityCallback, MediaControlle
)
}
- override fun onRequestPermissionsResult(requestCode: Int, permissions: Array, grantResults: IntArray) {
+ override fun onRequestPermissionsResult(
+ requestCode: Int,
+ permissions: Array,
+ grantResults: IntArray
+ ) {
when (requestCode) {
Constants.WRITE_EXTERNAL_STORAGE_REQUEST -> if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
setupBook()
} else {
- Toast.makeText(this, getString(R.string.cannot_access_epub_message), Toast.LENGTH_LONG).show()
+ Toast.makeText(
+ this,
+ getString(R.string.cannot_access_epub_message),
+ Toast.LENGTH_LONG
+ ).show()
finish()
}
}
diff --git a/folioreader/src/main/java/com/folioreader/ui/adapter/DictionaryAdapter.java b/folioreader/src/main/java/com/folioreader/ui/adapter/EnglishDictionaryAdapter.java
similarity index 90%
rename from folioreader/src/main/java/com/folioreader/ui/adapter/DictionaryAdapter.java
rename to folioreader/src/main/java/com/folioreader/ui/adapter/EnglishDictionaryAdapter.java
index b524e6904..86cce1c71 100644
--- a/folioreader/src/main/java/com/folioreader/ui/adapter/DictionaryAdapter.java
+++ b/folioreader/src/main/java/com/folioreader/ui/adapter/EnglishDictionaryAdapter.java
@@ -14,7 +14,7 @@
import com.folioreader.Config;
import com.folioreader.R;
import com.folioreader.model.dictionary.*;
-import com.folioreader.ui.base.DictionaryCallBack;
+import com.folioreader.ui.base.EnglishDictionaryCallBack;
import com.folioreader.util.AppUtil;
import java.util.ArrayList;
@@ -24,14 +24,14 @@
* @author gautam chibde on 4/7/17.
*/
-public class DictionaryAdapter extends RecyclerView.Adapter {
+public class EnglishDictionaryAdapter extends RecyclerView.Adapter {
- private List results;
+ private List results;
private Context context;
- private DictionaryCallBack callBack;
+ private EnglishDictionaryCallBack callBack;
private static Config config;
- public DictionaryAdapter(Context context, DictionaryCallBack callBack) {
+ public EnglishDictionaryAdapter(Context context, EnglishDictionaryCallBack callBack) {
this.results = new ArrayList<>();
this.context = context;
this.callBack = callBack;
@@ -47,7 +47,7 @@ public DictionaryHolder onCreateViewHolder(ViewGroup parent, int viewType) {
@Override
@SuppressWarnings("PMD.InefficientEmptyStringCheck")
public void onBindViewHolder(DictionaryHolder holder, int position) {
- final DictionaryResults res = results.get(position);
+ final EnglishDictionaryResults res = results.get(position);
if (res.getPartOfSpeech() != null) {
int wordLength = res.getHeadword().length();
SpannableString spannableString = new SpannableString(res.getHeadword() + " - " + res.getPartOfSpeech());
@@ -101,7 +101,7 @@ public void onBindViewHolder(DictionaryHolder holder, int position) {
// holder.sound.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
-// Log.i("DictionaryAdapter", "clicked");
+// Log.i("EnglishDictionaryAdapter", "clicked");
// if (res.getPronunciations() != null) {
// final String url = getAudioUrl(res.getPronunciations());
// callBack.playMedia(url);
@@ -122,7 +122,7 @@ private String getAudioUrl(List pronunciations) {
return null;
}
- public void setResults(List resultsList) {
+ public void setResults(List resultsList) {
if (resultsList != null && !resultsList.isEmpty()) {
results.addAll(resultsList);
notifyDataSetChanged();
diff --git a/folioreader/src/main/java/com/folioreader/ui/adapter/HighlightAdapter.java b/folioreader/src/main/java/com/folioreader/ui/adapter/HighlightAdapter.java
index 4ffdc2ae2..bb5471841 100644
--- a/folioreader/src/main/java/com/folioreader/ui/adapter/HighlightAdapter.java
+++ b/folioreader/src/main/java/com/folioreader/ui/adapter/HighlightAdapter.java
@@ -6,9 +6,12 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.*;
+
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
+
import com.folioreader.Config;
import com.folioreader.R;
import com.folioreader.model.HighlightImpl;
@@ -28,6 +31,7 @@ public class HighlightAdapter extends RecyclerView.Adapter highlights, HighLightAdapterCallback callback, Config config) {
this.context = context;
this.highlights = highlights;
@@ -50,7 +54,7 @@ public void run() {
((AppCompatActivity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
- holder.container.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
+ holder.container.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
}
});
}
@@ -59,6 +63,7 @@ public void run() {
holder.content.setText(Html.fromHtml(getItem(position).getContent()));
UiUtil.setBackColorToTextView(holder.content,
getItem(position).getType());
+
holder.date.setText(AppUtil.formatDate(getItem(position).getDate()));
holder.container.setOnClickListener(new View.OnClickListener() {
@Override
@@ -71,6 +76,7 @@ public void onClick(View v) {
public void onClick(View v) {
callback.deleteHighlight(getItem(position).getId());
highlights.remove(position);
+ Toast.makeText(context, R.string.you_have_deleted_note, Toast.LENGTH_SHORT).show();
notifyDataSetChanged();
}
@@ -79,6 +85,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
callback.editNote(getItem(position), position);
+
}
});
if (getItem(position).getNote() != null) {
@@ -141,17 +148,36 @@ public void editNote(String note, int position) {
notifyDataSetChanged();
}
+ public void changeColorNote(String type, int position) {
+ highlights.get(position).setType(type);
+ notifyDataSetChanged();
+ }
+
+ public void deleteNote(int position) {
+ callback.deleteHighlight(getItem(position).getId());
+ highlights.remove(position);
+ notifyDataSetChanged();
+ }
+
+ public List getHighlights() {
+ return this.highlights;
+ }
+
+// public HighlightHolder getHolder() {
+// return this.holder;
+// }
+
static class HighlightHolder extends RecyclerView.ViewHolder {
private UnderlinedTextView content;
private ImageView delete, editNote;
private TextView date;
- private RelativeLayout container;
+ private ConstraintLayout container;
private TextView note;
private LinearLayout swipeLinearLayout;
HighlightHolder(View itemView) {
super(itemView);
- container = (RelativeLayout) itemView.findViewById(R.id.container);
+ container = (ConstraintLayout) itemView.findViewById(R.id.container);
swipeLinearLayout = (LinearLayout) itemView.findViewById(R.id.swipe_linear_layout);
content = (UnderlinedTextView) itemView.findViewById(R.id.utv_highlight_content);
delete = (ImageView) itemView.findViewById(R.id.iv_delete);
@@ -166,6 +192,6 @@ public interface HighLightAdapterCallback {
void deleteHighlight(int id);
- void editNote(HighlightImpl highlightImpl, int position);
+ void editNote(HighlightImpl highlightImpl, int position); //if delete note => return true;
}
}
diff --git a/folioreader/src/main/java/com/folioreader/ui/adapter/VietnameseDictionaryAdapter.java b/folioreader/src/main/java/com/folioreader/ui/adapter/VietnameseDictionaryAdapter.java
new file mode 100644
index 000000000..71f18a312
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/ui/adapter/VietnameseDictionaryAdapter.java
@@ -0,0 +1,78 @@
+package com.folioreader.ui.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.folioreader.R;
+import com.folioreader.model.dictionary.VietnameseDictionaryResult;
+import com.folioreader.ui.base.VietnameseDictionaryCallback;
+
+import java.util.List;
+
+public class VietnameseDictionaryAdapter extends RecyclerView.Adapter {
+ Context mContext;
+
+ private List resultList;
+
+ public VietnameseDictionaryAdapter(Context mContext, VietnameseDictionaryCallback callback) {
+ this.mContext = mContext;
+ // this.resultList = resultList;
+ }
+
+ @NonNull
+ @Override
+ public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ LayoutInflater inflater = LayoutInflater.from(parent.getContext());
+ View view = inflater.inflate(R.layout.item_dictionary, parent, false);
+ ViewHolder viewHolder = new ViewHolder(view);
+ return viewHolder;
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
+ VietnameseDictionaryResult result = resultList.get(position);
+ holder.example.setText(result.getExample());
+ holder.word.setText(result.getWord());
+ holder.define.setText(result.getDefine());
+ }
+
+ public void setResultList(List resultList) {
+ this.resultList = resultList;
+ }
+
+ public List getResultList() {
+ return resultList;
+ }
+
+ @Override
+ public int getItemCount() {
+ return resultList.size();
+ }
+
+ public class ViewHolder extends RecyclerView.ViewHolder {
+ private TextView word;
+ private TextView define;
+ private TextView example;
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ word = itemView.findViewById(R.id.tv_word);
+ define = itemView.findViewById(R.id.tv_definition);
+ example = itemView.findViewById(R.id.tv_examples);
+ //config view item
+ }
+ }
+
+ public void clear() {
+ if(resultList!=null) {
+ resultList.clear();
+ notifyItemRangeRemoved(0, resultList.size());
+ }
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/base/DictionaryCallBack.java b/folioreader/src/main/java/com/folioreader/ui/base/DictionaryCallBack.java
deleted file mode 100644
index 920b20119..000000000
--- a/folioreader/src/main/java/com/folioreader/ui/base/DictionaryCallBack.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.folioreader.ui.base;
-
-import com.folioreader.model.dictionary.Dictionary;
-
-/**
- * @author gautam chibde on 4/7/17.
- */
-
-public interface DictionaryCallBack extends BaseMvpView {
-
- void onDictionaryDataReceived(Dictionary dictionary);
-
- //TODO
- void playMedia(String url);
-}
diff --git a/folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryCallBack.java b/folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryCallBack.java
new file mode 100644
index 000000000..31e4a1edb
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryCallBack.java
@@ -0,0 +1,17 @@
+package com.folioreader.ui.base;
+
+import com.folioreader.model.dictionary.EnglishDictionary;
+
+import java.util.Dictionary;
+
+/**
+ * @author gautam chibde on 4/7/17.
+ */
+
+public interface EnglishDictionaryCallBack extends BaseMvpView {
+
+ void onEnglishDictionaryDataReceived(EnglishDictionary dictionary);
+
+ //TODO
+ void playMedia(String url);
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/base/DictionaryTask.java b/folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryTask.java
similarity index 75%
rename from folioreader/src/main/java/com/folioreader/ui/base/DictionaryTask.java
rename to folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryTask.java
index 0b8ad5a3e..ea6afb119 100644
--- a/folioreader/src/main/java/com/folioreader/ui/base/DictionaryTask.java
+++ b/folioreader/src/main/java/com/folioreader/ui/base/EnglishDictionaryTask.java
@@ -5,7 +5,8 @@
import android.util.Log;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.folioreader.model.dictionary.Dictionary;
+
+import com.folioreader.model.dictionary.EnglishDictionary;
import com.folioreader.network.TLSSocketFactory;
import com.folioreader.util.AppUtil;
@@ -19,18 +20,18 @@
* @author gautam chibde on 4/7/17.
*/
-public class DictionaryTask extends AsyncTask {
+public class EnglishDictionaryTask extends AsyncTask {
private static final String TAG = "DictionaryTask";
- private DictionaryCallBack callBack;
+ private EnglishDictionaryCallBack callBack;
- public DictionaryTask(DictionaryCallBack callBack) {
+ public EnglishDictionaryTask(EnglishDictionaryCallBack callBack) {
this.callBack = callBack;
}
@Override
- protected Dictionary doInBackground(String... strings) {
+ protected EnglishDictionary doInBackground(String... strings) {
String strUrl = strings[0];
try {
Log.v(TAG, "-> doInBackground -> url -> " + strUrl);
@@ -49,7 +50,7 @@ protected Dictionary doInBackground(String... strings) {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
- return objectMapper.readValue(stringBuilder.toString(), Dictionary.class);
+ return objectMapper.readValue(stringBuilder.toString(), EnglishDictionary.class);
} catch (Exception e) {
Log.e(TAG, "DictionaryTask failed", e);
}
@@ -57,13 +58,15 @@ protected Dictionary doInBackground(String... strings) {
}
@Override
- protected void onPostExecute(Dictionary dictionary) {
- super.onPostExecute(dictionary);
- if (dictionary != null) {
- callBack.onDictionaryDataReceived(dictionary);
+ protected void onPostExecute(EnglishDictionary englishDictionary) {
+ super.onPostExecute(englishDictionary);
+ if (englishDictionary != null) {
+ callBack.onEnglishDictionaryDataReceived(englishDictionary);
} else {
callBack.onError();
}
cancel(true);
}
+
+
}
diff --git a/folioreader/src/main/java/com/folioreader/ui/base/HtmlUtil.java b/folioreader/src/main/java/com/folioreader/ui/base/HtmlUtil.java
index 65946d51e..38dcba909 100644
--- a/folioreader/src/main/java/com/folioreader/ui/base/HtmlUtil.java
+++ b/folioreader/src/main/java/com/folioreader/ui/base/HtmlUtil.java
@@ -1,6 +1,7 @@
package com.folioreader.ui.base;
import android.content.Context;
+
import com.folioreader.Config;
import com.folioreader.Constants;
import com.folioreader.R;
@@ -23,6 +24,44 @@ public static String getHtmlContent(Context context, String htmlContent, Config
String cssPath =
String.format(context.getString(R.string.css_tag), "file:///android_asset/css/Style.css");
+ String fontFamily = null;
+ String fontStyle = null;
+
+ switch (config.getFont()) {
+ case Constants.FONT_ARVO:
+ fontFamily = "arvo";
+ fontStyle = "sans-serif";
+ break;
+ case Constants.FONT_LATO:
+ fontFamily = "lato";
+ fontStyle = "serif";
+ break;
+ case Constants.FONT_LORA:
+ fontFamily = "lora";
+ fontStyle = "serif";
+ break;
+ case Constants.FONT_UBUNTU:
+ fontFamily = "ubuntu";
+ fontStyle = "sans-serif";
+ break;
+ default:
+ // default or internal epub fonts will be used
+ break;
+ }
+
+ if (fontFamily != null) {
+ String[] textElements = {"p", "span", "h1", "h2", "h3", "h4", "h5", "h6"};
+ String fontFamilyStyle = "{font-family:\"{font family}\", {font style} !important;}"
+ .replace("{font family}", fontFamily)
+ .replace("{font style}", fontStyle);
+
+ cssPath = cssPath + "\n";
+ }
+
String jsPath = String.format(context.getString(R.string.script_tag),
"file:///android_asset/js/jsface.min.js") + "\n";
@@ -61,8 +100,8 @@ public static String getHtmlContent(Context context, String htmlContent, Config
String classes = "";
switch (config.getFont()) {
- case Constants.FONT_ANDADA:
- classes = "andada";
+ case Constants.FONT_ARVO:
+ classes = "arvo";
break;
case Constants.FONT_LATO:
classes = "lato";
@@ -70,8 +109,8 @@ public static String getHtmlContent(Context context, String htmlContent, Config
case Constants.FONT_LORA:
classes = "lora";
break;
- case Constants.FONT_RALEWAY:
- classes = "raleway";
+ case Constants.FONT_UBUNTU:
+ classes = "ubuntu";
break;
default:
break;
@@ -80,7 +119,6 @@ public static String getHtmlContent(Context context, String htmlContent, Config
if (config.isNightMode()) {
classes += " nightMode";
}
-
switch (config.getFontSize()) {
case 0:
classes += " textSizeOne";
@@ -101,7 +139,7 @@ public static String getHtmlContent(Context context, String htmlContent, Config
break;
}
- htmlContent = htmlContent.replace(" {
+ private VietnameseDictionaryDatabaseHelper databaseHelper;
+ private VietnameseDictionaryCallback callback;
+ private ArrayList vietnameseDictionaryResults;
+ // private static Config config;
+
+ public VietnameseDictionaryTask(VietnameseDictionaryCallback callback) {
+ this.callback = callback;
+
+ vietnameseDictionaryResults = new ArrayList();
+ }
+
+ @Override
+ protected void onPreExecute() {
+ super.onPreExecute();
+ }
+
+ @Override
+ protected VietnameseDictionary doInBackground(String... strings) {
+ String word = strings[0];
+
+ try {
+ Log.v("ViDictionaryTask", "-> doInBackground -> database -> " + word);
+ databaseHelper = VietnameseDictionaryDatabaseHelper.getInstance(callback.getContext_());
+ databaseHelper.openDatabase();
+ String defines = databaseHelper.getDefine(word);
+ databaseHelper.closeDatabase();
+
+ String[] define_example_List = defines.split("wdf_");
+ for (String pair : define_example_List) {
+
+ String[] pairArr = pair.split("wex_");
+
+ String define = pairArr[0];
+ Log.e("vi_Dict_Task: ",define +": "+define);
+ String example = pairArr[pairArr.length - 1];
+ Log.e("vi_Dict_Task: ",pairArr[pairArr.length - 1]);
+ if (example.contains("NoEx"))
+ vietnameseDictionaryResults.add(new VietnameseDictionaryResult( word, define, " "));
+ else
+ vietnameseDictionaryResults.add(new VietnameseDictionaryResult( word, define, example));
+ }
+
+ return new VietnameseDictionary(vietnameseDictionaryResults);
+
+ } catch (Exception e) {
+ Log.e("ViDictionaryTask", e.toString());
+ }
+ return null;
+
+ }
+
+ @Override
+ protected void onPostExecute(VietnameseDictionary vietnameseDictionary) {
+ super.onPostExecute(vietnameseDictionary);
+ Log.e("vi_Dict_Task: ",vietnameseDictionary.getResultsList().toString());
+ if (vietnameseDictionary != null) {
+ callback.onVietnameseDictionaryDataReceived(vietnameseDictionary);
+ } else {
+ callback.onError();
+ }
+ cancel(true);
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/fragment/AddHighlightNoteFragment.java b/folioreader/src/main/java/com/folioreader/ui/fragment/AddHighlightNoteFragment.java
new file mode 100644
index 000000000..4bfc7c692
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/ui/fragment/AddHighlightNoteFragment.java
@@ -0,0 +1,193 @@
+package com.folioreader.ui.fragment;
+
+import android.app.Dialog;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Bundle;
+import android.text.TextUtils;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+
+import com.folioreader.R;
+import com.folioreader.model.HighlightImpl;
+import com.folioreader.model.event.MediaOverlayHighlightStyleEvent;
+
+public class AddHighlightNoteFragment extends DialogFragment {
+ private View view;
+ private MediaOverlayHighlightStyleEvent.Style style;
+ private String selectedText;
+ private String note;
+
+ public AddHighlightNoteFragment(String selectedText) {
+ this.selectedText = selectedText;
+ }
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ view = inflater.inflate(R.layout.dialog_edit_notes, container, false);
+ setUpView();
+ return view;
+ }
+
+ private void setUpView() {
+ getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ Button btn_SaveNote = view.findViewById(R.id.btn_save_note);
+ Button btn_DeleteNote = view.findViewById(R.id.btn_delete_note);
+ ImageButton btn_EditNote_Red = view.findViewById(R.id.btn_edit_note_red);
+ ImageButton btn_EditNote_Orange = view.findViewById(R.id.btn_edit_note_orange);
+ ImageButton btn_EditNote_Blue = view.findViewById(R.id.btn_edit_note_blue);
+ ImageButton btn_EditNote_Green = view.findViewById(R.id.btn_edit_note_green);
+ //HighlightImpl highlightImpl =
+ }
+
+// public void editNote(final HighlightImpl highlightImpl, final int position) {
+// // Update here
+// final Dialog dialog = new Dialog(getActivity(), R.style.DialogCustomTheme);
+// dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
+// dialog.setContentView(R.layout.dialog_edit_notes);
+//
+// if (highlightImpl.getTmpColorLabel().equals("red")) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_red_blur);
+// }
+// if (highlightImpl.getTmpColorLabel().equals("orange")) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_orange_blur);
+// }
+// if (highlightImpl.getTmpColorLabel().equals("blue")) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_blue_blur);
+// }
+// if (highlightImpl.getTmpColorLabel().equals("green")) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_green_blur);
+// }
+//
+// dialog.show();
+//
+// String noteText = highlightImpl.getNote();
+// ((EditText) dialog.findViewById(R.id.edit_note)).setText(noteText);
+//
+// Button btn_DeleteNote = dialog.findViewById(R.id.btn_delete_note);
+// ImageButton btn_EditNote_Red = dialog.findViewById(R.id.btn_edit_note_red);
+// ImageButton btn_EditNote_Orange = dialog.findViewById(R.id.btn_edit_note_orange);
+// ImageButton btn_EditNote_Blue = dialog.findViewById(R.id.btn_edit_note_blue);
+// ImageButton btn_EditNote_Green = dialog.findViewById(R.id.btn_edit_note_green);
+//
+// dialog.findViewById(R.id.btn_save_note).setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// String note =
+// ((EditText) dialog.findViewById(R.id.edit_note)).getText().toString();
+// if (!TextUtils.isEmpty(note)) {
+// highlightImpl.setNote(note);
+// if (HighLightTable.updateHighlight(highlightImpl)) {
+// HighlightUtil.sendHighlightBroadcastEvent(
+// HighlightFragment.this.getActivity().getApplicationContext(),
+// highlightImpl,
+// HighLight.HighLightAction.MODIFY);
+// adapter.editNote(note, position);
+// }
+// dialog.dismiss();
+// } else {
+// Toast.makeText(getActivity(),
+// getString(R.string.please_enter_note),
+// Toast.LENGTH_SHORT).show();
+// }
+// }
+// });
+// btn_DeleteNote.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// adapter.deleteNote(position);
+// Toast.makeText(getActivity(), R.string.you_have_deleted_note, Toast.LENGTH_SHORT).show();
+// dialog.dismiss();
+// }
+// });
+//
+// btn_EditNote_Red.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_red_blur);
+//
+// highlightImpl.setType("highlight_red");
+// highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+//
+// if (HighLightTable.updateHighlight(highlightImpl)) {
+// HighlightUtil.sendHighlightBroadcastEvent(
+// HighlightFragment.this.getActivity().getApplicationContext(),
+// highlightImpl,
+// HighLight.HighLightAction.MODIFY);
+// }
+// EventBus.getDefault().post(new UpdateHighlightEvent());
+// adapter.changeColorNote("highlight_red", position);
+// }
+// });
+//
+// btn_EditNote_Orange.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_orange_blur);
+//
+// highlightImpl.setType("highlight_orange");
+// highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+//
+// if (HighLightTable.updateHighlight(highlightImpl)) {
+// HighlightUtil.sendHighlightBroadcastEvent(
+// HighlightFragment.this.getActivity().getApplicationContext(),
+// highlightImpl,
+// HighLight.HighLightAction.MODIFY);
+// }
+// EventBus.getDefault().post(new UpdateHighlightEvent());
+// adapter.changeColorNote("highlight_orange", position);
+// }
+// });
+//
+// btn_EditNote_Blue.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_blue_blur);
+//
+// highlightImpl.setType("highlight_blue");
+// highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+//
+// if (HighLightTable.updateHighlight(highlightImpl)) {
+// HighlightUtil.sendHighlightBroadcastEvent(
+// HighlightFragment.this.getActivity().getApplicationContext(),
+// highlightImpl,
+// HighLight.HighLightAction.MODIFY);
+// }
+// EventBus.getDefault().post(new UpdateHighlightEvent());
+// adapter.changeColorNote("highlight_blue", position);
+// }
+// });
+//
+// btn_EditNote_Green.setOnClickListener(new View.OnClickListener() {
+// @Override
+// public void onClick(View v) {
+// ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_green_blur);
+//
+// highlightImpl.setType("highlight_green");
+// highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+//
+// if (HighLightTable.updateHighlight(highlightImpl)) {
+// HighlightUtil.sendHighlightBroadcastEvent(
+// HighlightFragment.this.getActivity().getApplicationContext(),
+// highlightImpl,
+// HighLight.HighLightAction.MODIFY);
+// }
+// EventBus.getDefault().post(new UpdateHighlightEvent());
+// adapter.changeColorNote("highlight_green", position);
+// }
+// });
+//
+// }
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/fragment/DictionaryFragment.java b/folioreader/src/main/java/com/folioreader/ui/fragment/DictionaryFragment.java
index d48996493..085e6ac78 100644
--- a/folioreader/src/main/java/com/folioreader/ui/fragment/DictionaryFragment.java
+++ b/folioreader/src/main/java/com/folioreader/ui/fragment/DictionaryFragment.java
@@ -2,6 +2,7 @@
import android.app.Dialog;
import android.app.SearchManager;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.media.MediaPlayer;
@@ -13,19 +14,25 @@
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.*;
+
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.DialogFragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+
import com.folioreader.Config;
import com.folioreader.Constants;
import com.folioreader.R;
-import com.folioreader.model.dictionary.Dictionary;
+import com.folioreader.model.dictionary.EnglishDictionary;
+import com.folioreader.model.dictionary.VietnameseDictionary;
import com.folioreader.model.dictionary.Wikipedia;
-import com.folioreader.ui.adapter.DictionaryAdapter;
-import com.folioreader.ui.base.DictionaryCallBack;
-import com.folioreader.ui.base.DictionaryTask;
+import com.folioreader.ui.adapter.EnglishDictionaryAdapter;
+import com.folioreader.ui.adapter.VietnameseDictionaryAdapter;
+import com.folioreader.ui.base.EnglishDictionaryCallBack;
+import com.folioreader.ui.base.EnglishDictionaryTask;
+import com.folioreader.ui.base.VietnameseDictionaryCallback;
+import com.folioreader.ui.base.VietnameseDictionaryTask;
import com.folioreader.ui.base.WikipediaCallBack;
import com.folioreader.ui.base.WikipediaTask;
import com.folioreader.util.AppUtil;
@@ -34,28 +41,41 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
+import java.util.Locale;
/**
* @author gautam chibde on 4/7/17.
*/
public class DictionaryFragment extends DialogFragment
- implements DictionaryCallBack, WikipediaCallBack {
+ implements EnglishDictionaryCallBack, WikipediaCallBack, VietnameseDictionaryCallback {
private static final String TAG = "DictionaryFragment";
-
+ View view;
private String word;
-
private MediaPlayer mediaPlayer;
- private RecyclerView dictResults;
+ private RecyclerView recyclerView_dictResults;
private TextView noNetwork, dictionary, wikipedia, wikiWord, def;
private ProgressBar progressBar;
private Button googleSearch;
private LinearLayout wikiLayout;
private WebView wikiWebView;
- private DictionaryAdapter mAdapter;
+ private EnglishDictionaryAdapter en_English_dictionaryAdapter;
+ private VietnameseDictionaryAdapter vi_dictionaryAdapter;
+ private VietnameseDictionaryTask vi_dictionary_task;
private ImageView imageViewClose;
+ private EnglishDictionaryTask en_dictionary_task;
+ private WikipediaTask wiki_task;
+
+ private Spinner dictionarySpinner;
+ private String[] nationList_English = {"English", "Vietnamese"};
+ private String[] nationList_VietNamese = {"Tiếng Anh", "Tiếng Việt"};
+ private String[] nationList_Russian = {"Английский", "вьетнамский"};
+ private String[] nationList_Portuguese = {"Inglês", "vietnamita"};
+ private String[] nationList_Czech = {"Angličtina", "vietnamština"};
+
+
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -73,16 +93,35 @@ public void onActivityCreated(Bundle arg0) {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- return inflater.inflate(R.layout.layout_dictionary, container);
+ view = inflater.inflate(R.layout.layout_dictionary, container);
+ return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
+ setUpView();
+
+ }
+
+ private void setUpView() {
+ dictionarySpinner = (Spinner) view.findViewById(R.id.spn_dictionary_language);
+ ArrayAdapter spinnerArrayAdapter;
+
+ if (getDeviceLanguage().equals("vi"))
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_VietNamese);
+ else
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_English);
+ dictionarySpinner.setAdapter(spinnerArrayAdapter);
+ if (getDeviceLanguage().equals("vi")) {
+ dictionarySpinner.setSelection(1);
+ } else {
+ dictionarySpinner.setSelection(0);
+ }
noNetwork = (TextView) view.findViewById(R.id.no_network);
progressBar = (ProgressBar) view.findViewById(R.id.progress);
- dictResults = (RecyclerView) view.findViewById(R.id.rv_dict_results);
+ recyclerView_dictResults = (RecyclerView) view.findViewById(R.id.rv_dict_results);
googleSearch = (Button) view.findViewById(R.id.btn_google_search);
dictionary = (TextView) view.findViewById(R.id.btn_dictionary);
@@ -100,7 +139,8 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
dictionary.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- loadDictionary();
+ dictionarySpinner.setVisibility(View.VISIBLE);
+ loadEnglishDictionary();
}
});
@@ -108,6 +148,23 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
loadWikipedia();
+ dictionarySpinner.setVisibility(View.GONE);
+ }
+ });
+
+ dictionarySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ if (position == 1) {
+ loadVietnameseDictionary();
+ } else {
+ loadEnglishDictionary();
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
}
});
@@ -127,12 +184,12 @@ public void onClick(View v) {
dismiss();
}
});
- dictResults.setLayoutManager(new LinearLayoutManager(getActivity()));
- mAdapter = new DictionaryAdapter(getActivity(), this);
+ recyclerView_dictResults.setLayoutManager(new LinearLayoutManager(getActivity()));
+ en_English_dictionaryAdapter = new EnglishDictionaryAdapter(getContext(), this);
+ vi_dictionaryAdapter = new VietnameseDictionaryAdapter(getContext(), this);
configureTheme(view);
- loadDictionary();
}
private void configureTheme(View view) {
@@ -174,25 +231,44 @@ private void configureTheme(View view) {
}
}
- private void loadDictionary() {
+ private void loadEnglishDictionary() {
if (noNetwork.getVisibility() == View.VISIBLE || googleSearch.getVisibility() == View.VISIBLE) {
noNetwork.setVisibility(View.GONE);
googleSearch.setVisibility(View.GONE);
}
wikiWebView.loadUrl("about:blank");
- mAdapter.clear();
+ if(vi_dictionaryAdapter!=null) vi_dictionaryAdapter.clear();
dictionary.setSelected(true);
wikipedia.setSelected(false);
wikiLayout.setVisibility(View.GONE);
- dictResults.setVisibility(View.VISIBLE);
- DictionaryTask task = new DictionaryTask(this);
+ recyclerView_dictResults.setVisibility(View.VISIBLE);
+ en_dictionary_task = new EnglishDictionaryTask(this);
String urlString = null;
try {
urlString = Constants.DICTIONARY_BASE_URL + URLEncoder.encode(word, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "-> loadDictionary", e);
}
- task.execute(urlString);
+ en_dictionary_task.execute(urlString);
+ }
+
+ private void loadVietnameseDictionary() {
+ if (noNetwork.getVisibility() == View.VISIBLE || googleSearch.getVisibility() == View.VISIBLE) {
+ noNetwork.setVisibility(View.GONE);
+ googleSearch.setVisibility(View.GONE);
+ }
+ // code here
+ en_English_dictionaryAdapter.clear();
+ dictionary.setSelected(true);
+ wikipedia.setSelected(false);
+ recyclerView_dictResults.setVisibility(View.GONE);
+ recyclerView_dictResults.setVisibility(View.VISIBLE);
+
+ if (wikiLayout.getVisibility() == View.VISIBLE)
+ wikiLayout.setVisibility(View.GONE);
+ recyclerView_dictResults.setVisibility(View.VISIBLE);
+ vi_dictionary_task = new VietnameseDictionaryTask(this);
+ vi_dictionary_task.execute(word);
}
private void loadWikipedia() {
@@ -201,39 +277,53 @@ private void loadWikipedia() {
googleSearch.setVisibility(View.GONE);
}
wikiWebView.loadUrl("about:blank");
- mAdapter.clear();
+ en_English_dictionaryAdapter.clear();
wikiLayout.setVisibility(View.VISIBLE);
- dictResults.setVisibility(View.GONE);
+ recyclerView_dictResults.setVisibility(View.GONE);
dictionary.setSelected(false);
wikipedia.setSelected(true);
- WikipediaTask task = new WikipediaTask(this);
+ wiki_task = new WikipediaTask(this);
String urlString = null;
try {
urlString = Constants.WIKIPEDIA_API_URL + URLEncoder.encode(word, "UTF-8");
} catch (UnsupportedEncodingException e) {
Log.e(TAG, "-> loadWikipedia", e);
}
- task.execute(urlString);
+ wiki_task.execute(urlString);
}
@Override
public void onError() {
noNetwork.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
- noNetwork.setText("offline");
+ noNetwork.setText(R.string.offline);
googleSearch.setVisibility(View.GONE);
}
+
@Override
- public void onDictionaryDataReceived(Dictionary dictionary) {
+ public void onVietnameseDictionaryDataReceived(VietnameseDictionary vietnameseDictionary) {
progressBar.setVisibility(View.GONE);
- if (dictionary.getResults().isEmpty()) {
+ if (vietnameseDictionary.getResultsList().isEmpty()) {
noNetwork.setVisibility(View.VISIBLE);
googleSearch.setVisibility(View.VISIBLE);
- noNetwork.setText("Word not found");
+ noNetwork.setText(R.string.word_not_found);
} else {
- mAdapter.setResults(dictionary.getResults());
- dictResults.setAdapter(mAdapter);
+ vi_dictionaryAdapter.setResultList(vietnameseDictionary.getResultsList());
+ recyclerView_dictResults.setAdapter(vi_dictionaryAdapter);
+ }
+ }
+
+ @Override
+ public void onEnglishDictionaryDataReceived(EnglishDictionary englishDictionary) {
+ progressBar.setVisibility(View.GONE);
+ if (englishDictionary.getResultsList().isEmpty()) {
+ noNetwork.setVisibility(View.VISIBLE);
+ googleSearch.setVisibility(View.VISIBLE);
+ noNetwork.setText(R.string.word_not_found);
+ } else {
+ en_English_dictionaryAdapter.setResults(englishDictionary.getResultsList());
+ recyclerView_dictResults.setAdapter(en_English_dictionaryAdapter);
}
}
@@ -283,4 +373,16 @@ public void onStop() {
mediaPlayer.release();
}
}
+
+ private String getDeviceLanguage() {
+ Locale locale = getContext().getResources().getConfiguration().locale;
+ //return locale; //return vi_VN
+ return locale.getLanguage(); //return vi
+ }
+
+
+ @Override
+ public Context getContext_() {
+ return getContext();
+ }
}
diff --git a/folioreader/src/main/java/com/folioreader/ui/fragment/HighlightFragment.java b/folioreader/src/main/java/com/folioreader/ui/fragment/HighlightFragment.java
index e4c8a9d16..5ad041caa 100644
--- a/folioreader/src/main/java/com/folioreader/ui/fragment/HighlightFragment.java
+++ b/folioreader/src/main/java/com/folioreader/ui/fragment/HighlightFragment.java
@@ -3,20 +3,26 @@
import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
+import android.media.Image;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
+import android.widget.Button;
import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.Toast;
+
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+
import com.folioreader.Config;
import com.folioreader.Constants;
import com.folioreader.FolioReader;
@@ -28,24 +34,31 @@
import com.folioreader.ui.adapter.HighlightAdapter;
import com.folioreader.util.AppUtil;
import com.folioreader.util.HighlightUtil;
+
import org.greenrobot.eventbus.EventBus;
public class HighlightFragment extends Fragment implements HighlightAdapter.HighLightAdapterCallback {
private static final String HIGHLIGHT_ITEM = "highlight_item";
private View mRootView;
private HighlightAdapter adapter;
+ public static HighlightFragment instance;
private String mBookId;
-
-
+ private final String LOG_TAG = "HIGHLIGHT_FRM";
public static HighlightFragment newInstance(String bookId, String epubTitle) {
HighlightFragment highlightFragment = new HighlightFragment();
Bundle args = new Bundle();
args.putString(FolioReader.EXTRA_BOOK_ID, bookId);
args.putString(Constants.BOOK_TITLE, epubTitle);
highlightFragment.setArguments(args);
+ instance = highlightFragment;
return highlightFragment;
}
+ public static HighlightFragment getInstance()
+ {
+ return instance;
+ }
+
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -79,11 +92,13 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
@Override
public void onItemClick(HighlightImpl highlightImpl) {
- Intent intent = new Intent();
- intent.putExtra(HIGHLIGHT_ITEM, highlightImpl);
- intent.putExtra(Constants.TYPE, Constants.HIGHLIGHT_SELECTED);
- getActivity().setResult(Activity.RESULT_OK, intent);
- getActivity().finish();
+
+ Intent intent = new Intent();
+ intent.putExtra(HIGHLIGHT_ITEM, highlightImpl);
+ intent.putExtra(Constants.TYPE, Constants.HIGHLIGHT_SELECTED);
+ getActivity().setResult(Activity.RESULT_OK, intent);
+ getActivity().finish();
+
}
@Override
@@ -95,17 +110,40 @@ public void deleteHighlight(int id) {
@Override
public void editNote(final HighlightImpl highlightImpl, final int position) {
+ // Update here
+
+
final Dialog dialog = new Dialog(getActivity(), R.style.DialogCustomTheme);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.dialog_edit_notes);
+
+ if (highlightImpl.getTmpColorLabel().equals("red")) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_red_blur);
+ }
+ if (highlightImpl.getTmpColorLabel().equals("orange")) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_orange_blur);
+ }
+ if (highlightImpl.getTmpColorLabel().equals("blue")) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_blue_blur);
+ }
+ if (highlightImpl.getTmpColorLabel().equals("green")) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_green_blur);
+ }
+
dialog.show();
+
String noteText = highlightImpl.getNote();
((EditText) dialog.findViewById(R.id.edit_note)).setText(noteText);
+ Button btn_DeleteNote = dialog.findViewById(R.id.btn_delete_note);
+ ImageButton btn_EditNote_Red = dialog.findViewById(R.id.btn_edit_note_red);
+ ImageButton btn_EditNote_Orange = dialog.findViewById(R.id.btn_edit_note_orange);
+ ImageButton btn_EditNote_Blue = dialog.findViewById(R.id.btn_edit_note_blue);
+ ImageButton btn_EditNote_Green = dialog.findViewById(R.id.btn_edit_note_green);
+
dialog.findViewById(R.id.btn_save_note).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-
String note =
((EditText) dialog.findViewById(R.id.edit_note)).getText().toString();
if (!TextUtils.isEmpty(note)) {
@@ -125,6 +163,91 @@ public void onClick(View v) {
}
}
});
+ btn_DeleteNote.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ adapter.deleteNote(position);
+ Toast.makeText(getActivity(), R.string.you_have_deleted_note, Toast.LENGTH_SHORT).show();
+ dialog.dismiss();
+ }
+ });
+
+ btn_EditNote_Red.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_red_blur);
+
+ highlightImpl.setType("highlight_red");
+ highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+
+ if (HighLightTable.updateHighlight(highlightImpl)) {
+ HighlightUtil.sendHighlightBroadcastEvent(
+ HighlightFragment.this.getActivity().getApplicationContext(),
+ highlightImpl,
+ HighLight.HighLightAction.MODIFY);
+ }
+ EventBus.getDefault().post(new UpdateHighlightEvent());
+ adapter.changeColorNote("highlight_red", position);
+ }
+ });
+
+ btn_EditNote_Orange.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_orange_blur);
+
+ highlightImpl.setType("highlight_orange");
+ highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+
+ if (HighLightTable.updateHighlight(highlightImpl)) {
+ HighlightUtil.sendHighlightBroadcastEvent(
+ HighlightFragment.this.getActivity().getApplicationContext(),
+ highlightImpl,
+ HighLight.HighLightAction.MODIFY);
+ }
+ EventBus.getDefault().post(new UpdateHighlightEvent());
+ adapter.changeColorNote("highlight_orange", position);
+ }
+ });
+
+ btn_EditNote_Blue.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_blue_blur);
+
+ highlightImpl.setType("highlight_blue");
+ highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+
+ if (HighLightTable.updateHighlight(highlightImpl)) {
+ HighlightUtil.sendHighlightBroadcastEvent(
+ HighlightFragment.this.getActivity().getApplicationContext(),
+ highlightImpl,
+ HighLight.HighLightAction.MODIFY);
+ }
+ EventBus.getDefault().post(new UpdateHighlightEvent());
+ adapter.changeColorNote("highlight_blue", position);
+ }
+ });
+
+ btn_EditNote_Green.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ ((ImageView) dialog.findViewById(R.id.edit_note_background)).setImageResource(R.drawable.note_edittext_background_green_blur);
+
+ highlightImpl.setType("highlight_green");
+ highlightImpl.setRangy(HighLightTable.updateRangy(highlightImpl.getRangy(), highlightImpl.getType()));
+
+ if (HighLightTable.updateHighlight(highlightImpl)) {
+ HighlightUtil.sendHighlightBroadcastEvent(
+ HighlightFragment.this.getActivity().getApplicationContext(),
+ highlightImpl,
+ HighLight.HighLightAction.MODIFY);
+ }
+ EventBus.getDefault().post(new UpdateHighlightEvent());
+ adapter.changeColorNote("highlight_green", position);
+ }
+ });
+
}
}
diff --git a/folioreader/src/main/java/com/folioreader/ui/fragment/TranslateFragment.java b/folioreader/src/main/java/com/folioreader/ui/fragment/TranslateFragment.java
new file mode 100644
index 000000000..be5f1a93a
--- /dev/null
+++ b/folioreader/src/main/java/com/folioreader/ui/fragment/TranslateFragment.java
@@ -0,0 +1,206 @@
+package com.folioreader.ui.fragment;
+
+import android.content.Context;
+import android.graphics.Color;
+import android.graphics.drawable.ColorDrawable;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
+
+import com.folioreader.R;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Locale;
+
+import okhttp3.Call;
+import okhttp3.Callback;
+import okhttp3.OkHttpClient;
+import okhttp3.Request;
+import okhttp3.Response;
+
+public class TranslateFragment extends DialogFragment {
+ private View view;
+ private String[] nationList_English = {"English", "Vietnamese", "Russian", "Portuguese", "Czech","Turkish"};
+ private String[] nationList_VietNamese = {"Tiếng Anh", "Tiếng Việt", "Tiếng Nga", "Tiếng Bồ Đào Nha", "Tiếng Sec","Turkish"};
+ private String[] nationList_Russian = {"Английский", "вьетнамский", "русский", "португальский", "чешский","Turkish"};
+ private String[] nationList_Portuguese = {"Inglês", "vietnamita", "russo", "português", "tcheco","Turkish"};
+ private String[] nationList_Czech = {"Angličtina", "vietnamština", "ruština", "portugalština", "čeština","Turkish"};
+ private String[] nationList_Turkish= {"İngilizce", "Vietnamca", "Rusça", "Portekizce", "Çekce","Turkish"};
+ private String[] stand_list = {"en", "vi", "ru", "pt", "cs","tr"};
+ private TextView translated_word;
+ private Spinner trgLang_List;
+ private String source = "";
+ private String mean;
+
+ public TranslateFragment(String source) {
+ this.source = source;
+ }
+
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ view = inflater.inflate(R.layout.fragment_translate, container, false);
+ setUpView();
+ return view;
+ }
+
+ private void setUpView() {
+ getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
+ trgLang_List = view.findViewById(R.id.to_translated_spinner);
+ translated_word = view.findViewById(R.id.translate_word_mean);
+ ArrayAdapter spinnerArrayAdapter;
+ if (getDeviceLanguage().equals("vi")) {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_VietNamese);
+ } else if (getDeviceLanguage().equals("ru")) {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_Russian);
+ } else if (getDeviceLanguage().equals("pt")) {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_Portuguese);
+ } else if (getDeviceLanguage().equals("cs")) {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_Czech);
+ } else if (getDeviceLanguage().equals("tr")) {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_Turkish);
+ } else {
+ spinnerArrayAdapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_dropdown_item, nationList_English);
+ }
+
+
+ trgLang_List.setAdapter(spinnerArrayAdapter);
+ if (getDeviceLanguage().equals("vi")) {
+ trgLang_List.setSelection(1);
+ } else if (getDeviceLanguage().equals("ru")) {
+ trgLang_List.setSelection(2);
+ } else if (getDeviceLanguage().equals("pt")) {
+ trgLang_List.setSelection(3);
+ } else if (getDeviceLanguage().equals("cs")) {
+ trgLang_List.setSelection(4);
+ } else if (getDeviceLanguage().equals("tr")) {
+ trgLang_List.setSelection(5);
+ } else {
+ trgLang_List.setSelection(0);
+ }
+
+ trgLang_List.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ getMean(stand_list[trgLang_List.getSelectedItemPosition()]);
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ getMean(stand_list[trgLang_List.getSelectedItemPosition()]);
+ }
+ }
+ );
+ }
+
+ private String getDeviceLanguage() {
+ Locale locale = getContext().getResources().getConfiguration().locale;
+ //return locale; //return vi_VN
+ return locale.getLanguage(); //return vi
+ }
+
+ public boolean isInternetAvailble() {
+ return isConnectingToInternet() || isConnectingToWifi();
+ }
+
+ private boolean isConnectingToInternet() {
+ ConnectivityManager connectivity = (ConnectivityManager) getContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null) {
+ NetworkInfo[] info = connectivity.getAllNetworkInfo();
+ if (info != null)
+ for (int i = 0; i < info.length; i++)
+ if (info[i].getState() == NetworkInfo.State.CONNECTED) {
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ private boolean isConnectingToWifi() {
+ ConnectivityManager connManager = (ConnectivityManager) getContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo mWifi = connManager
+ .getNetworkInfo(ConnectivityManager.TYPE_WIFI);
+ if (mWifi != null) {
+ if (mWifi.getState() == NetworkInfo.State.CONNECTED)
+ return true;
+ }
+ return false;
+ }
+
+ private void getMean(String stand_trg) {
+ if (isInternetAvailble()) {
+ RequestMean requestMean = new RequestMean();
+ requestMean.execute("https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=" + stand_trg + "&dt=t&q=" + this.source);
+ }
+ else
+ {
+ translated_word.setText("No network connection!");
+ }
+ }
+
+ public class RequestMean extends AsyncTask {
+
+
+ public RequestMean() {
+
+ }
+
+ @Override
+ protected String doInBackground(String... strings) {
+ OkHttpClient client = new OkHttpClient();
+ Request.Builder builder = new Request.Builder();
+ builder.url(strings[0]);
+ Request request = builder.build();
+
+ try {
+ Response response = client.newCall(request).execute();
+ return response.body().string();
+ } catch (Exception e) {
+ Toast.makeText(getContext(), "Connect failed", Toast.LENGTH_SHORT).show();
+ return "!@#$";
+ }
+
+ }
+
+ @Override
+ protected void onPostExecute(String s) {
+ super.onPostExecute(s);
+ if (s.equals("!@#$")) {
+ translated_word.setText("No network connection!");
+ } else {
+ try {
+ JSONArray array_1 = new JSONArray(s);
+ String str_1 = array_1.getJSONArray(0).toString();
+ JSONArray array_2 = new JSONArray(str_1);
+ String str_2 = array_2.getJSONArray(0).toString();
+ String[] str = str_2.split(",");
+ mean = str[0].substring(2, str[0].length() - 1);
+ translated_word.setText(mean);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+}
diff --git a/folioreader/src/main/java/com/folioreader/ui/view/ConfigBottomSheetDialogFragment.kt b/folioreader/src/main/java/com/folioreader/ui/view/ConfigBottomSheetDialogFragment.kt
index 0118a612e..bbd46eade 100644
--- a/folioreader/src/main/java/com/folioreader/ui/view/ConfigBottomSheetDialogFragment.kt
+++ b/folioreader/src/main/java/com/folioreader/ui/view/ConfigBottomSheetDialogFragment.kt
@@ -159,23 +159,23 @@ class ConfigBottomSheetDialogFragment : BottomSheetDialogFragment() {
)
buttonVertical.setTextColor(colorStateList)
buttonHorizontal.setTextColor(colorStateList)
- view_config_font_andada.setTextColor(colorStateList)
+ view_config_font_arvo.setTextColor(colorStateList)
view_config_font_lato.setTextColor(colorStateList)
view_config_font_lora.setTextColor(colorStateList)
- view_config_font_raleway.setTextColor(colorStateList)
+ view_config_font_ubuntu.setTextColor(colorStateList)
- view_config_font_andada.setOnClickListener { selectFont(Constants.FONT_ANDADA, true) }
+ view_config_font_arvo.setOnClickListener { selectFont(Constants.FONT_ARVO, true) }
view_config_font_lato.setOnClickListener { selectFont(Constants.FONT_LATO, true) }
view_config_font_lora.setOnClickListener { selectFont(Constants.FONT_LORA, true) }
- view_config_font_raleway.setOnClickListener { selectFont(Constants.FONT_RALEWAY, true) }
+ view_config_font_ubuntu.setOnClickListener { selectFont(Constants.FONT_UBUNTU, true) }
}
private fun selectFont(selectedFont: Int, isReloadNeeded: Boolean) {
when (selectedFont) {
- Constants.FONT_ANDADA -> setSelectedFont(true, false, false, false)
+ Constants.FONT_ARVO -> setSelectedFont(true, false, false, false)
Constants.FONT_LATO -> setSelectedFont(false, true, false, false)
Constants.FONT_LORA -> setSelectedFont(false, false, true, false)
- Constants.FONT_RALEWAY -> setSelectedFont(false, false, false, true)
+ Constants.FONT_UBUNTU -> setSelectedFont(false, false, false, true)
}
config.font = selectedFont
if (isAdded && isReloadNeeded) {
@@ -184,11 +184,11 @@ class ConfigBottomSheetDialogFragment : BottomSheetDialogFragment() {
}
}
- private fun setSelectedFont(andada: Boolean, lato: Boolean, lora: Boolean, raleway: Boolean) {
- view_config_font_andada.isSelected = andada
+ private fun setSelectedFont(arvo: Boolean, lato: Boolean, lora: Boolean, ubuntu: Boolean) {
+ view_config_font_arvo.isSelected = arvo
view_config_font_lato.isSelected = lato
view_config_font_lora.isSelected = lora
- view_config_font_raleway.isSelected = raleway
+ view_config_font_ubuntu.isSelected = ubuntu
}
private fun toggleBlackTheme() {
diff --git a/folioreader/src/main/java/com/folioreader/ui/view/FolioWebView.kt b/folioreader/src/main/java/com/folioreader/ui/view/FolioWebView.kt
index 7ee774e56..cda298ea6 100644
--- a/folioreader/src/main/java/com/folioreader/ui/view/FolioWebView.kt
+++ b/folioreader/src/main/java/com/folioreader/ui/view/FolioWebView.kt
@@ -31,8 +31,10 @@ import com.folioreader.model.HighlightImpl.HighlightStyle
import com.folioreader.model.sqlite.HighLightTable
import com.folioreader.ui.activity.FolioActivity
import com.folioreader.ui.activity.FolioActivityCallback
+import com.folioreader.ui.fragment.AddHighlightNoteFragment
import com.folioreader.ui.fragment.DictionaryFragment
import com.folioreader.ui.fragment.FolioPageFragment
+import com.folioreader.ui.fragment.TranslateFragment
import com.folioreader.util.AppUtil
import com.folioreader.util.HighlightUtil
import com.folioreader.util.UiUtil
@@ -105,7 +107,6 @@ class FolioWebView : WebView {
private var lastTouchAction: Int = 0
private var destroyed: Boolean = false
private var handleHeight: Int = 0
-
private var lastScrollType: LastScrollType? = null
val contentHeightVal: Int
@@ -156,13 +157,23 @@ class FolioWebView : WebView {
private inner class HorizontalGestureListener : GestureDetector.SimpleOnGestureListener() {
- override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, distanceX: Float, distanceY: Float): Boolean {
+ override fun onScroll(
+ e1: MotionEvent?,
+ e2: MotionEvent?,
+ distanceX: Float,
+ distanceY: Float
+ ): Boolean {
//Log.d(LOG_TAG, "-> onScroll -> e1 = " + e1 + ", e2 = " + e2 + ", distanceX = " + distanceX + ", distanceY = " + distanceY);
lastScrollType = LastScrollType.USER
return false
}
- override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean {
+ override fun onFling(
+ e1: MotionEvent?,
+ e2: MotionEvent?,
+ velocityX: Float,
+ velocityY: Float
+ ): Boolean {
//Log.d(LOG_TAG, "-> onFling -> e1 = " + e1 + ", e2 = " + e2 + ", velocityX = " + velocityX + ", velocityY = " + velocityY);
if (!webViewPager.isScrolling) {
@@ -212,13 +223,23 @@ class FolioWebView : WebView {
private inner class VerticalGestureListener : GestureDetector.SimpleOnGestureListener() {
- override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, distanceX: Float, distanceY: Float): Boolean {
+ override fun onScroll(
+ e1: MotionEvent?,
+ e2: MotionEvent?,
+ distanceX: Float,
+ distanceY: Float
+ ): Boolean {
//Log.v(LOG_TAG, "-> onScroll -> e1 = " + e1 + ", e2 = " + e2 + ", distanceX = " + distanceX + ", distanceY = " + distanceY);
lastScrollType = LastScrollType.USER
return false
}
- override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean {
+ override fun onFling(
+ e1: MotionEvent?,
+ e2: MotionEvent?,
+ velocityX: Float,
+ velocityY: Float
+ ): Boolean {
//Log.v(LOG_TAG, "-> onFling -> e1 = " + e1 + ", e2 = " + e2 + ", velocityX = " + velocityX + ", velocityY = " + velocityY);
lastScrollType = LastScrollType.USER
return false
@@ -227,7 +248,11 @@ class FolioWebView : WebView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
- constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
+ constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
+ context,
+ attrs,
+ defStyleAttr
+ )
private fun init() {
Log.v(LOG_TAG, "-> init")
@@ -262,11 +287,11 @@ class FolioWebView : WebView {
}
viewTextSelection = LayoutInflater.from(ctw).inflate(R.layout.text_selection, null)
- viewTextSelection.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED)
+ viewTextSelection.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED)
- viewTextSelection.yellowHighlight.setOnClickListener {
- Log.v(LOG_TAG, "-> onClick -> yellowHighlight")
- onHighlightColorItemsClicked(HighlightStyle.Yellow, false)
+ viewTextSelection.orangeHighlight.setOnClickListener {
+ Log.v(LOG_TAG, "-> onClick -> orangeHighlight")
+ onHighlightColorItemsClicked(HighlightStyle.Orange, false)
}
viewTextSelection.greenHighlight.setOnClickListener {
Log.v(LOG_TAG, "-> onClick -> greenHighlight")
@@ -276,31 +301,42 @@ class FolioWebView : WebView {
Log.v(LOG_TAG, "-> onClick -> blueHighlight")
onHighlightColorItemsClicked(HighlightStyle.Blue, false)
}
- viewTextSelection.pinkHighlight.setOnClickListener {
- Log.v(LOG_TAG, "-> onClick -> pinkHighlight")
- onHighlightColorItemsClicked(HighlightStyle.Pink, false)
+ viewTextSelection.redHighlight.setOnClickListener {
+ Log.v(LOG_TAG, "-> onClick -> redHighlight")
+ onHighlightColorItemsClicked(HighlightStyle.Red, false)
}
viewTextSelection.underlineHighlight.setOnClickListener {
Log.v(LOG_TAG, "-> onClick -> underlineHighlight")
onHighlightColorItemsClicked(HighlightStyle.Underline, false)
}
+ viewTextSelection.addNoteSelection.setOnClickListener{
+ Log.v(LOG_TAG, "-> onClick -> addHighlightNote")
+ dismissPopupWindow()
+ loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
+ }
+
viewTextSelection.deleteHighlight.setOnClickListener {
Log.v(LOG_TAG, "-> onClick -> deleteHighlight")
dismissPopupWindow()
- loadUrl("javascript:clearSelection()")
- loadUrl("javascript:deleteThisHighlight()")
+ loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
+ //loadUrl("javascript:deleteThisHighlight(${it.id})")
}
viewTextSelection.copySelection.setOnClickListener {
dismissPopupWindow()
loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
}
- viewTextSelection.shareSelection.setOnClickListener {
+// viewTextSelection.shareSelection.setOnClickListener {
+// dismissPopupWindow()
+// loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
+// }
+ viewTextSelection.defineSelection.setOnClickListener {
dismissPopupWindow()
loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
}
- viewTextSelection.defineSelection.setOnClickListener {
+
+ viewTextSelection.translateSelection.setOnClickListener {
dismissPopupWindow()
loadUrl("javascript:onTextSelectionItemClicked(${it.id})")
}
@@ -310,21 +346,43 @@ class FolioWebView : WebView {
fun onTextSelectionItemClicked(id: Int, selectedText: String?) {
uiHandler.post { loadUrl("javascript:clearSelection()") }
-
+ //id of View
when (id) {
+
+ R.id.addNoteSelection ->
+ {
+ Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> addHighlightNoteSelection -> $selectedText")
+ uiHandler.post { showAddHighlightNoteDialog(selectedText) }
+ }
+
R.id.copySelection -> {
Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> copySelection -> $selectedText")
UiUtil.copyToClipboard(context, selectedText)
- Toast.makeText(context, context.getString(R.string.copied), Toast.LENGTH_SHORT).show()
+ Toast.makeText(context, context.getString(R.string.copied), Toast.LENGTH_SHORT)
+ .show()
}
- R.id.shareSelection -> {
- Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> shareSelection -> $selectedText")
- UiUtil.share(context, selectedText)
+// R.id.shareSelection -> {
+// Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> shareSelection -> $selectedText")
+// UiUtil.share(context, selectedText)
+// }
+ R.id.deleteHighlight ->{
+ Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> deleteSelection -> $selectedText")
+ uiHandler.post { deleteThisHighlight(selectedText) }
}
+
R.id.defineSelection -> {
Log.v(LOG_TAG, "-> onTextSelectionItemClicked -> defineSelection -> $selectedText")
uiHandler.post { showDictDialog(selectedText) }
}
+
+ R.id.translateSelection -> {
+ Log.v(
+ LOG_TAG,
+ "-> onTextSelectionItemClicked -> translatedSelection -> $selectedText"
+ )
+ uiHandler.post { showTranslateFragment(selectedText) }
+ }
+
else -> {
Log.w(LOG_TAG, "-> onTextSelectionItemClicked -> unknown id = $id")
}
@@ -338,6 +396,20 @@ class FolioWebView : WebView {
dictionaryFragment.arguments = bundle
dictionaryFragment.show(parentFragment.fragmentManager, DictionaryFragment::class.java.name)
}
+ private fun showAddHighlightNoteDialog(selectedText: String?) {
+ val addHighlightNoteFragment = AddHighlightNoteFragment(selectedText)
+ val bundle = Bundle()
+ bundle.putString(Constants.SELECTED_WORD, selectedText)
+ addHighlightNoteFragment.arguments = bundle
+ addHighlightNoteFragment.show(parentFragment.fragmentManager, AddHighlightNoteFragment::class.java.name)
+ }
+ private fun showTranslateFragment(selectedText: String?) {
+ val translateFragment = TranslateFragment(selectedText)
+ val bundle = Bundle()
+ bundle.putString(Constants.SELECTED_WORD, selectedText)
+ translateFragment.arguments = bundle
+ translateFragment.show(parentFragment.fragmentManager, TranslateFragment::class.java.name)
+ }
private fun onHighlightColorItemsClicked(style: HighlightStyle, isAlreadyCreated: Boolean) {
parentFragment.highlight(style, isAlreadyCreated)
@@ -466,7 +538,7 @@ class FolioWebView : WebView {
fun fadeInSeekBarIfInvisible()
}
- private inner class TextSelectionCb : ActionMode.Callback {
+ private inner class TextSelectionCb : Callback {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
Log.d(LOG_TAG, "-> onCreateActionMode")
@@ -503,6 +575,7 @@ class FolioWebView : WebView {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
Log.d(LOG_TAG, "-> onCreateActionMode")
menu.clear()
+
return true
}
@@ -580,7 +653,8 @@ class FolioWebView : WebView {
if (Build.VERSION.SDK_INT < 23) {
val folioActivityRef: WeakReference = folioActivityCallback.activity
- val mWindowManagerField = ReflectionUtils.findField(FolioActivity::class.java, "mWindowManager")
+ val mWindowManagerField =
+ ReflectionUtils.findField(FolioActivity::class.java, "mWindowManager")
mWindowManagerField.isAccessible = true
val mWindowManager = mWindowManagerField.get(folioActivityRef.get())
@@ -596,7 +670,8 @@ class FolioWebView : WebView {
val config = AppUtil.getSavedConfig(context)!!
for (view in mViews) {
- val handleViewClass = Class.forName("com.android.org.chromium.content.browser.input.HandleView")
+ val handleViewClass =
+ Class.forName("com.android.org.chromium.content.browser.input.HandleView")
if (handleViewClass.isInstance(view)) {
val mDrawableField = ReflectionUtils.findField(handleViewClass, "mDrawable")
@@ -608,7 +683,8 @@ class FolioWebView : WebView {
} else {
val folioActivityRef: WeakReference = folioActivityCallback.activity
- val mWindowManagerField = ReflectionUtils.findField(FolioActivity::class.java, "mWindowManager")
+ val mWindowManagerField =
+ ReflectionUtils.findField(FolioActivity::class.java, "mWindowManager")
mWindowManagerField.isAccessible = true
val mWindowManager = mWindowManagerField.get(folioActivityRef.get())
@@ -624,19 +700,23 @@ class FolioWebView : WebView {
val config = AppUtil.getSavedConfig(context)!!
for (view in mViews) {
- val popupDecorViewClass = Class.forName("android.widget.PopupWindow\$PopupDecorView")
+ val popupDecorViewClass =
+ Class.forName("android.widget.PopupWindow\$PopupDecorView")
if (!popupDecorViewClass.isInstance(view))
continue
val mChildrenField = ReflectionUtils.findField(popupDecorViewClass, "mChildren")
mChildrenField.isAccessible = true
- val mChildren = mChildrenField.get(view) as kotlin.Array
+ val mChildren = mChildrenField.get(view) as Array
//val pathClassLoader = PathClassLoader("/system/app/Chrome/Chrome.apk", ClassLoader.getSystemClassLoader())
val pathClassLoader =
- PathClassLoader("/system/app/Chrome/Chrome.apk", folioActivityRef.get()?.classLoader)
+ PathClassLoader(
+ "/system/app/Chrome/Chrome.apk",
+ folioActivityRef.get()?.classLoader
+ )
val popupTouchHandleDrawableClass = Class.forName(
"org.chromium.android_webview.PopupTouchHandleDrawable",
@@ -646,7 +726,8 @@ class FolioWebView : WebView {
//if (!popupTouchHandleDrawableClass.isInstance(mChildren[0]))
// continue
- val mDrawableField = ReflectionUtils.findField(popupTouchHandleDrawableClass, "mDrawable")
+ val mDrawableField =
+ ReflectionUtils.findField(popupTouchHandleDrawableClass, "mDrawable")
mDrawableField.isAccessible = true
val mDrawable = mDrawableField.get(mChildren[0]) as Drawable
UiUtil.setColorIntToDrawable(config.themeColor, mDrawable)
diff --git a/folioreader/src/main/java/com/folioreader/util/UiUtil.java b/folioreader/src/main/java/com/folioreader/util/UiUtil.java
index 8bdb3cb80..fd79df3c8 100644
--- a/folioreader/src/main/java/com/folioreader/util/UiUtil.java
+++ b/folioreader/src/main/java/com/folioreader/util/UiUtil.java
@@ -117,14 +117,14 @@ public static void keepScreenAwake(boolean enable, Context context) {
public static void setBackColorToTextView(UnderlinedTextView textView, String type) {
Context context = textView.getContext();
- if (type.equals("highlight_yellow")) {
- setUnderLineColor(textView, context, R.color.highlight_yellow, R.color.highlight_yellow);
+ if (type.equals("highlight_orange")) {
+ setUnderLineColor(textView, context, R.color.highlight_orange, R.color.highlight_orange);
} else if (type.equals("highlight_green")) {
setUnderLineColor(textView, context, R.color.highlight_green, R.color.highlight_green);
} else if (type.equals("highlight_blue")) {
setUnderLineColor(textView, context, R.color.highlight_blue, R.color.highlight_blue);
- } else if (type.equals("highlight_pink")) {
- setUnderLineColor(textView, context, R.color.highlight_pink, R.color.highlight_pink);
+ } else if (type.equals("highlight_red")) {
+ setUnderLineColor(textView, context, R.color.highlight_red, R.color.highlight_red);
} else if (type.equals("highlight_underline")) {
setUnderLineColor(textView, context, android.R.color.transparent, android.R.color.holo_red_dark);
textView.setUnderlineWidth(2.0f);
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 0abc9e252..de4d7b224 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Sep 25 12:48:54 IST 2018
+#Fri Dec 06 11:43:53 ICT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
diff --git a/sample/build.gradle b/sample/build.gradle
index a89dc4bc6..ae1b0cf84 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -49,18 +49,18 @@ android {
}
dependencies {
- implementation fileTree(include: ['*.jar'], dir: 'libs')
- implementation "androidx.appcompat:appcompat:$versions.appcompat"
- implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
+ implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
- androidTestImplementation "androidx.test.ext:junit:1.0.0"
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
-
+ androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
+ implementation 'com.android.support:design:28.0.0'
implementation project(':folioreader')
- //implementation "com.folioreader:folioreader:$versions.folioreaderSdk"
- implementation "com.fasterxml.jackson.core:jackson-core:$versions.jackson"
- implementation "com.fasterxml.jackson.core:jackson-annotations:$versions.jackson"
- implementation "com.fasterxml.jackson.core:jackson-databind:$versions.jackson"
- implementation "com.fasterxml.jackson.module:jackson-module-kotlin:$versions.jackson"
+ implementation "com.fasterxml.jackson.core:jackson-core:2.9.7"
+ implementation "com.fasterxml.jackson.core:jackson-annotations:2.9.7"
+ implementation "com.fasterxml.jackson.core:jackson-databind:2.9.7"
+ implementation "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.7"
}
diff --git a/sample/src/main/assets/Testlink.epub b/sample/src/main/assets/Testlink.epub
new file mode 100644
index 000000000..76264c322
Binary files /dev/null and b/sample/src/main/assets/Testlink.epub differ
diff --git a/sample/src/main/assets/The Adventures Of Sherlock Holmes - Adventure I.epub b/sample/src/main/assets/The Adventures Of Sherlock Holmes - Adventure I.epub
new file mode 100644
index 000000000..177edc44e
Binary files /dev/null and b/sample/src/main/assets/The Adventures Of Sherlock Holmes - Adventure I.epub differ
diff --git a/sample/src/main/assets/WakeUp.epub b/sample/src/main/assets/WakeUp.epub
new file mode 100644
index 000000000..2316f06eb
Binary files /dev/null and b/sample/src/main/assets/WakeUp.epub differ
diff --git a/sample/src/main/java/com/folioreader/android/sample/HomeActivity.java b/sample/src/main/java/com/folioreader/android/sample/HomeActivity.java
index 25c63427d..de3aa1ccc 100644
--- a/sample/src/main/java/com/folioreader/android/sample/HomeActivity.java
+++ b/sample/src/main/java/com/folioreader/android/sample/HomeActivity.java
@@ -15,19 +15,27 @@
*/
package com.folioreader.android.sample;
+import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.Toast;
+
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.fragment.app.FragmentTransaction;
+
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.folioreader.Config;
import com.folioreader.FolioReader;
import com.folioreader.model.HighLight;
+import com.folioreader.model.HighlightImpl;
import com.folioreader.model.locators.ReadLocator;
import com.folioreader.ui.base.OnSaveHighlight;
+import com.folioreader.ui.fragment.HighlightFragment;
import com.folioreader.util.AppUtil;
import com.folioreader.util.OnHighlightListener;
import com.folioreader.util.ReadLocatorListener;
@@ -44,19 +52,26 @@ public class HomeActivity extends AppCompatActivity
private static final String LOG_TAG = HomeActivity.class.getSimpleName();
private FolioReader folioReader;
+ private ImageView dummyImageView;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
+
folioReader = FolioReader.get()
.setOnHighlightListener(this)
.setReadLocatorListener(this)
.setOnClosedListener(this);
getHighlightsAndSave();
+ findViewById(R.id.dummyImage).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ }
+ });
findViewById(R.id.btn_raw).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -67,31 +82,35 @@ public void onClick(View v) {
config.setAllowedDirection(Config.AllowedDirection.VERTICAL_AND_HORIZONTAL);
folioReader.setConfig(config, true)
- .openBook(R.raw.accessible_epub_3);
+ .openBook("/sdcard/Download/TTH.epub");
}
});
findViewById(R.id.btn_assest).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-
- ReadLocator readLocator = getLastReadLocator();
-
- Config config = AppUtil.getSavedConfig(getApplicationContext());
- if (config == null)
- config = new Config();
- config.setAllowedDirection(Config.AllowedDirection.VERTICAL_AND_HORIZONTAL);
-
- folioReader.setReadLocator(readLocator);
- folioReader.setConfig(config, true)
- .openBook("file:///android_asset/TheSilverChair.epub");
+ HighlightFragment highlightFragment = HighlightFragment.newInstance("_simple_book", "");
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.replace(R.id.test_layout, highlightFragment);
+ ft.commit();
+
+// ReadLocator readLocator = getLastReadLocator();
+//
+// Config config = AppUtil.getSavedConfig(getApplicationContext());
+// if (config == null)
+// config = new Config();
+// config.setAllowedDirection(Config.AllowedDirection.VERTICAL_AND_HORIZONTAL);
+//
+// folioReader.setReadLocator(readLocator);
+// folioReader.setConfig(config, true)
+// .openBook("/sdcard/Download/sa ch.epub");
}
});
}
private ReadLocator getLastReadLocator() {
- String jsonString = loadAssetTextAsString("Locators/LastReadLocators/last_read_locator_1.json");
+ String jsonString = loadAssetTextAsString("LastReadLocators/last_read_locator_1.json");
return ReadLocator.fromJson(jsonString);
}
@@ -179,4 +198,8 @@ public void onHighlight(HighLight highlight, HighLight.HighLightAction type) {
public void onFolioReaderClosed() {
Log.v(LOG_TAG, "-> onFolioReaderClosed");
}
+
+ public void dummyMethod() {
+ return;
+ }
}
\ No newline at end of file
diff --git a/sample/src/main/java/com/folioreader/android/sample/TestFragment.java b/sample/src/main/java/com/folioreader/android/sample/TestFragment.java
new file mode 100644
index 000000000..d764d20b2
--- /dev/null
+++ b/sample/src/main/java/com/folioreader/android/sample/TestFragment.java
@@ -0,0 +1,35 @@
+package com.folioreader.android.sample;
+
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+
+import androidx.fragment.app.Fragment;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+public class TestFragment extends Fragment {
+
+ public TestFragment() {
+ // Required empty public constructor
+ }
+
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ return inflater.inflate(R.layout.fragment_blank, container, false);
+ }
+
+
+
+}
diff --git a/sample/src/main/res/layout/activity_home.xml b/sample/src/main/res/layout/activity_home.xml
index 4ca27fa06..3e42c5347 100644
--- a/sample/src/main/res/layout/activity_home.xml
+++ b/sample/src/main/res/layout/activity_home.xml
@@ -1,4 +1,6 @@
@@ -22,4 +24,23 @@
android:layout_marginRight="10dp"
android:text="Open epub assests" />
+
+
+
+
+
+
+
diff --git a/sample/src/main/res/layout/fragment_blank.xml b/sample/src/main/res/layout/fragment_blank.xml
new file mode 100644
index 000000000..4cd85ae01
--- /dev/null
+++ b/sample/src/main/res/layout/fragment_blank.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
index 69b22338c..0bc580b7a 100644
--- a/sample/src/main/res/values/colors.xml
+++ b/sample/src/main/res/values/colors.xml
@@ -1,6 +1,6 @@
- #008577
+ #03a4f9
#00574B
#D81B60
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index 33b4d002b..26264104d 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -1,3 +1,6 @@
FolioReader Sample
+
+
+ Hello blank fragment
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
index 5885930df..87323a24a 100644
--- a/sample/src/main/res/values/styles.xml
+++ b/sample/src/main/res/values/styles.xml
@@ -3,7 +3,7 @@
diff --git a/versions.gradle b/versions.gradle
index 8c420eed1..335d4c40b 100644
--- a/versions.gradle
+++ b/versions.gradle
@@ -1,6 +1,6 @@
def versions = [:]
-versions.folioreaderSdk = "0.5.4"
+versions.folioreaderSdk = "0.5.4-1"
versions.r2SharedKotlin = "1.0.4-2"
versions.r2StreamerKotlin = "1.0.4-2"
@@ -11,7 +11,7 @@ versions.androidMinSdk = 21
versions.androidCompileSdk = 28
versions.androidTargetSdk = 28
-versions.androidGradlePlugin = "3.2.1"
+versions.androidGradlePlugin = '3.5.2'
versions.kotlin = "1.3.11"
versions.appcompat = "1.0.2"
|