summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AndroidManifest.xml2
-rw-r--r--res/drawable-hdpi/action_search.pngbin0 -> 1759 bytes
-rw-r--r--res/drawable-mdpi/action_search.pngbin0 -> 1429 bytes
-rw-r--r--res/drawable-xhdpi/action_search.pngbin0 -> 2117 bytes
-rw-r--r--res/layout/searchlist.xml20
-rw-r--r--res/menu/podfetcher.xml1
-rw-r--r--res/values/ids.xml1
-rw-r--r--res/values/strings.xml5
-rw-r--r--src/de/danoeh/antennapod/activity/MainActivity.java3
-rw-r--r--src/de/danoeh/antennapod/activity/SearchActivity.java64
10 files changed, 94 insertions, 2 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ecacd413c..b11491905 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -130,7 +130,7 @@
<activity android:label="@string/about_pref" android:name=".activity.AboutActivity" android:theme="@style/Theme.Sherlock.Light.NoActionBar"></activity>
<activity android:label="@string/opml_import_label" android:name=".activity.OpmlImportActivity"></activity>
<activity android:label="@string/opml_import_label" android:name=".activity.OpmlFeedChooserActivity"></activity>
- <activity android:name=".activity.SearchActivity" android:theme="@style/Theme.Sherlock.Light.NoActionBar">
+ <activity android:name=".activity.SearchActivity" android:launchMode="singleTop" android:label="@string/search_results_label" android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.SEARCH"/>
</intent-filter>
diff --git a/res/drawable-hdpi/action_search.png b/res/drawable-hdpi/action_search.png
new file mode 100644
index 000000000..e6b704518
--- /dev/null
+++ b/res/drawable-hdpi/action_search.png
Binary files differ
diff --git a/res/drawable-mdpi/action_search.png b/res/drawable-mdpi/action_search.png
new file mode 100644
index 000000000..3aa644048
--- /dev/null
+++ b/res/drawable-mdpi/action_search.png
Binary files differ
diff --git a/res/drawable-xhdpi/action_search.png b/res/drawable-xhdpi/action_search.png
new file mode 100644
index 000000000..804420aee
--- /dev/null
+++ b/res/drawable-xhdpi/action_search.png
Binary files differ
diff --git a/res/layout/searchlist.xml b/res/layout/searchlist.xml
new file mode 100644
index 000000000..71d5e828d
--- /dev/null
+++ b/res/layout/searchlist.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <ListView
+ android:id="@id/android:list"
+ android:layout_width="match_parent"
+ android:layout_height="0dp"
+ android:layout_weight="1" />
+
+ <TextView
+ android:id="@id/android:empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center"
+ android:gravity="center" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/res/menu/podfetcher.xml b/res/menu/podfetcher.xml
index 9eccb775b..acb2e6f97 100644
--- a/res/menu/podfetcher.xml
+++ b/res/menu/podfetcher.xml
@@ -21,4 +21,5 @@
<item android:id="@+id/show_preferences" android:title="@string/settings_label" android:icon="@drawable/action_settings" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/show_player" android:title="@string/show_player_label" android:icon="@drawable/av_play" android:showAsAction="collapseActionView"></item>
<item android:id="@+id/opml_import" android:title="@string/opml_import_label" android:showAsAction="collapseActionView"></item>
+ <item android:id="@id/search_item" android:icon="@drawable/action_search" android:title="@string/search_label" android:showAsAction="collapseActionView"></item>
</menu>
diff --git a/res/values/ids.xml b/res/values/ids.xml
index f7cd4e62e..f3eae7671 100644
--- a/res/values/ids.xml
+++ b/res/values/ids.xml
@@ -7,5 +7,6 @@
<item type="id" name="clear_queue_item"/>
<item type="id" name="select_all_item"/>
<item type="id" name="deselect_all_item"/>
+ <item type="id" name="search_item"/>
</resources> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2a00375d0..839ab0c9e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -140,6 +140,11 @@
<string name="found_in_label">Found in:\u0020</string>
<string name="found_in_shownotes_label">Found in shownotes</string>
<string name="found_in_chapters_label">Found in chapters</string>
+ <string name="search_status_searching">Searching...</string>
+ <string name="search_status_no_results">No results were found</string>
+ <string name="search_results_label">Search results</string>
+ <string name="search_term_label">You searched:\u0020</string>
+ <string name="search_label">Search</string>
</resources> \ No newline at end of file
diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java
index 3423ddc21..ad325d0d2 100644
--- a/src/de/danoeh/antennapod/activity/MainActivity.java
+++ b/src/de/danoeh/antennapod/activity/MainActivity.java
@@ -108,6 +108,9 @@ public class MainActivity extends SherlockFragmentActivity {
case R.id.opml_import:
startActivity(new Intent(this, OpmlImportActivity.class));
return true;
+ case R.id.search_item:
+ onSearchRequested();
+ return true;
default:
return super.onOptionsItemSelected(item);
}
diff --git a/src/de/danoeh/antennapod/activity/SearchActivity.java b/src/de/danoeh/antennapod/activity/SearchActivity.java
index 9cc3b1717..8f05e533f 100644
--- a/src/de/danoeh/antennapod/activity/SearchActivity.java
+++ b/src/de/danoeh/antennapod/activity/SearchActivity.java
@@ -8,14 +8,23 @@ import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
+import android.view.View;
+import android.widget.ListView;
+import android.widget.TextView;
import com.actionbarsherlock.app.SherlockListActivity;
+import com.actionbarsherlock.view.Menu;
+import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
+import de.danoeh.antennapod.R;
import de.danoeh.antennapod.adapter.SearchlistAdapter;
-import de.danoeh.antennapod.feed.FeedComponent;
+import de.danoeh.antennapod.feed.Feed;
+import de.danoeh.antennapod.feed.FeedItem;
import de.danoeh.antennapod.feed.FeedSearcher;
import de.danoeh.antennapod.feed.SearchResult;
+import de.danoeh.antennapod.fragment.FeedlistFragment;
+import de.danoeh.antennapod.fragment.ItemlistFragment;
public class SearchActivity extends SherlockListActivity {
private static final String TAG = "SearchActivity";
@@ -23,22 +32,72 @@ public class SearchActivity extends SherlockListActivity {
private SearchlistAdapter searchAdapter;
private ArrayList<SearchResult> content;
+ private TextView txtvStatus;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ setContentView(R.layout.searchlist);
+ txtvStatus = (TextView) findViewById(android.R.id.empty);
if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
if (AppConfig.DEBUG)
Log.d(TAG, "Starting search");
String query = getIntent().getStringExtra(SearchManager.QUERY);
+ getSupportActionBar().setSubtitle(
+ getString(R.string.search_term_label) + query);
startSearch(query);
}
}
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ startActivity(new Intent(this, MainActivity.class));
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+ SearchResult selection = searchAdapter.getItem(position);
+ if (selection.getComponent().getClass() == Feed.class) {
+ Feed feed = (Feed) selection.getComponent();
+ Intent launchIntent = new Intent(this, FeedItemlistActivity.class);
+ launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED,
+ feed.getId());
+ startActivity(launchIntent);
+
+ } else if (selection.getComponent().getClass() == FeedItem.class) {
+ FeedItem item = (FeedItem) selection.getComponent();
+ Intent launchIntent = new Intent(this, ItemviewActivity.class);
+ launchIntent.putExtra(FeedlistFragment.EXTRA_SELECTED_FEED, item
+ .getFeed().getId());
+ launchIntent.putExtra(ItemlistFragment.EXTRA_SELECTED_FEEDITEM,
+ item.getId());
+ startActivity(launchIntent);
+ }
+ }
+
@SuppressLint({ "NewApi", "NewApi" })
private void startSearch(String query) {
AsyncTask<String, Void, ArrayList<SearchResult>> executor = new AsyncTask<String, Void, ArrayList<SearchResult>>() {
@Override
+ protected void onPreExecute() {
+ txtvStatus.setText(R.string.search_status_searching);
+ }
+
+ @Override
protected ArrayList<SearchResult> doInBackground(String... params) {
if (AppConfig.DEBUG)
Log.d(TAG, "Starting background work");
@@ -57,6 +116,9 @@ public class SearchActivity extends SherlockListActivity {
content);
getListView().setAdapter(searchAdapter);
searchAdapter.notifyDataSetChanged();
+ if (content.isEmpty()) {
+ txtvStatus.setText(R.string.search_status_no_results);
+ }
}