Users can now delete individual thumbnails by holding on the image and selecting delete.
parent
3df16e781f
commit
46ca46673e
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.eleybourn.bookcatalogue"
|
||||
android:versionName="2.4b" android:versionCode="26">
|
||||
android:versionName="2.4.2" android:versionCode="27">
|
||||
<application android:label="@string/app_name" android:icon="@drawable/logo_bc">
|
||||
<activity android:name=".BookCatalogue"
|
||||
android:label="@string/app_name">
|
||||
|
|
4
README
4
README
|
@ -41,6 +41,10 @@ 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 v2.4.2
|
||||
* You can now delete individual thumbnails by holding on the image and
|
||||
selecting delete.
|
||||
|
||||
New in v2.4
|
||||
* Adding books will now (finally) search Amazon
|
||||
* A field for list price has been included (Requested by Brenda)
|
||||
|
|
|
@ -96,4 +96,5 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="download_thumbs">Thumbnails are being downloaded in the background</string>
|
||||
<string name="search_fail">Searching for the book failed. Please check your network settings.</string>
|
||||
<string name="menu_delete_thumb">Delete Thumbnail</string>
|
||||
</resources>
|
||||
|
|
|
@ -1015,7 +1015,7 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
|
||||
|
|
|
@ -29,7 +29,10 @@ import android.database.Cursor;
|
|||
import android.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
|
@ -67,6 +70,8 @@ public class BookEditFields extends Activity {
|
|||
public static String ADDED_SERIES = "ADDED_SERIES";
|
||||
public static String ADDED_TITLE = "ADDED_TITLE";
|
||||
public static String ADDED_AUTHOR = "ADDED_AUTHOR";
|
||||
|
||||
private static final int DELETE_ID = 1;
|
||||
|
||||
protected void getRowId() {
|
||||
/* Get any information from the extras bundle */
|
||||
|
@ -160,6 +165,14 @@ public class BookEditFields extends Activity {
|
|||
}
|
||||
populateFields();
|
||||
|
||||
mImageView.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
||||
@Override
|
||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
|
||||
MenuItem delete = menu.add(0, DELETE_ID, 0, R.string.menu_delete_thumb);
|
||||
delete.setIcon(android.R.drawable.ic_menu_delete);
|
||||
}
|
||||
});
|
||||
|
||||
mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
saveState();
|
||||
|
@ -187,6 +200,42 @@ public class BookEditFields extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextItemSelected(MenuItem item) {
|
||||
switch(item.getItemId()) {
|
||||
case DELETE_ID:
|
||||
deleteThumbnail(mRowId);
|
||||
populateFields();
|
||||
return true;
|
||||
}
|
||||
return super.onContextItemSelected(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the provided thumbnail from the sdcard
|
||||
*
|
||||
* @param id The id of the book (and thumbnail) to delete
|
||||
*/
|
||||
private void deleteThumbnail(long id) {
|
||||
try {
|
||||
String tmpThumbFilename = Environment.getExternalStorageDirectory() + "/" + CatalogueDBAdapter.LOCATION + "/" + id + ".jpg";
|
||||
File thumb = new File(tmpThumbFilename);
|
||||
thumb.delete();
|
||||
|
||||
tmpThumbFilename = Environment.getExternalStorageDirectory() + "/" + CatalogueDBAdapter.LOCATION + "/tmp.jpg";
|
||||
thumb = new File(tmpThumbFilename);
|
||||
thumb.delete();
|
||||
} catch (Exception e) {
|
||||
// something has gone wrong.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will populate the forms elements in three different ways
|
||||
* 1. If a valid rowId exists it will populate the fields from the database
|
||||
* 2. If fields have been passed from another activity (e.g. ISBNSearch) it will populate the fields from the bundle
|
||||
* 3. It will leave the fields blank for new books.
|
||||
*/
|
||||
private void populateFields() {
|
||||
Bundle extras = getIntent().getExtras();
|
||||
if (mRowId == null) {
|
||||
|
@ -217,7 +266,12 @@ public class BookEditFields extends Activity {
|
|||
mPagesText.setText(book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_PAGES)));
|
||||
mConfirmButton.setText(R.string.confirm_save);
|
||||
String thumbFilename = Environment.getExternalStorageDirectory() + "/" + CatalogueDBAdapter.LOCATION + "/" + mRowId + ".jpg";
|
||||
mImageView.setImageBitmap(BitmapFactory.decodeFile(thumbFilename));
|
||||
File thumb = new File(thumbFilename);
|
||||
if (thumb.exists()) {
|
||||
mImageView.setImageBitmap(BitmapFactory.decodeFile(thumbFilename));
|
||||
} else {
|
||||
mImageView.setImageResource(android.R.drawable.ic_menu_help);
|
||||
}
|
||||
rating = book.getFloat(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_RATING));
|
||||
read = (book.getInt(book.getColumnIndex(CatalogueDBAdapter.KEY_READ))==0 ? false:true);
|
||||
notes = book.getString(book.getColumnIndexOrThrow(CatalogueDBAdapter.KEY_NOTES));
|
||||
|
@ -252,8 +306,13 @@ public class BookEditFields extends Activity {
|
|||
}
|
||||
mPagesText.setText(book[9]);
|
||||
mConfirmButton.setText(R.string.confirm_add);
|
||||
String tmpThumbFilename = Environment.getExternalStorageDirectory() + "/" + CatalogueDBAdapter.LOCATION + "/tmp.jpg";
|
||||
mImageView.setImageBitmap(BitmapFactory.decodeFile(tmpThumbFilename));
|
||||
String thumbFilename = Environment.getExternalStorageDirectory() + "/" + CatalogueDBAdapter.LOCATION + "/tmp.jpg";
|
||||
File thumb = new File(thumbFilename);
|
||||
if (thumb.exists()) {
|
||||
mImageView.setImageBitmap(BitmapFactory.decodeFile(thumbFilename));
|
||||
} else {
|
||||
mImageView.setImageResource(android.R.drawable.ic_menu_help);
|
||||
}
|
||||
} else {
|
||||
// Manual Add
|
||||
getParent().setTitle(this.getResources().getString(R.string.app_name) + ": " + this.getResources().getString(R.string.menu_insert));
|
||||
|
@ -271,16 +330,16 @@ public class BookEditFields extends Activity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
populateFields();
|
||||
}
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
populateFields();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will save a book into the database, by either updating or created a book.
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
package com.eleybourn.bookcatalogue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
@ -210,7 +209,7 @@ public class BookISBNSearch extends Activity {
|
|||
//Log.e("Book Catalogue", "SAX Parsing Error " + e.getMessage());
|
||||
} catch (SAXException e) {
|
||||
//Log.e("Book Catalogue", "SAX Exception " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
//Log.e("Book Catalogue", "SAX IO Exception " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
|
@ -250,7 +249,7 @@ public class BookISBNSearch extends Activity {
|
|||
//Log.e("Book Catalogue", "SAX Parsing Error " + e.getMessage());
|
||||
} catch (SAXException e) {
|
||||
//Log.e("Book Catalogue", "SAX Exception " + e.getMessage());
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
//Log.e("Book Catalogue", "SAX IO Exception " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -126,7 +126,7 @@ public class CatalogueDBAdapter {
|
|||
;
|
||||
|
||||
private final Context mCtx;
|
||||
private static final int DATABASE_VERSION = 30;
|
||||
private static final int DATABASE_VERSION = 31;
|
||||
|
||||
/**
|
||||
* This is a specific version of the SQLiteOpenHelper class. It handles onCreate and onUpgrade events
|
||||
|
@ -291,6 +291,11 @@ public class CatalogueDBAdapter {
|
|||
message += "* A field for list price has been included (Requested by Brenda)\n\n";
|
||||
message += "* You can bulk update the thumbnails for all books with ISBN's from the Admin page\n\n";
|
||||
}
|
||||
if (curVersion == 30) {
|
||||
//do nothing
|
||||
curVersion++;
|
||||
message += "* You can now delete individual thumbnails by holding on the image and selecting delete.\n\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -597,7 +602,7 @@ public class CatalogueDBAdapter {
|
|||
where +
|
||||
" ORDER BY a." + KEY_FAMILY_NAME + ", a." + KEY_GIVEN_NAMES;
|
||||
Cursor results = mDb.rawQuery(sql, null);
|
||||
int pos = getIntValue(results, 0)+1;
|
||||
int pos = getIntValue(results, 0);
|
||||
return pos;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue