Search in sources :

Example 1 with LENGTH_LONG

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();
}
Also used : LibraryGroupsFragment(me.devsaki.hentoid.fragments.library.LibraryGroupsFragment) Content(me.devsaki.hentoid.database.domains.Content) LibraryViewModel(me.devsaki.hentoid.viewmodels.LibraryViewModel) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) WindowManager(android.view.WindowManager) ImageView(android.widget.ImageView) Attribute(me.devsaki.hentoid.database.domains.Attribute) RC_DRAWER(me.devsaki.hentoid.events.CommunicationEvent.RC_DRAWER) ContentHelper(me.devsaki.hentoid.util.ContentHelper) BuildConfig(me.devsaki.hentoid.BuildConfig) ActionBarDrawerToggle(androidx.appcompat.app.ActionBarDrawerToggle) Handler(android.os.Handler) Looper(android.os.Looper) Map(java.util.Map) Fragment(androidx.fragment.app.Fragment) View(android.view.View) EV_SEARCH(me.devsaki.hentoid.events.CommunicationEvent.EV_SEARCH) EV_UPDATE_SORT(me.devsaki.hentoid.events.CommunicationEvent.EV_UPDATE_SORT) ArchiveProgressNotification(me.devsaki.hentoid.notification.archive.ArchiveProgressNotification) RC_CONTENTS(me.devsaki.hentoid.events.CommunicationEvent.RC_CONTENTS) EV_DISABLE(me.devsaki.hentoid.events.CommunicationEvent.EV_DISABLE) SearchView(androidx.appcompat.widget.SearchView) ThreadMode(org.greenrobot.eventbus.ThreadMode) UpdateSuccessDialogFragment(me.devsaki.hentoid.fragments.library.UpdateSuccessDialogFragment) CommunicationEvent(me.devsaki.hentoid.events.CommunicationEvent) Timber(timber.log.Timber) ViewModelFactory(me.devsaki.hentoid.viewmodels.ViewModelFactory) IdRes(androidx.annotation.IdRes) List(java.util.List) EV_CLOSED(me.devsaki.hentoid.events.CommunicationEvent.EV_CLOSED) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Grouping(me.devsaki.hentoid.enums.Grouping) ProcessEvent(me.devsaki.hentoid.events.ProcessEvent) DocumentFile(androidx.documentfile.provider.DocumentFile) Toolbar(androidx.appcompat.widget.Toolbar) ArchiveCompleteNotification(me.devsaki.hentoid.notification.archive.ArchiveCompleteNotification) CollectionDAO(me.devsaki.hentoid.database.CollectionDAO) Snackbar(com.google.android.material.snackbar.Snackbar) ViewDragHelper(androidx.customview.widget.ViewDragHelper) DrawerLayout(androidx.drawerlayout.widget.DrawerLayout) Debouncer(me.devsaki.hentoid.util.Debouncer) Preferences(me.devsaki.hentoid.util.Preferences) Intent(android.content.Intent) ViewPager2(androidx.viewpager2.widget.ViewPager2) HashMap(java.util.HashMap) BaseTransientBottomBar(com.google.android.material.snackbar.BaseTransientBottomBar) AppUpdatedEvent(me.devsaki.hentoid.events.AppUpdatedEvent) NotificationManager(me.devsaki.hentoid.util.notification.NotificationManager) MenuItem(android.view.MenuItem) FragmentActivity(androidx.fragment.app.FragmentActivity) FragmentStateAdapter(androidx.viewpager2.adapter.FragmentStateAdapter) RC_GROUPS(me.devsaki.hentoid.events.CommunicationEvent.RC_GROUPS) SuppressLint(android.annotation.SuppressLint) TooltipHelper(me.devsaki.hentoid.util.TooltipHelper) EV_ENABLE(me.devsaki.hentoid.events.CommunicationEvent.EV_ENABLE) Helper(me.devsaki.hentoid.util.Helper) SelectExtension(com.mikepenz.fastadapter.select.SelectExtension) EventBus(org.greenrobot.eventbus.EventBus) LibraryContentFragment(me.devsaki.hentoid.fragments.library.LibraryContentFragment) PermissionHelper(me.devsaki.hentoid.util.PermissionHelper) ArchiveNotificationChannel(me.devsaki.hentoid.notification.archive.ArchiveNotificationChannel) ViewModelProvider(androidx.lifecycle.ViewModelProvider) GravityCompat(androidx.core.view.GravityCompat) Field(java.lang.reflect.Field) FileHelper(me.devsaki.hentoid.util.FileHelper) ObjectBoxDAO(me.devsaki.hentoid.database.ObjectBoxDAO) PopupMenu(androidx.appcompat.widget.PopupMenu) ArchiveStartNotification(me.devsaki.hentoid.notification.archive.ArchiveStartNotification) ArrowOrientation(com.skydoves.balloon.ArrowOrientation) R(me.devsaki.hentoid.R) Subscribe(org.greenrobot.eventbus.Subscribe) SharedPreferences(android.content.SharedPreferences) LENGTH_LONG(com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG) EV_ADVANCED_SEARCH(me.devsaki.hentoid.events.CommunicationEvent.EV_ADVANCED_SEARCH) Collections(java.util.Collections) ArchiveCompleteNotification(me.devsaki.hentoid.notification.archive.ArchiveCompleteNotification)

