Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-exclude-hidden-file-or-folder-…
Browse files Browse the repository at this point in the history
…option-when-create-custom-media-folder-type
  • Loading branch information
BBBOND authored Dec 19, 2023
2 parents ba509c3 + 69d3136 commit 2631bc5
Show file tree
Hide file tree
Showing 17 changed files with 137 additions and 35 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import android.content.Intent;
import android.view.View;

import com.owncloud.android.AbstractIT;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.OCFile;
Expand Down Expand Up @@ -135,4 +138,25 @@ public void open() {
waitForIdleSync();
screenshot(sut);
}

@Test
@ScreenshotTest
public void testMoveOrCopy() {
Intent intent = new Intent();
FolderPickerActivity targetActivity = activityRule.launchActivity(intent);

waitForIdleSync();
screenshot(targetActivity);
}

@Test
@ScreenshotTest
public void testChooseLocationAction() {
Intent intent = new Intent();
intent.putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.CHOOSE_LOCATION);
FolderPickerActivity targetActivity = activityRule.launchActivity(intent);

waitForIdleSync();
screenshot(targetActivity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -347,16 +347,17 @@ public OCUpload[] getAllStoredUploads() {

public OCUpload getUploadByRemotePath(String remotePath){
OCUpload result = null;
Cursor cursor = getDB().query(
try (Cursor cursor = getDB().query(
ProviderTableMeta.CONTENT_URI_UPLOADS,
null,
ProviderTableMeta.UPLOADS_REMOTE_PATH + "=?",
new String[]{remotePath},
ProviderTableMeta.UPLOADS_REMOTE_PATH+ " ASC");
ProviderTableMeta.UPLOADS_REMOTE_PATH + " ASC")) {

if (cursor != null) {
if (cursor.moveToFirst()) {
result = createOCUploadFromCursor(cursor);
if (cursor != null) {
if (cursor.moveToFirst()) {
result = createOCUploadFromCursor(cursor);
}
}
}
Log_OC.d(TAG, "Retrieve job " + result + " for remote path " + remotePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ private void resetSearchAction() {
*/
private void popBack() {
// pop back fragment
binding.fabMain.setImageResource(R.drawable.ic_plus);
resetScrolling(true);
popSortListGroupVisibility();
super.onBackPressed();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ open class FolderPickerActivity :
private var mSearchOnlyFolders = false
var isDoNotEnterEncryptedFolder = false
private set

private var mCancelBtn: MaterialButton? = null
private var mCopyBtn: MaterialButton? = null
private var mChooseBtn: MaterialButton? = null
private var mMoveBtn: MaterialButton? = null

private var caption: String? = null
Expand Down Expand Up @@ -107,10 +109,8 @@ open class FolderPickerActivity :
View.GONE
mAction = intent.getStringExtra(EXTRA_ACTION)

if (mAction != null) {
caption = resources.getText(R.string.folder_picker_choose_caption_text).toString()
mSearchOnlyFolders = true
isDoNotEnterEncryptedFolder = true
if (mAction != null && mAction == CHOOSE_LOCATION) {
setupUIForChooseButton()
} else {
caption = themeUtils.getDefaultDisplayNameForRootFolder(this)
}
Expand All @@ -126,12 +126,27 @@ open class FolderPickerActivity :

// sets message for empty list of folders
setBackgroundText()

handleOnBackPressed()

Log_OC.d(TAG, "onCreate() end")
}

private fun setupUIForChooseButton() {
caption = resources.getText(R.string.folder_picker_choose_caption_text).toString()
mSearchOnlyFolders = true
isDoNotEnterEncryptedFolder = true

mCopyBtn?.visibility = View.GONE
mMoveBtn?.visibility = View.GONE
mChooseBtn?.visibility = View.VISIBLE

val chooseButtonSpacer = findViewById<View>(R.id.choose_button_spacer)
val moveOrCopyButtonSpacer = findViewById<View>(R.id.move_or_copy_button_spacer)

chooseButtonSpacer.visibility = View.VISIBLE
moveOrCopyButtonSpacer.visibility = View.GONE
}

private fun handleOnBackPressed() {
onBackPressedDispatcher.addCallback(
this,
Expand Down Expand Up @@ -389,34 +404,43 @@ open class FolderPickerActivity :
mCancelBtn = findViewById(R.id.folder_picker_btn_cancel)
mCopyBtn = findViewById(R.id.folder_picker_btn_copy)
mMoveBtn = findViewById(R.id.folder_picker_btn_move)
mChooseBtn = findViewById(R.id.folder_picker_btn_choose)

mCopyBtn?.let {
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it)
it.setOnClickListener(this)
}

if (mCopyBtn != null) {
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mCopyBtn!!)
mCopyBtn!!.setOnClickListener(this)
mMoveBtn?.let {
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(it)
it.setOnClickListener(this)
}
if (mMoveBtn != null) {
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(mMoveBtn!!)
mMoveBtn!!.setOnClickListener(this)

mChooseBtn?.let {
viewThemeUtils.material.colorMaterialButtonPrimaryTonal(it)
it.setOnClickListener(this)
}

if (mCancelBtn != null) {
mCancelBtn?.let {
if (this is FilePickerActivity) {
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(mCancelBtn!!)
viewThemeUtils.material.colorMaterialButtonPrimaryFilled(it)
} else {
viewThemeUtils.material.colorMaterialButtonText(mCancelBtn!!)
viewThemeUtils.material.colorMaterialButtonText(it)
}
mCancelBtn!!.setOnClickListener(this)

it.setOnClickListener(this)
}
}

override fun onClick(v: View) {
when (v) {
mChooseBtn -> processOperation(v)
mCancelBtn -> finish()
mCopyBtn, mMoveBtn -> copyOrMove(v)
mCopyBtn, mMoveBtn -> processOperation(v)
}
}

private fun copyOrMove(v: View) {
private fun processOperation(v: View) {
val i = intent
val resultData = Intent()
resultData.putExtra(EXTRA_FOLDER, listOfFilesFragment?.currentFile)
Expand All @@ -426,20 +450,27 @@ open class FolderPickerActivity :
}

mTargetFilePaths?.let {
val action = when (v) {
mCopyBtn -> OperationsService.ACTION_COPY_FILE
mMoveBtn -> OperationsService.ACTION_MOVE_FILE
else -> throw IllegalArgumentException("Unknown operation")
if (v == mCopyBtn || v == mMoveBtn) {
moveOrCopyFiles(v, it)
}

fileOperationsHelper.moveOrCopyFiles(action, it, file)
resultData.putStringArrayListExtra(EXTRA_FILE_PATHS, it)
}

setResult(RESULT_OK, resultData)
finish()
}

private fun moveOrCopyFiles(v: View, filePathList: ArrayList<String>) {
val action = if (v == mCopyBtn) {
OperationsService.ACTION_COPY_FILE
} else {
OperationsService.ACTION_MOVE_FILE
}

fileOperationsHelper.moveOrCopyFiles(action, filePathList, file)
}

override fun onRemoteOperationFinish(operation: RemoteOperation<*>?, result: RemoteOperationResult<*>) {
super.onRemoteOperationFinish(operation, result)
if (operation is CreateFolderOperation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,9 @@ class SyncedFolderPreferencesDialogFragment : DialogFragment(), Injectable {
}

binding.remoteFolderContainer.setOnClickListener {
val action = Intent(activity, FolderPickerActivity::class.java)
val action = Intent(activity, FolderPickerActivity::class.java).apply {
putExtra(FolderPickerActivity.EXTRA_ACTION, FolderPickerActivity.CHOOSE_LOCATION)
}
requireActivity().startActivityForResult(action, REQUEST_CODE__SELECT_REMOTE_FOLDER)
}
binding.localFolderContainer.setOnClickListener {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/res/layout/files_folder_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">

<include layout="@layout/toolbar_standard" />
Expand Down Expand Up @@ -49,6 +50,13 @@
android:orientation="horizontal"
android:padding="@dimen/standard_padding">

<View
android:id="@+id/choose_button_spacer"
android:visibility="gone"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>

<com.google.android.material.button.MaterialButton
android:id="@+id/folder_picker_btn_cancel"
style="@style/Widget.Material3.Button.TextButton"
Expand All @@ -58,7 +66,19 @@
android:layout_weight="1"
app:cornerRadius="@dimen/button_corner_radius" />

<com.google.android.material.button.MaterialButton
android:id="@+id/folder_picker_btn_choose"
android:visibility="gone"
tools:visibility="visible"
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/folder_picker_choose_button_text"
app:cornerRadius="@dimen/button_corner_radius" />

<View
android:id="@+id/move_or_copy_button_spacer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"/>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-b+en+001/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@
<string name="uploader_error_message_source_file_not_found">File selected for upload not found. Please check whether the file exists.</string>
<string name="uploader_error_title_file_cannot_be_uploaded">This file cannot be uploaded</string>
<string name="uploader_error_title_no_file_to_upload">No file to upload</string>
<string name="uploader_file_not_found_message">File not found. Are you sure that this file exists or has a previous conflict not been resolved?</string>
<string name="uploader_file_not_found_on_server_message">We couldnt locate the file on server. Another user may have deleted the file</string>
<string name="uploader_info_dirname">Folder name</string>
<string name="uploader_local_files_uploaded">Try to upload local files again</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-gl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,10 @@
<string name="uploader_error_message_source_file_not_found">Non foi atopado o ficheiro seleccionado para enviar. Comprobe se existe o ficheiro.</string>
<string name="uploader_error_title_file_cannot_be_uploaded">Non é posíbel enviar este ficheiro</string>
<string name="uploader_error_title_no_file_to_upload">Non hai ficheiros para enviar</string>
<string name="uploader_file_not_found_message">Non se atopou o ficheiro. Está seguro de que este ficheiro existe ou non se resolveu un conflito anterior?</string>
<string name="uploader_file_not_found_on_server_message">Non foi posíbel localizar o ficheiro no servidor. Outro usuario pode ter eliminado o ficheiro</string>
<string name="uploader_info_dirname">Nome do cartafol</string>
<string name="uploader_local_files_uploaded">Tente enviar os ficheiros locais de novo</string>
<string name="uploader_top_message">Escoller o cartafol de envío</string>
<string name="uploader_upload_failed_content_single">Non foi posíbel enviar: %1$s</string>
<string name="uploader_upload_failed_credentials_error">Produciuse un fallo no envío, acceda de novo.</string>
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
<string name="conflict_message_description">Если вы выберете обе версии, локальный файл будет иметь номер, добавленный к его имени.</string>
<string name="conflict_server_file">Файл с сервера</string>
<string name="contact_backup_title">Резервная копия контактов</string>
<string name="contact_no_permission">Требуется разрешение на контакт.</string>
<string name="contactlist_item_icon">Значок пользователя в списке контактов</string>
<string name="contactlist_no_permission">Отсутствуют разрешения, ничего не импортировано.</string>
<string name="contacts">Контакты</string>
Expand Down Expand Up @@ -252,6 +253,7 @@
<string name="ecosystem_apps_more">Больше приложений для Nextcloud</string>
<string name="ecosystem_apps_notes">Заметки для Nextcloud</string>
<string name="ecosystem_apps_talk">Конференции для Nextcloud</string>
<string name="email_pick_failed">Невозможно выбрать адрес электронной почты.</string>
<string name="encrypted">Зашифровать</string>
<string name="end_to_end_encryption_confirm_button">Параметры шифрования</string>
<string name="end_to_end_encryption_decrypting">Расшифровка…</string>
Expand Down Expand Up @@ -336,6 +338,7 @@
<string name="file_list_empty_shared_headline">Вы ничем не поделились</string>
<string name="file_list_empty_unified_search_no_results">По вашему запросу ничего не найдено</string>
<string name="file_list_folder">каталог</string>
<string name="file_list_live">ТРАНСЛИРУЕТСЯ</string>
<string name="file_list_loading">Получение данных…</string>
<string name="file_list_no_app_for_file_type">Не найдено приложение для открытия этого типа файлов.</string>
<string name="file_list_seconds_ago">несколько секунд назад</string>
Expand Down Expand Up @@ -640,6 +643,7 @@
<string name="remove_e2e">Вы можете удалить сквозное шифрование локально на этом клиенте</string>
<string name="remove_e2e_message">Вы можете удалить сквозное шифрование локально на этом клиенте. Зашифрованные файлы останутся на сервере, но больше не будут синхронизироваться с этим компьютером.</string>
<string name="remove_fail_msg">Ошибка при удалении</string>
<string name="remove_local_account">Удалить локальную учетную запись</string>
<string name="remove_notification_failed">Не удалось скрыть уведомление.</string>
<string name="remove_push_notification">Удалить</string>
<string name="remove_success_msg">Удалено</string>
Expand Down
Loading

0 comments on commit 2631bc5

Please sign in to comment.