diff --git a/data/resources/application/en.xml b/data/resources/application/en.xml index abcbaf22b..c3642539e 100644 --- a/data/resources/application/en.xml +++ b/data/resources/application/en.xml @@ -193,17 +193,6 @@ - - - - - - - - - - - diff --git a/data/resources/application/ru.xml b/data/resources/application/ru.xml index 5f09cdcc0..aa1e88c9b 100644 --- a/data/resources/application/ru.xml +++ b/data/resources/application/ru.xml @@ -194,17 +194,6 @@ - - - - - - - - - - - diff --git a/platform/android/src/org/geometerplus/android/fbreader/SQLiteBooksDatabase.java b/platform/android/src/org/geometerplus/android/fbreader/SQLiteBooksDatabase.java index 0c33a6937..1c80a6346 100644 --- a/platform/android/src/org/geometerplus/android/fbreader/SQLiteBooksDatabase.java +++ b/platform/android/src/org/geometerplus/android/fbreader/SQLiteBooksDatabase.java @@ -36,9 +36,13 @@ final class SQLiteBooksDatabase extends BooksDatabase { SQLiteBooksDatabase() { myDatabase = ZLAndroidApplication.Instance().openOrCreateDatabase("books.db", Context.MODE_PRIVATE, null); - if (myDatabase.getVersion() == 0) { - createTables(); + switch (myDatabase.getVersion()) { + case 0: + createTables(); + case 1: + updateTables1(); } + myDatabase.setVersion(2); } public void executeAsATransaction(Runnable actions) { @@ -51,56 +55,6 @@ final class SQLiteBooksDatabase extends BooksDatabase { } } - private void createTables() { - myDatabase.beginTransaction(); - myDatabase.execSQL( - "CREATE TABLE Books(" + - "book_id INTEGER PRIMARY KEY," + - "encoding TEXT," + - "language TEXT," + - "title TEXT NOT NULL," + - "file_name TEXT UNIQUE NOT NULL)"); - myDatabase.execSQL( - "CREATE TABLE Authors(" + - "author_id INTEGER PRIMARY KEY," + - "name TEXT NOT NULL," + - "sort_key TEXT NOT NULL," + - "CONSTRAINT Authors_Unique UNIQUE (name, sort_key))"); - myDatabase.execSQL( - "CREATE TABLE BookAuthor(" + - "author_id INTEGER NOT NULL REFERENCES Authors(author_id)," + - "book_id INTEGER NOT NULL REFERENCES Books(book_id)," + - "author_index INTEGER NOT NULL," + - "CONSTRAINT BookAuthor_Unique0 UNIQUE (author_id, book_id)," + - "CONSTRAINT BookAuthor_Unique1 UNIQUE (book_id, author_index))"); - myDatabase.execSQL( - "CREATE TABLE Series(" + - "series_id INTEGER PRIMARY KEY," + - "name TEXT UNIQUE NOT NULL)"); - myDatabase.execSQL( - "CREATE TABLE BookSeries(" + - "series_id INTEGER NOT NULL REFERENCES Series(series_id)," + - "book_id INTEGER NOT NULL UNIQUE REFERENCES Books(book_id)," + - "book_index INTEGER)"); - // TODO: parent->parent_id - myDatabase.execSQL( - "CREATE TABLE Tags(" + - "tag_id INTEGER PRIMARY KEY," + - "name TEXT NOT NULL," + - "parent INTEGER REFERENCES Tags(tag_id)," + - "CONSTRAINT Tags_Unique UNIQUE (name, parent))"); - // TODO: tag_id, book_id -> NOT NULL - myDatabase.execSQL( - "CREATE TABLE BookTag(" + - "tag_id INTEGER REFERENCES Tags(tag_id)," + - "book_id INTEGER REFERENCES Books(book_id)," + - "CONSTRAINT BookTag_Unique UNIQUE (tag_id, book_id))"); - myDatabase.setTransactionSuccessful(); - myDatabase.endTransaction(); - - myDatabase.setVersion(1); - } - private static void bindString(SQLiteStatement statement, int index, String value) { if (value != null) { statement.bindString(index, value); @@ -220,10 +174,10 @@ final class SQLiteBooksDatabase extends BooksDatabase { private long getTagId(Tag tag) { if (myGetTagIdStatement == null) { myGetTagIdStatement = myDatabase.compileStatement( - "SELECT tag_id FROM Tags WHERE parent = ? AND name = ?" + "SELECT tag_id FROM Tags WHERE parent_id = ? AND name = ?" ); myCreateTagIdStatement = myDatabase.compileStatement( - "INSERT INTO Tags (parent,name) VALUES (?,?)" + "INSERT INTO Tags (parent_id,name) VALUES (?,?)" ); } { @@ -270,7 +224,7 @@ final class SQLiteBooksDatabase extends BooksDatabase { private Tag getTagById(long id) { Tag tag = myTagById.get(id); if (tag == null) { - final Cursor cursor = myDatabase.rawQuery("SELECT parent,name FROM Tags WHERE tag_id = ?", new String[] { "" + id }); + final Cursor cursor = myDatabase.rawQuery("SELECT parent_id,name FROM Tags WHERE tag_id = ?", new String[] { "" + id }); if (cursor.moveToNext()) { final Tag parent = cursor.isNull(0) ? null : getTagById(cursor.getLong(0)); tag = Tag.getTag(parent, cursor.getString(1)); @@ -367,4 +321,76 @@ final class SQLiteBooksDatabase extends BooksDatabase { } catch (SQLException e) { } } + + private void createTables() { + myDatabase.beginTransaction(); + myDatabase.execSQL( + "CREATE TABLE Books(" + + "book_id INTEGER PRIMARY KEY," + + "encoding TEXT," + + "language TEXT," + + "title TEXT NOT NULL," + + "file_name TEXT UNIQUE NOT NULL)"); + myDatabase.execSQL( + "CREATE TABLE Authors(" + + "author_id INTEGER PRIMARY KEY," + + "name TEXT NOT NULL," + + "sort_key TEXT NOT NULL," + + "CONSTRAINT Authors_Unique UNIQUE (name, sort_key))"); + myDatabase.execSQL( + "CREATE TABLE BookAuthor(" + + "author_id INTEGER NOT NULL REFERENCES Authors(author_id)," + + "book_id INTEGER NOT NULL REFERENCES Books(book_id)," + + "author_index INTEGER NOT NULL," + + "CONSTRAINT BookAuthor_Unique0 UNIQUE (author_id, book_id)," + + "CONSTRAINT BookAuthor_Unique1 UNIQUE (book_id, author_index))"); + myDatabase.execSQL( + "CREATE TABLE Series(" + + "series_id INTEGER PRIMARY KEY," + + "name TEXT UNIQUE NOT NULL)"); + myDatabase.execSQL( + "CREATE TABLE BookSeries(" + + "series_id INTEGER NOT NULL REFERENCES Series(series_id)," + + "book_id INTEGER NOT NULL UNIQUE REFERENCES Books(book_id)," + + "book_index INTEGER)"); + myDatabase.execSQL( + "CREATE TABLE Tags(" + + "tag_id INTEGER PRIMARY KEY," + + "name TEXT NOT NULL," + + "parent INTEGER REFERENCES Tags(tag_id)," + + "CONSTRAINT Tags_Unique UNIQUE (name, parent))"); + myDatabase.execSQL( + "CREATE TABLE BookTag(" + + "tag_id INTEGER REFERENCES Tags(tag_id)," + + "book_id INTEGER REFERENCES Books(book_id)," + + "CONSTRAINT BookTag_Unique UNIQUE (tag_id, book_id))"); + myDatabase.setTransactionSuccessful(); + myDatabase.endTransaction(); + } + + private void updateTables1() { + myDatabase.beginTransaction(); + + myDatabase.execSQL("ALTER TABLE Tags RENAME TO Tags_Obsolete"); + myDatabase.execSQL( + "CREATE TABLE Tags(" + + "tag_id INTEGER PRIMARY KEY," + + "name TEXT NOT NULL," + + "parent_id INTEGER REFERENCES Tags(tag_id)," + + "CONSTRAINT Tags_Unique UNIQUE (name, parent_id))"); + myDatabase.execSQL("INSERT INTO Tags (tag_id,name,parent_id) SELECT tag_id,name,parent FROM Tags_Obsolete"); + myDatabase.execSQL("DROP TABLE Tags_Obsolete"); + + myDatabase.execSQL("ALTER TABLE BookTag RENAME TO BookTag_Obsolete"); + myDatabase.execSQL( + "CREATE TABLE BookTag(" + + "tag_id INTEGER NOT NULL REFERENCES Tags(tag_id)," + + "book_id INTEGER NOT NULL REFERENCES Books(book_id)," + + "CONSTRAINT BookTag_Unique UNIQUE (tag_id, book_id))"); + myDatabase.execSQL("INSERT INTO BookTag (tag_id,book_id) SELECT tag_id,book_id FROM BookTag_Obsolete"); + myDatabase.execSQL("DROP TABLE BookTag_Obsolete"); + + myDatabase.setTransactionSuccessful(); + myDatabase.endTransaction(); + } } diff --git a/src/org/geometerplus/fbreader/fbreader/BookTextView.java b/src/org/geometerplus/fbreader/fbreader/BookTextView.java index 3e6ec8d9c..d8ece5d8c 100644 --- a/src/org/geometerplus/fbreader/fbreader/BookTextView.java +++ b/src/org/geometerplus/fbreader/fbreader/BookTextView.java @@ -50,17 +50,11 @@ public class BookTextView extends FBView { private String myFileName; - public ZLBooleanOption ShowTOCMarksOption; - - public final ZLBooleanOption OpenInBrowserOption = - new ZLBooleanOption("Web Browser", "Enabled", true); - BookTextView(ZLPaintContext context) { super(context); - ShowTOCMarksOption = new ZLBooleanOption("Indicator", "ShowTOCMarks", false); } - public void setModels(ArrayList/**/ models, String fileName) { + public void setModels(ArrayList models, String fileName) { myFileName = fileName; myPositionStack.clear(); @@ -89,8 +83,7 @@ public class BookTextView extends FBView { final int wordIndex = option.getValue(); option.changeName(CHAR_PREFIX + i); final int charIndex = option.getValue(); - myPositionStack.add(new Position(modelIndex, paragraphIndex, - wordIndex, charIndex)); + myPositionStack.add(new Position(modelIndex, paragraphIndex, wordIndex, charIndex)); } } if (!myPositionStack.isEmpty()) { @@ -197,9 +190,7 @@ public class BookTextView extends FBView { if (id != null) { switch (hyperlinkKind) { case FBTextKind.EXTERNAL_HYPERLINK: - if (OpenInBrowserOption.getValue()) { - ZLibrary.Instance().openInBrowser(id); - } + ZLibrary.Instance().openInBrowser(id); return true; case FBTextKind.FOOTNOTE: case FBTextKind.INTERNAL_HYPERLINK: diff --git a/src/org/geometerplus/fbreader/optionsDialog/OptionsDialog.java b/src/org/geometerplus/fbreader/optionsDialog/OptionsDialog.java index 47281a274..1d27af133 100644 --- a/src/org/geometerplus/fbreader/optionsDialog/OptionsDialog.java +++ b/src/org/geometerplus/fbreader/optionsDialog/OptionsDialog.java @@ -87,11 +87,6 @@ public class OptionsDialog { colorsTab.addOption("", builder.colorEntry()); new KeyBindingsPage(fbreader, myDialog.createTab("Keys")); - - final ZLDialogContent webTab = myDialog.createTab("Web"); - webTab.addOption("defaultText", - new ZLToggleBooleanOptionEntry(fbreader.BookTextView.OpenInBrowserOption) - ); } public ZLOptionsDialog getDialog() { diff --git a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java index c922de948..aafeb8772 100644 --- a/src/org/geometerplus/zlibrary/text/view/ZLTextView.java +++ b/src/org/geometerplus/zlibrary/text/view/ZLTextView.java @@ -39,14 +39,14 @@ public abstract class ZLTextView extends ZLView { } public final void setModel(ZLTextModel model) { - final ArrayList list = new ArrayList(1); + final ArrayList list = new ArrayList(1); list.add(model); setModels(list, 0); } public abstract void setModelIndex(int modelIndex); - public abstract void setModels(ArrayList/**/ model, int current); + public abstract void setModels(ArrayList model, int current); public abstract void scrollPage(boolean forward, int scrollingMode, int value); diff --git a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java index a808733e7..d4fa7caa3 100644 --- a/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java +++ b/src/org/geometerplus/zlibrary/text/view/impl/ZLTextViewImpl.java @@ -36,7 +36,7 @@ public abstract class ZLTextViewImpl extends ZLTextView { private ZLTextModel myModel; protected int myCurrentModelIndex; - private ArrayList/**/ myModelList; + private ArrayList myModelList; private final ZLTextSelectionModel mySelectionModel; protected static class Position { @@ -111,8 +111,8 @@ public abstract class ZLTextViewImpl extends ZLTextView { mySelectionModel = new ZLTextSelectionModel(this); } - public void setModels(ArrayList models, int current) { - myModelList = (models != null) ? models : new ArrayList(); + public void setModels(ArrayList models, int current) { + myModelList = (models != null) ? models : new ArrayList(); myModel = (current >= 0 && current < myModelList.size()) ? (ZLTextModel)myModelList.get(current) : null; myCurrentModelIndex = current; @@ -151,7 +151,7 @@ public abstract class ZLTextViewImpl extends ZLTextView { return myModel; } - protected ArrayList getModelList() { + protected ArrayList getModelList() { return myModelList; }