Skip to content

Commit 0435482

Browse files
committed
Fix that file renaming did not survive folder navigation
Signed-off-by: Philipp Hasper <vcs@hasper.info>
1 parent f4d7170 commit 0435482

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

app/src/androidTest/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivityIT.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,44 @@ class ReceiveExternalFilesActivityIT : AbstractIT() {
163163
onView(withText(R.string.uploader_btn_upload_text))
164164
.check(matches(isDisplayed()))
165165
.check(matches(isEnabled()))
166+
167+
// Enter the subfolder and verify that the text stays intact
168+
val expectedSubFolderTitle = (getCurrentActivity() as ToolbarActivity).getActionBarTitle(subFolder, false)
169+
onView(withText(expectedSubFolderTitle))
170+
.perform(ViewActions.click())
171+
onView(withId(R.id.toolbar))
172+
.check(matches(hasDescendant(withText(expectedSubFolderTitle))))
173+
onView(withId(R.id.user_input))
174+
.check(matches(withText(fourthFileName)))
175+
.perform(ViewActions.click())
176+
.check(matches(withSelectedText(fourthFileName.removeFileExtension())))
177+
178+
// Set a new, shorter file name
179+
val fifthFileName = "short.jpg"
180+
onView(withId(R.id.user_input))
181+
.perform(ViewActions.typeTextIntoFocusedView(fifthFileName.removeFileExtension()))
182+
.check(matches(withText(fifthFileName)))
183+
184+
// Start the upload, so the folder is stored in the preferences.
185+
// Even though the upload is expected to fail because the backend is not mocked (yet?)
186+
onView(withText(R.string.uploader_btn_upload_text))
187+
.check(matches(isDisplayed()))
188+
.check(matches(isEnabled()))
189+
.perform(ViewActions.click())
190+
}
191+
192+
// Start a new file receive flow. Should now start in the sub folder, but with the original filename again
193+
launchActivity<ReceiveExternalFilesActivity>(intent).use {
194+
val expectedMainFolderTitle = (getCurrentActivity() as ToolbarActivity).getActionBarTitle(subFolder, false)
195+
onView(withId(R.id.toolbar))
196+
.check(matches(hasDescendant(withText(expectedMainFolderTitle))))
197+
198+
onView(withText(R.string.uploader_btn_upload_text))
199+
.check(matches(isDisplayed()))
200+
.check(matches(isEnabled()))
201+
202+
onView(withId(R.id.user_input))
203+
.check(matches(withText(imageFile.name)))
166204
}
167205
}
168206
}

app/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,9 +908,10 @@ private void setupFileNameInputField() {
908908
if (fileName == null) {
909909
return;
910910
}
911+
final String userProvidedFileName = Objects.requireNonNullElse(binding.userInput.getText(), "").toString();
911912

912913
binding.userInput.setVisibility(View.VISIBLE);
913-
binding.userInput.setText(fileName);
914+
binding.userInput.setText(userProvidedFileName.isEmpty() ? fileName : userProvidedFileName);
914915
binding.userInput.addTextChangedListener(this);
915916
mFileDisplayNameTransformer = uri ->
916917
Objects.requireNonNullElse(binding.userInput.getText(), fileName).toString();

0 commit comments

Comments
 (0)