Search in sources :

Example 1 with OnPermissionDenied

use of permissions.dispatcher.OnPermissionDenied in project ETSMobile-Android2 by ApplETS.

the class MoodleCourseDetailsFragment method showPermissionsSnackbar.

/**
 * Shows a snackbar in case he/she needs to allow the app to write to external storage
 * in order to download a file coming from Moodle.
 */
@OnPermissionDenied(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@OnNeverAskAgain(Manifest.permission.WRITE_EXTERNAL_STORAGE)
void showPermissionsSnackbar() {
    Snackbar snackbar = Snackbar.make(getView(), R.string.moodle_allow_storage_permissions, Snackbar.LENGTH_SHORT).setAction(R.string.action_settings, (listener) -> Utility.goToAppSettings(listener.getContext())).setActionTextColor(ContextCompat.getColor(getActivity(), R.color.ets_red));
    snackbar.show();
}
Also used : Context(android.content.Context) MoodleWebService(ca.etsmtl.applets.etsmobile.http.MoodleWebService) Bundle(android.os.Bundle) Environment(android.os.Environment) NonNull(androidx.annotation.NonNull) MoodleCoreCourse(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreCourse) Uri(android.net.Uri) Intent(android.content.Intent) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) Response(retrofit2.Response) MoodleCoreModule(ca.etsmtl.applets.etsmobile.model.moodle.MoodleCoreModule) ArrayList(java.util.ArrayList) Manifest(android.Manifest) OnPermissionDenied(permissions.dispatcher.OnPermissionDenied) Utility(ca.etsmtl.applets.etsmobile.util.Utility) Toast(android.widget.Toast) OnNeverAskAgain(permissions.dispatcher.OnNeverAskAgain) View(android.view.View) Build(android.os.Build) ExpandableListMoodleSectionAdapter(ca.etsmtl.applets.etsmobile.ui.adapter.ExpandableListMoodleSectionAdapter) ContextCompat(androidx.core.content.ContextCompat) Cursor(android.database.Cursor) LayoutInflater(android.view.LayoutInflater) IntentFilter(android.content.IntentFilter) BroadcastReceiver(android.content.BroadcastReceiver) RuntimePermissions(permissions.dispatcher.RuntimePermissions) ViewGroup(android.view.ViewGroup) File(java.io.File) ApplicationManager(ca.etsmtl.applets.etsmobile.ApplicationManager) DownloadManager(android.app.DownloadManager) NeedsPermission(permissions.dispatcher.NeedsPermission) List(java.util.List) Callback(retrofit2.Callback) R(ca.etsmtl.applets.etsmobile2.R) ActivityNotFoundException(android.content.ActivityNotFoundException) FileProvider(androidx.core.content.FileProvider) MoodleModuleContent(ca.etsmtl.applets.etsmobile.model.moodle.MoodleModuleContent) ExpandableListView(android.widget.ExpandableListView) Snackbar(com.google.android.material.snackbar.Snackbar) Collections(java.util.Collections) Call(retrofit2.Call) MimeTypeMap(android.webkit.MimeTypeMap) FilenameUtils(org.apache.commons.io.FilenameUtils) Snackbar(com.google.android.material.snackbar.Snackbar) OnNeverAskAgain(permissions.dispatcher.OnNeverAskAgain) OnPermissionDenied(permissions.dispatcher.OnPermissionDenied)

Aggregations

Manifest (android.Manifest)1 DownloadManager (android.app.DownloadManager)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 Intent (android.content.Intent)1 IntentFilter (android.content.IntentFilter)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 Build (android.os.Build)1 Bundle (android.os.Bundle)1 Environment (android.os.Environment)1 LayoutInflater (android.view.LayoutInflater)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 MimeTypeMap (android.webkit.MimeTypeMap)1 ExpandableListView (android.widget.ExpandableListView)1 Toast (android.widget.Toast)1 NonNull (androidx.annotation.NonNull)1 ContextCompat (androidx.core.content.ContextCompat)1