diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 5627077e1..ed441e090 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -40,15 +40,16 @@
android:name=".activity.MainActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/app_name" >
-
-
-
-
-
-
+ android:value="de.danoeh.antennapod.activity.SearchActivity" />
+
+
+
+
+
+ android:value="de.danoeh.antennapod.activity.SearchActivity" />
+
-
+ android:value="de.danoeh.antennapod.activity.MiroGuideSearchActivity" />
+
-
diff --git a/res/xml/searchable.xml b/res/xml/searchable.xml
index 522bd9be5..ee73aca8d 100644
--- a/res/xml/searchable.xml
+++ b/res/xml/searchable.xml
@@ -1,5 +1,4 @@
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java b/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java
index 64e4f2d30..c53a4cc7b 100644
--- a/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java
+++ b/src/de/danoeh/antennapod/activity/FeedItemlistActivity.java
@@ -1,6 +1,9 @@
package de.danoeh.antennapod.activity;
import android.annotation.SuppressLint;
+import android.app.SearchManager;
+import android.app.SearchableInfo;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
@@ -10,6 +13,7 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.Menu;
@@ -113,6 +117,15 @@ public class FeedItemlistActivity extends ActionBarActivity {
MenuItemCompat.setShowAsAction(menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
.setIcon(drawables.getDrawable(0)),
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);
+ MenuItemCompat.setActionView(menu.findItem(R.id.search_item), new SearchView(this));
+
+ SearchManager searchManager =
+ (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
+ searchView.setIconifiedByDefault(true);
+
+ searchView.setSearchableInfo(
+ searchManager.getSearchableInfo(getComponentName()));
return FeedMenuHandler
.onCreateOptionsMenu(new MenuInflater(this), menu);
} else {
@@ -155,9 +168,6 @@ public class FeedItemlistActivity extends ActionBarActivity {
};
conDialog.createNewDialog().show();
break;
- case R.id.search_item:
- onSearchRequested();
- break;
case android.R.id.home:
Intent intent = new Intent(this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@ -185,4 +195,17 @@ public class FeedItemlistActivity extends ActionBarActivity {
}
}
+ @Override
+ public void startActivity(Intent intent) {
+ if (intent.getAction() != null &&
+ intent.getAction().equals(Intent.ACTION_SEARCH)) {
+ addSearchInformation(intent);
+ }
+ super.startActivity(intent);
+ }
+
+ private void addSearchInformation(Intent startIntent) {
+ startIntent.putExtra(SearchActivity.EXTRA_FEED_ID, feed.getId());
+ }
+
}
diff --git a/src/de/danoeh/antennapod/activity/ItemviewActivity.java b/src/de/danoeh/antennapod/activity/ItemviewActivity.java
index 43eea93e4..4c0fdfdba 100644
--- a/src/de/danoeh/antennapod/activity/ItemviewActivity.java
+++ b/src/de/danoeh/antennapod/activity/ItemviewActivity.java
@@ -65,6 +65,7 @@ public class ItemviewActivity extends ActionBarActivity {
@Override
public void onStop() {
super.onStop();
+ EventDistributor.getInstance().unregister(contentUpdate);
if (AppConfig.DEBUG)
Log.d(TAG, "Stopping Activity");
}
diff --git a/src/de/danoeh/antennapod/activity/MainActivity.java b/src/de/danoeh/antennapod/activity/MainActivity.java
index 92b56461c..20c53553b 100644
--- a/src/de/danoeh/antennapod/activity/MainActivity.java
+++ b/src/de/danoeh/antennapod/activity/MainActivity.java
@@ -2,15 +2,19 @@ package de.danoeh.antennapod.activity;
import java.util.ArrayList;
+import android.app.SearchManager;
+import android.app.SearchableInfo;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
+import android.support.v4.view.MenuItemCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.Menu;
@@ -150,9 +154,6 @@ public class MainActivity extends ActionBarActivity {
case R.id.show_player:
startActivity(PlaybackService.getPlayerActivityIntent(this));
return true;
- case R.id.search_item:
- onSearchRequested();
- return true;
case R.id.show_playback_history:
startActivity(new Intent(this, PlaybackHistoryActivity.class));
return true;
@@ -177,7 +178,18 @@ public class MainActivity extends ActionBarActivity {
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = new MenuInflater(this);
inflater.inflate(R.menu.main, menu);
- return true;
+
+ SearchManager searchManager =
+ (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
+ searchView.setIconifiedByDefault(true);
+
+ SearchableInfo info = searchManager.getSearchableInfo(getComponentName());
+ searchView.setSearchableInfo(
+ searchManager.getSearchableInfo(getComponentName()));
+
+
+ return true;
}
public static class TabsAdapter extends FragmentPagerAdapter implements
diff --git a/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java b/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java
index 99da9944f..40306e4da 100644
--- a/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java
+++ b/src/de/danoeh/antennapod/activity/MiroGuideMainActivity.java
@@ -1,11 +1,15 @@
package de.danoeh.antennapod.activity;
import android.annotation.SuppressLint;
+import android.app.SearchManager;
+import android.app.SearchableInfo;
+import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBarActivity;
+import android.support.v7.widget.SearchView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -44,6 +48,7 @@ public class MiroGuideMainActivity extends ActionBarActivity implements AdapterV
txtvStatus = (TextView) findViewById(android.R.id.empty);
listView = (ListView) findViewById(android.R.id.list);
listView.setOnItemClickListener(this);
+ listView.setEmptyView(txtvStatus);
}
@Override
@@ -129,6 +134,15 @@ public class MiroGuideMainActivity extends ActionBarActivity implements AdapterV
new int[]{R.attr.action_search})
.getDrawable(0)),
MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ MenuItemCompat.setActionView(menu.findItem(R.id.search_item), new SearchView(this));
+
+ SearchManager searchManager =
+ (SearchManager) getSystemService(Context.SEARCH_SERVICE);
+ SearchView searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.search_item));
+ searchView.setIconifiedByDefault(true);
+ searchView.setSearchableInfo(
+ searchManager.getSearchableInfo(getComponentName()));
+
return true;
}
@@ -138,9 +152,6 @@ public class MiroGuideMainActivity extends ActionBarActivity implements AdapterV
case android.R.id.home:
finish();
return true;
- case R.id.search_item:
- onSearchRequested();
- return true;
default:
return false;
}
diff --git a/src/de/danoeh/antennapod/activity/SearchActivity.java b/src/de/danoeh/antennapod/activity/SearchActivity.java
index b6bdab83c..257ae86ae 100644
--- a/src/de/danoeh/antennapod/activity/SearchActivity.java
+++ b/src/de/danoeh/antennapod/activity/SearchActivity.java
@@ -1,5 +1,6 @@
package de.danoeh.antennapod.activity;
+import java.util.ArrayList;
import java.util.List;
import android.annotation.SuppressLint;
@@ -36,7 +37,6 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.searchactivity.extra.feedId";
private SearchlistAdapter searchAdapter;
- private List content;
/**
* ID of the feed that is being searched or null if the search is global.
@@ -46,6 +46,7 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
private ListView listView;
private TextView txtvStatus;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(UserPreferences.getTheme());
@@ -57,6 +58,9 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
txtvStatus = (TextView) findViewById(android.R.id.empty);
listView.setOnItemClickListener(this);
+ searchAdapter = new SearchlistAdapter(this, 0, new ArrayList());
+ listView.setAdapter(searchAdapter);
+ listView.setEmptyView(txtvStatus);
}
@Override
@@ -69,11 +73,10 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
super.onResume();
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- Bundle extra = intent.getBundleExtra(SearchManager.APP_DATA);
- if (extra != null) {
+ if (intent.hasExtra(SearchActivity.EXTRA_FEED_ID)) {
if (AppConfig.DEBUG)
Log.d(TAG, "Found bundle extra");
- feedID = extra.getLong(EXTRA_FEED_ID);
+ feedID = intent.getLongExtra(SearchActivity.EXTRA_FEED_ID, 0);
}
if (AppConfig.DEBUG)
Log.d(TAG, "Starting search");
@@ -149,15 +152,16 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
if (AppConfig.DEBUG)
Log.d(TAG, "Found " + result.size()
+ " results");
- content = result;
- searchAdapter = new SearchlistAdapter(
- SearchActivity.this, 0, content);
- listView.setAdapter(searchAdapter);
+ searchAdapter.clear();
+ searchAdapter.addAll(result);
searchAdapter.notifyDataSetChanged();
- if (content.isEmpty()) {
- txtvStatus
- .setText(R.string.search_status_no_results);
+ txtvStatus
+ .setText(R.string.search_status_no_results);
+ if (!searchAdapter.isEmpty()) {
+ txtvStatus.setVisibility(View.GONE);
+ } else {
+ txtvStatus.setVisibility(View.VISIBLE);
}
}
});