diff --git a/app/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.kt b/app/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.kt
index 0ca1cde470..38c74ca57e 100644
--- a/app/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.kt
+++ b/app/src/main/java/com/owncloud/android/ui/dialog/RenameFileDialogFragment.kt
@@ -37,6 +37,7 @@ import com.owncloud.android.ui.activity.FileDisplayActivity
import com.owncloud.android.utils.DisplayUtils
import com.owncloud.android.utils.KeyboardUtils
import com.owncloud.android.utils.theme.ViewThemeUtils
+import java.io.File
import javax.inject.Inject
/**
@@ -178,9 +179,13 @@ class RenameFileDialogFragment : DialogFragment(), DialogInterface.OnClickListen
if (isFileHidden(newFileName)) {
binding.userInputContainer.error = getText(R.string.hidden_file_name_warning)
+ positiveButton?.isEnabled = true
} else if (errorMessage != null) {
binding.userInputContainer.error = errorMessage
positiveButton?.isEnabled = false
+ } else if (checkExtensionRenamed(newFileName)) {
+ binding.userInputContainer.error = getText(R.string.warn_rename_extension)
+ positiveButton?.isEnabled = true
} else if (binding.userInputContainer.error != null) {
binding.userInputContainer.error = null
// Called to remove extra padding
@@ -191,6 +196,17 @@ class RenameFileDialogFragment : DialogFragment(), DialogInterface.OnClickListen
override fun afterTextChanged(s: Editable) = Unit
+ private fun checkExtensionRenamed(newFileName: String): Boolean {
+ mTargetFile?.fileName?.let { previousFileName ->
+ val previousExtension = File(previousFileName).extension
+ val newExtension = File(newFileName).extension
+
+ return previousExtension != newExtension
+ }
+
+ return false
+ }
+
companion object {
private const val ARG_TARGET_FILE = "TARGET_FILE"
private const val ARG_PARENT_FOLDER = "PARENT_FOLDER"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index bbf49635e8..60a5c33418 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1268,11 +1268,10 @@
Please select a server…
Unread notifications exist
Remove folder from internal two way sync
-
Two way sync not set up
To set up a two way sync folder, please enable it in the details tab of the folder in question.
Internal two way sync
Disable for all folders
-
Pending Remove Operation
+ Changing the extension might cause this file to open in a different application