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.R;
import com.simplemobiletools.gallery.Utils; import com.simplemobiletools.gallery.Utils;
import com.simplemobiletools.gallery.adapters.DirectoryAdapter; import com.simplemobiletools.gallery.adapters.DirectoryAdapter;
import com.simplemobiletools.gallery.asynctasks.CopyTask;
import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask; import com.simplemobiletools.gallery.asynctasks.GetDirectoriesAsynctask;
import com.simplemobiletools.gallery.dialogs.ChangeSorting; import com.simplemobiletools.gallery.dialogs.ChangeSorting;
import com.simplemobiletools.gallery.dialogs.CopyDialog;
import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog; import com.simplemobiletools.gallery.dialogs.RenameDirectoryDialog;
import com.simplemobiletools.gallery.models.Directory; import com.simplemobiletools.gallery.models.Directory;
@ -40,6 +42,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -49,7 +52,8 @@ import butterknife.ButterKnife;
public class MainActivity extends SimpleActivity public class MainActivity extends SimpleActivity
implements AdapterView.OnItemClickListener, GridView.MultiChoiceModeListener, GridView.OnTouchListener, 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_grid) GridView mGridView;
@BindView(R.id.directories_holder) SwipeRefreshLayout mSwipeRefreshLayout; @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) { private boolean isPickImageIntent(Intent intent) {
return isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent)); return isPickIntent(intent) && (hasImageContentData(intent) || isImageType(intent));
} }
@ -480,6 +504,9 @@ public class MainActivity extends SimpleActivity
unhideFolders(); unhideFolders();
mode.finish(); mode.finish();
return true; return true;
case R.id.cab_copy:
displayCopyDialog();
return true;
default: default:
return false; return false;
} }
@ -562,4 +589,14 @@ public class MainActivity extends SimpleActivity
mGridView.setOnTouchListener(this); mGridView.setOnTouchListener(this);
mGridView.setChoiceMode(GridView.CHOICE_MODE_MULTIPLE_MODAL); 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:icon="@mipmap/unhide"
android:title="@string/unhide_folder" android:title="@string/unhide_folder"
app:showAsAction="ifRoom"/> app:showAsAction="ifRoom"/>
<item
android:id="@+id/cab_copy"
android:title="@string/copy_move"
app:showAsAction="never"/>
<item <item
android:id="@+id/cab_delete" android:id="@+id/cab_delete"
android:icon="@mipmap/delete" android:icon="@mipmap/delete"