Added Miro Guide search

This commit is contained in:
daniel oeh 2012-08-02 22:05:46 +02:00
parent 2fd169fa99
commit bdbdc94448
6 changed files with 151 additions and 7 deletions

View File

@ -61,7 +61,9 @@
android:name="android.app.default_searchable"
android:value=".activity.SearchActivity" />
</activity>
<activity android:name="de.danoeh.antennapod.activity.ItemviewActivity" android:configChanges="keyboardHidden|orientation"/>
<activity
android:name="de.danoeh.antennapod.activity.ItemviewActivity"
android:configChanges="keyboardHidden|orientation" />
<activity
android:name="de.danoeh.antennapod.activity.DownloadActivity"
android:label="@string/downloads_label" />
@ -98,7 +100,7 @@
</intent-filter>
</receiver>
<activity android:name=".activity.FeedInfoActivity">
<activity android:name=".activity.FeedInfoActivity" >
</activity>
<service
@ -175,7 +177,24 @@
android:name="android.app.default_searchable"
android:value=".activity.SearchActivity" />
</activity>
<activity android:name=".activity.MiroGuideMainActivity" android:label="@string/miro_guide_label"></activity>
<activity
android:name=".activity.MiroGuideMainActivity"
android:label="@string/miro_guide_label" >
<meta-data
android:name="android.app.default_searchable"
android:value=".activity.MiroSearchActivity" />
</activity>
<activity android:name=".activity.MiroSearchActivity" android:launchMode="singleTop" android:configChanges="keyboardHidden|orientation">
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/miro_searchable" />
<meta-data
android:name="android.app.default_searchable"
android:value=".activity.MiroSearchActivity" />
</activity>
</application>
</manifest>

13
res/layout/mirosearch.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/channellistFragment"
android:name=".fragment.MiroChannellistFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>

View File

@ -163,6 +163,7 @@
<string name="txtv_browse_miroguide_label">Or browse the Miro Guide:</string>
<string name="miro_guide_label">Miro Guide</string>
<string name="loading_label">Loading...</string>
<string name="miro_search_hint">Search Miro Guide</string>
</resources>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android" android:hint="@string/miro_search_hint" android:label="@string/app_name" android:icon="@drawable/ic_launcher">
</searchable>

View File

@ -8,6 +8,8 @@ import android.widget.ArrayAdapter;
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;
@ -66,7 +68,8 @@ public class MiroGuideMainActivity extends SherlockListActivity {
@Override
protected void onPostExecute(Void result) {
if (exception == null) {
if (AppConfig.DEBUG) Log.d(TAG, "Successfully loaded categories");
if (AppConfig.DEBUG)
Log.d(TAG, "Successfully loaded categories");
categories = c;
createAdapter();
} else {
@ -101,4 +104,26 @@ public class MiroGuideMainActivity extends SherlockListActivity {
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
.setIcon(R.drawable.action_search)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.search_item:
onSearchRequested();
return true;
default:
return false;
}
}
}

View File

@ -0,0 +1,81 @@
package de.danoeh.antennapod.activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.fragment.MiroChannellistFragment;
public class MiroSearchActivity extends SherlockFragmentActivity {
private static final String TAG = "MiroSearchActivity";
private MiroChannellistFragment listFragment;
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.mirosearch);
}
@Override
protected void onResume() {
super.onResume();
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
String query = intent.getStringExtra(SearchManager.QUERY);
getSupportActionBar()
.setSubtitle(
getString(R.string.search_term_label) + "\""
+ query + "\"");
handleSearchRequest(query);
}
}
private void handleSearchRequest(String query) {
if (AppConfig.DEBUG)
Log.d(TAG, "Performing search");
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
listFragment = MiroChannellistFragment.newInstance("name", query,
"name");
ft.replace(R.id.channellistFragment, listFragment);
ft.commit();
}
@Override
protected void onNewIntent(Intent intent) {
setIntent(intent);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(Menu.NONE, R.id.search_item, Menu.NONE, R.string.search_label)
.setIcon(R.drawable.action_search)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.search_item:
onSearchRequested();
return true;
default:
return false;
}
}
}