add a copy menu button at folder view too

This commit is contained in:
tibbi 2016-11-09 22:47:27 +01:00
parent 8487ef44c4
commit c176959305
2 changed files with 42 additions and 1 deletions

View file

@ -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<File> 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() {
}
}

View file

@ -21,6 +21,10 @@
android:icon="@mipmap/unhide"
android:title="@string/unhide_folder"
app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_copy"
android:title="@string/copy_move"
app:showAsAction="never"/>
<item
android:id="@+id/cab_delete"
android:icon="@mipmap/delete"