|
|
@ -25,7 +25,6 @@ import android.os.Bundle; |
|
|
|
import android.provider.SearchRecentSuggestions; |
|
|
|
import android.provider.SearchRecentSuggestions; |
|
|
|
import android.support.v4.view.MenuItemCompat; |
|
|
|
import android.support.v4.view.MenuItemCompat; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
import android.support.v7.view.ContextThemeWrapper; |
|
|
|
|
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.support.v7.widget.Toolbar; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.Menu; |
|
|
|
import android.view.MenuItem; |
|
|
|
import android.view.MenuItem; |
|
|
@ -46,6 +45,7 @@ import org.androidannotations.annotations.SystemService; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.androidannotations.annotations.ViewById; |
|
|
|
import org.transdroid.R; |
|
|
|
import org.transdroid.R; |
|
|
|
import org.transdroid.core.app.search.SearchHelper; |
|
|
|
import org.transdroid.core.app.search.SearchHelper; |
|
|
|
|
|
|
|
import org.transdroid.core.app.search.SearchHelper.SearchSortOrder; |
|
|
|
import org.transdroid.core.app.search.SearchSite; |
|
|
|
import org.transdroid.core.app.search.SearchSite; |
|
|
|
import org.transdroid.core.app.settings.ApplicationSettings; |
|
|
|
import org.transdroid.core.app.settings.ApplicationSettings; |
|
|
|
import org.transdroid.core.app.settings.SystemSettings_; |
|
|
|
import org.transdroid.core.app.settings.SystemSettings_; |
|
|
@ -85,6 +85,8 @@ public class SearchActivity extends AppCompatActivity { |
|
|
|
private List<SearchSetting> searchSites; |
|
|
|
private List<SearchSetting> searchSites; |
|
|
|
private SearchSetting lastUsedSite; |
|
|
|
private SearchSetting lastUsedSite; |
|
|
|
private String lastUsedQuery; |
|
|
|
private String lastUsedQuery; |
|
|
|
|
|
|
|
private MenuItem sortByAdded; |
|
|
|
|
|
|
|
private MenuItem sortBySeeders; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
|
public void onCreate(Bundle savedInstanceState) { |
|
|
@ -177,6 +179,14 @@ public class SearchActivity extends AppCompatActivity { |
|
|
|
searchView.setIconifiedByDefault(false); |
|
|
|
searchView.setIconifiedByDefault(false); |
|
|
|
MenuItemCompat.setActionView(item, searchView); |
|
|
|
MenuItemCompat.setActionView(item, searchView); |
|
|
|
searchMenu = item; |
|
|
|
searchMenu = item; |
|
|
|
|
|
|
|
sortBySeeders = menu.findItem(R.id.action_sort_seeders); |
|
|
|
|
|
|
|
sortByAdded = menu.findItem(R.id.action_sort_added); |
|
|
|
|
|
|
|
final SearchSortOrder sortOrder = applicationSettings.getLastUsedSearchSortOrder(); |
|
|
|
|
|
|
|
if (sortOrder == SearchSortOrder.BySeeders) { |
|
|
|
|
|
|
|
sortBySeeders.setChecked(true); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sortByAdded.setChecked(true); |
|
|
|
|
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -304,7 +314,7 @@ public class SearchActivity extends AppCompatActivity { |
|
|
|
getSupportActionBar() |
|
|
|
getSupportActionBar() |
|
|
|
.setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.search_queryonsite, lastUsedQuery, lastUsedSite.getName()))); |
|
|
|
.setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.search_queryonsite, lastUsedQuery, lastUsedSite.getName()))); |
|
|
|
// 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, applicationSettings.getLastUsedSearchSortOrder()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -314,4 +324,23 @@ public class SearchActivity extends AppCompatActivity { |
|
|
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.transdroid.org/latest-search"))); |
|
|
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.transdroid.org/latest-search"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptionsItem(R.id.action_sort_added) |
|
|
|
|
|
|
|
protected void sortByDateAdded() { |
|
|
|
|
|
|
|
if (sortByAdded.isChecked()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sortByAdded.setChecked(true); |
|
|
|
|
|
|
|
applicationSettings.setLastUsedSearchSortOrder(SearchSortOrder.Combined); |
|
|
|
|
|
|
|
refreshSearch(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptionsItem(R.id.action_sort_seeders) |
|
|
|
|
|
|
|
protected void sortBySeeders() { |
|
|
|
|
|
|
|
if (sortBySeeders.isChecked()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sortBySeeders.setChecked(true); |
|
|
|
|
|
|
|
applicationSettings.setLastUsedSearchSortOrder(SearchSortOrder.BySeeders); |
|
|
|
|
|
|
|
refreshSearch(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|