Browse Source

Hide search and RSS settings if not supported (i.e. in Lite version).

pull/11/merge
Eric Kok 11 years ago
parent
commit
3e6989fa49
  1. 37
      core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

37
core/src/org/transdroid/core/gui/settings/MainSettingsActivity.java

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

Loading…
Cancel
Save