Search in sources :

Example 1 with OnNeverAskAgain

use of permissions.dispatcher.OnNeverAskAgain in project file.io-app by rumaan.

the class MainActivity method showAppDetailsSettings.

/* Opens App info screen in settings */
@OnNeverAskAgain({ Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE })
void showAppDetailsSettings() {
    Toast.makeText(this, getString(R.string.app_wont_work), Toast.LENGTH_LONG).show();
    try {
        Intent intent;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
            intent = new Intent(Intent.ACTION_APPLICATION_PREFERENCES);
            intent.setData(Uri.parse("package:" + getPackageName()));
            startActivity(intent);
        } else {
            intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package: " + getPackageName()));
            startActivity(intent);
        }
    } catch (ActivityNotFoundException e) {
        Intent intent = new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
        startActivity(intent);
        e.printStackTrace();
    }
}
Also used : ActivityNotFoundException(android.content.ActivityNotFoundException) Intent(android.content.Intent) OnNeverAskAgain(permissions.dispatcher.OnNeverAskAgain)

Example 2 with OnNeverAskAgain

use of permissions.dispatcher.OnNeverAskAgain 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

ActivityNotFoundException (android.content.ActivityNotFoundException)2 Intent (android.content.Intent)2 OnNeverAskAgain (permissions.dispatcher.OnNeverAskAgain)2 Manifest (android.Manifest)1 DownloadManager (android.app.DownloadManager)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)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