diff --git a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt index a8f5988c5e..32a8873074 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt +++ b/app/src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.kt @@ -73,7 +73,9 @@ open class FolderPickerActivity : var isDoNotEnterEncryptedFolder = false private set private var mCancelBtn: MaterialButton? = null - private var mChooseBtn: MaterialButton? = null + private var mCopyBtn: MaterialButton? = null + private var mMoveBtn: MaterialButton? = null + private var caption: String? = null private var mAction: String? = null @@ -85,6 +87,7 @@ open class FolderPickerActivity : override fun onCreate(savedInstanceState: Bundle?) { Log_OC.d(TAG, "onCreate() start") super.onCreate(savedInstanceState) + if (this is FilePickerActivity) { setContentView(R.layout.files_picker) } else { @@ -101,29 +104,15 @@ open class FolderPickerActivity : findViewById(R.id.switch_grid_view_button).visibility = View.GONE mAction = intent.getStringExtra(EXTRA_ACTION) + if (mAction != null) { - when (mAction) { - MOVE -> { - caption = resources.getText(R.string.move_to).toString() - mSearchOnlyFolders = true - isDoNotEnterEncryptedFolder = true - } - COPY -> { - caption = resources.getText(R.string.copy_to).toString() - mSearchOnlyFolders = true - isDoNotEnterEncryptedFolder = true - } - CHOOSE_LOCATION -> { - caption = resources.getText(R.string.choose_location).toString() - mSearchOnlyFolders = true - isDoNotEnterEncryptedFolder = true - mChooseBtn!!.text = resources.getString(R.string.common_select) - } - else -> caption = themeUtils.getDefaultDisplayNameForRootFolder(this) - } + caption = resources.getText(R.string.folder_picker_choose_caption_text).toString() + mSearchOnlyFolders = true + isDoNotEnterEncryptedFolder = true } else { caption = themeUtils.getDefaultDisplayNameForRootFolder(this) } + mTargetFilePaths = intent.getStringArrayListExtra(EXTRA_FILE_PATHS) if (savedInstanceState == null) { @@ -351,7 +340,8 @@ open class FolderPickerActivity : } private fun toggleChooseEnabled() { - mChooseBtn?.isEnabled = checkFolderSelectable() + mCopyBtn?.isEnabled = checkFolderSelectable() + mMoveBtn?.isEnabled = checkFolderSelectable() } // for copy and move, disable selecting parent folder of target files @@ -385,10 +375,16 @@ open class FolderPickerActivity : */ private fun initControls() { mCancelBtn = findViewById(R.id.folder_picker_btn_cancel) - mChooseBtn = findViewById(R.id.folder_picker_btn_choose) - if (mChooseBtn != null) { - viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mChooseBtn!!) - mChooseBtn!!.setOnClickListener(this) + mCopyBtn = findViewById(R.id.btnCopy) + mMoveBtn = findViewById(R.id.btnMove) + + if (mCopyBtn != null) { + viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mCopyBtn!!) + mCopyBtn!!.setOnClickListener(this) + } + if (mMoveBtn != null) { + viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mMoveBtn!!) + mMoveBtn!!.setOnClickListener(this) } if (mCancelBtn != null) { if (this is FilePickerActivity) { @@ -403,7 +399,7 @@ open class FolderPickerActivity : override fun onClick(v: View) { if (v == mCancelBtn) { finish() - } else if (v == mChooseBtn) { + } else if (v == mCopyBtn || v == mMoveBtn) { val i = intent val resultData = Intent() resultData.putExtra(EXTRA_FOLDER, listOfFilesFragment!!.currentFile) diff --git a/app/src/main/res/layout/files_folder_picker.xml b/app/src/main/res/layout/files_folder_picker.xml index a9b85539fa..5db665ab27 100644 --- a/app/src/main/res/layout/files_folder_picker.xml +++ b/app/src/main/res/layout/files_folder_picker.xml @@ -46,27 +46,34 @@ + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e06538ddf5..54fc5482f7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -433,6 +433,11 @@ Nothing in here. You can add a folder. Choose + Copy + Move + Choose target folder + + Unable to move file. Please check whether it exists. It is not possible to move a folder into one of its own underlying folders The file is already present in the destination folder