1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2025-01-07 10:42:07 +00:00

Support Variable Size Blocks (VSB) (fixes #153) (#156)

* ConfigXml/Folder - Add "useLargeBlocks"

* Update folder model defaults

* UI for Variable Size Blocks (VBS) (fixes #153)
This commit is contained in:
Catfriend1 2018-12-28 12:38:35 +01:00 committed by GitHub
parent 63d9f29ceb
commit 323f45ae23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 47 additions and 7 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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.

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

View file

@ -277,6 +277,28 @@
</LinearLayout>
<!-- variableSizeBlocks -->
<android.support.v7.widget.SwitchCompat
android:id="@+id/variableSizeBlocks"
style="@style/Widget.Syncthing.TextView.Label.Details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="false"
android:drawableLeft="@drawable/ic_developer_board_black_24dp"
android:drawableStart="@drawable/ic_developer_board_black_24dp"
android:text="@string/folder_variable_size_blocks_caption" />
<TextView
android:id="@+id/variableSizeBlocksDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="75dp"
android:layout_marginStart="75dp"
android:layout_marginTop="-20dp"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"
android:text="@string/folder_variable_size_blocks_description"
android:focusable="false"/>
<LinearLayout
android:id="@+id/editIgnoresContainer"
android:layout_width="match_parent"

View file

@ -193,6 +193,10 @@ Please report any problems you encounter via Github.</string>
<string name="folder_fileWatcher">Watch for changes</string>
<string name="folder_fileWatcherDescription">Asks operating system to notify about changes to files. If disabled falls back to periodic hourly scans.</string>
<!-- Setting title and description -->
<string name="folder_variable_size_blocks_caption">Variable Size Blocks</string>
<string name="folder_variable_size_blocks_description">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.</string>
<!-- Setting title -->
<string name="folder_pause">Pause Folder</string>