1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-27 13:21:30 +00:00

Fixed settings not being enabled after restart

This commit is contained in:
Felix Ableitner 2016-11-10 23:39:24 +09:00
parent 2ecca8f1bd
commit a3c30f4ac6

View file

@ -157,16 +157,17 @@ public class SettingsFragment extends PreferenceFragment
@Override
public void onApiChange(SyncthingService.State currentState) {
boolean enabled = currentState == SyncthingService.State.ACTIVE;
if (!enabled || !mSyncthingService.getApi().isConfigLoaded()) {
PreferenceScreen ps = getPreferenceScreen();
for (int i = 0; i < ps.getPreferenceCount(); i++) {
Preference p = ps.getPreference(i);
p.setEnabled("category_run_conditions".equals(p.getKey()));
}
return;
boolean syncthingActive = currentState == SyncthingService.State.ACTIVE;
boolean enableAllPrefs = syncthingActive && mSyncthingService.getApi().isConfigLoaded();
PreferenceScreen ps = getPreferenceScreen();
for (int i = 0; i < ps.getPreferenceCount(); i++) {
Preference p = ps.getPreference(i);
p.setEnabled(enableAllPrefs || "category_run_conditions".equals(p.getKey()));
}
if (!enableAllPrefs)
return;
mApi = mSyncthingService.getApi();
mSyncthingVersion.setSummary(mApi.getVersion());
mOptions = mApi.getOptions();