1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-02 01:01:17 +00:00

SettingsActivity: findPreference - cast category result to PreferenceScreen

This commit is contained in:
Catfriend1 2019-03-28 23:57:04 +01:00
parent 90f9eccb64
commit ecb379d379

View file

@ -161,7 +161,7 @@ public class SettingsActivity extends SyncthingActivity {
private Dialog mCurrentPrefScreenDialog = null; private Dialog mCurrentPrefScreenDialog = null;
/* Run conditions */ /* Run conditions */
private Preference mCategoryRunConditions; private PreferenceScreen mCategoryRunConditions;
private ListPreference mPowerSource; private ListPreference mPowerSource;
private CheckBoxPreference mRunOnMobileData; private CheckBoxPreference mRunOnMobileData;
private CheckBoxPreference mRunOnWifi; private CheckBoxPreference mRunOnWifi;
@ -177,7 +177,7 @@ public class SettingsActivity extends SyncthingActivity {
private Languages mLanguages; private Languages mLanguages;
/* Syncthing Options */ /* Syncthing Options */
private Preference mCategorySyncthingOptions; private PreferenceScreen mCategorySyncthingOptions;
private EditTextPreference mDeviceName; private EditTextPreference mDeviceName;
private EditTextPreference mListenAddresses; private EditTextPreference mListenAddresses;
private EditTextPreference mMaxRecvKbps; private EditTextPreference mMaxRecvKbps;
@ -297,7 +297,7 @@ public class SettingsActivity extends SyncthingActivity {
getString(R.string.run_on_whitelisted_wifi_networks, wifiSsidSummary) getString(R.string.run_on_whitelisted_wifi_networks, wifiSsidSummary)
); );
mCategoryRunConditions = findPreference("category_run_conditions"); mCategoryRunConditions = (PreferenceScreen) findPreference("category_run_conditions");
setPreferenceCategoryChangeListener(mCategoryRunConditions, this::onRunConditionPreferenceChange); setPreferenceCategoryChangeListener(mCategoryRunConditions, this::onRunConditionPreferenceChange);
/* Behaviour */ /* Behaviour */
@ -333,7 +333,7 @@ public class SettingsActivity extends SyncthingActivity {
mDownloadSupportBundle = findPreference(KEY_DOWNLOAD_SUPPORT_BUNDLE); mDownloadSupportBundle = findPreference(KEY_DOWNLOAD_SUPPORT_BUNDLE);
Preference undoIgnoredDevicesFolders = findPreference(KEY_UNDO_IGNORED_DEVICES_FOLDERS); Preference undoIgnoredDevicesFolders = findPreference(KEY_UNDO_IGNORED_DEVICES_FOLDERS);
mCategorySyncthingOptions = findPreference("category_syncthing_options"); mCategorySyncthingOptions = (PreferenceScreen) findPreference("category_syncthing_options");
setPreferenceCategoryChangeListener(mCategorySyncthingOptions, this::onSyncthingPreferenceChange); setPreferenceCategoryChangeListener(mCategorySyncthingOptions, this::onSyncthingPreferenceChange);
mSyncthingApiKey.setOnPreferenceClickListener(this); mSyncthingApiKey.setOnPreferenceClickListener(this);
mDownloadSupportBundle.setOnPreferenceClickListener(this); mDownloadSupportBundle.setOnPreferenceClickListener(this);
@ -549,10 +549,9 @@ public class SettingsActivity extends SyncthingActivity {
} }
private void setPreferenceCategoryChangeListener( private void setPreferenceCategoryChangeListener(
Preference category, Preference.OnPreferenceChangeListener listener) { PreferenceScreen category, Preference.OnPreferenceChangeListener listener) {
PreferenceScreen ps = (PreferenceScreen) category; for (int i = 0; i < category.getPreferenceCount(); i++) {
for (int i = 0; i < ps.getPreferenceCount(); i++) { Preference p = category.getPreference(i);
Preference p = ps.getPreference(i);
p.setOnPreferenceChangeListener(listener); p.setOnPreferenceChangeListener(listener);
} }
} }