diff --git a/assets/resources/application/be.xml b/assets/resources/application/be.xml index 674aaee7a..13de0fc1e 100644 --- a/assets/resources/application/be.xml +++ b/assets/resources/application/be.xml @@ -859,6 +859,15 @@ + + + + + + + + + @@ -896,16 +905,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/bg.xml b/assets/resources/application/bg.xml index 7215d90e6..30710712d 100644 --- a/assets/resources/application/bg.xml +++ b/assets/resources/application/bg.xml @@ -858,6 +858,15 @@ + + + + + + + + + @@ -895,16 +904,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/ca.xml b/assets/resources/application/ca.xml index 3b7fe26d4..8809e0f35 100644 --- a/assets/resources/application/ca.xml +++ b/assets/resources/application/ca.xml @@ -312,16 +312,13 @@ - - - + + + - - - @@ -580,13 +577,6 @@ - - - - - - - @@ -884,89 +874,19 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + @@ -1010,17 +930,35 @@ - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/resources/application/cs.xml b/assets/resources/application/cs.xml index b85687d9b..33f6ed900 100644 --- a/assets/resources/application/cs.xml +++ b/assets/resources/application/cs.xml @@ -862,6 +862,15 @@ + + + + + + + + + @@ -899,16 +908,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/da.xml b/assets/resources/application/da.xml index d4a557129..10a045b4a 100644 --- a/assets/resources/application/da.xml +++ b/assets/resources/application/da.xml @@ -871,7 +871,19 @@ + + + + + + + + + + + + @@ -915,18 +927,8 @@ - - - - - - - - - - - + @@ -956,10 +958,4 @@ - - - - - - diff --git a/assets/resources/application/de.xml b/assets/resources/application/de.xml index 85c2e246d..da5b01038 100644 --- a/assets/resources/application/de.xml +++ b/assets/resources/application/de.xml @@ -855,6 +855,15 @@ + + + + + + + + + @@ -892,16 +901,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/el.xml b/assets/resources/application/el.xml index 6766ff09b..e87afab75 100644 --- a/assets/resources/application/el.xml +++ b/assets/resources/application/el.xml @@ -851,6 +851,15 @@ + + + + + + + + + @@ -888,16 +897,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/en.xml b/assets/resources/application/en.xml index aa4aec16a..a854f439c 100644 --- a/assets/resources/application/en.xml +++ b/assets/resources/application/en.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/es.xml b/assets/resources/application/es.xml index 6602cf515..9625e5592 100644 --- a/assets/resources/application/es.xml +++ b/assets/resources/application/es.xml @@ -858,6 +858,15 @@ + + + + + + + + + @@ -895,16 +904,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/eu.xml b/assets/resources/application/eu.xml index f4d358ea1..07cf1d324 100644 --- a/assets/resources/application/eu.xml +++ b/assets/resources/application/eu.xml @@ -49,8 +49,8 @@ - - + + @@ -306,17 +306,17 @@ + + + - - - - + @@ -350,7 +350,7 @@ - + @@ -585,7 +585,7 @@ - + @@ -745,13 +745,13 @@ - - - - - - - + + + + + + + @@ -788,8 +788,8 @@ - - + + @@ -873,6 +873,15 @@ + + + + + + + + + @@ -881,7 +890,7 @@ - + @@ -916,16 +925,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/fa.xml b/assets/resources/application/fa.xml index abfbd285f..5785214e9 100644 --- a/assets/resources/application/fa.xml +++ b/assets/resources/application/fa.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/fr.xml b/assets/resources/application/fr.xml index dc9060b27..4b3ca6874 100644 --- a/assets/resources/application/fr.xml +++ b/assets/resources/application/fr.xml @@ -846,6 +846,15 @@ + + + + + + + + + @@ -883,16 +892,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/gl.xml b/assets/resources/application/gl.xml index 521c346f0..b63c26959 100644 --- a/assets/resources/application/gl.xml +++ b/assets/resources/application/gl.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/hu.xml b/assets/resources/application/hu.xml index c2bb64d13..b13cc9b9b 100644 --- a/assets/resources/application/hu.xml +++ b/assets/resources/application/hu.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/hy.xml b/assets/resources/application/hy.xml index 48dfb08ec..8c7d0888a 100644 --- a/assets/resources/application/hy.xml +++ b/assets/resources/application/hy.xml @@ -858,6 +858,15 @@ + + + + + + + + + @@ -895,16 +904,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/it.xml b/assets/resources/application/it.xml index 3bfa3d82a..310b9e13a 100644 --- a/assets/resources/application/it.xml +++ b/assets/resources/application/it.xml @@ -844,6 +844,15 @@ + + + + + + + + + @@ -881,16 +890,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/ka.xml b/assets/resources/application/ka.xml index 121c4ab60..90fc49e77 100644 --- a/assets/resources/application/ka.xml +++ b/assets/resources/application/ka.xml @@ -858,6 +858,15 @@ + + + + + + + + + @@ -895,16 +904,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/nb.xml b/assets/resources/application/nb.xml index 37eb2a70c..41bfaa4da 100644 --- a/assets/resources/application/nb.xml +++ b/assets/resources/application/nb.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/nl.xml b/assets/resources/application/nl.xml index 273ca4c74..ad3683518 100644 --- a/assets/resources/application/nl.xml +++ b/assets/resources/application/nl.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/pl.xml b/assets/resources/application/pl.xml index 0565cf974..880070e2f 100644 --- a/assets/resources/application/pl.xml +++ b/assets/resources/application/pl.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/pt.xml b/assets/resources/application/pt.xml index 5cac59526..030e1ae6c 100644 --- a/assets/resources/application/pt.xml +++ b/assets/resources/application/pt.xml @@ -855,6 +855,15 @@ + + + + + + + + + @@ -892,16 +901,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/ro.xml b/assets/resources/application/ro.xml index 31831d8cf..0ab196ffa 100644 --- a/assets/resources/application/ro.xml +++ b/assets/resources/application/ro.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/ru.xml b/assets/resources/application/ru.xml index b30d61b03..ced6d427c 100644 --- a/assets/resources/application/ru.xml +++ b/assets/resources/application/ru.xml @@ -858,6 +858,15 @@ + + + + + + + + + @@ -895,16 +904,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/sr.xml b/assets/resources/application/sr.xml index 9f65be947..55ed2431a 100644 --- a/assets/resources/application/sr.xml +++ b/assets/resources/application/sr.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/th.xml b/assets/resources/application/th.xml index a3f6d1ee4..0c2835f66 100644 --- a/assets/resources/application/th.xml +++ b/assets/resources/application/th.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/tr.xml b/assets/resources/application/tr.xml index 5037634f5..21080ebfb 100644 --- a/assets/resources/application/tr.xml +++ b/assets/resources/application/tr.xml @@ -853,6 +853,15 @@ + + + + + + + + + @@ -890,16 +899,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/uk.xml b/assets/resources/application/uk.xml index 31b78cdfa..ecd951c09 100644 --- a/assets/resources/application/uk.xml +++ b/assets/resources/application/uk.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/vi.xml b/assets/resources/application/vi.xml index 4aba986f9..daab72bcc 100644 --- a/assets/resources/application/vi.xml +++ b/assets/resources/application/vi.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/zh.xml b/assets/resources/application/zh.xml index 5c6d76261..fdf2e23f5 100644 --- a/assets/resources/application/zh.xml +++ b/assets/resources/application/zh.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/assets/resources/application/zh_TW.xml b/assets/resources/application/zh_TW.xml index d98cd0222..ed9a8460c 100644 --- a/assets/resources/application/zh_TW.xml +++ b/assets/resources/application/zh_TW.xml @@ -843,6 +843,15 @@ + + + + + + + + + @@ -880,16 +889,6 @@ - - - - - - - - - - diff --git a/build.xml b/build.xml index 56b2b5e2f..feeb14367 100644 --- a/build.xml +++ b/build.xml @@ -46,8 +46,8 @@ - - + + diff --git a/jni/Android.mk b/jni/Android.mk index 5c0719fb4..bb7f58b2a 100644 --- a/jni/Android.mk +++ b/jni/Android.mk @@ -29,7 +29,7 @@ include $(BUILD_STATIC_LIBRARY) include $(CLEAR_VARS) -LOCAL_MODULE := NativeFormats-v3 +LOCAL_MODULE := NativeFormats-v4 LOCAL_CFLAGS := -Wall LOCAL_LDLIBS := -lz -llog LOCAL_STATIC_LIBRARIES := expat diff --git a/jni/NativeFormats/JavaNativeFormatPlugin.cpp b/jni/NativeFormats/JavaNativeFormatPlugin.cpp index 83558f393..b7fb3915d 100644 --- a/jni/NativeFormats/JavaNativeFormatPlugin.cpp +++ b/jni/NativeFormats/JavaNativeFormatPlugin.cpp @@ -114,20 +114,20 @@ static void fillLanguageAndEncoding(JNIEnv* env, jobject javaBook, Book &book) { } extern "C" -JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readMetaInfoNative(JNIEnv* env, jobject thiz, jobject javaBook) { +JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readMetaInfoNative(JNIEnv* env, jobject thiz, jobject javaBook) { shared_ptr plugin = findCppPlugin(thiz); if (plugin.isNull()) { - return JNI_FALSE; + return 1; } shared_ptr book = Book::loadFromJavaBook(env, javaBook); if (!plugin->readMetaInfo(*book)) { - return JNI_FALSE; + return 2; } fillMetaInfo(env, javaBook, *book); - return JNI_TRUE; + return 0; } extern "C" @@ -252,10 +252,10 @@ static void initTOC(JNIEnv *env, jobject javaModel, const ContentsTree &tree) { } extern "C" -JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readModelNative(JNIEnv* env, jobject thiz, jobject javaModel) { +JNIEXPORT jint JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPlugin_readModelNative(JNIEnv* env, jobject thiz, jobject javaModel) { shared_ptr plugin = findCppPlugin(thiz); if (plugin.isNull()) { - return JNI_FALSE; + return 1; } jobject javaBook = AndroidUtil::Field_NativeBookModel_Book->value(javaModel); @@ -263,15 +263,15 @@ JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPl shared_ptr book = Book::loadFromJavaBook(env, javaBook); shared_ptr model = new BookModel(book, javaModel); if (!plugin->readModel(*model)) { - return JNI_FALSE; + return 2; } if (!model->flush()) { AndroidUtil::throwCachedCharStorageException("Cannot write file from native code"); - return JNI_FALSE; + return 3; } if (!initInternalHyperlinks(env, javaModel, *model)) { - return JNI_FALSE; + return 4; } initTOC(env, javaModel, *model->contentsTree()); @@ -279,11 +279,11 @@ JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPl shared_ptr textModel = model->bookTextModel(); jobject javaTextModel = createTextModel(env, javaModel, *textModel); if (javaTextModel == 0) { - return JNI_FALSE; + return 5; } AndroidUtil::Method_NativeBookModel_setBookTextModel->call(javaModel, javaTextModel); if (env->ExceptionCheck()) { - return JNI_FALSE; + return 6; } env->DeleteLocalRef(javaTextModel); @@ -292,15 +292,15 @@ JNIEXPORT jboolean JNICALL Java_org_geometerplus_fbreader_formats_NativeFormatPl for (; it != footnotes.end(); ++it) { jobject javaFootnoteModel = createTextModel(env, javaModel, *it->second); if (javaFootnoteModel == 0) { - return JNI_FALSE; + return 7; } AndroidUtil::Method_NativeBookModel_setFootnoteModel->call(javaModel, javaFootnoteModel); if (env->ExceptionCheck()) { - return JNI_FALSE; + return 8; } env->DeleteLocalRef(javaFootnoteModel); } - return JNI_TRUE; + return 0; } extern "C" diff --git a/src/org/geometerplus/android/fbreader/FBReader.java b/src/org/geometerplus/android/fbreader/FBReader.java index 96a8f86a7..7ba0b6fe9 100644 --- a/src/org/geometerplus/android/fbreader/FBReader.java +++ b/src/org/geometerplus/android/fbreader/FBReader.java @@ -140,6 +140,16 @@ public final class FBReader extends Activity implements ZLApplicationWindow { myBook = createBookForFile(ZLFile.createFileByPath(data.getPath())); } } + if (myBook != null) { + ZLFile file = myBook.File; + if (!file.exists()) { + if (file.getPhysicalFile() != null) { + file = file.getPhysicalFile(); + } + UIUtil.showErrorMessage(this, "fileNotFound", file.getPath()); + myBook = null; + } + } Config.Instance().runOnStart(new Runnable() { public void run() { myFBReaderApp.openBook(myBook, bookmark, action); diff --git a/src/org/geometerplus/android/util/UIUtil.java b/src/org/geometerplus/android/util/UIUtil.java index 9b8d87097..dced7dd0b 100644 --- a/src/org/geometerplus/android/util/UIUtil.java +++ b/src/org/geometerplus/android/util/UIUtil.java @@ -140,20 +140,24 @@ public abstract class UIUtil { }); } - public static void showMessageText(Context context, String text) { - Toast.makeText(context, text, Toast.LENGTH_SHORT).show(); + public static void showMessageText(final Activity activity, final String text) { + activity.runOnUiThread(new Runnable() { + public void run() { + Toast.makeText(activity, text, Toast.LENGTH_SHORT).show(); + } + }); } - public static void showErrorMessage(Context context, String resourceKey) { + public static void showErrorMessage(Activity activity, String resourceKey) { showMessageText( - context, + activity, ZLResource.resource("errorMessage").getResource(resourceKey).getValue() ); } - public static void showErrorMessage(Context context, String resourceKey, String parameter) { + public static void showErrorMessage(Activity activity, String resourceKey, String parameter) { showMessageText( - context, + activity, ZLResource.resource("errorMessage").getResource(resourceKey).getValue().replace("%s", parameter) ); } diff --git a/src/org/geometerplus/fbreader/bookmodel/BookModel.java b/src/org/geometerplus/fbreader/bookmodel/BookModel.java index 58ef81d5d..f5ad7213c 100644 --- a/src/org/geometerplus/fbreader/bookmodel/BookModel.java +++ b/src/org/geometerplus/fbreader/bookmodel/BookModel.java @@ -41,7 +41,9 @@ public abstract class BookModel { model = new JavaBookModel(book); break; default: - throw new BookReadingException("unknownPluginType", plugin.type().toString(), null); + throw new BookReadingException( + "unknownPluginType", null, new String[] { plugin.type().toString() } + ); } plugin.readModel(model); diff --git a/src/org/geometerplus/fbreader/bookmodel/BookReadingException.java b/src/org/geometerplus/fbreader/bookmodel/BookReadingException.java index 36f9b4909..8a93d172b 100644 --- a/src/org/geometerplus/fbreader/bookmodel/BookReadingException.java +++ b/src/org/geometerplus/fbreader/bookmodel/BookReadingException.java @@ -31,26 +31,30 @@ public final class BookReadingException extends Exception { throw new BookReadingException(resourceId, file); } - private static String getResourceText(String resourceId) { - return ZLResource.resource("bookReadingException").getResource(resourceId).getValue(); + private static String getResourceText(String resourceId, String ... params) { + String message = ZLResource.resource("errorMessage").getResource(resourceId).getValue(); + for (String p : params) { + message = message.replaceFirst("%s", p); + } + return message; } public final ZLFile File; - public BookReadingException(String resourceId, String param, ZLFile file) { - super(getResourceText(resourceId).replace("%s", param)); + public BookReadingException(String resourceId, ZLFile file, String[] params) { + super(getResourceText(resourceId, params)); File = file; } public BookReadingException(String resourceId, ZLFile file) { - super(getResourceText(resourceId).replace("%s", file.getPath())); - File = file; + this(resourceId, file, new String[] { file.getPath() }); } public BookReadingException(IOException e, ZLFile file) { super(getResourceText( - e instanceof ZipException ? "errorReadingZip" : "errorReadingFile" - ).replace("%s", file.getPath()), e); + e instanceof ZipException ? "errorReadingZip" : "errorReadingFile", + file.getPath() + ), e); File = file; } } diff --git a/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java b/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java index a38f2d328..693dee6c8 100644 --- a/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java +++ b/src/org/geometerplus/fbreader/fbreader/FBReaderApp.java @@ -218,7 +218,7 @@ public final class FBReaderApp extends ZLApplication { } } - synchronized void openBookInternal(Book book, Bookmark bookmark, boolean force) { + private synchronized void openBookInternal(Book book, Bookmark bookmark, boolean force) { if (book == null) { book = Collection.getRecentBook(0); if (book == null || !book.File.exists()) { diff --git a/src/org/geometerplus/fbreader/formats/NativeFormatPlugin.java b/src/org/geometerplus/fbreader/formats/NativeFormatPlugin.java index af5367ef2..de778c9cc 100644 --- a/src/org/geometerplus/fbreader/formats/NativeFormatPlugin.java +++ b/src/org/geometerplus/fbreader/formats/NativeFormatPlugin.java @@ -48,12 +48,17 @@ public class NativeFormatPlugin extends FormatPlugin { @Override synchronized public void readMetaInfo(Book book) throws BookReadingException { - if (!readMetaInfoNative(book)) { - throw new BookReadingException("errorReadingFile", book.File); + final int code = readMetaInfoNative(book); + if (code != 0) { + throw new BookReadingException( + "nativeCodeFailure", + book.File, + new String[] { String.valueOf(code), book.File.getPath() } + ); } } - private native boolean readMetaInfoNative(Book book); + private native int readMetaInfoNative(Book book); synchronized public void readUids(Book book) throws BookReadingException { readUidsNative(book); @@ -73,12 +78,17 @@ public class NativeFormatPlugin extends FormatPlugin { @Override synchronized public void readModel(BookModel model) throws BookReadingException { - if (!readModelNative(model)) { - throw new BookReadingException("errorReadingFile", model.Book.File); + final int code = readModelNative(model); + if (code != 0) { + throw new BookReadingException( + "nativeCodeFailure", + model.Book.File, + new String[] { String.valueOf(code), model.Book.File.getPath() } + ); } } - private native boolean readModelNative(BookModel model); + private native int readModelNative(BookModel model); @Override public ZLImage readCover(final ZLFile file) { diff --git a/src/org/geometerplus/fbreader/formats/PluginCollection.java b/src/org/geometerplus/fbreader/formats/PluginCollection.java index 2094ccaee..25177c9e6 100644 --- a/src/org/geometerplus/fbreader/formats/PluginCollection.java +++ b/src/org/geometerplus/fbreader/formats/PluginCollection.java @@ -30,7 +30,7 @@ import org.geometerplus.fbreader.formats.pdb.MobipocketPlugin; public class PluginCollection { static { - System.loadLibrary("NativeFormats-v3"); + System.loadLibrary("NativeFormats-v4"); } private static PluginCollection ourInstance;