Search menu button + beginning add by name menu button
parent
fba7a4af7f
commit
35d0d2730a
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 38 KiB |
Binary file not shown.
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 55 KiB |
|
@ -2,7 +2,8 @@
|
|||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5sp">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5sp">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:gravity="center_horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<EditText android:id="@+id/author"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/author"
|
||||
android:padding="10sp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
/>
|
||||
<EditText android:id="@+id/title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/title"
|
||||
android:padding="10sp"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
/>
|
||||
|
||||
<Button android:id="@+id/search"
|
||||
android:text="@string/search"
|
||||
android:layout_width="fill_parent"
|
||||
android:width="175sp"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<TextView android:id="@+id/isbn_search_status"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -216,4 +216,6 @@
|
|||
<string name="genre">Genre</string>
|
||||
<string name="auto_update">Would you like to automatically update the following fields now \n* Genre \n* Description \n* Thumbnails\n\n If you select Cancel you can always run this again from the Administration page</string>
|
||||
<string name="notset">Not Set</string>
|
||||
<string name="menu_search">Search Books</string>
|
||||
<string name="menu_insert_name">Add by Author/Title</string>
|
||||
</resources>
|
|
@ -87,6 +87,8 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
private static final int EDIT_BOOK = Menu.FIRST + 10;
|
||||
private static final int EDIT_BOOK_NOTES = Menu.FIRST + 11;
|
||||
private static final int EDIT_BOOK_FRIENDS = Menu.FIRST + 12;
|
||||
private static final int SEARCH = Menu.FIRST + 13;
|
||||
private static final int INSERT_NAME_ID = Menu.FIRST + 14;
|
||||
|
||||
public static String bookshelf = "All Books";
|
||||
private ArrayAdapter<String> spinnerAdapter;
|
||||
|
@ -1072,6 +1074,9 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
MenuItem insertISBN = menu.add(0, INSERT_ISBN_ID, 2, R.string.menu_insert_isbn);
|
||||
insertISBN.setIcon(android.R.drawable.ic_menu_zoom);
|
||||
|
||||
MenuItem insertName = menu.add(0, INSERT_NAME_ID, 2, R.string.menu_insert_name);
|
||||
insertName.setIcon(android.R.drawable.ic_menu_zoom);
|
||||
|
||||
if (expanded == true) {
|
||||
MenuItem collapse = menu.add(0, SORT_BY_AUTHOR_EXPANDED, 3, R.string.menu_sort_by_author_collapsed);
|
||||
collapse.setIcon(R.drawable.ic_menu_collapse);
|
||||
|
@ -1087,6 +1092,9 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
MenuItem admin = menu.add(0, ADMIN, 5, adminTitle);
|
||||
admin.setIcon(android.R.drawable.ic_menu_manage);
|
||||
|
||||
MenuItem search = menu.add(0, SEARCH, 4, R.string.menu_search);
|
||||
search.setIcon(android.R.drawable.ic_menu_search);
|
||||
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
|
@ -1110,7 +1118,7 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
createBook();
|
||||
return true;
|
||||
case INSERT_ISBN_ID:
|
||||
createBookISBN();
|
||||
createBookISBN("isbn");
|
||||
return true;
|
||||
case INSERT_BARCODE_ID:
|
||||
createBookScan();
|
||||
|
@ -1118,6 +1126,12 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
case ADMIN:
|
||||
adminPage();
|
||||
return true;
|
||||
case SEARCH:
|
||||
onSearchRequested();
|
||||
return true;
|
||||
case INSERT_NAME_ID:
|
||||
createBookISBN("name");
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onMenuItemSelected(featureId, item);
|
||||
|
@ -1363,8 +1377,9 @@ public class BookCatalogue extends ExpandableListActivity {
|
|||
/**
|
||||
* Load the Search by ISBN Activity
|
||||
*/
|
||||
private void createBookISBN() {
|
||||
private void createBookISBN(String by) {
|
||||
Intent i = new Intent(this, BookISBNSearch.class);
|
||||
i.putExtra(BookISBNSearch.BY, by);
|
||||
startActivityForResult(i, ACTIVITY_ISBN);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,11 @@ import android.widget.Toast;
|
|||
*/
|
||||
public class BookISBNSearch extends Activity {
|
||||
private static final int CREATE_BOOK = 0;
|
||||
public static final String BY = "by";
|
||||
|
||||
private EditText mIsbnText;
|
||||
private EditText mTitleText;
|
||||
private EditText mAuthorText;
|
||||
private TextView mIsbnStatus;
|
||||
private Button mConfirmButton;
|
||||
private CatalogueDBAdapter mDbHelper;
|
||||
|
@ -73,17 +76,18 @@ public class BookISBNSearch extends Activity {
|
|||
mDbHelper = new CatalogueDBAdapter(this);
|
||||
mDbHelper.open();
|
||||
|
||||
setContentView(R.layout.isbn_search);
|
||||
mIsbnText = (EditText) findViewById(R.id.isbn);
|
||||
mIsbnStatus = (TextView) findViewById(R.id.isbn_search_status);
|
||||
mConfirmButton = (Button) findViewById(R.id.search);
|
||||
isbn = extras.getString("isbn");
|
||||
String by = extras.getString(BY);
|
||||
|
||||
if (extras != null) {
|
||||
if (isbn != null) {
|
||||
//ISBN has been passed by another component
|
||||
isbn = extras.getString("isbn");
|
||||
mIsbnText.setText(isbn);
|
||||
go(isbn);
|
||||
} else {
|
||||
go(isbn, "", "");
|
||||
} else if (by.equals("isbn")) {
|
||||
setContentView(R.layout.isbn_search);
|
||||
mIsbnText = (EditText) findViewById(R.id.isbn);
|
||||
mIsbnStatus = (TextView) findViewById(R.id.isbn_search_status);
|
||||
mConfirmButton = (Button) findViewById(R.id.search);
|
||||
|
||||
// Set the number buttons
|
||||
Button button1 = (Button) findViewById(R.id.isbn_1);
|
||||
|
@ -122,7 +126,21 @@ public class BookISBNSearch extends Activity {
|
|||
mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
String mIsbn = mIsbnText.getText().toString();
|
||||
go(mIsbn);
|
||||
go(mIsbn, "", "");
|
||||
}
|
||||
});
|
||||
} else if (by.equals("name")) {
|
||||
setContentView(R.layout.name_search);
|
||||
mAuthorText = (EditText) findViewById(R.id.author);
|
||||
mTitleText = (EditText) findViewById(R.id.title);
|
||||
mIsbnStatus = (TextView) findViewById(R.id.isbn_search_status);
|
||||
mConfirmButton = (Button) findViewById(R.id.search);
|
||||
|
||||
mConfirmButton.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View view) {
|
||||
String mAuthor = mAuthorText.getText().toString();
|
||||
String mTitle = mTitleText.getText().toString();
|
||||
go("", mAuthor, mTitle);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -172,7 +190,7 @@ public class BookISBNSearch extends Activity {
|
|||
*
|
||||
* @param isbn The ISBN to search
|
||||
*/
|
||||
protected void go(String isbn) {
|
||||
protected void go(String isbn, String author, String title) {
|
||||
// If the book already exists, do not continue
|
||||
mConfirmButton.setEnabled(false);
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue