Skip to content

Commit 21a5f8d

Browse files
committed
let the user know if some files couldnt be copied / moved
1 parent f457c28 commit 21a5f8d

File tree

9 files changed

+43
-25
lines changed

9 files changed

+43
-25
lines changed

app/src/main/java/com/simplemobiletools/filemanager/Utils.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
package com.simplemobiletools.filemanager
22

33
import android.content.Context
4-
import com.simplemobiletools.filepicker.extensions.getFileDocument
5-
import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions
6-
import com.simplemobiletools.filepicker.extensions.scanFile
7-
import com.simplemobiletools.filepicker.extensions.toast
4+
import com.simplemobiletools.filepicker.extensions.*
85
import java.io.File
6+
import java.util.*
97

108
class Utils {
119
companion object {
@@ -20,5 +18,7 @@ class Utils {
2018
fun getFileDocument(context: Context, path: String, treeUri: String) = context.getFileDocument(path, treeUri)
2119

2220
fun scanFile(context: Context, file: File) = context.scanFile(file) {}
21+
22+
fun scanFiles(context: Context, files: ArrayList<File>) = context.scanFiles(files) {}
2323
}
2424
}

app/src/main/java/com/simplemobiletools/filemanager/fragments/ItemsFragment.java

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
public class ItemsFragment extends android.support.v4.app.Fragment
5353
implements AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener, ListView.MultiChoiceModeListener,
54-
ListView.OnTouchListener, CopyMoveTask.CopyMoveListener {
54+
ListView.OnTouchListener {
5555
@BindView(R.id.items_list) ListView mListView;
5656
@BindView(R.id.items_swipe_refresh) SwipeRefreshLayout mSwipeRefreshLayout;
5757
@BindView(R.id.items_holder) CoordinatorLayout mCoordinatorLayout;
@@ -358,17 +358,34 @@ public void onSuccess() {
358358
}
359359

360360
private void displayCopyDialog() {
361-
final List<Integer> itemIndexes = getSelectedItemIndexes();
362-
if (itemIndexes.isEmpty())
361+
final List<Integer> fileIndexes = getSelectedItemIndexes();
362+
if (fileIndexes.isEmpty())
363363
return;
364364

365-
final ArrayList<File> itemsToCopy = new ArrayList<>(itemIndexes.size());
366-
for (Integer i : itemIndexes) {
365+
final ArrayList<File> files = new ArrayList<>(fileIndexes.size());
366+
for (Integer i : fileIndexes) {
367367
FileDirItem item = mItems.get(i);
368-
itemsToCopy.add(new File(item.getPath()));
368+
files.add(new File(item.getPath()));
369369
}
370370

371-
new CopyDialog((SimpleActivity) getActivity(), itemsToCopy, this);
371+
new CopyDialog((SimpleActivity) getActivity(), files, new CopyMoveTask.CopyMoveListener() {
372+
@Override
373+
public void copySucceeded(boolean deleted, boolean copiedAll) {
374+
int msgId;
375+
if (deleted) {
376+
fillItems();
377+
msgId = copiedAll ? R.string.moving_success : R.string.moving_success_partial;
378+
} else {
379+
msgId = copiedAll? R.string.copying_success : R.string.copying_success_partial;
380+
}
381+
Utils.Companion.showToast(getContext(), msgId);
382+
}
383+
384+
@Override
385+
public void copyFailed() {
386+
Utils.Companion.showToast(getContext(), R.string.copy_move_failed);
387+
}
388+
});
372389
}
373390

374391
private FileDirItem getSelectedItem() {
@@ -476,17 +493,6 @@ public void onDestroyActionMode(ActionMode mode) {
476493
mSelectedItemsCnt = 0;
477494
}
478495

479-
@Override
480-
public void copySucceeded(boolean deleted) {
481-
fillItems();
482-
Utils.Companion.showToast(getContext(), deleted ? R.string.moving_success : R.string.copying_success);
483-
}
484-
485-
@Override
486-
public void copyFailed() {
487-
Utils.Companion.showToast(getContext(), R.string.copy_move_failed);
488-
}
489-
490496
public interface ItemInteractionListener {
491497
void itemClicked(FileDirItem item);
492498
}

app/src/main/kotlin/com/simplemobiletools/filemanager/dialogs/CopyDialog.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
9292
updatedFiles.addAll(files)
9393
for (file in files) {
9494
val destination = File(destinationDir, file.name)
95-
file.renameTo(destination)
96-
updatedFiles.add(destination)
95+
if (file.renameTo(destination))
96+
updatedFiles.add(destination)
9797
}
9898

9999
context.scanFiles(updatedFiles) {}
100100
context.toast(R.string.moving_success)
101101
dismiss()
102-
copyMoveListener.copySucceeded(true)
102+
copyMoveListener.copySucceeded(true, files.size * 2 == updatedFiles.size)
103103
}
104104
}
105105
})

app/src/main/res/values-de/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Abbrechen</string>
4141
<string name="press_back_again">Drücke erneut zum Schließen</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 Datei/Ordner gelöscht</item>

app/src/main/res/values-it/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Annulla</string>
4141
<string name="press_back_again">Premi di nuovo indietro per uscire</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 elemento eliminato</item>

app/src/main/res/values-ja/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Cancel</string>
4141
<string name="press_back_again">Press back again to exit</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 アイテムを削除しました</item>

app/src/main/res/values-pt-rPT/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Cancelar</string>
4141
<string name="press_back_again">Prima novamente para sair</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 item apagado</item>

app/src/main/res/values-sv/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Cancel</string>
4141
<string name="press_back_again">Press back again to exit</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 objekt borttagen</item>

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
<string name="ok">OK</string>
4040
<string name="cancel">Cancel</string>
4141
<string name="press_back_again">Press back again to exit</string>
42+
<string name="moving_success_partial">Some files could not be moved</string>
43+
<string name="copying_success_partial">Some files could not be copied</string>
4244

4345
<plurals name="items_deleted">
4446
<item quantity="one">1 item deleted</item>

0 commit comments

Comments
 (0)