1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 14:21:16 +00:00

Fixed settings behaviour when Syncthing is disabled

This commit is contained in:
Felix Ableitner 2016-11-07 20:01:36 +09:00
parent 8d6ce42297
commit c961562c3c
2 changed files with 16 additions and 5 deletions

View file

@ -21,9 +21,9 @@ import com.nutomic.syncthingandroid.activities.SyncthingActivity;
import com.nutomic.syncthingandroid.model.Config;
import com.nutomic.syncthingandroid.model.Device;
import com.nutomic.syncthingandroid.model.Options;
import com.nutomic.syncthingandroid.views.WifiSsidPreference;
import com.nutomic.syncthingandroid.service.RestApi;
import com.nutomic.syncthingandroid.service.SyncthingService;
import com.nutomic.syncthingandroid.views.WifiSsidPreference;
import java.security.InvalidParameterException;
import java.util.List;
@ -149,16 +149,23 @@ public class SettingsFragment extends PreferenceFragment
public void onServiceConnected() {
mSyncthingService = ((SyncthingActivity) getActivity()).getService();
mSyncthingService.registerOnApiChangeListener(this);
mGui = mSyncthingService.getApi().getGui();
mOptions = mSyncthingService.getApi().getOptions();
if (mSyncthingService.getApi().isConfigLoaded()) {
mGui = mSyncthingService.getApi().getGui();
mOptions = mSyncthingService.getApi().getOptions();
}
}
@Override
public void onApiChange(SyncthingService.State currentState) {
boolean enabled = currentState == SyncthingService.State.ACTIVE;
getPreferenceScreen().setEnabled(enabled);
if (!enabled)
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;
}
mApi = mSyncthingService.getApi();
mSyncthingVersion.setSummary(mApi.getVersion());

View file

@ -326,6 +326,10 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
}).execute();
}
public boolean isConfigLoaded() {
return mConfig != null;
}
/**
* Requests and parses system version information.
*/