@ -29,7 +29,8 @@ import org.transdroid.core.app.settings.ApplicationSettings;
@@ -29,7 +29,8 @@ import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.RssfeedSetting ;
import org.transdroid.core.app.settings.ServerSetting ;
import org.transdroid.core.app.settings.WebsearchSetting ;
import org.transdroid.core.gui.* ;
import org.transdroid.core.gui.TorrentsActivity_ ;
import org.transdroid.core.gui.navigation.NavigationHelper ;
import org.transdroid.core.gui.settings.RssfeedPreference.OnRssfeedClickedListener ;
import org.transdroid.core.gui.settings.ServerPreference.OnServerClickedListener ;
import org.transdroid.core.gui.settings.WebsearchPreference.OnWebsearchClickedListener ;
@ -52,6 +53,8 @@ import com.actionbarsherlock.app.SherlockPreferenceActivity;
@@ -52,6 +53,8 @@ import com.actionbarsherlock.app.SherlockPreferenceActivity;
@EActivity
public class MainSettingsActivity extends SherlockPreferenceActivity {
@Bean
protected NavigationHelper navigationHelper ;
@Bean
protected ApplicationSettings applicationSettings ;
@Bean
@ -73,11 +76,16 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
@@ -73,11 +76,16 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
if ( getPreferenceScreen ( ) ! = null )
getPreferenceScreen ( ) . removeAll ( ) ;
boolean enableSearchUi = navigationHelper . enableSearchUi ( ) ;
boolean enableRssUi = navigationHelper . enableRssUi ( ) ;
// Load the preference menu and attach actions
addPreferencesFromResource ( R . xml . pref_main ) ;
findPreference ( "header_addserver" ) . setOnPreferenceClickListener ( onAddServer ) ;
findPreference ( "header_addwebsearch" ) . setOnPreferenceClickListener ( onAddWebsearch ) ;
findPreference ( "header_addrssfeed" ) . setOnPreferenceClickListener ( onAddRssfeed ) ;
if ( enableSearchUi )
findPreference ( "header_addwebsearch" ) . setOnPreferenceClickListener ( onAddWebsearch ) ;
if ( enableRssUi )
findPreference ( "header_addrssfeed" ) . setOnPreferenceClickListener ( onAddRssfeed ) ;
findPreference ( "header_background" ) . setOnPreferenceClickListener ( onBackgroundSettings ) ;
findPreference ( "header_system" ) . setOnPreferenceClickListener ( onSystemSettings ) ;
@ -89,6 +97,25 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
@@ -89,6 +97,25 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
onServerClicked ) ) ;
}
// Add existing RSS feeds
if ( ! enableRssUi ) {
// RSS should be disabled
getPreferenceScreen ( ) . removePreference ( findPreference ( "header_rssfeeds" ) ) ;
} else {
List < RssfeedSetting > rssfeeds = applicationSettings . getRssfeedSettings ( ) ;
for ( RssfeedSetting rssfeedSetting : rssfeeds ) {
getPreferenceScreen ( ) . addPreference (
new RssfeedPreference ( this ) . setRssfeedSetting ( rssfeedSetting ) . setOnRssfeedClickedListener (
onRssfeedClicked ) ) ;
}
}
if ( ! enableSearchUi ) {
// Search should be disabled
getPreferenceScreen ( ) . removePreference ( findPreference ( "header_searchsites" ) ) ;
return ;
}
// Add existing websearch sites
List < WebsearchSetting > websearches = applicationSettings . getWebsearchSettings ( ) ;
for ( WebsearchSetting websearchSetting : websearches ) {
@ -97,14 +124,6 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
@@ -97,14 +124,6 @@ public class MainSettingsActivity extends SherlockPreferenceActivity {
onWebsearchClicked ) ) ;
}
// Add existing RSS feeds
List < RssfeedSetting > rssfeeds = applicationSettings . getRssfeedSettings ( ) ;
for ( RssfeedSetting rssfeedSetting : rssfeeds ) {
getPreferenceScreen ( ) . addPreference (
new RssfeedPreference ( this ) . setRssfeedSetting ( rssfeedSetting ) . setOnRssfeedClickedListener (
onRssfeedClicked ) ) ;
}
// Construct list of all available search sites, in-app and web
ListPreference setSite = ( ListPreference ) findPreference ( "header_setsearchsite" ) ;
// Retrieve the available in-app search sites (using the Torrent Search package)