1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Added per-repo rescan interval setting.

The default is 86400 (one day), because this shouldn't be needed with the
previous addition of inotify.
This commit is contained in:
Felix Ableitner 2014-09-24 18:33:27 +03:00
parent 924be98aaa
commit 2363d92f22
5 changed files with 28 additions and 1 deletions

View file

@ -54,6 +54,8 @@ public class RepoSettingsFragment extends PreferenceFragment
private Preference mDirectory;
private EditTextPreference mRescanInterval;
private CheckBoxPreference mRepoMaster;
private PreferenceScreen mNodes;
@ -83,6 +85,8 @@ public class RepoSettingsFragment extends PreferenceFragment
mRepoId.setOnPreferenceChangeListener(this);
mDirectory = findPreference("directory");
mDirectory.setOnPreferenceClickListener(this);
mRescanInterval = (EditTextPreference) findPreference("rescan_interval");
mRescanInterval.setOnPreferenceChangeListener(this);
mRepoMaster = (CheckBoxPreference) findPreference("repo_master");
mRepoMaster.setOnPreferenceChangeListener(this);
mNodes = (PreferenceScreen) findPreference("nodes");
@ -108,6 +112,7 @@ public class RepoSettingsFragment extends PreferenceFragment
mRepo = new RestApi.Repo();
mRepo.ID = "";
mRepo.Directory = "";
mRepo.RescanIntervalS = 86400;
mRepo.NodeIds = new ArrayList<>();
mRepo.Versioning = new RestApi.Versioning();
} else {
@ -125,6 +130,8 @@ public class RepoSettingsFragment extends PreferenceFragment
mRepoId.setText(mRepo.ID);
mRepoId.setSummary(mRepo.ID);
mDirectory.setSummary(mRepo.Directory);
mRescanInterval.setText(Integer.toString(mRepo.RescanIntervalS));
mRescanInterval.setSummary(Integer.toString(mRepo.RescanIntervalS));
mRepoMaster.setChecked(mRepo.ReadOnly);
List<RestApi.Node> nodesList = mSyncthingService.getApi().getNodes();
for (RestApi.Node n : nodesList) {
@ -132,7 +139,6 @@ public class RepoSettingsFragment extends PreferenceFragment
cbp.setTitle(n.Name);
cbp.setKey(KEY_NODE_SHARED);
cbp.setOnPreferenceChangeListener(RepoSettingsFragment.this);
// FIXME: something wrong here
cbp.setChecked(false);
for (String n2 : mRepo.NodeIds) {
if (n2.equals(n.NodeID)) {
@ -221,6 +227,11 @@ public class RepoSettingsFragment extends PreferenceFragment
mRepo.Directory = (String) o;
repoUpdated();
return true;
} else if (preference.equals(mRescanInterval)) {
mRepo.RescanIntervalS = Integer.parseInt((String) o);
mRescanInterval.setSummary((String) o);
repoUpdated();
return true;
} else if (preference.equals(mRepoMaster)) {
mRepo.ReadOnly = (Boolean) o;
repoUpdated();

View file

@ -82,6 +82,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String Invalid;
public List<String> NodeIds;
public boolean ReadOnly;
public int RescanIntervalS;
public Versioning Versioning;
}
@ -478,6 +479,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
r.NodeIds.add(mLocalNodeId);
r.ReadOnly = json.getBoolean("ReadOnly");
r.RescanIntervalS = json.getInt("RescanIntervalS");
JSONObject versioning = json.getJSONObject("Versioning");
if (versioning.getString("Type").equals("simple")) {
SimpleVersioning sv = new SimpleVersioning();
@ -776,6 +778,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
for (String key : repo.Versioning.getParams().keySet()) {
params.put(key, repo.Versioning.getParams().get(key));
}
r.put("RescanIntervalS", repo.RescanIntervalS);
r.put("Versioning", versioning);
requireRestart(activity);
} catch (JSONException e) {

View file

@ -86,6 +86,9 @@
<!-- Setting title -->
<string name="directory">Directory</string>
<!-- Setting title -->
<string name="rescan_interval">Rescan Interval</string>
<!-- Setting title -->
<string name="repo_master">Repository Master</string>

View file

@ -10,6 +10,11 @@
android:key="directory"
android:title="@string/directory" />
<EditTextPreference
android:key="rescan_interval"
android:title="@string/rescan_interval"
android:inputType="numberDecimal" />
<CheckBoxPreference
android:key="repo_master"
android:title="@string/repo_master" />

View file

@ -14,6 +14,11 @@
android:enabled="false"
style="?android:preferenceInformationStyle" />
<EditTextPreference
android:key="rescan_interval"
android:title="@string/rescan_interval"
android:inputType="numberDecimal" />
<CheckBoxPreference
android:key="repo_master"
android:title="@string/repo_master" />