From 50f344fc8f6dca76ac7a1f18a1dc6456c44d4fb1 Mon Sep 17 00:00:00 2001 From: Evan Leybourn Date: Thu, 18 Nov 2010 23:32:27 +1100 Subject: [PATCH] Changed audiobook to format - included guide/companion --- README | 3 + res/layout/edit_book.xml | 13 ++-- res/values/strings.xml | 7 +- .../AdministrationFunctions.java | 18 ++--- .../eleybourn/bookcatalogue/BookBackup.java | 4 +- .../bookcatalogue/BookEditAnthology.java | 4 +- .../bookcatalogue/BookEditFields.java | 55 +++++++++++----- .../bookcatalogue/BookEditNotes.java | 6 +- .../bookcatalogue/CatalogueDBAdapter.java | 66 +++++++++++++++---- .../bookcatalogue/FieldVisibility.java | 12 ++-- 10 files changed, 130 insertions(+), 58 deletions(-) diff --git a/README b/README index 579b856..0e7d1ce 100644 --- a/README +++ b/README @@ -41,6 +41,9 @@ Features include; case. e.g. "The murder on the links" becomes "The Murder on the Links" * Using ISBN or Barcode scanning will also download a thumbnail (if available) +New in v3.1 + + New in v3.0.1 * Export bug fixed * Further enhancements to the new ISBN screen diff --git a/res/layout/edit_book.xml b/res/layout/edit_book.xml index 1a568c9..706daf6 100755 --- a/res/layout/edit_book.xml +++ b/res/layout/edit_book.xml @@ -125,6 +125,12 @@ android:inputType="numberDecimal" /> + + - - About this App This screen will show you the current version of the Book Catalogue you are running as well as links to the app homepage, source code and my email address. Has this book been signed -This book is an Audiobook +Audiobook Date started reading Date finished reading Location of the book @@ -207,4 +207,9 @@ Searching Amazon Select bookshelves for this book Select Bookshelves +Format +Paperback +Hard Cover +eBook +Guide / Companion diff --git a/src/com/eleybourn/bookcatalogue/AdministrationFunctions.java b/src/com/eleybourn/bookcatalogue/AdministrationFunctions.java index 552f9bf..b55158d 100644 --- a/src/com/eleybourn/bookcatalogue/AdministrationFunctions.java +++ b/src/com/eleybourn/bookcatalogue/AdministrationFunctions.java @@ -407,7 +407,7 @@ public class AdministrationFunctions extends Activity { '"' + CatalogueDBAdapter.KEY_LOCATION+ "\"," + //18 '"' + CatalogueDBAdapter.KEY_READ_START+ "\"," + //19 '"' + CatalogueDBAdapter.KEY_READ_END+ "\"," + //20 - '"' + CatalogueDBAdapter.KEY_AUDIOBOOK+ "\"," + //21 + '"' + CatalogueDBAdapter.KEY_FORMAT+ "\"," + //21 '"' + CatalogueDBAdapter.KEY_SIGNED+ "\"," + //22 '"' + CatalogueDBAdapter.KEY_LOANED_TO+ "\"," + //23 '"' + "anthology_titles," + "\"" + //24 @@ -491,7 +491,7 @@ public class AdministrationFunctions extends Activity { row += "\"" + formatCell(books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LOCATION))) + "\","; row += "\"" + formatCell(dateReadStartString) + "\","; row += "\"" + formatCell(dateReadEndString) + "\","; - row += "\"" + formatCell(books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_AUDIOBOOK))) + "\","; + row += "\"" + formatCell(books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_FORMAT))) + "\","; row += "\"" + formatCell(books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_SIGNED))) + "\","; row += "\"" + formatCell(books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LOANED_TO))+"") + "\","; row += "\"" + formatCell(anthology_titles) + "\""; @@ -803,11 +803,11 @@ public class AdministrationFunctions extends Activity { read_end = ""; } - boolean audiobook = false; + String format = ""; try { - audiobook = (imported[21].equals("0")? false:true); + format = imported[21]; } catch (Exception e) { - audiobook = false; + format = ""; } boolean signed = false; @@ -842,21 +842,21 @@ public class AdministrationFunctions extends Activity { // Its a new entry, but the ISBN exists id = book.getLong(0); book.moveToFirst(); - mDbHelper.updateBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.updateBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); importUpdated++; } else { - id = mDbHelper.createBook(author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + id = mDbHelper.createBook(author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); importCreated++; } } else { Cursor book = mDbHelper.fetchBookById(id); int rows = book.getCount(); if (rows == 0) { - mDbHelper.createBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.createBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); importCreated++; } else { // Book exists and should be updated if it has changed - mDbHelper.updateBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.updateBook(id, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); importUpdated++; } } diff --git a/src/com/eleybourn/bookcatalogue/BookBackup.java b/src/com/eleybourn/bookcatalogue/BookBackup.java index cda9abe..bf14ff0 100644 --- a/src/com/eleybourn/bookcatalogue/BookBackup.java +++ b/src/com/eleybourn/bookcatalogue/BookBackup.java @@ -72,7 +72,7 @@ public class BookBackup extends Activity { CatalogueDBAdapter.KEY_LOCATION+ "\t" + //18 CatalogueDBAdapter.KEY_READ_START+ "\t" + //19 CatalogueDBAdapter.KEY_READ_END+ "\t" + //20 - CatalogueDBAdapter.KEY_AUDIOBOOK+ "\t" + //21 + CatalogueDBAdapter.KEY_FORMAT+ "\t" + //21 CatalogueDBAdapter.KEY_SIGNED+ "\t" + //22 CatalogueDBAdapter.KEY_LOANED_TO+ "\t" + //23 "anthology_titles\t" + //24 @@ -146,7 +146,7 @@ public class BookBackup extends Activity { row += books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LOCATION)) + "\t"; row += dateReadStartString + "\t"; row += dateReadEndString + "\t"; - row += books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_AUDIOBOOK)) + "\t"; + row += books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_FORMAT)) + "\t"; row += books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_SIGNED)) + "\t"; row += books.getString(books.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LOANED_TO)) + "\t"; row += anthology_titles + "\t"; diff --git a/src/com/eleybourn/bookcatalogue/BookEditAnthology.java b/src/com/eleybourn/bookcatalogue/BookEditAnthology.java index afa751b..34d5a32 100644 --- a/src/com/eleybourn/bookcatalogue/BookEditAnthology.java +++ b/src/com/eleybourn/bookcatalogue/BookEditAnthology.java @@ -496,7 +496,7 @@ public class BookEditAnthology extends ListActivity { String location = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LOCATION)); String read_start = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_READ_START)); String read_end = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_READ_END)); - boolean audiobook = (book.getInt(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_AUDIOBOOK))==0? false:true); + String format = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_FORMAT)); boolean signed = (book.getInt(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_SIGNED))==0? false:true); int pages = book.getInt(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_PAGES)); @@ -506,7 +506,7 @@ public class BookEditAnthology extends ListActivity { Toast.makeText(this, R.string.unknown_error, Toast.LENGTH_LONG).show(); finish(); } else { - mDbHelper.updateBook(mRowId, bookAuthor, bookTitle, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.updateBook(mRowId, bookAuthor, bookTitle, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); } return; } diff --git a/src/com/eleybourn/bookcatalogue/BookEditFields.java b/src/com/eleybourn/bookcatalogue/BookEditFields.java index f9955dd..2a4b79f 100644 --- a/src/com/eleybourn/bookcatalogue/BookEditFields.java +++ b/src/com/eleybourn/bookcatalogue/BookEditFields.java @@ -56,6 +56,7 @@ import android.widget.DatePicker; import android.widget.EditText; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.Spinner; import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; @@ -74,7 +75,10 @@ public class BookEditFields extends Activity { private EditText mListPriceText; private EditText mPagesText; private CheckBox mAnthologyCheckBox; - private CheckBox mAudiobookCheckBox; + private Spinner mFormatText; + private ArrayList formats = new ArrayList(); + + private ArrayAdapter spinnerAdapter; private Button mConfirmButton; private Button mCancelButton; private Long mRowId; @@ -169,19 +173,19 @@ public class BookEditFields extends Activity { ArrayAdapter author_adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, getAuthors()); mAuthorText = (AutoCompleteTextView) findViewById(R.id.author); mAuthorText.setAdapter(author_adapter); - field_visibility = mPrefs.getBoolean(visibility_prefix + "author", true); + field_visibility = mPrefs.getBoolean(visibility_prefix + CatalogueDBAdapter.KEY_AUTHOR, true); if (field_visibility == false) { mAuthorText.setVisibility(GONE); } mTitleText = (EditText) findViewById(R.id.title); - field_visibility = mPrefs.getBoolean(visibility_prefix + "title", true); + field_visibility = mPrefs.getBoolean(visibility_prefix + CatalogueDBAdapter.KEY_TITLE, true); if (field_visibility == false) { mTitleText.setVisibility(GONE); } mIsbnText = (EditText) findViewById(R.id.isbn); - field_visibility = mPrefs.getBoolean(visibility_prefix + "isbn", true); + field_visibility = mPrefs.getBoolean(visibility_prefix + CatalogueDBAdapter.KEY_ISBN, true); if (field_visibility == false) { mIsbnText.setVisibility(GONE); } @@ -189,7 +193,7 @@ public class BookEditFields extends Activity { ArrayAdapter publisher_adapter = new ArrayAdapter(this, android.R.layout.simple_dropdown_item_1line, getPublishers()); mPublisherText = (AutoCompleteTextView) findViewById(R.id.publisher); mPublisherText.setAdapter(publisher_adapter); - field_visibility = mPrefs.getBoolean(visibility_prefix + "publisher", true); + field_visibility = mPrefs.getBoolean(visibility_prefix + CatalogueDBAdapter.KEY_PUBLISHER, true); if (field_visibility == false) { mPublisherText.setVisibility(GONE); } @@ -234,10 +238,21 @@ public class BookEditFields extends Activity { mAnthologyCheckBox.setVisibility(GONE); } - mAudiobookCheckBox = (CheckBox) findViewById(R.id.audiobook); - field_visibility = mPrefs.getBoolean(visibility_prefix + "audiobook", true); + mFormatText = (Spinner) findViewById(R.id.format); + spinnerAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item); + spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mFormatText.setAdapter(spinnerAdapter); + formats.add(getString(R.string.paperback)); + formats.add(getString(R.string.hardcover)); + formats.add(getString(R.string.ebook)); + formats.add(getString(R.string.audiobook)); + formats.add(getString(R.string.guide)); + for (int i=0; i 0) { mRowId = id; File thumb = CatalogueDBAdapter.fetchThumbnail(0); @@ -785,7 +806,7 @@ public class BookEditFields extends Activity { thumb.renameTo(real); } } else { - mDbHelper.updateBook(mRowId, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.updateBook(mRowId, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); } /* These are global variables that will be sent via intent back to the list view */ added_author = author; diff --git a/src/com/eleybourn/bookcatalogue/BookEditNotes.java b/src/com/eleybourn/bookcatalogue/BookEditNotes.java index be30361..b88d057 100644 --- a/src/com/eleybourn/bookcatalogue/BookEditNotes.java +++ b/src/com/eleybourn/bookcatalogue/BookEditNotes.java @@ -66,7 +66,7 @@ public class BookEditNotes extends Activity { private String list_price; private int anthology; private int pages; - private boolean audiobook; + private String format; private static final int GONE = 8; @@ -232,7 +232,7 @@ public class BookEditNotes extends Activity { list_price = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_LIST_PRICE)); anthology = book.getInt(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_ANTHOLOGY)); pages = book.getInt(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_PAGES)); - audiobook = (book.getInt(book.getColumnIndex(CatalogueDBAdapter.KEY_AUDIOBOOK))==0? false:true); + format = book.getString(book.getColumnIndex(CatalogueDBAdapter.KEY_FORMAT)); } else { // Manual Add //This should never happen @@ -279,7 +279,7 @@ public class BookEditNotes extends Activity { Toast.makeText(this, R.string.unknown_error, Toast.LENGTH_LONG).show(); finish(); } else { - mDbHelper.updateBook(mRowId, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + mDbHelper.updateBook(mRowId, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); } return; } diff --git a/src/com/eleybourn/bookcatalogue/CatalogueDBAdapter.java b/src/com/eleybourn/bookcatalogue/CatalogueDBAdapter.java index f5c081a..beb1291 100644 --- a/src/com/eleybourn/bookcatalogue/CatalogueDBAdapter.java +++ b/src/com/eleybourn/bookcatalogue/CatalogueDBAdapter.java @@ -63,7 +63,8 @@ public class CatalogueDBAdapter { public static final String KEY_LOCATION = "location"; public static final String KEY_READ_START = "read_start"; public static final String KEY_READ_END = "read_end"; - public static final String KEY_AUDIOBOOK = "audiobook"; + public static final String KEY_FORMAT = "format"; + public static final String OLD_KEY_AUDIOBOOK = "audiobook"; public static final String KEY_SIGNED = "signed"; public static final String KEY_AUTHOR_FORMATTED = "author_formatted"; @@ -126,7 +127,7 @@ public class CatalogueDBAdapter { KEY_LOCATION + " text, " + KEY_READ_START + " date, " + KEY_READ_END + " date, " + - KEY_AUDIOBOOK + " boolean not null default 'f', " + + KEY_FORMAT + " text, " + KEY_SIGNED + " boolean not null default 'f' " + ")"; @@ -187,14 +188,14 @@ public class CatalogueDBAdapter { "b." + KEY_LOCATION + " as " + KEY_LOCATION + ", " + "b." + KEY_READ_START + " as " + KEY_READ_START + ", " + "b." + KEY_READ_END + " as " + KEY_READ_END + ", " + - "b." + KEY_AUDIOBOOK + " as " + KEY_AUDIOBOOK + ", " + + "b." + KEY_FORMAT + " as " + KEY_FORMAT + ", " + "b." + KEY_SIGNED + " as " + KEY_SIGNED + ", " + "CASE WHEN " + KEY_SERIES + "='' THEN '' ELSE b." + KEY_SERIES + " || CASE WHEN " + KEY_SERIES_NUM + "='' THEN '' ELSE ' #' || b." + KEY_SERIES_NUM + " END END AS " + KEY_SERIES_FORMATTED; private static String BOOKSHELF_TABLES = DB_TB_BOOKS + " b LEFT OUTER JOIN " + DB_TB_BOOK_BOOKSHELF_WEAK + " w ON (b." + KEY_ROWID + "=w." + KEY_BOOK + ") LEFT OUTER JOIN " + DB_TB_BOOKSHELF + " bs ON (bs." + KEY_ROWID + "=w." + KEY_BOOKSHELF + ") "; private final Context mCtx; - public static final int DATABASE_VERSION = 44; + public static final int DATABASE_VERSION = 46; /** * This is a specific version of the SQLiteOpenHelper class. It handles onCreate and onUpgrade events @@ -415,7 +416,7 @@ public class CatalogueDBAdapter { db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + KEY_LOCATION + " text"); db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + KEY_READ_START + " date"); db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + KEY_READ_END + " date"); - db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + KEY_AUDIOBOOK + " boolean not null default 'f'"); + db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + OLD_KEY_AUDIOBOOK + " boolean not null default 'f'"); db.execSQL("ALTER TABLE " + DB_TB_BOOKS + " ADD " + KEY_SIGNED + " boolean not null default 'f'"); } catch (Exception e) { //do nothing @@ -427,7 +428,7 @@ public class CatalogueDBAdapter { db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + KEY_LOCATION + "=''"); db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + KEY_READ_START + "=''"); db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + KEY_READ_END + "=''"); - db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + KEY_AUDIOBOOK + "='f'"); + db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + OLD_KEY_AUDIOBOOK + "='f'"); db.execSQL("UPDATE " + DB_TB_BOOKS + " SET " + KEY_SIGNED + "='f'"); } catch (Exception e) { //do nothing @@ -490,7 +491,7 @@ public class CatalogueDBAdapter { db.execSQL("INSERT INTO " + DB_TB_BOOK_BOOKSHELF_WEAK + " (" + KEY_BOOK + ", " + KEY_BOOKSHELF + ") SELECT " + KEY_ROWID + ", " + KEY_BOOKSHELF + " FROM " + DB_TB_BOOKS + ""); db.execSQL("CREATE TABLE tmp1 AS SELECT _id, " + KEY_AUTHOR + ", " + KEY_TITLE + ", " + KEY_ISBN + ", " + KEY_PUBLISHER + ", " + KEY_DATE_PUBLISHED + ", " + KEY_RATING + ", " + KEY_READ + ", " + KEY_SERIES + ", " + KEY_PAGES + ", " + KEY_SERIES_NUM + ", " + KEY_NOTES + ", " + - KEY_LIST_PRICE + ", " + KEY_ANTHOLOGY + ", " + KEY_LOCATION + ", " + KEY_READ_START + ", " + KEY_READ_END + ", " + KEY_AUDIOBOOK + ", " + + KEY_LIST_PRICE + ", " + KEY_ANTHOLOGY + ", " + KEY_LOCATION + ", " + KEY_READ_START + ", " + KEY_READ_END + ", " + OLD_KEY_AUDIOBOOK + ", " + KEY_SIGNED + " FROM " + DB_TB_BOOKS); db.execSQL("CREATE TABLE tmp2 AS SELECT _id, " + KEY_BOOK + ", " + KEY_LOANED_TO + " FROM " + DB_TB_LOAN ); db.execSQL("CREATE TABLE tmp3 AS SELECT _id, " + KEY_BOOK + ", " + KEY_AUTHOR + ", " + KEY_TITLE + ", " + KEY_POSITION + " FROM " + DB_TB_ANTHOLOGY); @@ -532,6 +533,45 @@ public class CatalogueDBAdapter { ")"); db.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS anthology_pk_idx ON " + DB_TB_ANTHOLOGY + " (" + KEY_BOOK + ", " + KEY_AUTHOR + ", " + KEY_TITLE + ")"); } + if (curVersion == 44) { + //do nothing + curVersion++; + db.execSQL("CREATE TABLE tmp1 AS SELECT _id, " + KEY_AUTHOR + ", " + KEY_TITLE + ", " + KEY_ISBN + ", " + KEY_PUBLISHER + ", " + + KEY_DATE_PUBLISHED + ", " + KEY_RATING + ", " + KEY_READ + ", " + KEY_SERIES + ", " + KEY_PAGES + ", " + KEY_SERIES_NUM + ", " + KEY_NOTES + ", " + + KEY_LIST_PRICE + ", " + KEY_ANTHOLOGY + ", " + KEY_LOCATION + ", " + KEY_READ_START + ", " + KEY_READ_END + ", " + + "CASE WHEN " + OLD_KEY_AUDIOBOOK + "='t' THEN 'Audiobook' ELSE 'Paperback' END AS " + OLD_KEY_AUDIOBOOK + ", " + + KEY_SIGNED + " FROM " + DB_TB_BOOKS); + db.execSQL("CREATE TABLE tmp2 AS SELECT _id, " + KEY_BOOK + ", " + KEY_LOANED_TO + " FROM " + DB_TB_LOAN ); + db.execSQL("CREATE TABLE tmp3 AS SELECT _id, " + KEY_BOOK + ", " + KEY_AUTHOR + ", " + KEY_TITLE + ", " + KEY_POSITION + " FROM " + DB_TB_ANTHOLOGY); + db.execSQL("CREATE TABLE tmp4 AS SELECT " + KEY_BOOK + ", " + KEY_BOOKSHELF+ " FROM " + DB_TB_BOOK_BOOKSHELF_WEAK); + + db.execSQL("DROP TABLE " + DB_TB_ANTHOLOGY); + db.execSQL("DROP TABLE " + DB_TB_LOAN); + db.execSQL("DROP TABLE " + DB_TB_BOOKS); + db.execSQL("DROP TABLE " + DB_TB_BOOK_BOOKSHELF_WEAK); + + db.execSQL(DATABASE_CREATE_BOOKS); + db.execSQL(DATABASE_CREATE_LOAN); + db.execSQL(DATABASE_CREATE_ANTHOLOGY); + db.execSQL(DATABASE_CREATE_BOOK_BOOKSHELF_WEAK); + + db.execSQL("INSERT INTO " + DB_TB_BOOKS + " SELECT * FROM tmp1"); + db.execSQL("INSERT INTO " + DB_TB_LOAN + " SELECT * FROM tmp2"); + db.execSQL("INSERT INTO " + DB_TB_ANTHOLOGY + " SELECT * FROM tmp3"); + db.execSQL("INSERT INTO " + DB_TB_BOOK_BOOKSHELF_WEAK + " SELECT * FROM tmp4"); + + db.execSQL("DROP TABLE tmp1"); + db.execSQL("DROP TABLE tmp2"); + db.execSQL("DROP TABLE tmp3"); + db.execSQL("DROP TABLE tmp4"); + + db.execSQL(DATABASE_CREATE_INDICES); + } + if (curVersion == 45) { + //do nothing + curVersion++; + db.execSQL("DELETE FROM " + DB_TB_LOAN + " WHERE " + KEY_LOANED_TO + "='null'" ); + } } } @@ -1441,8 +1481,8 @@ public class CatalogueDBAdapter { * @param signed Is this copy signed * @return rowId or -1 if failed */ - public long createBook(String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, Boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, boolean audiobook, boolean signed) { - return createBook(0, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, audiobook, signed); + public long createBook(String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, Boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, String format, boolean signed) { + return createBook(0, author, title, isbn, publisher, date_published, rating, bookshelf, read, series, pages, series_num, notes, list_price, anthology, location, read_start, read_end, format, signed); } /** @@ -1472,7 +1512,7 @@ public class CatalogueDBAdapter { * @param signed Is this copy signed * @return rowId or -1 if failed */ - public long createBook(long id, String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, Boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, boolean audiobook, boolean signed) { + public long createBook(long id, String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, Boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, String format, boolean signed) { ContentValues initialValues = new ContentValues(); String[] names = processAuthorName(author); Cursor authorId = getAuthorByName(names); @@ -1504,7 +1544,7 @@ public class CatalogueDBAdapter { initialValues.put(KEY_LOCATION, location); initialValues.put(KEY_READ_START, read_start); initialValues.put(KEY_READ_END, read_end); - initialValues.put(KEY_AUDIOBOOK, audiobook); + initialValues.put(KEY_FORMAT, format); initialValues.put(KEY_SIGNED, signed); authorId.close(); @@ -1679,7 +1719,7 @@ public class CatalogueDBAdapter { * @param signed Is this copy signed * @return true if the note was successfully updated, false otherwise */ - public boolean updateBook(long rowId, String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, boolean audiobook, boolean signed) { + public boolean updateBook(long rowId, String author, String title, String isbn, String publisher, String date_published, float rating, String bookshelf, boolean read, String series, int pages, String series_num, String notes, String list_price, int anthology, String location, String read_start, String read_end, String format, boolean signed) { boolean success; ContentValues args = new ContentValues(); String[] names = processAuthorName(author); @@ -1708,7 +1748,7 @@ public class CatalogueDBAdapter { args.put(KEY_LOCATION, location); args.put(KEY_READ_START, read_start); args.put(KEY_READ_END, read_end); - args.put(KEY_AUDIOBOOK, audiobook); + args.put(KEY_FORMAT, format); args.put(KEY_SIGNED, signed); authorId.close(); diff --git a/src/com/eleybourn/bookcatalogue/FieldVisibility.java b/src/com/eleybourn/bookcatalogue/FieldVisibility.java index 69568b6..0216c64 100644 --- a/src/com/eleybourn/bookcatalogue/FieldVisibility.java +++ b/src/com/eleybourn/bookcatalogue/FieldVisibility.java @@ -60,13 +60,17 @@ public class FieldVisibility extends Activity { */ public void setupFields() { // The fields to show/hide - String[] fields = {"author", "title", "thumbnail", "isbn", "series", "series_num", "publisher", "date_published", - "bookshelf", "pages", "list_price", "read", "rating", "notes", "anthology", "location", "read_start", - "read_end", "audiobook", "signed"}; + String[] fields = {CatalogueDBAdapter.KEY_AUTHOR, CatalogueDBAdapter.KEY_TITLE, "thumbnail", + CatalogueDBAdapter.KEY_ISBN, CatalogueDBAdapter.KEY_SERIES, CatalogueDBAdapter.KEY_SERIES_NUM, + CatalogueDBAdapter.KEY_PUBLISHER, CatalogueDBAdapter.KEY_DATE_PUBLISHED, CatalogueDBAdapter.KEY_BOOKSHELF, + CatalogueDBAdapter.KEY_PAGES, CatalogueDBAdapter.KEY_LIST_PRICE, CatalogueDBAdapter.KEY_READ, + CatalogueDBAdapter.KEY_RATING, CatalogueDBAdapter.KEY_NOTES, CatalogueDBAdapter.KEY_ANTHOLOGY, + CatalogueDBAdapter.KEY_LOCATION, CatalogueDBAdapter.KEY_READ_START, CatalogueDBAdapter.KEY_READ_END, + CatalogueDBAdapter.KEY_FORMAT, CatalogueDBAdapter.KEY_SIGNED}; int[] fieldRs = {R.string.author, R.string.title, R.string.thumbnail, R.string.isbn, R.string.series, R.string.series_num, R.string.publisher, R.string.date_published, R.string.bookshelf, R.string.pages, R.string.list_price, R.string.read, R.string.rating, R.string.notes, R.string.anthology, R.string.location, - R.string.read_start, R.string.read_end, R.string.audiobook, R.string.signed}; + R.string.read_start, R.string.read_end, R.string.format, R.string.signed}; boolean[] compulsary = {true, true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false};