diff --git a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java index 0846fc326..5795a1063 100644 --- a/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/gallery/activities/MainActivity.java @@ -31,8 +31,10 @@ import com.simplemobiletools.gallery.Constants; import com.simplemobiletools.gallery.R; import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.adapters.DirectoryAdapter; +import com.simplemobiletools.gallery.asynctasks.CopyTask; import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask; import com.simplemobiletools.gallery.dialogs.ChangeSorting; +import com.simplemobiletools.gallery.dialogs.CopyDialog; import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog; import com.simplemobiletools.gallery.models.Directory; @@ -40,6 +42,7 @@ import org.jetbrains.annotations.NotNull; import java.io.File; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -49,7 +52,8 @@ import butterknife.ButterKnife; public class MainActivity extends SimpleActivity implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, - SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener, GetDirectoriesAsynctask.GetDirectoriesListener { + SwipeRefreshLayout.OnRefreshListener, ChangeSorting.ChangeDialogListener, GetDirectoriesAsynctask.GetDirectoriesListener, + CopyTask.CopyDoneListener { @BindView(R.id.directories_grid) GridView mGridView; @BindView(R.id.directories_holder) SwipeRefreshLayout mSwipeRefreshLayout; @@ -315,6 +319,26 @@ public class MainActivity extends SimpleActivity }); } + private void displayCopyDialog() { + final List files = new ArrayList<>(); + final SparseBooleanArray items = mGridView.getCheckedItemPositions(); + final int cnt = items.size(); + for (int i = 0; i < cnt; i++) { + if (items.valueAt(i)) { + final int id = items.keyAt(i); + final File dir = new File(mDirs.get(id).getPath()); + files.addAll(Arrays.asList(dir.listFiles())); + } + } + + new CopyDialog(this, files, this, new CopyDialog.OnCopyListener() { + @Override + public void onSuccess() { + + } + }); + } + private boolean isPickImageIntent(Intent intent) { return isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent)); } @@ -480,6 +504,9 @@ public class MainActivity extends SimpleActivity unhideFolders(); mode.finish(); return true; + case R.id.cab_copy: + displayCopyDialog(); + return true; default: return false; } @@ -562,4 +589,14 @@ public class MainActivity extends SimpleActivity mGridView.setOnTouchListener(this); mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL); } + + @Override + public void copySucceeded(@NotNull File destinationDir) { + + } + + @Override + public void copyFailed() { + + } } diff --git a/app/src/main/res/menu/directories_cab.xml b/app/src/main/res/menu/directories_cab.xml index e0a623691..349a6524c 100644 --- a/app/src/main/res/menu/directories_cab.xml +++ b/app/src/main/res/menu/directories_cab.xml @@ -21,6 +21,10 @@ android:icon="@mipmap/unhide" android:title="@string/unhide_folder" app:showAsAction="ifRoom"/> +