Search in sources :

Example 26 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project android by nextcloud.

the class UploadFilesActivity method checkLocalStoragePathPickerPermission.

private void checkLocalStoragePathPickerPermission() {
    if (!PermissionUtil.checkExternalStoragePermission(this)) {
        // Check if we should show an explanation
        if (PermissionUtil.shouldShowRequestPermissionRationale(this, PermissionUtil.getExternalStoragePermission())) {
            // Show explanation to the user and then request permission
            Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), R.string.permission_storage_access, Snackbar.LENGTH_INDEFINITE).setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(this));
            ThemeSnackbarUtils.colorSnackbar(this, snackbar);
            snackbar.show();
        } else {
            // No explanation needed, request the permission.
            PermissionUtil.requestExternalStoragePermission(this);
        }
        return;
    }
    showLocalStoragePathPickerDialog();
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Example 27 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project android by nextcloud.

the class DisplayUtils method showSnackMessage.

/**
 * Show a temporary message in a {@link Snackbar} bound to the content view.
 *
 * @param context         to load resources.
 * @param view            The content view the {@link Snackbar} is bound to.
 * @param messageResource The resource id of the string resource to use. Can be formatted text.
 * @param formatArgs      The format arguments that will be used for substitution.
 * @return The created {@link Snackbar}
 */
public static Snackbar showSnackMessage(Context context, View view, @StringRes int messageResource, Object... formatArgs) {
    final Snackbar snackbar = Snackbar.make(view, String.format(context.getString(messageResource, formatArgs)), Snackbar.LENGTH_LONG);
    snackbar.show();
    return snackbar;
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Example 28 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project android by nextcloud.

the class DisplayUtils method showSnackMessage.

/**
 * Show a temporary message in a {@link Snackbar} bound to the content view.
 *
 * @param activity The {@link Activity} to which's content view the {@link Snackbar} is bound.
 * @param message  Message to show.
 * @return The created {@link Snackbar}
 */
public static Snackbar showSnackMessage(Activity activity, String message) {
    final Snackbar snackbar = Snackbar.make(activity.findViewById(android.R.id.content), message, Snackbar.LENGTH_LONG);
    snackbar.show();
    return snackbar;
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Example 29 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project android by nextcloud.

the class DisplayUtils method showSnackMessage.

/**
 * Show a temporary message in a {@link Snackbar} bound to the given view.
 *
 * @param view            The view the {@link Snackbar} is bound to.
 * @param messageResource The resource id of the string resource to use. Can be formatted text.
 * @return The created {@link Snackbar}
 */
public static Snackbar showSnackMessage(View view, @StringRes int messageResource) {
    final Snackbar snackbar = Snackbar.make(view, messageResource, Snackbar.LENGTH_LONG);
    snackbar.show();
    return snackbar;
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Example 30 with Snackbar

use of com.google.android.material.snackbar.Snackbar in project android by nextcloud.

the class MediaProvider method checkPermissions.

private static void checkPermissions(@Nullable Activity activity) {
    if (activity != null && !PermissionUtil.checkExternalStoragePermission(activity.getApplicationContext())) {
        // Check if we should show an explanation
        if (PermissionUtil.shouldShowRequestPermissionRationale(activity, PermissionUtil.getExternalStoragePermission())) {
            // Show explanation to the user and then request permission
            Snackbar snackbar = Snackbar.make(activity.findViewById(R.id.ListLayout), R.string.permission_storage_access, Snackbar.LENGTH_INDEFINITE).setAction(R.string.common_ok, v -> PermissionUtil.requestExternalStoragePermission(activity));
            ThemeSnackbarUtils.colorSnackbar(activity.getApplicationContext(), snackbar);
            snackbar.show();
        } else {
            // No explanation needed, request the permission.
            PermissionUtil.requestExternalStoragePermission(activity);
        }
    }
}
Also used : Snackbar(com.google.android.material.snackbar.Snackbar)

Aggregations

Snackbar (com.google.android.material.snackbar.Snackbar)110 View (android.view.View)61 Intent (android.content.Intent)46 TextView (android.widget.TextView)41 AlertDialog (androidx.appcompat.app.AlertDialog)29 Context (android.content.Context)28 ImageView (android.widget.ImageView)28 LayoutInflater (android.view.LayoutInflater)24 ArrayList (java.util.ArrayList)23 RecyclerView (androidx.recyclerview.widget.RecyclerView)22 Bundle (android.os.Bundle)20 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)20 DialogInterface (android.content.DialogInterface)19 List (java.util.List)19 CreateCardView (me.ccrama.redditslide.Views.CreateCardView)18 Submission (net.dean.jraw.models.Submission)18 SubredditView (me.ccrama.redditslide.Activities.SubredditView)17 ApiException (net.dean.jraw.ApiException)17 Activity (android.app.Activity)16 OnSingleClickListener (me.ccrama.redditslide.util.OnSingleClickListener)16