|
|
@ -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 |
|
|
@ -69,15 +72,20 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { |
|
|
|
super.onResume(); |
|
|
|
super.onResume(); |
|
|
|
|
|
|
|
|
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch); |
|
|
|
if (enableSearchUi) |
|
|
|
findPreference("header_addrssfeed").setOnPreferenceClickListener(onAddRssfeed); |
|
|
|
findPreference("header_addwebsearch").setOnPreferenceClickListener(onAddWebsearch); |
|
|
|
|
|
|
|
if (enableRssUi) |
|
|
|
|
|
|
|
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,6 +97,25 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { |
|
|
|
onServerClicked)); |
|
|
|
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
|
|
|
|
// Add existing websearch sites
|
|
|
|
List<WebsearchSetting> websearches = applicationSettings.getWebsearchSettings(); |
|
|
|
List<WebsearchSetting> websearches = applicationSettings.getWebsearchSettings(); |
|
|
|
for (WebsearchSetting websearchSetting : websearches) { |
|
|
|
for (WebsearchSetting websearchSetting : websearches) { |
|
|
@ -97,14 +124,6 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { |
|
|
|
onWebsearchClicked)); |
|
|
|
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
|
|
|
|
// Construct list of all available search sites, in-app and web
|
|
|
|
ListPreference setSite = (ListPreference) findPreference("header_setsearchsite"); |
|
|
|
ListPreference setSite = (ListPreference) findPreference("header_setsearchsite"); |
|
|
|
// Retrieve the available in-app search sites (using the Torrent Search package)
|
|
|
|
// Retrieve the available in-app search sites (using the Torrent Search package)
|
|
|
@ -124,7 +143,7 @@ public class MainSettingsActivity extends SherlockPreferenceActivity { |
|
|
|
// Supply the Preference list names and values
|
|
|
|
// Supply the Preference list names and values
|
|
|
|
setSite.setEntries(siteNames.toArray(new String[siteNames.size()])); |
|
|
|
setSite.setEntries(siteNames.toArray(new String[siteNames.size()])); |
|
|
|
setSite.setEntryValues(siteValues.toArray(new String[siteValues.size()])); |
|
|
|
setSite.setEntryValues(siteValues.toArray(new String[siteValues.size()])); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|