Example 2 with LENGTH_LONG

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);
}
Also used : Bundle(android.os.Bundle) ProgressBar(android.widget.ProgressBar) NonNull(androidx.annotation.NonNull) Single(io.reactivex.Single) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) CheckBox(android.widget.CheckBox) ByteArrayInputStream(java.io.ByteArrayInputStream) Disposables(io.reactivex.disposables.Disposables) Helper(me.devsaki.hentoid.util.Helper) SwitchMaterial(com.google.android.material.switchmaterial.SwitchMaterial) Handler(android.os.Handler) Looper(android.os.Looper) JsonHelper(me.devsaki.hentoid.util.JsonHelper) View(android.view.View) Schedulers(io.reactivex.schedulers.Schedulers) Build(android.os.Build) OutputStream(java.io.OutputStream) FragmentManager(androidx.fragment.app.FragmentManager) JsonContentCollection(me.devsaki.hentoid.json.JsonContentCollection) LayoutInflater(android.view.LayoutInflater) IOException(java.io.IOException) PorterDuff(android.graphics.PorterDuff) FileHelper(me.devsaki.hentoid.util.FileHelper) ViewGroup(android.view.ViewGroup) StandardCharsets(java.nio.charset.StandardCharsets) Timber(timber.log.Timber) ObjectBoxDAO(me.devsaki.hentoid.database.ObjectBoxDAO) R(me.devsaki.hentoid.R) ViewCompat.requireViewById(androidx.core.view.ViewCompat.requireViewById) Disposable(io.reactivex.disposables.Disposable) Nullable(androidx.annotation.Nullable) Grouping(me.devsaki.hentoid.enums.Grouping) ThemeHelper(me.devsaki.hentoid.util.ThemeHelper) LENGTH_LONG(com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG) CollectionDAO(me.devsaki.hentoid.database.CollectionDAO) Snackbar(com.google.android.material.snackbar.Snackbar) DialogFragment(androidx.fragment.app.DialogFragment) InputStream(java.io.InputStream) ContextXKt(me.devsaki.hentoid.core.ContextXKt) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) Handler(android.os.Handler) IOException(java.io.IOException)

