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();
}
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;
}
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;
}
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;
}
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);
}
}
}
Aggregations