mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 10:19:33 +02:00
archive processing has been fixed
This commit is contained in:
parent
a6c3270553
commit
95849ddc7f
19 changed files with 47 additions and 63 deletions
|
@ -8,5 +8,5 @@ VR:
|
|||
NP:
|
||||
DONE Локализовать все сообщения
|
||||
* Отдельная иконка для архивов
|
||||
* Архивы в архивах
|
||||
DONE Архивы в архивах
|
||||
* filesystem: return special result (exception?) if directory is not readable
|
||||
|
|
|
@ -19,6 +19,6 @@ DONE Highlight current book
|
|||
* Bug: search with no results clears search results subtree; should not
|
||||
* garbage in Boris Akunin, Сказки для идиотов
|
||||
* duplicate tags in the same book
|
||||
* Bug: b1.zip (paths in zips?)
|
||||
* Bug: b1.zip, archive inside archive
|
||||
DONE Bug: b1.zip (paths in zips?)
|
||||
DONE Bug: b1.zip, archive inside archive
|
||||
* Open the help file if the current book is deleted from library
|
||||
|
|
|
@ -60,7 +60,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
|||
|
||||
private void migrate(Context context) {
|
||||
final int version = myDatabase.getVersion();
|
||||
final int currentVersion = 11;
|
||||
final int currentVersion = 12;
|
||||
if (version >= currentVersion) {
|
||||
return;
|
||||
}
|
||||
|
@ -91,6 +91,8 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
|||
updateTables9();
|
||||
case 10:
|
||||
updateTables10();
|
||||
case 11:
|
||||
updateTables11();
|
||||
}
|
||||
myDatabase.setTransactionSuccessful();
|
||||
myDatabase.endTransaction();
|
||||
|
@ -568,7 +570,7 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
|||
final String[] parameters = { null };
|
||||
FileInfo current = null;
|
||||
for (ZLFile f : fileStack) {
|
||||
parameters[0] = f.getName(false);
|
||||
parameters[0] = f.getLongName();
|
||||
final Cursor cursor = myDatabase.rawQuery(
|
||||
(current == null) ?
|
||||
"SELECT file_id,size FROM Files WHERE name = ?" :
|
||||
|
@ -1113,4 +1115,8 @@ public final class SQLiteBooksDatabase extends BooksDatabase {
|
|||
"CREATE TABLE IF NOT EXISTS Favorites(" +
|
||||
"book_id INTEGER UNIQUE NOT NULL REFERENCES Books(book_id))");
|
||||
}
|
||||
|
||||
private void updateTables11() {
|
||||
myDatabase.execSQL("UPDATE Files SET size = size + 1");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,13 +46,7 @@ class ShowBookInfoAction extends FBAction {
|
|||
final BookModel model = Reader.Model;
|
||||
if (model != null && model.Book != null) {
|
||||
final ZLFile file = model.Book.File;
|
||||
final ZLFile physicalFile = file.getPhysicalFile();
|
||||
if (physicalFile == null || physicalFile == file) {
|
||||
intent.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, file.getPath());
|
||||
} else {
|
||||
intent.putExtra(BookInfoActivity.CURRENT_BOOK_PATH_KEY, physicalFile.getPath());
|
||||
intent.putExtra(BookInfoActivity.CURRENT_BOOK_ARCHIVE_ENTRY_KEY, file.getName(false));
|
||||
}
|
||||
}
|
||||
myBaseActivity.startActivityForResult(
|
||||
intent, FBReader.REPAINT_CODE
|
||||
|
|
|
@ -221,9 +221,8 @@ public final class FileManager extends BaseActivity {
|
|||
if (children.size() == 1) {
|
||||
final ZLFile child = children.get(0);
|
||||
if (child.getPath().endsWith(".fb2")) {
|
||||
final String fileName = file.getName(false);
|
||||
myFile = child;
|
||||
myName = fileName.substring(fileName.lastIndexOf('/') + 1);
|
||||
myName = file.getLongName();
|
||||
mySummary = null;
|
||||
return;
|
||||
}
|
||||
|
@ -235,12 +234,7 @@ public final class FileManager extends BaseActivity {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
if (myName != null) {
|
||||
return myName;
|
||||
}
|
||||
|
||||
final String fileName = myFile.getName(false);
|
||||
return fileName.substring(fileName.lastIndexOf('/') + 1);
|
||||
return myName != null ? myName : myFile.getLongName();
|
||||
}
|
||||
|
||||
public String getSummary() {
|
||||
|
|
|
@ -85,7 +85,6 @@ class LanguagePreference extends ZLStringListPreference {
|
|||
|
||||
public class BookInfoActivity extends ZLPreferenceActivity {
|
||||
public static final String CURRENT_BOOK_PATH_KEY = "CurrentBookPath";
|
||||
public static final String CURRENT_BOOK_ARCHIVE_ENTRY_KEY = "CurrentArchiveEntryPath";
|
||||
|
||||
private Book myBook;
|
||||
|
||||
|
@ -100,11 +99,7 @@ public class BookInfoActivity extends ZLPreferenceActivity {
|
|||
}
|
||||
|
||||
final String path = intent.getStringExtra(CURRENT_BOOK_PATH_KEY);
|
||||
final String archiveEntry = intent.getStringExtra(CURRENT_BOOK_ARCHIVE_ENTRY_KEY);
|
||||
ZLFile file = ZLFile.createFile(null, path);
|
||||
if (archiveEntry != null) {
|
||||
file = ZLFile.createFile(file, archiveEntry);
|
||||
}
|
||||
final ZLFile file = ZLFile.createFileByPath(path);
|
||||
myBook = Book.getByFile(file);
|
||||
|
||||
if (myBook.File.getPhysicalFile() != null) {
|
||||
|
|
|
@ -136,9 +136,11 @@ public final class FBReaderApp extends ZLApplication {
|
|||
}
|
||||
|
||||
public void openBook(final Book book, final Bookmark bookmark) {
|
||||
if (Model != null) {
|
||||
if (bookmark == null & book.File.getPath().equals(Model.Book.File.getPath())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
ZLDialogManager.Instance().wait("loadingBook", new Runnable() {
|
||||
public void run() {
|
||||
openBookInternal(book, bookmark);
|
||||
|
|
|
@ -215,7 +215,7 @@ class OEBBookReader extends ZLXMLReaderAdapter implements XMLNamespaces {
|
|||
if ((type != null) && (COVER_IMAGE.equals(type))) {
|
||||
myModelReader.setMainTextModel();
|
||||
final ZLFile imageFile = ZLFile.createFileByPath(myFilePrefix + href);
|
||||
final String imageName = imageFile.getName(false);
|
||||
final String imageName = imageFile.getLongName();
|
||||
myModelReader.addImageReference(imageName, (short)0);
|
||||
myModelReader.addImage(imageName, new ZLFileImage(MimeTypes.MIME_IMAGE_AUTO, imageFile));
|
||||
}
|
||||
|
|
|
@ -23,14 +23,9 @@ import org.geometerplus.zlibrary.core.filesystem.ZLFile;
|
|||
|
||||
public class MiscUtil {
|
||||
public static String htmlDirectoryPrefix(ZLFile file) {
|
||||
String shortName = file.getName(false);
|
||||
String shortName = file.getShortName();
|
||||
String path = file.getPath();
|
||||
int index = -1;
|
||||
if ((path.length() > shortName.length()) &&
|
||||
(path.charAt(path.length() - shortName.length() - 1) == ':')) {
|
||||
index = shortName.lastIndexOf('/');
|
||||
}
|
||||
return path.substring(0, path.length() - shortName.length() + index + 1);
|
||||
return path.substring(0, path.length() - shortName.length());
|
||||
}
|
||||
|
||||
public static String archiveEntryName(String fullPath) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class XHTMLTagImageAction extends XHTMLTagAction {
|
|||
if (flag) {
|
||||
modelReader.endParagraph();
|
||||
}
|
||||
final String imageName = imageFile.getName(false);
|
||||
final String imageName = imageFile.getLongName();
|
||||
modelReader.addImageReference(imageName, (short)0);
|
||||
modelReader.addImage(imageName, new ZLFileImage(MimeTypes.MIME_IMAGE_AUTO, imageFile));
|
||||
if (flag) {
|
||||
|
|
|
@ -121,7 +121,9 @@ public class Book {
|
|||
return false;
|
||||
}
|
||||
if ((myTitle == null) || (myTitle.length() == 0)) {
|
||||
setTitle(File.getName(true));
|
||||
final String fileName = File.getShortName();
|
||||
final int index = fileName.lastIndexOf('.');
|
||||
setTitle(index > 0 ? fileName.substring(0, index) : fileName);
|
||||
}
|
||||
final String demoPathPrefix = Paths.BooksDirectoryOption().getValue() + java.io.File.separator + "Demos" + java.io.File.separator;
|
||||
if (File.getPath().startsWith(demoPathPrefix)) {
|
||||
|
|
|
@ -145,7 +145,7 @@ public final class FileInfoSet {
|
|||
}
|
||||
FileInfo info = myInfosByFile.get(file);
|
||||
if (info == null) {
|
||||
info = get(file.getName(false), get(file.getParent()));
|
||||
info = get(file.getLongName(), get(file.getParent()));
|
||||
myInfosByFile.put(file, info);
|
||||
}
|
||||
return info;
|
||||
|
|
|
@ -95,7 +95,9 @@ public final class Library {
|
|||
if (book != null) {
|
||||
myBooks.add(book);
|
||||
} else if (file.isArchive()) {
|
||||
System.err.println("ARCHIVE: " + file.getPath());
|
||||
for (ZLFile entry : fileInfos.archiveEntries(file)) {
|
||||
System.err.println("ENTRY: " + entry.getPath());
|
||||
collectBooks(entry, fileInfos, savedBooks, doReadMetaInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ public abstract class ZLArchiveEntryFile extends ZLFile {
|
|||
|
||||
protected final ZLFile myParent;
|
||||
protected final String myName;
|
||||
private String myShortName;
|
||||
|
||||
protected ZLArchiveEntryFile(ZLFile parent, String name) {
|
||||
myParent = parent;
|
||||
|
@ -101,17 +100,8 @@ public abstract class ZLArchiveEntryFile extends ZLFile {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithExtension() {
|
||||
if (myShortName == null) {
|
||||
final String name = myName;
|
||||
final int index = name.lastIndexOf('/');
|
||||
if (index == -1) {
|
||||
myShortName = name;
|
||||
} else {
|
||||
myShortName = name.substring(index + 1);
|
||||
}
|
||||
}
|
||||
return myShortName;
|
||||
public String getLongName() {
|
||||
return myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -35,15 +35,15 @@ public abstract class ZLFile {
|
|||
int ARCHIVE = 0xff00;
|
||||
};
|
||||
|
||||
private String myNameWithoutExtension;
|
||||
private String myExtension;
|
||||
private String myShortName;
|
||||
protected int myArchiveType;
|
||||
private boolean myIsCached;
|
||||
protected void init() {
|
||||
final String name = getNameWithExtension();
|
||||
final String name = getLongName();
|
||||
final int index = name.lastIndexOf('.');
|
||||
myNameWithoutExtension = (index != -1) ? name.substring(0, index) : name;
|
||||
myExtension = (index != -1) ? name.substring(index + 1).toLowerCase().intern() : "";
|
||||
myExtension = (index > 0) ? name.substring(index + 1).toLowerCase().intern() : "";
|
||||
myShortName = name.substring(name.lastIndexOf('/') + 1);
|
||||
|
||||
/*
|
||||
if (lowerCaseName.endsWith(".gz")) {
|
||||
|
@ -140,9 +140,10 @@ public abstract class ZLFile {
|
|||
return (0 != (myArchiveType & ArchiveType.ARCHIVE));
|
||||
}
|
||||
|
||||
protected abstract String getNameWithExtension();
|
||||
public final String getName(boolean hideExtension) {
|
||||
return hideExtension ? myNameWithoutExtension : getNameWithExtension();
|
||||
public abstract String getLongName();
|
||||
|
||||
public final String getShortName() {
|
||||
return myShortName;
|
||||
}
|
||||
|
||||
public final String getExtension() {
|
||||
|
|
|
@ -59,7 +59,7 @@ public final class ZLPhysicalFile extends ZLFile {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getNameWithExtension() {
|
||||
public String getLongName() {
|
||||
return isDirectory() ? getPath() : myFile.getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,17 @@ public abstract class ZLResourceFile extends ZLFile {
|
|||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return myPath;
|
||||
}
|
||||
|
||||
public String getNameWithExtension() {
|
||||
@Override
|
||||
public String getLongName() {
|
||||
return myPath.substring(myPath.lastIndexOf('/') + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZLPhysicalFile getPhysicalFile() {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ public class ZLLanguageDetector {
|
|||
|
||||
public ZLLanguageDetector() {
|
||||
for (ZLFile file : ZLLanguageUtil.patternsFile().children()) {
|
||||
final String name = file.getName(true);
|
||||
final String name = file.getShortName();
|
||||
final int index = name.indexOf('_');
|
||||
if (index != -1) {
|
||||
final String language = name.substring(0, index);
|
||||
|
|
|
@ -64,7 +64,7 @@ public abstract class ZLLanguageUtil {
|
|||
if (ourLanguageCodes.isEmpty()) {
|
||||
TreeSet<String> codes = new TreeSet<String>();
|
||||
for (ZLFile file : patternsFile().children()) {
|
||||
String name = file.getName(false);
|
||||
String name = file.getShortName();
|
||||
final int index = name.indexOf("_");
|
||||
if (index != -1) {
|
||||
String str = name.substring(0, index);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue