also allow export in FileDetailFragment

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2022-07-04 08:13:47 +02:00
parent 72044454c1
commit 9fb607cc9a
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 39 additions and 18 deletions

View file

@ -44,6 +44,7 @@ import com.google.android.material.tabs.TabLayout;
import com.nextcloud.client.account.User;
import com.nextcloud.client.account.UserAccountManager;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.jobs.BackgroundJobManager;
import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.client.preferences.AppPreferences;
@ -80,6 +81,7 @@ import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import javax.inject.Inject;
@ -115,6 +117,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
@Inject ThemeColorUtils themeColorUtils;
@Inject ThemeLayoutUtils themeLayoutUtils;
@Inject ThemeBarUtils themeBarUtils;
@Inject BackgroundJobManager backgroundJobManager;
/**
* Public factory method to create new FileDetailFragment instances.
@ -408,6 +411,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
containerActivity.getFileOperationsHelper().syncFile(getFile());
return true;
} else if (itemId == R.id.action_export_file) {
ArrayList<OCFile> list = new ArrayList<>();
list.add(getFile());
containerActivity.getFileOperationsHelper().exportFiles(list,
getContext(),
getView(),
backgroundJobManager);
return true;
} else if (itemId == R.id.action_set_as_wallpaper) {
containerActivity.getFileOperationsHelper().setPictureAs(getFile(), getView());
return true;

View file

@ -1187,7 +1187,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
exitSelectionMode();
return true;
} else if (itemId == R.id.action_export_file) {
exportFiles(checkedFiles);
mContainerActivity.getFileOperationsHelper().exportFiles(checkedFiles,
getContext(),
getView(),
backgroundJobManager);
exitSelectionMode();
return true;
} else if (itemId == R.id.action_cancel_sync) {
@ -1830,23 +1833,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
}
private void exportFiles(Collection<OCFile> files) {
Context context = getContext();
View view = getView();
if (context != null && view != null) {
DisplayUtils.showSnackMessage(view,
context.getString(
R.string.export_start,
context.getResources().getQuantityString(R.plurals.files,
files.size(),
files.size())
));
}
backgroundJobManager.startImmediateFilesExportJob(files);
}
private void showSpaceErrorDialog(OCFile file, long availableSpaceOnDevice) {
SyncFileNotEnoughSpaceDialogFragment dialog =
SyncFileNotEnoughSpaceDialogFragment.newInstance(file, availableSpaceOnDevice);

View file

@ -49,6 +49,7 @@ import android.webkit.MimeTypeMap;
import com.nextcloud.client.account.CurrentAccountProvider;
import com.nextcloud.client.account.User;
import com.nextcloud.client.jobs.BackgroundJobManager;
import com.nextcloud.client.network.ConnectivityService;
import com.nextcloud.java.util.Optional;
import com.owncloud.android.MainApp;
@ -1033,6 +1034,24 @@ public class FileOperationsHelper {
fileActivity.showLoadingDialog(fileActivity.getString(R.string.wait_a_moment));
}
public void exportFiles(Collection<OCFile> files,
Context context,
View view,
BackgroundJobManager backgroundJobManager) {
if (context != null && view != null) {
DisplayUtils.showSnackMessage(view,
context.getString(
R.string.export_start,
context.getResources().getQuantityString(R.plurals.files,
files.size(),
files.size())
));
}
backgroundJobManager.startImmediateFilesExportJob(files);
}
public long getOpIdWaitingFor() {
return mWaitingForOpId;
}

View file

@ -32,6 +32,11 @@
android:title="@string/filedetails_download"
app:showAsAction="never"
android:showAsAction="never" />
<item
android:id="@+id/action_export_file"
android:title="@string/filedetails_export"
app:showAsAction="never"
android:showAsAction="never" />
<item
android:id="@+id/action_send_file"
android:title="@string/common_send"