Browse Source

Tweaked tablet search layout.

pull/11/head
Eric Kok 11 years ago
parent
commit
34a3834526
  1. 2
      core/res/layout-w600dp/activity_search.xml
  2. 1
      core/res/values/strings.xml
  3. 9
      core/src/org/transdroid/core/gui/search/SearchActivity.java
  4. 16
      core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

2
core/res/layout-w600dp/activity_search.xml

@ -35,7 +35,7 @@
android:id="@+id/searchresults_list" android:id="@+id/searchresults_list"
android:layout_width="0dip" android:layout_width="0dip"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="3" android:layout_weight="2"
class="org.transdroid.core.gui.search.SearchResultsFragment_" class="org.transdroid.core.gui.search.SearchResultsFragment_"
tools:layout="@layout/fragment_searchresults" /> tools:layout="@layout/fragment_searchresults" />

1
core/res/values/strings.xml

@ -158,6 +158,7 @@
<string name="result_maxspeedsset">Maximum transfer speeds set</string> <string name="result_maxspeedsset">Maximum transfer speeds set</string>
<string name="search_torrentsearch">Torrent search</string> <string name="search_torrentsearch">Torrent search</string>
<string name="search_queryonsite">\'%1$s\' on %2$s</string>
<string name="search_hint">Search for torrents</string> <string name="search_hint">Search for torrents</string>
<string name="search_noresults">No results for your query</string> <string name="search_noresults">No results for your query</string>
<string name="search_seeders">S: %1$s</string> <string name="search_seeders">S: %1$s</string>

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

@ -186,7 +186,6 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
private void handleIntent(Intent intent) { private void handleIntent(Intent intent) {
lastUsedQuery = parseQuery(intent); lastUsedQuery = parseQuery(intent);
getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(lastUsedQuery));
// Is this actually a full HTTP URL? Then redirect this request to add the URL directly // Is this actually a full HTTP URL? Then redirect this request to add the URL directly
if (lastUsedQuery != null if (lastUsedQuery != null
@ -247,15 +246,23 @@ public class SearchActivity extends SherlockFragmentActivity implements OnNaviga
@OptionsItem(resName = "action_refresh") @OptionsItem(resName = "action_refresh")
protected void refreshSearch() { protected void refreshSearch() {
if (lastUsedSite instanceof WebsearchSetting) { if (lastUsedSite instanceof WebsearchSetting) {
// Start a browser page directly to the requested search results // Start a browser page directly to the requested search results
WebsearchSetting websearch = (WebsearchSetting) lastUsedSite; WebsearchSetting websearch = (WebsearchSetting) lastUsedSite;
startActivity(new Intent(Intent.ACTION_VIEW, startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse(String.format(websearch.getBaseUrl(), lastUsedQuery)))); Uri.parse(String.format(websearch.getBaseUrl(), lastUsedQuery))));
} else if (lastUsedSite instanceof SearchSite) { } else if (lastUsedSite instanceof SearchSite) {
// Update the activity title (only shown on large devices)
getSupportActionBar().setTitle(
NavigationHelper.buildCondensedFontString(getString(R.string.search_queryonsite, lastUsedQuery,
lastUsedSite.getName())));
// Save the search site currently used to search for future usage // Save the search site currently used to search for future usage
applicationSettings.setLastUsedSearchSite((SearchSite) lastUsedSite); applicationSettings.setLastUsedSearchSite((SearchSite) lastUsedSite);
// Ask the results fragment to start a search for the specified query // Ask the results fragment to start a search for the specified query
fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite); fragmentResults.startSearch(lastUsedQuery, (SearchSite) lastUsedSite);
} }
} }

16
core/src/org/transdroid/core/gui/search/SearchResultsFragment.java

@ -32,6 +32,8 @@ import org.transdroid.core.app.search.SearchHelper;
import org.transdroid.core.app.search.SearchHelper.SearchSortOrder; import org.transdroid.core.app.search.SearchHelper.SearchSortOrder;
import org.transdroid.core.app.search.SearchResult; import org.transdroid.core.app.search.SearchResult;
import org.transdroid.core.app.search.SearchSite; import org.transdroid.core.app.search.SearchSite;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
import android.content.Intent; import android.content.Intent;
@ -73,6 +75,16 @@ public class SearchResultsFragment extends SherlockFragment {
@AfterViews @AfterViews
protected void init() { protected void init() {
// On large screens where this fragment is shown next to the sites list; we show a continues grey vertical line
// to separate the lists visually
if (!NavigationHelper_.getInstance_(getActivity()).isSmallScreen()) {
if (SystemSettings_.getInstance_(getActivity()).useDarkTheme()) {
resultsList.setBackgroundResource(R.drawable.details_list_background_dark);
} else {
resultsList.setBackgroundResource(R.drawable.details_list_background_light);
}
}
// Set up the list adapter, which allows multi-select // Set up the list adapter, which allows multi-select
resultsList.setAdapter(resultsAdapter); resultsList.setAdapter(resultsAdapter);
resultsList.setMultiChoiceModeListener(onItemsSelected); resultsList.setMultiChoiceModeListener(onItemsSelected);
@ -161,8 +173,8 @@ public class SearchResultsFragment extends SherlockFragment {
SearchResult first = checked.get(0); SearchResult first = checked.get(0);
// Open the torrent's web page in the browser // Open the torrent's web page in the browser
if (checked.size() > 1) if (checked.size() > 1)
Toast.makeText(getActivity(), getString(R.string.search_openingdetails, first), Toast.LENGTH_LONG) Toast.makeText(getActivity(), getString(R.string.search_openingdetails, first.getName()),
.show(); Toast.LENGTH_LONG).show();
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(first.getDetailsUrl()))); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(first.getDetailsUrl())));
return true; return true;
} else { } else {

Loading…
Cancel
Save