Browse Source

React to hardware search button presses by opening the search view (by expanding the menu option).

pull/11/head
Eric Kok 11 years ago
parent
commit
54b2b206ea
  1. 12
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  2. 10
      core/src/org/transdroid/core/gui/search/SearchActivity.java

12
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -135,6 +135,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -135,6 +135,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
protected ServerStatusView serverStatusView;
@SystemService
protected SearchManager searchManager;
private MenuItem searchMenu = null;
// Settings
@Bean
@ -262,10 +263,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -262,10 +263,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// For Android 2.1+, add an expandable SearchView to the action bar
MenuItem item = menu.findItem(R.id.action_search);
if (android.os.Build.VERSION.SDK_INT >= 8) {
final SearchView searchView = new SearchView(this);
SearchView searchView = new SearchView(this);
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
item.setActionView(searchView);
searchMenu = item;
}
}
return true;
@ -486,6 +488,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi @@ -486,6 +488,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
}
@Override
public boolean onSearchRequested() {
if (searchMenu != null) {
searchMenu.expandActionView();
}
return true;
}
@OptionsItem(resName = "action_add_fromurl")
protected void startUrlEntryDialog() {
UrlEntryDialog.startUrlEntry(this);

10
core/src/org/transdroid/core/gui/search/SearchActivity.java

@ -77,6 +77,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga @@ -77,6 +77,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
protected SearchHelper searchHelper;
@SystemService
protected SearchManager searchManager;
private MenuItem searchMenu = null;
private SearchRecentSuggestions suggestions = new SearchRecentSuggestions(this,
TorrentSearchHistoryProvider.AUTHORITY, TorrentSearchHistoryProvider.MODE);
@ -154,6 +155,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga @@ -154,6 +155,7 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setQueryRefinementEnabled(true);
item.setActionView(searchView);
searchMenu = item;
}
}
return true;
@ -198,6 +200,14 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga @@ -198,6 +200,14 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
}
@Override
public boolean onSearchRequested() {
if (searchMenu != null) {
searchMenu.expandActionView();
}
return true;
}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@OptionsItem(android.R.id.home)
protected void navigateUp() {

Loading…
Cancel
Save