let the user know if some files couldnt be copied / moved
This commit is contained in:
parent
f457c2842c
commit
21a5f8d685
9 changed files with 43 additions and 25 deletions
|
@ -1,11 +1,9 @@
|
|||
package com.simplemobiletools.filemanager
|
||||
|
||||
import android.content.Context
|
||||
import com.simplemobiletools.filepicker.extensions.getFileDocument
|
||||
import com.simplemobiletools.filepicker.extensions.needsStupidWritePermissions
|
||||
import com.simplemobiletools.filepicker.extensions.scanFile
|
||||
import com.simplemobiletools.filepicker.extensions.toast
|
||||
import com.simplemobiletools.filepicker.extensions.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class Utils {
|
||||
companion object {
|
||||
|
@ -20,5 +18,7 @@ class Utils {
|
|||
fun getFileDocument(context: Context, path: String, treeUri: String) = context.getFileDocument(path, treeUri)
|
||||
|
||||
fun scanFile(context: Context, file: File) = context.scanFile(file) {}
|
||||
|
||||
fun scanFiles(context: Context, files: ArrayList<File>) = context.scanFiles(files) {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ import butterknife.OnClick;
|
|||
|
||||
public class ItemsFragment extends android.support.v4.app.Fragment
|
||||
implements AdapterView.OnItemClickListener, SwipeRefreshLayout.OnRefreshListener, ListView.MultiChoiceModeListener,
|
||||
ListView.OnTouchListener, CopyMoveTask.CopyMoveListener {
|
||||
ListView.OnTouchListener {
|
||||
@BindView(R.id.items_list) ListView mListView;
|
||||
@BindView(R.id.items_swipe_refresh) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||
@BindView(R.id.items_holder) CoordinatorLayout mCoordinatorLayout;
|
||||
|
@ -358,17 +358,34 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||
}
|
||||
|
||||
private void displayCopyDialog() {
|
||||
final List<Integer> itemIndexes = getSelectedItemIndexes();
|
||||
if (itemIndexes.isEmpty())
|
||||
final List<Integer> fileIndexes = getSelectedItemIndexes();
|
||||
if (fileIndexes.isEmpty())
|
||||
return;
|
||||
|
||||
final ArrayList<File> itemsToCopy = new ArrayList<>(itemIndexes.size());
|
||||
for (Integer i : itemIndexes) {
|
||||
final ArrayList<File> files = new ArrayList<>(fileIndexes.size());
|
||||
for (Integer i : fileIndexes) {
|
||||
FileDirItem item = mItems.get(i);
|
||||
itemsToCopy.add(new File(item.getPath()));
|
||||
files.add(new File(item.getPath()));
|
||||
}
|
||||
|
||||
new CopyDialog((SimpleActivity) getActivity(), itemsToCopy, this);
|
||||
new CopyDialog((SimpleActivity) getActivity(), files, new CopyMoveTask.CopyMoveListener() {
|
||||
@Override
|
||||
public void copySucceeded(boolean deleted, boolean copiedAll) {
|
||||
int msgId;
|
||||
if (deleted) {
|
||||
fillItems();
|
||||
msgId = copiedAll ? R.string.moving_success : R.string.moving_success_partial;
|
||||
} else {
|
||||
msgId = copiedAll? R.string.copying_success : R.string.copying_success_partial;
|
||||
}
|
||||
Utils.Companion.showToast(getContext(), msgId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFailed() {
|
||||
Utils.Companion.showToast(getContext(), R.string.copy_move_failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private FileDirItem getSelectedItem() {
|
||||
|
@ -476,17 +493,6 @@ public class ItemsFragment extends android.support.v4.app.Fragment
|
|||
mSelectedItemsCnt = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copySucceeded(boolean deleted) {
|
||||
fillItems();
|
||||
Utils.Companion.showToast(getContext(), deleted ? R.string.moving_success : R.string.copying_success);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFailed() {
|
||||
Utils.Companion.showToast(getContext(), R.string.copy_move_failed);
|
||||
}
|
||||
|
||||
public interface ItemInteractionListener {
|
||||
void itemClicked(FileDirItem item);
|
||||
}
|
||||
|
|
|
@ -92,14 +92,14 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
|||
updatedFiles.addAll(files)
|
||||
for (file in files) {
|
||||
val destination = File(destinationDir, file.name)
|
||||
file.renameTo(destination)
|
||||
updatedFiles.add(destination)
|
||||
if (file.renameTo(destination))
|
||||
updatedFiles.add(destination)
|
||||
}
|
||||
|
||||
context.scanFiles(updatedFiles) {}
|
||||
context.toast(R.string.moving_success)
|
||||
dismiss()
|
||||
copyMoveListener.copySucceeded(true)
|
||||
copyMoveListener.copySucceeded(true, files.size * 2 == updatedFiles.size)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Abbrechen</string>
|
||||
<string name="press_back_again">Drücke erneut zum Schließen</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 Datei/Ordner gelöscht</item>
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Annulla</string>
|
||||
<string name="press_back_again">Premi di nuovo indietro per uscire</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 elemento eliminato</item>
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="press_back_again">Press back again to exit</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 アイテムを削除しました</item>
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancelar</string>
|
||||
<string name="press_back_again">Prima novamente para sair</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 item apagado</item>
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="press_back_again">Press back again to exit</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 objekt borttagen</item>
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
<string name="press_back_again">Press back again to exit</string>
|
||||
<string name="moving_success_partial">Some files could not be moved</string>
|
||||
<string name="copying_success_partial">Some files could not be copied</string>
|
||||
|
||||
<plurals name="items_deleted">
|
||||
<item quantity="one">1 item deleted</item>
|
||||
|
|
Loading…
Reference in a new issue