mirror of
https://github.com/nextcloud/android.git
synced 2024-12-19 07:22:06 +03:00
Merge pull request #13755 from nextcloud/warnOnExtensionRename
Warn when file extension is renamed
This commit is contained in:
commit
034ab2c22e
2 changed files with 17 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -1268,11 +1268,10 @@
|
|||
<string name="please_select_a_server">Please select a server…</string>
|
||||
<string name="notification_icon_description">Unread notifications exist</string>
|
||||
<string name="unset_internal_two_way_sync_description">Remove folder from internal two way sync</string>
|
||||
|
||||
<string name="two_way_sync_activity_empty_list_title">Two way sync not set up</string>
|
||||
<string name="two_way_sync_activity_empty_list_desc">To set up a two way sync folder, please enable it in the details tab of the folder in question.</string>
|
||||
<string name="two_way_sync_activity_title">Internal two way sync</string>
|
||||
<string name="two_way_sync_activity_disable_all_button_title">Disable for all folders</string>
|
||||
|
||||
<string name="oc_file_list_adapter_offline_operation_remove_description_text">Pending Remove Operation</string>
|
||||
<string name="warn_rename_extension">Changing the extension might cause this file to open in a different application</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue