@ -25,7 +25,6 @@ import android.os.Bundle;
@@ -25,7 +25,6 @@ import android.os.Bundle;
import android.provider.SearchRecentSuggestions ;
import android.support.v4.view.MenuItemCompat ;
import android.support.v7.app.AppCompatActivity ;
import android.support.v7.view.ContextThemeWrapper ;
import android.support.v7.widget.Toolbar ;
import android.view.Menu ;
import android.view.MenuItem ;
@ -46,6 +45,7 @@ import org.androidannotations.annotations.SystemService;
@@ -46,6 +45,7 @@ import org.androidannotations.annotations.SystemService;
import org.androidannotations.annotations.ViewById ;
import org.transdroid.R ;
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.settings.ApplicationSettings ;
import org.transdroid.core.app.settings.SystemSettings_ ;
@ -85,6 +85,8 @@ public class SearchActivity extends AppCompatActivity {
@@ -85,6 +85,8 @@ public class SearchActivity extends AppCompatActivity {
private List < SearchSetting > searchSites ;
private SearchSetting lastUsedSite ;
private String lastUsedQuery ;
private MenuItem sortByAdded ;
private MenuItem sortBySeeders ;
@Override
public void onCreate ( Bundle savedInstanceState ) {
@ -177,6 +179,14 @@ public class SearchActivity extends AppCompatActivity {
@@ -177,6 +179,14 @@ public class SearchActivity extends AppCompatActivity {
searchView . setIconifiedByDefault ( false ) ;
MenuItemCompat . setActionView ( item , searchView ) ;
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 ;
}
@ -304,7 +314,7 @@ public class SearchActivity extends AppCompatActivity {
@@ -304,7 +314,7 @@ public class SearchActivity extends AppCompatActivity {
getSupportActionBar ( )
. setTitle ( NavigationHelper . buildCondensedFontString ( getString ( R . string . search_queryonsite , lastUsedQuery , lastUsedSite . getName ( ) ) ) ) ;
// 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 {
@@ -314,4 +324,23 @@ public class SearchActivity extends AppCompatActivity {
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 ( ) ;
}
}