use of com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG in project Hentoid by avluis.
the class LibraryActivity method onContentArchiveSuccess.
/**
* Callback for the success of the "archive item" action
*/
private void onContentArchiveSuccess() {
archiveNotificationManager.notify(new ArchiveCompleteNotification(archiveProgress, false));
Snackbar.make(viewPager, getResources().getQuantityString(R.plurals.archive_success, archiveProgress, archiveProgress), LENGTH_LONG).setAction(R.string.open_folder, v -> FileHelper.openFile(this, FileHelper.getDownloadsFolder())).show();
}
use of com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG in project Hentoid by avluis.
the class MetaExportDialogFragment method onJsonSerialized.
private void onJsonSerialized(@NonNull String json, boolean exportLibrary, boolean exportFavsOnly, boolean exportQueue, boolean exportBookmarks) {
exportDisposable.dispose();
// Use a random number to avoid erasing older exports by mistake
String targetFileName = Helper.getRandomInt(9999) + ".json";
if (exportBookmarks)
targetFileName = "bkmks-" + targetFileName;
if (exportQueue)
targetFileName = "queue-" + targetFileName;
if (exportLibrary && !exportFavsOnly)
targetFileName = "library-" + targetFileName;
else if (exportLibrary)
targetFileName = "favs-" + targetFileName;
targetFileName = "export-" + targetFileName;
try {
try (OutputStream newDownload = FileHelper.openNewDownloadOutputStream(requireContext(), targetFileName, JsonHelper.JSON_MIME_TYPE)) {
try (InputStream input = new ByteArrayInputStream(json.getBytes(StandardCharsets.UTF_8))) {
Helper.copy(input, newDownload);
}
}
Snackbar.make(rootView, R.string.copy_download_folder_success, LENGTH_LONG).setAction(R.string.open_folder, v -> FileHelper.openFile(requireContext(), FileHelper.getDownloadsFolder())).show();
} catch (IOException | IllegalArgumentException e) {
Snackbar.make(rootView, R.string.copy_download_folder_fail, LENGTH_LONG).show();
}
if (dao != null)
dao.cleanup();
// Dismiss after 3s, for the user to be able to see and use the snackbar
new Handler(Looper.getMainLooper()).postDelayed(this::dismissAllowingStateLoss, 3000);
}
use of com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG in project Hentoid by avluis.
the class ViewerBottomImageFragment method onCopyClick.
/**
* Handle click on "Copy" action button
*/
private void onCopyClick() {
String targetFileName = image.getContent().getTarget().getUniqueSiteId() + "-" + image.getName() + "." + FileHelper.getExtension(image.getFileUri());
try {
Uri fileUri = Uri.parse(image.getFileUri());
if (!FileHelper.fileExists(requireContext(), fileUri))
return;
try (OutputStream newDownload = FileHelper.openNewDownloadOutputStream(requireContext(), targetFileName, image.getMimeType())) {
try (InputStream input = FileHelper.getInputStream(requireContext(), fileUri)) {
Helper.copy(input, newDownload);
}
}
Snackbar.make(rootView, R.string.copy_download_folder_success, LENGTH_LONG).setAction(R.string.open_folder, v -> FileHelper.openFile(requireContext(), FileHelper.getDownloadsFolder())).show();
} catch (IOException | IllegalArgumentException e) {
Snackbar.make(rootView, R.string.copy_download_folder_fail, LENGTH_LONG).show();
}
}
use of com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG in project Hentoid by avluis.
the class PermissionIntroFragment method showPermissionComplaintManual.
private void showPermissionComplaintManual() {
View view = getView();
if (view == null)
return;
Snackbar.make(view, R.string.permissioncomplaint_snackbar_manual, LENGTH_LONG).setAction(android.R.string.ok, v -> invokeOpenSettings()).show();
}
use of com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG in project Hentoid by avluis.
the class PermissionIntroFragment method showPermissionComplaint.
private void showPermissionComplaint() {
View view = getView();
if (view == null)
return;
Snackbar.make(view, R.string.permissioncomplaint_snackbar, LENGTH_LONG).setAction(android.R.string.ok, v -> invokeAskPermission()).show();
}
Aggregations