From 323f45ae239ae2b8d993644e9c60c52b9da0ba00 Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Fri, 28 Dec 2018 12:38:35 +0100 Subject: [PATCH] Support Variable Size Blocks (VSB) (fixes #153) (#156) * ConfigXml/Folder - Add "useLargeBlocks" * Update folder model defaults * UI for Variable Size Blocks (VBS) (fixes #153) --- .../activities/FolderActivity.java | 9 +++++++ .../syncthingandroid/model/Folder.java | 17 ++++++++------ .../syncthingandroid/util/ConfigXml.java | 2 ++ .../ic_developer_board_black_24dp.png | Bin 0 -> 208 bytes .../ic_developer_board_black_24dp.png | Bin 0 -> 147 bytes .../ic_developer_board_black_24dp.png | Bin 0 -> 189 bytes .../ic_developer_board_black_24dp.png | Bin 0 -> 234 bytes .../ic_developer_board_black_24dp.png | Bin 0 -> 313 bytes app/src/main/res/layout/fragment_folder.xml | 22 ++++++++++++++++++ app/src/main/res/values/strings.xml | 4 ++++ 10 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_developer_board_black_24dp.png create mode 100644 app/src/main/res/drawable-mdpi/ic_developer_board_black_24dp.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_developer_board_black_24dp.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_developer_board_black_24dp.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_developer_board_black_24dp.png diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java index 11c7970e..1f66b97c 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java @@ -109,6 +109,7 @@ public class FolderActivity extends SyncthingActivity private TextView mPullOrderDescriptionView; private TextView mVersioningDescriptionView; private TextView mVersioningTypeView; + private SwitchCompat mVariableSizeBlocks; private TextView mEditIgnoreListTitle; private EditText mEditIgnoreListContent; @@ -162,6 +163,10 @@ public class FolderActivity extends SyncthingActivity } mFolderNeedsToUpdate = true; break; + case R.id.variableSizeBlocks: + mFolder.useLargeBlocks = isChecked; + mFolderNeedsToUpdate = true; + break; } } }; @@ -193,6 +198,7 @@ public class FolderActivity extends SyncthingActivity mPullOrderDescriptionView = findViewById(R.id.pullOrderDescription); mVersioningDescriptionView = findViewById(R.id.versioningDescription); mVersioningTypeView = findViewById(R.id.versioningType); + mVariableSizeBlocks = findViewById(R.id.variableSizeBlocks); mDevicesContainer = findViewById(R.id.devicesContainer); mEditIgnoreListTitle = findViewById(R.id.edit_ignore_list_title); mEditIgnoreListContent = findViewById(R.id.edit_ignore_list_content); @@ -449,6 +455,7 @@ public class FolderActivity extends SyncthingActivity mFolderFileWatcher.setOnCheckedChangeListener(null); mFolderPaused.setOnCheckedChangeListener(null); mCustomSyncConditionsSwitch.setOnCheckedChangeListener(null); + mVariableSizeBlocks.setOnCheckedChangeListener(null); // Update views mLabelView.setText(mFolder.label); @@ -458,6 +465,7 @@ public class FolderActivity extends SyncthingActivity updateVersioningDescription(); mFolderFileWatcher.setChecked(mFolder.fsWatcherEnabled); mFolderPaused.setChecked(mFolder.paused); + mVariableSizeBlocks.setChecked(mFolder.useLargeBlocks); findViewById(R.id.editIgnoresContainer).setVisibility(mIsCreateMode ? View.GONE : View.VISIBLE); // Update views - custom sync conditions. @@ -491,6 +499,7 @@ public class FolderActivity extends SyncthingActivity mFolderFileWatcher.setOnCheckedChangeListener(mCheckedListener); mFolderPaused.setOnCheckedChangeListener(mCheckedListener); mCustomSyncConditionsSwitch.setOnCheckedChangeListener(mCheckedListener); + mVariableSizeBlocks.setOnCheckedChangeListener(mCheckedListener); } @Override diff --git a/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java b/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java index bd920003..9dd462f1 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/model/Folder.java @@ -13,6 +13,7 @@ import java.util.Map; public class Folder { + // Folder Configuration public String id; public String label; public String filesystemType = "basic"; @@ -30,16 +31,18 @@ public class Folder { public int pullerMaxPendingKiB; public int hashers = 0; public String order = "random"; - public boolean ignoreDelete; - public int scanProgressIntervalS; - public int pullerPauseS; + public boolean ignoreDelete = false; + public int scanProgressIntervalS = 0; + public int pullerPauseS = 0; public int maxConflicts = 10; - public boolean disableSparseFiles; - public boolean disableTempIndexes; - public boolean paused; - public boolean useLargeBlocks; + public boolean disableSparseFiles = false; + public boolean disableTempIndexes = false; + public boolean paused = false; + public boolean useLargeBlocks = false; public int weakHashThresholdPct = 25; public String markerName = ".stfolder"; + + // Folder Status public String invalid; public static class Versioning implements Serializable { diff --git a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index f1737655..76c44ae7 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -398,6 +398,7 @@ public class ConfigXml { folder.hashers = getContentOrDefault(r.getElementsByTagName("hashers").item(0), 0); folder.order = getContentOrDefault(r.getElementsByTagName("order").item(0), "random"); folder.paused = getContentOrDefault(r.getElementsByTagName("paused").item(0), false); + folder.useLargeBlocks = getContentOrDefault(r.getElementsByTagName("useLargeBlocks").item(0), false); // Devices /* @@ -480,6 +481,7 @@ public class ConfigXml { setConfigElement(r, "hashers", Integer.toString(folder.hashers)); setConfigElement(r, "order", folder.order); setConfigElement(r, "paused", Boolean.toString(folder.paused)); + setConfigElement(r, "useLargeBlocks", Boolean.toString(folder.useLargeBlocks)); // Update devices that share this folder. // Pass 1: Remove all devices below that folder in XML except the local device. diff --git a/app/src/main/res/drawable-hdpi/ic_developer_board_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_developer_board_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..e4b9f2e052fb39429c0876b25962fb897d17b058 GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^Dj>|k0wldT1B8LpbWaz@kP61PQyV#33z!+5`V=zizdcLYX17(CE_}9Pk4!c?nTqZxe`hTJp-Qx3;$56Ra`wkiuK~- zd$abt|Ezm8@eLURqH+z&lTW$mB)T;aiq7q5U$WbkzLb6Mw< G&;$S`#7g%7 literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-mdpi/ic_developer_board_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_developer_board_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..8dbba68d5128b5c654c4eb79d780770c38347515 GIT binary patch literal 147 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjQJyZ2Ar*|t3amX$^$Ppgj{HA) zT$)Gv3up0#yNEfwkoOTwU}M~5q4?GL64R;Xj1@;2)g<@|8#L`|J|Fy` v(=8Xca7UfXibFg78XsOim^OjSjgjFz^NqmCdMb86TNpfD{an^LB{Ts5dzLXY literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xhdpi/ic_developer_board_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_developer_board_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..fd284354185f63fc37dd10046ba0d34cb73c179e GIT binary patch literal 189 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA0wn)(8}b0D7Ec$)kP61P(;3+s90XkNi#n~m z9qzuuSTrPkMna>{jkMe!?-{czBM$2<7clT6B;_Fi(xcdEVQpuO-^+CTk&`xG3TPQ80mFI?#!z&k;~aUsi9#-qYp z&c>=~%vq4|&d9NeW#?%Y&QJdX>^vqYT>EqR(9eGT=XU<4JeqSF+Y)4xOV4?ff8p2@ ha#)AG{{YZ>)|ct?O0y^H<^Ubf;OXk;vd$@?2>?pRU3~xm literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_developer_board_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_developer_board_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..264dd59c9876e87e86ef33e7319a559385413ea4 GIT binary patch literal 313 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD0wg^q?%&M7z{ud~;uuoF`1UsAGNwQY_m9jx zXN2P3J6hMQRn%R$y=_ZdIJd`TC#8uFwTu%Cz90LtwD=!Gr~EM<P)bpgU%w3l{Gv z);iGn=uw`tc)75GLjwcjPKJy5f9v8u{%2z05Kwrqnc*m>zyy|n*&vyFCs;UEyjjb@ z#PY*H9i*74MoJW{Yu`$7Fzv2%u}|dsQl>W=dDFNI7VnrJGXH-4{_l((_N%fc#jwlr zPTi^#U&oQ*c{;dv#)dS1o;|j&>yB?Y0|al_LT7h19_@(R1Pl@ePgg&ebxsLQ06Lv` Aod5s; literal 0 HcmV?d00001 diff --git a/app/src/main/res/layout/fragment_folder.xml b/app/src/main/res/layout/fragment_folder.xml index 99d12898..04e1fcda 100644 --- a/app/src/main/res/layout/fragment_folder.xml +++ b/app/src/main/res/layout/fragment_folder.xml @@ -277,6 +277,28 @@ + + + + + Watch for changes Asks operating system to notify about changes to files. If disabled falls back to periodic hourly scans. + + Variable Size Blocks + Variable size blocks (also "large blocks") are more efficient for large files. If you enable this on one folder, you have to enable it for this folder on all devices. + Pause Folder