Example 3 with LENGTH_LONG

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();
    }
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) NonNull(androidx.annotation.NonNull) MaterialAlertDialogBuilder(com.google.android.material.dialog.MaterialAlertDialogBuilder) Uri(android.net.Uri) ImageView(android.widget.ImageView) BitmapFactory(android.graphics.BitmapFactory) BaseTransientBottomBar(com.google.android.material.snackbar.BaseTransientBottomBar) Drawable(android.graphics.drawable.Drawable) ColorStateList(android.content.res.ColorStateList) WebpDrawableTransformation(com.bumptech.glide.integration.webp.decoder.WebpDrawableTransformation) ImageViewerActivityBundle(me.devsaki.hentoid.activities.bundles.ImageViewerActivityBundle) Helper(me.devsaki.hentoid.util.Helper) ImageFile(me.devsaki.hentoid.database.domains.ImageFile) View(android.view.View) HentoidApp(me.devsaki.hentoid.core.HentoidApp) OutputStream(java.io.OutputStream) ImageViewerViewModel(me.devsaki.hentoid.viewmodels.ImageViewerViewModel) FragmentManager(androidx.fragment.app.FragmentManager) RequestOptions(com.bumptech.glide.request.RequestOptions) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) WebpDrawable(com.bumptech.glide.integration.webp.decoder.WebpDrawable) Transformation(com.bumptech.glide.load.Transformation) Point(android.graphics.Point) IOException(java.io.IOException) BitmapDrawable(android.graphics.drawable.BitmapDrawable) FileHelper(me.devsaki.hentoid.util.FileHelper) ViewGroup(android.view.ViewGroup) Timber(timber.log.Timber) ViewModelFactory(me.devsaki.hentoid.viewmodels.ViewModelFactory) R(me.devsaki.hentoid.R) ViewCompat.requireViewById(androidx.core.view.ViewCompat.requireViewById) List(java.util.List) ContentNotProcessedException(me.devsaki.hentoid.util.exception.ContentNotProcessedException) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) Glide(com.bumptech.glide.Glide) ThemeHelper(me.devsaki.hentoid.util.ThemeHelper) LENGTH_LONG(com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG) BottomSheetDialogFragment(com.google.android.material.bottomsheet.BottomSheetDialogFragment) Bitmap(android.graphics.Bitmap) CenterInside(com.bumptech.glide.load.resource.bitmap.CenterInside) ImageHelper.tintBitmap(me.devsaki.hentoid.util.ImageHelper.tintBitmap) Snackbar(com.google.android.material.snackbar.Snackbar) InputStream(java.io.InputStream) InputStream(java.io.InputStream) OutputStream(java.io.OutputStream) IOException(java.io.IOException) Uri(android.net.Uri)

Example 4 with LENGTH_LONG

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();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) SlidePolicy(com.github.appintro.SlidePolicy) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) IntroActivity(me.devsaki.hentoid.activities.IntroActivity) Intent(android.content.Intent) ViewGroup(android.view.ViewGroup) R(me.devsaki.hentoid.R) Manifest(android.Manifest) Nullable(androidx.annotation.Nullable) BuildConfig(me.devsaki.hentoid.BuildConfig) LENGTH_LONG(com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Settings(android.provider.Settings) PermissionHelper(me.devsaki.hentoid.util.PermissionHelper) ContextCompat(androidx.core.content.ContextCompat) Snackbar(com.google.android.material.snackbar.Snackbar) View(android.view.View)

Example 5 with LENGTH_LONG

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();
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) PackageManager(android.content.pm.PackageManager) SlidePolicy(com.github.appintro.SlidePolicy) LayoutInflater(android.view.LayoutInflater) NonNull(androidx.annotation.NonNull) Uri(android.net.Uri) IntroActivity(me.devsaki.hentoid.activities.IntroActivity) Intent(android.content.Intent) ViewGroup(android.view.ViewGroup) R(me.devsaki.hentoid.R) Manifest(android.Manifest) Nullable(androidx.annotation.Nullable) BuildConfig(me.devsaki.hentoid.BuildConfig) LENGTH_LONG(com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Settings(android.provider.Settings) PermissionHelper(me.devsaki.hentoid.util.PermissionHelper) ContextCompat(androidx.core.content.ContextCompat) Snackbar(com.google.android.material.snackbar.Snackbar) View(android.view.View)

Aggregations

Bundle (android.os.Bundle)5 View (android.view.View)5 NonNull (androidx.annotation.NonNull)5 Nullable (androidx.annotation.Nullable)5 LENGTH_LONG (com.google.android.material.snackbar.BaseTransientBottomBar.LENGTH_LONG)5 Snackbar (com.google.android.material.snackbar.Snackbar)5 LayoutInflater (android.view.LayoutInflater)4 ViewGroup (android.view.ViewGroup)4 R (me.devsaki.hentoid.R)4 Context (android.content.Context)3 Intent (android.content.Intent)3 PackageManager (android.content.pm.PackageManager)3 Uri (android.net.Uri)3 Fragment (androidx.fragment.app.Fragment)3 BuildConfig (me.devsaki.hentoid.BuildConfig)3 Manifest (android.Manifest)2 Handler (android.os.Handler)2 Looper (android.os.Looper)2 Settings (android.provider.Settings)2 ContextCompat (androidx.core.content.ContextCompat)2