diff --git a/build.gradle b/build.gradle
index 6e82884da..38614e812 100644
--- a/build.gradle
+++ b/build.gradle
@@ -8,9 +8,10 @@ buildscript {
url 'https://maven.google.com/'
name 'Google'
}
+ google()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.0'
+ classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
}
diff --git a/folioreader/build.gradle b/folioreader/build.gradle
index b33e4108e..aa6b422a1 100644
--- a/folioreader/build.gradle
+++ b/folioreader/build.gradle
@@ -28,8 +28,8 @@ ext {
android {
useLibrary 'org.apache.http.legacy'
- compileSdkVersion 26
- buildToolsVersion "26.0.2"
+ compileSdkVersion 27
+ buildToolsVersion '27.0.3'
defaultConfig {
versionCode 1
@@ -82,7 +82,7 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':webViewMarker')
- final ANDROID_LIB_VERSION = '26.0.2'
+ final ANDROID_LIB_VERSION = '27.+'
//noinspection GradleDependency
compile "com.android.support:appcompat-v7:$ANDROID_LIB_VERSION"
diff --git a/folioreader/res/values-pt-rBR/strings.xml b/folioreader/res/values-pt-rBR/strings.xml
index 47524d529..93a0f2f0d 100644
--- a/folioreader/res/values-pt-rBR/strings.xml
+++ b/folioreader/res/values-pt-rBR/strings.xml
@@ -30,4 +30,5 @@
Ok
Painel superior
Escolha 2 linguagens
+ Can\'t open file
\ No newline at end of file
diff --git a/folioreader/res/values-ru/strings.xml b/folioreader/res/values-ru/strings.xml
index 764d690c2..79097c4be 100644
--- a/folioreader/res/values-ru/strings.xml
+++ b/folioreader/res/values-ru/strings.xml
@@ -41,5 +41,6 @@
Сохранить заметку
пожалуйста введите заметку
Содержание
+ Can\'t open file
diff --git a/folioreader/res/values/strings.xml b/folioreader/res/values/strings.xml
index c9867a1bd..a49008683 100644
--- a/folioreader/res/values/strings.xml
+++ b/folioreader/res/values/strings.xml
@@ -91,4 +91,7 @@
Dictionary
Wikipedia
Cannot open epub it needs storage access !
+ horizontal
+ vertical
+ Can\'t open file
diff --git a/folioreader/src/main/java/com/folioreader/ui/folio/activity/FolioActivity.java b/folioreader/src/main/java/com/folioreader/ui/folio/activity/FolioActivity.java
index ba2ebf385..b5824f5f9 100644
--- a/folioreader/src/main/java/com/folioreader/ui/folio/activity/FolioActivity.java
+++ b/folioreader/src/main/java/com/folioreader/ui/folio/activity/FolioActivity.java
@@ -58,7 +58,6 @@
import com.folioreader.ui.folio.presenter.MainPresenter;
import com.folioreader.util.AppUtil;
import com.folioreader.util.FileUtil;
-
import com.folioreader.util.UiUtil;
import com.folioreader.view.ConfigBottomSheetDialogFragment;
import com.folioreader.view.DirectionalViewpager;
@@ -74,6 +73,9 @@
import org.readium.r2_streamer.server.EpubServerSingleton;
import java.io.IOException;
+import java.net.URLEncoder;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
@@ -162,7 +164,10 @@ protected void onCreate(Bundle savedInstanceState) {
if (ContextCompat.checkSelfPermission(FolioActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(FolioActivity.this, Constants.getWriteExternalStoragePerms(), Constants.WRITE_EXTERNAL_STORAGE_REQUEST);
} else {
- setupBook();
+ if(setupBook() == false){
+ Toast.makeText(this, R.string.cant_open_file, Toast.LENGTH_LONG);
+ finish();
+ }
}
initAudioView();
@@ -205,27 +210,52 @@ public void onClick(View v) {
}
}
- private void initBook(String mEpubFileName, int mEpubRawId, String mEpubFilePath, EpubSourceType mEpubSourceType) {
+ private Boolean initBook(String mEpubFileName, int mEpubRawId, String mEpubFilePath, EpubSourceType mEpubSourceType) {
+ Log.v(TAG, "initBook >>");
+ Boolean result = false;
try {
int portNumber = getIntent().getIntExtra(Config.INTENT_PORT, Constants.PORT_NUMBER);
mEpubServer = EpubServerSingleton.getEpubServerInstance(portNumber);
mEpubServer.start();
String path = FileUtil.saveEpubFileAndLoadLazyBook(FolioActivity.this, mEpubSourceType, mEpubFilePath,
mEpubRawId, mEpubFileName);
- addEpub(path);
- String urlString = Constants.LOCALHOST + bookFileName + "/manifest";
- new MainPresenter(this).parseManifest(urlString);
+ if(addEpub(path)){
+ String urlString = Constants.LOCALHOST + URLEncoder.encode(bookFileName, "UTF-8") + "/manifest";
+ Log.v(TAG, "initBook urlString = " + urlString);
+ new MainPresenter(this).parseManifest(urlString);
+
+ result = true;
+ }
} catch (IOException e) {
Log.e(TAG, "initBook failed", e);
}
+ Log.v(TAG, "initBook <<");
+
+ return result;
}
- private void addEpub(String path) throws IOException {
+ private Boolean addEpub(String path) throws IOException {
+ Log.v(TAG, "addEpub >>");
+ Log.v(TAG, "addEpub path = " + path);
+ Log.v(TAG, "addEpub bookFileName = " + bookFileName);
+
+ Boolean result = true;
+
Container epubContainer = new EpubContainer(path);
- mEpubServer.addEpub(epubContainer, "/" + bookFileName);
+ try{
+ mEpubServer.addEpub(epubContainer, "/" + URLEncoder.encode(bookFileName));
+ }
+ catch(Exception ex){
+ Log.e(TAG, "addEpub error = " + ex.getMessage());
+ result = false;
+ }
getEpubResource();
+
+ Log.v(TAG, "addEpub <<");
+
+ return result;
}
private void getEpubResource() {
@@ -488,11 +518,12 @@ public void onLoadPublication(EpubPublication publication) {
}
private void setConfig() {
- if (AppUtil.getSavedConfig(this) != null) {
- mConfig = AppUtil.getSavedConfig(this);
- } else if (getIntent().getParcelableExtra(Config.INTENT_CONFIG) != null) {
+ if (getIntent().getParcelableExtra(Config.INTENT_CONFIG) != null) {
mConfig = getIntent().getParcelableExtra(Config.INTENT_CONFIG);
AppUtil.saveConfig(this, mConfig);
+ Log.v(TAG, "setConfig (2) isShowTts = " + mConfig.isShowTts());
+ } else if (AppUtil.getSavedConfig(this) != null) {
+ mConfig = AppUtil.getSavedConfig(this);
} else {
mConfig = new Config.ConfigBuilder().build();
AppUtil.saveConfig(this, mConfig);
@@ -673,9 +704,29 @@ public void initColors() {
UiUtil.setColorToImage(this, mConfig.getThemeColor(), ((ImageView) findViewById(R.id.btn_speaker)).getDrawable());
}
- private void setupBook() {
- bookFileName = FileUtil.getEpubFilename(this, mEpubSourceType, mEpubFilePath, mEpubRawId);
- initBook(bookFileName, mEpubRawId, mEpubFilePath, mEpubSourceType);
+ public String md5(String s) {
+ try {
+ // Create MD5 Hash
+ MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
+ digest.update(s.getBytes());
+ byte messageDigest[] = digest.digest();
+
+ // Create Hex String
+ StringBuffer hexString = new StringBuffer();
+ for (int i=0; i