Skip to content

Feature/permissions library #1855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Preparing fir issue #1773] Added a utility function which would take…
… the user to app settings screen where he could manually give us the required permission
  • Loading branch information
ashishkumar468 committed Aug 22, 2018
commit da395427572a4c242d8f2c7e87e7e49048670b0a
19 changes: 19 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/utils/PermissionUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package fr.free.nrw.commons.utils;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

public class PermissionUtils {

//Can be used by any activity which requires a permission which has been blocked(marked never ask again by the user)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very helpful comment! :) But could you please write this in Javadoc format to take advantage of IDE support?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been there, will do it

//It open the app settings from where the user can manully give us the required permission.
public static void askUserToManuallyEnablePermissionFromSettings(
Activity activity) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", activity.getPackageName(), null);
intent.setData(uri);
activity.startActivityForResult(intent, Constants.REQUEST_CODES.OPEN_APPLICATION_DETAIL_SETTINGS);
}
}