diff --git a/build.gradle b/build.gradle index 334072821..368aa997d 100644 --- a/build.gradle +++ b/build.gradle @@ -14,9 +14,10 @@ buildscript { url 'https://maven.google.com/' name 'Google' } + google() } dependencies { - classpath 'com.android.tools.build:gradle:3.1.2' + 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:2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$KOTLIN_VERSION" diff --git a/folioreader/res/values-ja/strings.xml b/folioreader/res/values-ja/strings.xml new file mode 100644 index 000000000..6925e991d --- /dev/null +++ b/folioreader/res/values-ja/strings.xml @@ -0,0 +1,34 @@ + + + folioreader + 共有 + コピー + 送信先: + コピーしました + 1分未満 ·  + %1$d 分 ·  + %1$d 分 ·  + ハイライト + 定義 + ハイライト + スタイル + キャンセル + 読み込み中 + しばらくお待ちください + 編集 + 保存 + 入力してください + 目次 + 辞書 + epubを開くことができません。ストレージアクセスが必要です ! + 残り %1$d ページ + 残り %1$d ページ + フォントの変更e + フォント色 + スタイルの変更 + スタイルを変更できません! + Ok + 上部パネルサイズ: + 2つの言語を選択する: + このフィルは開けません。 + \ No newline at end of file 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 0ae3da5f8..a49008683 100644 --- a/folioreader/res/values/strings.xml +++ b/folioreader/res/values/strings.xml @@ -93,4 +93,5 @@ 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 07d57f19d..ae5b7c997 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 @@ -59,6 +59,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; @@ -131,7 +134,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(); + } } toolbar = findViewById(R.id.toolbar); @@ -153,27 +159,52 @@ public void startContentHighlightActivity() { overridePendingTransition(R.anim.slide_in_up, R.anim.slide_out_up); } - 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() { @@ -369,15 +400,22 @@ 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) { + Log.v(TAG, "setConfig >>"); + + Bundle args = getIntent().getExtras(); + Log.v(TAG, "setConfig args = " + args.toString()); + + 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); } + Log.v(TAG, "setConfig <<"); } @Override @@ -394,9 +432,29 @@ public void pause() { public void onError() { } - 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