Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #353 from Grunthos/master

4.0.6 release
  • Loading branch information...
commit 0d673d0b1aa69be472c6648f820d8ee32df85a65 2 parents b776a4a + b08a9fe
@eleybourn authored
View
2  AndroidManifest.xml
@@ -2,7 +2,7 @@
<!-- android:installLocation="preferExternal" when building with API > 4 -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eleybourn.bookcatalogue"
- android:installLocation="preferExternal" android:versionName="4.0.6" android:versionCode="86">
+ android:installLocation="preferExternal" android:versionName="4.0.6" android:versionCode="88">
<application android:name=".BookCatalogueApp" android:label="@string/app_name" android:icon="@drawable/ic_launcher2" >
<provider android:name=".SearchSuggestionProvider" android:authorities="com.eleybourn.bookcatalogue.SearchSuggestionProvider" />
<service android:enabled="true" android:name=".BcQueueManager" />
View
8 README
@@ -41,13 +41,21 @@ Features include;
case. e.g. "The murder on the links" becomes "Murder on the Links, The"
* Using ISBN or Barcode scanning will also download a thumbnail (if available)
+new in 4.0.6
+* When adding books, scanning or typing an existing ISBN allows you the option to edit the book.
+* Allow ASINs to be manually entered as well as ISBNs
+* German translation updates
+* Bug fixes when cropping cover images
+
new in 4.0.5
* fix bug when updating books
+
new in 4.0.4
* search now searches series and anthology data
* allows non-numeric data entry in series position
* better sorting of leading numerics in series position
* various esoteric bugs fixed
+
new in 4.0.3
* ISBNs are now validated when searching or scanning (new beep sound and related preference)
* Loaned & Not Loaned list now includes all books
View
19 src/com/eleybourn/bookcatalogue/BookCatalogueApp.java
@@ -74,8 +74,8 @@
/** Not sure this is a good idea. Stores the Application context once created */
public static Context context = null;
- /** Flag indicating the current database has a broken unicode collation */
- private static Boolean mUnicodeBroken = null;
+ /** Flag indicating the collation we use in the current database is case-sensitive */
+ private static Boolean mCollationCaseSensitive = null;
/** Used to sent notifications regarding tasks */
private static NotificationManager mNotifier;
@@ -114,17 +114,18 @@ public void onCreate() {
}
/**
- * Check if sqlite unicode collation is broken (ie. case sensitive); cache the result.
- * This bug was introduced in ICS and present in 4.0-4.0.3, at least.
+ * Check if sqlite collation is case sensitive; cache the result.
+ * This bug was introduced in ICS and present in 4.0-4.0.3, at least that meant that
+ * UNICODE collation became CS. We now use a LOCALIZED Collation, but still check if CI.
*
* @param db Any sqlite database connection
*
- * @return Flag indicating 'Collate UNICODE' is broken.
+ * @return Flag indicating 'Collate <our-collation>' is broken.
*/
- public static boolean isUnicodeCaseSensitive(SQLiteDatabase db) {
- if (mUnicodeBroken == null)
- mUnicodeBroken = UnicodeBroken.isCaseSensitive(db);
- return mUnicodeBroken;
+ public static boolean isCollationCaseSensitive(SQLiteDatabase db) {
+ if (mCollationCaseSensitive == null)
+ mCollationCaseSensitive = CollationCaseSensitive.isCaseSensitive(db);
+ return mCollationCaseSensitive;
}
// /**
View
68 src/com/eleybourn/bookcatalogue/BookISBNSearch.java
@@ -47,7 +47,7 @@
* It currently only searches Google Books, but Amazon will be coming soon.
*/
public class BookISBNSearch extends ActivityWithTasks {
- private static final int CREATE_BOOK = 0;
+ //private static final int CREATE_BOOK = 0;
public static final String BY = "by";
// private static Integer mIdCounter = 0;
@@ -394,7 +394,9 @@ protected void go(String isbn, String author, String title) {
try {
if (isbn != null && !isbn.equals("")) {
- final boolean allowAsin = ((CheckBox) BookISBNSearch.this.findViewById(R.id.asinCheckbox) ).isChecked();
+ // If the layout has an 'Allow ASIN' checkbox, see if it is checked.
+ final CheckBox allowAsinCb = (CheckBox) BookISBNSearch.this.findViewById(R.id.asinCheckbox);
+ final boolean allowAsin = allowAsinCb != null ? allowAsinCb.isChecked() : false;
if (!IsbnUtils.isValid(isbn) && (!allowAsin || !AsinUtils.isValid(isbn) ) ) {
int msg;
@@ -414,32 +416,40 @@ protected void go(String isbn, String author, String title) {
startScannerActivity();
}
return;
- } else if (mDbHelper.checkIsbnExists(isbn)) {
- // Verify - this can be a dangerous operation
- AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage(R.string.duplicate_book_message).create();
- alertDialog.setTitle(R.string.duplicate_book_title);
- alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
- alertDialog.setButton(this.getResources().getString(R.string.ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- doSearchBook();
- return;
- }
- });
- alertDialog.setButton2(this.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- //do nothing
- if (mMode == MODE_SCAN) {
- // reset the now-discarded details
- mIsbn = "";
- mAuthor = "";
- mTitle = "";
- startScannerActivity();
+ } else {
+ final long existingId = mDbHelper.getIdFromIsbn(isbn);
+ if (existingId > 0) {
+ // Verify - this can be a dangerous operation
+ AlertDialog alertDialog = new AlertDialog.Builder(this).setMessage(R.string.duplicate_book_message).create();
+ alertDialog.setTitle(R.string.duplicate_book_title);
+ alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
+ alertDialog.setButton(this.getResources().getString(R.string.add), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ doSearchBook();
+ return;
}
- return;
- }
- });
- alertDialog.show();
- return;
+ });
+ alertDialog.setButton3(this.getResources().getString(R.string.edit_book), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ BookEdit.editBook(BookISBNSearch.this, existingId, BookEdit.TAB_EDIT);
+ }
+ });
+ alertDialog.setButton2(this.getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ //do nothing
+ if (mMode == MODE_SCAN) {
+ // reset the now-discarded details
+ mIsbn = "";
+ mAuthor = "";
+ mTitle = "";
+ startScannerActivity();
+ }
+ return;
+ }
+ });
+ alertDialog.show();
+ return;
+ }
}
}
} catch (Exception e) {
@@ -560,7 +570,7 @@ public String convertDate(String date) {
private void createBook(Bundle book) {
Intent i = new Intent(this, BookEdit.class);
i.putExtra("bookData", book);
- startActivityForResult(i, CREATE_BOOK);
+ startActivityForResult(i, R.id.ACTIVITY_EDIT_BOOK);
//dismissProgress();
}
@@ -594,7 +604,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent intent)
finish();
}
break;
- case CREATE_BOOK:
+ case R.id.ACTIVITY_EDIT_BOOK:
if (intent != null)
mLastBookIntent = intent;
View
40 src/com/eleybourn/bookcatalogue/CatalogueDBAdapter.java
@@ -132,8 +132,13 @@
// We tried 'Collate UNICODE' but it seemed to be case sensitive. We ended
// up with 'Ursula Le Guin' and 'Ursula le Guin'.
+ //
+ // We now use Collate LOCALE and check to see if it is case sensitive. We *hope* in the
+ // future Android will add LOCALE_CI (or equivalent).
+ //
//public static final String COLLATION = "Collate NOCASE";
- public static final String COLLATION = " Collate UNICODE ";
+ //public static final String COLLATION = " Collate UNICODE ";
+ public static final String COLLATION = " Collate LOCALIZED "; // NOTE: Important to have start/end spaces!
public static final String[] EMPTY_STRNG_ARRAY = new String[] {};
@@ -517,7 +522,7 @@ private static String getBookFields(String alias, String idName) {
// + " LEFT OUTER JOIN " + DB_TB_SERIES + " s ON (s." + KEY_ROWID + "=w." + KEY_SERIES_ID + ") ";
//TODO: Update database version RELEASE: Update database version
- public static final int DATABASE_VERSION = 77;
+ public static final int DATABASE_VERSION = 78;
private TableInfo mBooksInfo = null;
@@ -1494,8 +1499,14 @@ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
if (curVersion == 76) {
//do nothing
curVersion++;
+ }
+ if (curVersion == 77) {
+ //do nothing
+ curVersion++;
message += "New in v4.0.6\n\n";
- message += "* Allow ASINs to be entered manually as well as ISBNs\n\n";
+ message += "* When adding books, scanning or typing an existing ISBN allows you the option to edit the book.\n";
+ message += "* Allow ASINs to be entered manually as well as ISBNs\n";
+ message += "* German translation updates (Robert Wetzlmayr)\n";
}
// Rebuild all indices
@@ -2810,19 +2821,28 @@ public long getBookIdFromUuid(String uuid) {
return 0L;
}
}
+
+ private SynchronizedStatement mGetIdFromIsbnStmt = null;
+ /**
+ *
+ * @param isbn The isbn to search by
+ * @return boolean indicating ISBN already in DB
+ */
+ public long getIdFromIsbn(String isbn) {
+ if (mGetIdFromIsbnStmt == null) {
+ mGetIdFromIsbnStmt = mStatements.add("mGetIdFromIsbnStmt", "Select Coalesce(max(" + KEY_ROWID + "), -1) From " + DB_TB_BOOKS + " Where Upper(" + KEY_ISBN + ") = Upper(?)");
+ }
+ mGetIdFromIsbnStmt.bindString(1, isbn);
+ return mGetIdFromIsbnStmt.simpleQueryForLong();
+ }
- private SynchronizedStatement mCheckIsbnExistsStmt = null;
/**
*
* @param isbn The isbn to search by
* @return boolean indicating ISBN already in DB
*/
public boolean checkIsbnExists(String isbn) {
- if (mCheckIsbnExistsStmt == null) {
- mCheckIsbnExistsStmt = mStatements.add("mCheckIsbnExistsStmt", "Select Count(*) From " + DB_TB_BOOKS + " Where Upper(" + KEY_ISBN + ") = Upper(?)");
- }
- mCheckIsbnExistsStmt.bindString(1, isbn);
- return mCheckIsbnExistsStmt.simpleQueryForLong() > 0;
+ return getIdFromIsbn(isbn) > 0;
}
/**
@@ -3579,7 +3599,7 @@ public Cursor fetchAllAuthorsByBook(long rowId) {
// Hash to *try* to avoid duplicates
HashSet<String> foundSoFar = new HashSet<String>();
ArrayList<String> list = new ArrayList<String>();
- Cursor c = mDb.rawQuery("Select distinct " + KEY_FORMAT + " from " + DB_TB_BOOKS + " Order by lower(" + KEY_FORMAT + ") collate UNICODE");
+ Cursor c = mDb.rawQuery("Select distinct " + KEY_FORMAT + " from " + DB_TB_BOOKS + " Order by lower(" + KEY_FORMAT + ") " + COLLATION);
try {
while (c.moveToNext()) {
String name = c.getString(0);
View
42 src/com/eleybourn/bookcatalogue/CollationCaseSensitive.java
@@ -0,0 +1,42 @@
+package com.eleybourn.bookcatalogue;
+
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+/**
+ * Class to detect if collation implementations are case sensitive.
+ * This was built because ICS broke the UNICODE collation (making it CS) and we needed
+ * to check for collation case-sensitivity.
+ *
+ * This bug was introduced in ICS and present in 4.0-4.0.3, at least.
+ *
+ * Now the code has been generalized to allow for arbitrary changes to choice of collation.
+ *
+ * @author Philip Warner
+ */
+public class CollationCaseSensitive {
+ public static boolean isCaseSensitive(SQLiteDatabase db) {
+ Cursor c = null;
+
+ // Drop and create table
+ db.execSQL("Drop Table If Exists collation_cs_check");
+ db.execSQL("Create Table collation_cs_check (t text, i int)");
+ try {
+ // Row that *should* be returned first assuming 'a' <=> 'A'
+ db.execSQL("insert into collation_cs_check values ('a', 1)");
+ // Row that *should* be returned second assuming 'a' <=> 'A'; will be returned first if 'A' < 'a'.
+ db.execSQL("insert into collation_cs_check values ('A', 2)");
+ c = db.rawQuery("Select t, i from collation_cs_check order by t " + CatalogueDBAdapter.COLLATION + ", i", new String[] {});
+ c.moveToFirst();
+ String s = c.getString(0);
+ return !s.equals("a");
+ } finally {
+ // Cleanup
+ try {
+ if (c != null)
+ c.close();
+ } catch (Exception e) {}
+ try { db.execSQL("Drop Table If Exists collation_cs_check"); } catch (Exception e) {}
+ }
+ }
+}
View
17 src/com/eleybourn/bookcatalogue/CropCropImage.java
@@ -183,9 +183,11 @@ public void run() {
mHandler.post(new Runnable() {
public void run() {
if (b != mBitmap && b != null) {
- mImageView.setImageBitmapResetBase(b, true);
- mBitmap.recycle();
+ // Do not recycle until mBitmap has been set to the new bitmap!
+ Bitmap toRecycle = mBitmap;
mBitmap = b;
+ mImageView.setImageBitmapResetBase(mBitmap, true);
+ toRecycle.recycle();
}
if (mImageView.getScale() == 1F) {
mImageView.center(true, true);
@@ -388,14 +390,17 @@ private void saveOutput(Bitmap croppedImage) {
@Override
protected void onPause() {
- super.onPause();
- CropBitmapManager.instance().cancelThreadDecoding(mDecodingThreads);
- mBitmap.recycle();
+ super.onPause();
+ CropBitmapManager.instance().cancelThreadDecoding(mDecodingThreads);
+ // DO NOT RECYCLE HERE; will leave mBitmap unusable after a resume.
+ //mBitmap.recycle();
}
@Override
protected void onDestroy() {
- super.onDestroy();
+ super.onDestroy();
+ if (mBitmap != null && !mBitmap.isRecycled())
+ mBitmap.recycle();
}
View
4 src/com/eleybourn/bookcatalogue/SearchCatalogue.java
@@ -185,8 +185,8 @@ private void doSearch() {
long t0 = System.currentTimeMillis();
//BooksCursor c = mDbHelper.fetchAllBooks(""/*order*/, ""/*bookshelf*/,
- // "(" + CatalogueDBAdapter.KEY_FAMILY_NAME + " like '%" + author + "%' Collate UNICODE or " + CatalogueDBAdapter.KEY_GIVEN_NAMES + " like '%" + author + "%' Collate UNICODE)",
- // "b." + CatalogueDBAdapter.KEY_TITLE + " like '%" + title + "%' Collate UNICODE",
+ // "(" + CatalogueDBAdapter.KEY_FAMILY_NAME + " like '%" + author + "%' " + CatalogueDBAdapter.COLLATION + " or " + CatalogueDBAdapter.KEY_GIVEN_NAMES + " like '%" + author + "%' " + CatalogueDBAdapter.COLLATION + ")",
+ // "b." + CatalogueDBAdapter.KEY_TITLE + " like '%" + title + "%' " + CatalogueDBAdapter.COLLATION + ",
// ""/*searchText*/, ""/*loaned_to*/, ""/*seriesName*/);
// Get the cursor
View
39 src/com/eleybourn/bookcatalogue/UnicodeBroken.java
@@ -1,39 +0,0 @@
-package com.eleybourn.bookcatalogue;
-
-import android.database.Cursor;
-import android.database.sqlite.SQLiteDatabase;
-
-/**
- * Class to detect broken implementations of UNICODE collation
- * in SQLite; (ie. case sensitive).
- *
- * This bug was introduced in ICS and present in 4.0-4.0.3, at least.
- *
- * @author Philip Warner
- */
-public class UnicodeBroken {
- public static boolean isCaseSensitive(SQLiteDatabase db) {
- Cursor c = null;
-
- // Drop and create table
- db.execSQL("Drop Table If Exists unicode_broken");
- db.execSQL("Create Table unicode_broken (t text, i int)");
- try {
- // Row that *should* be returned first assuming 'a' <=> 'A'
- db.execSQL("insert into unicode_broken values ('a', 1)");
- // Row that *should* be returned second assuming 'a' <=> 'A'; will be returned first if 'A' < 'a'.
- db.execSQL("insert into unicode_broken values ('A', 2)");
- c = db.rawQuery("Select t, i from unicode_broken order by t collate UNICODE, i", new String[] {});
- c.moveToFirst();
- String s = c.getString(0);
- return !s.equals("a");
- } finally {
- // Cleanup
- try {
- if (c != null)
- c.close();
- } catch (Exception e) {}
- try { db.execSQL("Drop Table If Exists unicode_broken"); } catch (Exception e) {}
- }
- }
-}
View
43 src/com/eleybourn/bookcatalogue/booklist/BooklistBuilder.java
@@ -793,8 +793,10 @@ public void build(int preferredState, long markId, String bookshelf, String auth
sql += " where " + where.toString();
long t1 = System.currentTimeMillis();
- // Check if the UNICODE collation is case sensitive; bug introduced in ICS
- boolean unicodeIsCs = BookCatalogueApp.isUnicodeCaseSensitive(mDb.getUnderlyingDatabase());
+ // Check if the collation we use is case sensitive; bug introduced in ICS was to make UNICODE not CI.
+ // Due to bugs in other language sorting, we are now forced to use a different collation anyway, but
+ // we still check if it is CI.
+ boolean collationIsCs = BookCatalogueApp.isCollationCaseSensitive(mDb.getUnderlyingDatabase());
// List of column names appropriate for 'Order By' clause
String sortColNameList;
@@ -809,15 +811,15 @@ public void build(int preferredState, long markId, String bookshelf, String auth
for (SortedDomainInfo sdi: sort) {
indexCols.append(sdi.domain.name);
if (sdi.domain.type.toLowerCase().equals("text")) {
- indexCols.append(" Collate UNICODE");
+ indexCols.append(CatalogueDBAdapter.COLLATION);
- // *If* UNICODE is case-sensitive, handle it.
- if (unicodeIsCs)
+ // *If* collations is case-sensitive, handle it.
+ if (collationIsCs)
sortCols.append("lower(");
sortCols.append(sdi.domain.name);
- if (unicodeIsCs)
+ if (collationIsCs)
sortCols.append(")");
- sortCols.append(" Collate UNICODE");
+ sortCols.append(CatalogueDBAdapter.COLLATION);
} else {
sortCols.append(sdi.domain.name);
}
@@ -840,7 +842,8 @@ public void build(int preferredState, long markId, String bookshelf, String auth
final StringBuilder groupCols = new StringBuilder();;
for (DomainDefinition d: group) {
groupCols.append(d.name);
- groupCols.append(" Collate UNICODE, ");
+ groupCols.append(CatalogueDBAdapter.COLLATION);
+ groupCols.append(", ");
}
groupCols.append( DOM_LEVEL.name );
mGroupColumnList = groupCols.toString();
@@ -854,7 +857,7 @@ public void build(int preferredState, long markId, String bookshelf, String auth
String ix3Sql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + mGroupColumnList + ")";
String ix3aSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + DOM_LEVEL + ", " + mGroupColumnList + ")";
String ix3bSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + mGroupColumnList + ", " + DOM_LEVEL + ")";
- String ix3cSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + mGroupColumnList + ", " + DOM_ROOT_KEY + " Collate UNICODE)";
+ String ix3cSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + mGroupColumnList + ", " + DOM_ROOT_KEY + CatalogueDBAdapter.COLLATION + ")";
String ix3dSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + DOM_LEVEL + ", " + mGroupColumnList + ", " + DOM_ROOT_KEY + ")";
String ix3eSql = "Create Index " + mListTable + "_IX3 on " + mListTable + "(" + mGroupColumnList + ", " + DOM_ROOT_KEY + "," + DOM_LEVEL + ")";
String ix4Sql = "Create Index " + mListTable + "_IX4 on " + mListTable + "(" + DOM_LEVEL + "," + DOM_EXPANDED + "," + DOM_ROOT_KEY + ")";
@@ -897,7 +900,7 @@ public void build(int preferredState, long markId, String bookshelf, String auth
if (!collatedCols.equals(""))
collatedCols += ",";
cols += ",\n " + d.name;
- collatedCols += "\n " + d.name + " Collate UNICODE";
+ collatedCols += "\n " + d.name + CatalogueDBAdapter.COLLATION;
}
// Construct the summarization statement for this group
sql = "Insert Into " + mListTable + "(\n " + DOM_LEVEL + ",\n " + DOM_KIND +
@@ -906,7 +909,7 @@ public void build(int preferredState, long markId, String bookshelf, String auth
"\n select " + levelId + " as " + DOM_LEVEL + ",\n " + g.kind + " as " + DOM_KIND +
cols + "," + DOM_ROOT_KEY +
"\n from " + mListTable + "\n " + " where level = " + (levelId+1) +
- "\n Group by " + collatedCols + "," + DOM_ROOT_KEY + " Collate UNICODE";
+ "\n Group by " + collatedCols + "," + DOM_ROOT_KEY + CatalogueDBAdapter.COLLATION;
//"\n Group by " + DOM_LEVEL + ", " + DOM_KIND + collatedCols;
// Save, compile and run this statement
@@ -920,9 +923,9 @@ public void build(int preferredState, long markId, String bookshelf, String auth
SynchronizedStatement stmt;
long t3 = System.currentTimeMillis();
// Build an index if it will help sorting
- // - *If* UNICODE is case-sensitive, don't bother with index, since everything is wrapped in lower().
+ // - *If* collation is case-sensitive, don't bother with index, since everything is wrapped in lower().
// ENHANCE: ICS UNICODE: Consider adding a duplicate _lc (lower case) column to the SUMMARY table. Ugh.
- if (!unicodeIsCs) {
+ if (!collationIsCs) {
stmt = mStatements.add("ix1", ix1Sql);
mLevelBuildStmts.add(stmt);
stmt.execute();
@@ -1751,7 +1754,7 @@ public void finalize() {
// final StringBuilder sortCols = new StringBuilder();
// for (DomainDefinition d: sort) {
// sortCols.append(d.name);
-// sortCols.append(" Collate UNICODE, ");
+// sortCols.append(CatalogueDBAdapter.COLLATION + ", ");
// }
// sortCols.append(DOM_LEVEL.name);
// mSortColumnList = sortCols.toString();
@@ -1762,7 +1765,7 @@ public void finalize() {
// final StringBuilder groupCols = new StringBuilder();;
// for (DomainDefinition d: group) {
// groupCols.append(d.name);
-// groupCols.append(" Collate UNICODE, ");
+// groupCols.append(CatalogueDBAdapter.COLLATION + ", ");
// }
// groupCols.append( DOM_LEVEL.name );
// mGroupColumnList = groupCols.toString();
@@ -1773,7 +1776,7 @@ public void finalize() {
// final StringBuilder keyCols = new StringBuilder();;
// for (DomainDefinition d: keys) {
// keyCols.append(d.name);
-// keyCols.append(" Collate UNICODE, ");
+// keyCols.append(CatalogueDBAdapter.COLLATION + ", ");
// }
// keyCols.append( DOM_LEVEL.name );
// mKeyColumnList = keyCols.toString();
@@ -1844,7 +1847,7 @@ public void finalize() {
// insertSql += ", " + d;
// valuesSql += ", new." + d;
// if (summary.getKeys().contains(d))
-// conditionSql += " and l." + d + " = new." + d + " Collate UNICODE\n";
+// conditionSql += " and l." + d + " = new." + d + CatalogueDBAdapter.COLLATION + "\n";
// }
// //insertSql += ")\n Select " + valuesSql + " Where not exists(Select 1 From " + mListTable + " l where " + conditionSql + ")";
// //tgLines[i] = insertSql;
@@ -1926,8 +1929,8 @@ public void finalize() {
// if (!collatedCols.equals(""))
// collatedCols += ",";
// cols += ",\n " + d.name;
-// //collatedCols += ",\n " + d.name + " Collate UNICODE";
-// collatedCols += "\n " + d.name + " Collate UNICODE";
+// //collatedCols += ",\n " + d.name + CatalogueDBAdapter.COLLATION;
+// collatedCols += "\n " + d.name + CatalogueDBAdapter.COLLATION;
// }
// sql = "Insert Into " + mListTable + "(\n " + DOM_LEVEL + ",\n " + DOM_KIND +
// //",\n " + DOM_PARENT_KEY +
@@ -1937,7 +1940,7 @@ public void finalize() {
// //l.getKeyExpression() +
// cols + "," + DOM_ROOT_KEY +
// "\n from " + mListTable + "\n " + " where level = " + (levelId+1) +
-// "\n Group by " + collatedCols + "," + DOM_ROOT_KEY + " Collate UNICODE";
+// "\n Group by " + collatedCols + "," + DOM_ROOT_KEY + CatalogueDBAdapter.COLLATION;
// //"\n Group by " + DOM_LEVEL + ", " + DOM_KIND + collatedCols;
//
// SQLiteStatement stmt = mStatements.add("L" + i, sql);
View
5 src/com/eleybourn/bookcatalogue/database/DbSync.java
@@ -422,7 +422,8 @@ public Cursor query(String table, String[] columns, String selection, String[] s
}
/**
- * Locking-aware wrapper for underlying database method.
+ * Locking-aware wrapper for underlying database method; actually
+ * calls insertOrThrow since this method also throws exceptions
*
* @param sql
* @param selectionArgs
@@ -437,7 +438,7 @@ public long insert(String table, String nullColumnHack, ContentValues values) {
l = mSync.getExclusiveLock();
try {
- return mDb.insert(table, nullColumnHack, values);
+ return mDb.insertOrThrow(table, nullColumnHack, values);
} finally {
if (l != null)
l.unlock();
Please sign in to comment.
Something went wrong with that request. Please try again.