From b28394bc8f38fe76bd0e6e2bd915ed5c146ad2bf Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Mon, 11 Mar 2019 18:30:44 +0100 Subject: [PATCH] Create folder dialog - trim folder label (fixes #367) (#368) * FolderActivity: Trim folder label (fixes #367) * Only trim if EXTRA_FOLDER_LABEL extra was set --- .../nutomic/syncthingandroid/activities/FolderActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 2cb8d379..a31b7b88 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderActivity.java @@ -130,7 +130,7 @@ public class FolderActivity extends SyncthingActivity { private final TextWatcher mTextWatcher = new TextWatcherAdapter() { @Override public void afterTextChanged(Editable s) { - mFolder.label = mLabelView.getText().toString(); + mFolder.label = mLabelView.getText().toString().trim(); mFolder.id = mIdView.getText().toString(); // mPathView must not be handled here as it's handled by {@link onActivityResult} // mEditIgnoreListContent must not be handled here as it's written back when the dialog ends. @@ -680,6 +680,9 @@ public class FolderActivity extends SyncthingActivity { ? getIntent().getStringExtra(EXTRA_FOLDER_ID) : generateRandomFolderId(); mFolder.label = getIntent().getStringExtra(EXTRA_FOLDER_LABEL); + if (!TextUtils.isEmpty(mFolder.label)) { + mFolder.label = mFolder.label.trim(); + } mFolder.paused = false; mFolder.type = Constants.FOLDER_TYPE_SEND_RECEIVE; // Default for {@link #checkWriteAndUpdateUI}. mFolder.minDiskFree = new Folder.MinDiskFree();