diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..380b02b
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Search-View-Lab
\ No newline at end of file
diff --git a/.idea/Search-View-Lab.iml b/.idea/Search-View-Lab.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/Search-View-Lab.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..9a8b7e5
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..9cc0135
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+ Android Lint
+
+
+ Control flow issues
+
+
+ Error handling
+
+
+ Naming conventions
+
+
+ XML
+
+
+
+
+ Abstraction issues
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Users\USER\AppData\Roaming\Subversion
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..ad4618d
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..c34b21f
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,386 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ localhost
+ 5050
+
+
+
+
+
+
+ 1455580409362
+
+ 1455580409362
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/.name b/starter-code/.idea/.name
new file mode 100644
index 0000000..5e37776
--- /dev/null
+++ b/starter-code/.idea/.name
@@ -0,0 +1 @@
+starter-code
\ No newline at end of file
diff --git a/starter-code/.idea/compiler.xml b/starter-code/.idea/compiler.xml
new file mode 100644
index 0000000..9a8b7e5
--- /dev/null
+++ b/starter-code/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/copyright/profiles_settings.xml b/starter-code/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/starter-code/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/misc.xml b/starter-code/.idea/misc.xml
new file mode 100644
index 0000000..9cc0135
--- /dev/null
+++ b/starter-code/.idea/misc.xml
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
+
+ Android Lint
+
+
+ Control flow issues
+
+
+ Error handling
+
+
+ Naming conventions
+
+
+ XML
+
+
+
+
+ Abstraction issues
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Users\USER\AppData\Roaming\Subversion
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/modules.xml b/starter-code/.idea/modules.xml
new file mode 100644
index 0000000..5681c82
--- /dev/null
+++ b/starter-code/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/starter-code.iml b/starter-code/.idea/starter-code.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/starter-code/.idea/starter-code.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/vcs.xml b/starter-code/.idea/vcs.xml
new file mode 100644
index 0000000..6564d52
--- /dev/null
+++ b/starter-code/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/.idea/workspace.xml b/starter-code/.idea/workspace.xml
new file mode 100644
index 0000000..e501a27
--- /dev/null
+++ b/starter-code/.idea/workspace.xml
@@ -0,0 +1,251 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ localhost
+ 5050
+
+
+
+
+
+
+ 1455580497488
+
+ 1455580497488
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/.name b/starter-code/ShoppingListWithSearch/.idea/.name
new file mode 100644
index 0000000..10ee423
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/.name
@@ -0,0 +1 @@
+ShoppingListWithSearch
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/compiler.xml b/starter-code/ShoppingListWithSearch/.idea/compiler.xml
new file mode 100644
index 0000000..9a8b7e5
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/compiler.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/copyright/profiles_settings.xml b/starter-code/ShoppingListWithSearch/.idea/copyright/profiles_settings.xml
new file mode 100644
index 0000000..e7bedf3
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/copyright/profiles_settings.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/encodings.xml b/starter-code/ShoppingListWithSearch/.idea/encodings.xml
new file mode 100644
index 0000000..97626ba
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/gradle.xml b/starter-code/ShoppingListWithSearch/.idea/gradle.xml
new file mode 100644
index 0000000..fc132b2
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/misc.xml b/starter-code/ShoppingListWithSearch/.idea/misc.xml
new file mode 100644
index 0000000..515ab98
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/misc.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Android Lint
+
+
+ Control flow issues
+
+
+ Error handling
+
+
+ Naming conventions
+
+
+ XML
+
+
+
+
+ Abstraction issues
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ C:\Users\USER\AppData\Roaming\Subversion
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/modules.xml b/starter-code/ShoppingListWithSearch/.idea/modules.xml
new file mode 100644
index 0000000..27a232c
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/modules.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/runConfigurations.xml b/starter-code/ShoppingListWithSearch/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/.idea/vcs.xml b/starter-code/ShoppingListWithSearch/.idea/vcs.xml
new file mode 100644
index 0000000..6564d52
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/starter-code/ShoppingListWithSearch/app/src/main/AndroidManifest.xml b/starter-code/ShoppingListWithSearch/app/src/main/AndroidManifest.xml
index 77155bc..5cfdf83 100644
--- a/starter-code/ShoppingListWithSearch/app/src/main/AndroidManifest.xml
+++ b/starter-code/ShoppingListWithSearch/app/src/main/AndroidManifest.xml
@@ -1,6 +1,6 @@
-
+
-
-
+
-
+
+
+
+
+
+
diff --git a/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/MainActivity.java b/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/MainActivity.java
index ab2c048..fbb9986 100644
--- a/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/MainActivity.java
+++ b/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/MainActivity.java
@@ -1,14 +1,13 @@
package ly.generalassemb.drewmahrt.shoppinglistwithsearch;
import android.app.SearchManager;
-import android.content.Context;
+import android.content.Intent;
import android.database.Cursor;
-import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuInflater;
-import android.view.MenuItem;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
@@ -28,12 +27,30 @@ protected void onCreate(Bundle savedInstanceState) {
mCursorAdapter = new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1,cursor,new String[]{ShoppingSQLiteOpenHelper.COL_ITEM_NAME},new int[]{android.R.id.text1},0);
mShoppingListView.setAdapter(mCursorAdapter);
+
+ Intent intent = getIntent();
+ handleIntent(intent);
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ handleIntent(intent);
+ }
+
+ private void handleIntent(Intent intent) {
+ if(Intent.ACTION_SEARCH.equals(intent.getAction())){
+ String query = intent.getStringExtra(SearchManager.QUERY);
+ Cursor cursor = ShoppingSQLiteOpenHelper.getInstance(this).searchGroceries(query);
+ mCursorAdapter.swapCursor(cursor);
+ }
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater menuInflater = getMenuInflater();
menuInflater.inflate(R.menu.main_menu, menu);
-
- return super.onCreateOptionsMenu(menu);
+ SearchManager manager = (SearchManager) getSystemService(SEARCH_SERVICE);
+ SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
+ searchView.setSearchableInfo(manager.getSearchableInfo(getComponentName()));
+ return true;
}
}
diff --git a/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/ShoppingSQLiteOpenHelper.java b/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/ShoppingSQLiteOpenHelper.java
index f5a5974..2a531e9 100644
--- a/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/ShoppingSQLiteOpenHelper.java
+++ b/starter-code/ShoppingListWithSearch/app/src/main/java/ly/generalassemb/drewmahrt/shoppinglistwithsearch/ShoppingSQLiteOpenHelper.java
@@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.Arrays;
/**
* Created by drewmahrt on 12/28/15.
@@ -140,4 +141,18 @@ private void loadShoppingInfo(SQLiteDatabase db) throws IOException {
reader.close();
}
}
+
+ public Cursor searchGroceries(String query) {
+ SQLiteDatabase db = getReadableDatabase();
+ String selection = "";
+ for (int i = 1; i < SHOPPING_COLUMNS.length; i++) {
+ selection += SHOPPING_COLUMNS[i] + " LIKE ?";
+ if (i < SHOPPING_COLUMNS.length - 1) {
+ selection += " OR ";
+ }
+ }
+ Log.i(TAG, Arrays.toString(SHOPPING_COLUMNS));
+ String[] selectionArgs = {"%" + query + "%", "%" + query + "%", "%" + query + "%", "%" + query + "%"};
+ return db.query(SHOPPING_LIST_TABLE_NAME, SHOPPING_COLUMNS, selection, selectionArgs, null, null, null);
+ }
}
diff --git a/starter-code/ShoppingListWithSearch/app/src/main/res/xml/searchable.xml b/starter-code/ShoppingListWithSearch/app/src/main/res/xml/searchable.xml
new file mode 100644
index 0000000..fddbc13
--- /dev/null
+++ b/starter-code/ShoppingListWithSearch/app/src/main/res/xml/searchable.xml
@@ -0,0 +1,4 @@
+
+
\ No newline at end of file