diff --git a/Listify/app/src/main/AndroidManifest.xml b/Listify/app/src/main/AndroidManifest.xml
index ec91106..b23f14d 100644
--- a/Listify/app/src/main/AndroidManifest.xml
+++ b/Listify/app/src/main/AndroidManifest.xml
@@ -9,6 +9,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
+
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java
index f7294e7..f3961f5 100644
--- a/Listify/app/src/main/java/com/example/listify/MainActivity.java
+++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java
@@ -54,13 +54,12 @@ public class MainActivity extends AppCompatActivity {
searchButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
-// onSearchRequested();
Intent intent = new Intent(MainActivity.this, SearchResults.class);
- // Send them to the search results page
+
+ // Send user to SearchResults activity
startActivity(intent);
overridePendingTransition(R.anim.enter_from_left, R.anim.exit_from_left);
-
}
});
}
diff --git a/Listify/app/src/main/java/com/example/listify/SearchResults.java b/Listify/app/src/main/java/com/example/listify/SearchResults.java
index 61d44c8..8b2fa83 100644
--- a/Listify/app/src/main/java/com/example/listify/SearchResults.java
+++ b/Listify/app/src/main/java/com/example/listify/SearchResults.java
@@ -1,20 +1,14 @@
package com.example.listify;
-
-import android.app.SearchManager;
-import android.content.Intent;
+import android.media.Image;
import android.os.Bundle;
-
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import com.google.android.material.snackbar.Snackbar;
-
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
-
import android.view.View;
+import android.widget.EditText;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.SearchView;
-import android.widget.Toast;
public class SearchResults extends AppCompatActivity {
@@ -25,6 +19,7 @@ public class SearchResults extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
+ // Back button closes this activity and returns to previous activity (MainActivity)
ImageButton backButton = (ImageButton) findViewById(R.id.backToHomeButton);
backButton.setOnClickListener(new View.OnClickListener() {
@Override
@@ -34,23 +29,32 @@ public class SearchResults extends AppCompatActivity {
}
});
-// Intent intent = getIntent();
-// if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
-// String query = intent.getStringExtra(SearchManager.QUERY);
-// Toast.makeText(this, query, Toast.LENGTH_SHORT).show();
-// doSearch();
-// }
-
-
- SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
- SearchView searchView = (SearchView) findViewById(R.id.searchBar);
-// searchView.requestFocus();
+ // Set the search bar to be active and focused
+ final SearchView searchView = (SearchView) findViewById(R.id.searchBar);
searchView.setIconified(false);
+ // There's no easy way to find the close button on the search bar, so this is the way I'm
+ // doing it
+ int searchCloseButtonId = searchView.getContext().getResources().getIdentifier("android:id/search_close_btn", null, null);
+ ImageView closeButton = (ImageView) searchView.findViewById(searchCloseButtonId);
+ closeButton.setOnClickListener(new View.OnClickListener() {
+ // Override default close behavior to only clear the search text and the query
+ @Override
+ public void onClick(View v) {
+ // Finding the edit text of the search bar. Same as the method above
+ int searchTextId = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
+ EditText searchText = (EditText) searchView.findViewById(searchTextId);
+ searchText.setText("");
+ searchView.setQuery("", false);
+ }
+ });
+
+ // Handle searches
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
doSearch(query);
+ // TODO: Display the search results listview
return false;
}
@@ -60,25 +64,17 @@ public class SearchResults extends AppCompatActivity {
}
});
-// searchView.setSearchableInfo(searchManager.getSearchableInfo((getComponentName())));
-// searchView.setSubmitButtonEnabled(true);
-
-// FloatingActionButton fab = findViewById(R.id.fab);
-// fab.setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View view) {
-// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
-// .setAction("Action", null).show();
-// }
-// });
}
+ // Override default phone back button to add animation
@Override
public void onBackPressed() {
super.onBackPressed();
overridePendingTransition(R.anim.enter_from_right, R.anim.exit_from_right);
}
+ // TODO: This function will handle the search operation with the database and return
+ // a listview to caller to be displayed
private ListView doSearch(String query) {
System.out.println(query);
return null;
diff --git a/Listify/app/src/main/java/com/example/listify/SearchableActivity.java b/Listify/app/src/main/java/com/example/listify/SearchableActivity.java
deleted file mode 100644
index 40e1527..0000000
--- a/Listify/app/src/main/java/com/example/listify/SearchableActivity.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.example.listify;
-
-//import android.app.ListActivity;
-import android.app.SearchManager;
-import android.content.Intent;
-import android.os.Bundle;
-
-import com.google.android.material.floatingactionbutton.FloatingActionButton;
-import com.google.android.material.snackbar.Snackbar;
-
-import androidx.appcompat.app.AppCompatActivity;
-import androidx.appcompat.widget.Toolbar;
-
-import android.view.View;
-import android.widget.ImageButton;
-
-public class SearchableActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_searchable);
-
-// Toolbar toolbar = findViewById(R.id.toolbar);
-// setSupportActionBar(toolbar);
-//
-// FloatingActionButton fab = findViewById(R.id.fab);
-// fab.setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View view) {
-// Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
-// .setAction("Action", null).show();
-// }
-// });
-
- // Get search query and send it to doSearch()
- Intent intent = getIntent();
- if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- String query = intent.getStringExtra(SearchManager.QUERY);
- doSearch(query);
- }
- }
-
- // TODO: Implement database search and return results
- // https://developer.android.com/guide/topics/search/search-dialog#SearchingYourData
- public void doSearch(String query) {
- return;
- }
-}
\ No newline at end of file
diff --git a/Listify/app/src/main/res/layout/activity_search_results.xml b/Listify/app/src/main/res/layout/activity_search_results.xml
index c40ef26..457d2e1 100644
--- a/Listify/app/src/main/res/layout/activity_search_results.xml
+++ b/Listify/app/src/main/res/layout/activity_search_results.xml
@@ -41,14 +41,5 @@
-
-
-
-
-
-
-
-
-
-
+ \
\ No newline at end of file
diff --git a/Listify/app/src/main/res/layout/activity_searchable.xml b/Listify/app/src/main/res/layout/activity_searchable.xml
deleted file mode 100644
index bf5cae6..0000000
--- a/Listify/app/src/main/res/layout/activity_searchable.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Listify/app/src/main/res/layout/content_search.xml b/Listify/app/src/main/res/layout/content_search.xml
deleted file mode 100644
index 3691469..0000000
--- a/Listify/app/src/main/res/layout/content_search.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
\ No newline at end of file
diff --git a/Listify/app/src/main/res/xml/searchable.xml b/Listify/app/src/main/res/xml/searchable.xml
index 24584f4..b95cc73 100644
--- a/Listify/app/src/main/res/xml/searchable.xml
+++ b/Listify/app/src/main/res/xml/searchable.xml
@@ -1,5 +1,5 @@
+android:label="@string/app_label"
+android:hint="@string/search_hint" >
\ No newline at end of file