forked from commons-app/apps-android-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/permissions library (commons-app#1855)
* Added permission for Dexter, the runtime permission handling library * [Preparing fir issue commons-app#1773] Added a utility function which would take the user to app settings screen where he could manually give us the required permission * Added an alert dialog with positive and negative callback [Preparing fir issue commons-app#1773] * Improvements in the way External Storage Permission is handled in MultipleShareActivity[Bug fix commons-app#1697] 1. Used dexter to handle the external storage permission 2. Behaviour changes : When user tries to share(uppload) images to commons via MultipleShareActivity, following decision tree is followed a. If the app has permission for external storage, normal upload operation is followed b. If the app does not has the permission for external storage, dexter is used to ask for the same c. If the user gives us the required permission, normal upload flow is proceeded d. If the doesnot gives us the required permission a rationale dialog is shown with the appropriate message to let him know why we need the permission e. If he presses okay, steps a-c are followed and if he presses cancel, we close the app. f. If while asking for permission, the user chooses never ask again, then next time he tries to upload an image via MSA, the rational dialog follows the app setting screen where he could manually give us the required permission and the onActivityResult of same is handled * Added a Constants class to handle request and result codes from one place and other related constants common to the all app elements * replaced hardcoded strings ok and cancel in DialogUtil to string resources * init permission rationale dialog in activities onCreate * Code formatting, updated access modifiers wherever required, added javadocs for new methods created * *shifted constants to app class *Added JavaDocs in PermissionUtils * removed class REQUEST_CODES from CommonsApplication and instead put the enclosing constants in the App class itself
- Loading branch information
1 parent
d455c35
commit e2aadc9
Showing
6 changed files
with
172 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,11 @@ public class CommonsApplication extends Application { | |
@Inject @Named("application_preferences") SharedPreferences applicationPrefs; | ||
@Inject @Named("prefs") SharedPreferences otherPrefs; | ||
|
||
/** | ||
* Constants begin | ||
*/ | ||
public static final int OPEN_APPLICATION_DETAIL_SETTINGS = 1001; | ||
|
||
public static final String DEFAULT_EDIT_SUMMARY = "Uploaded using [[COM:MOA|Commons Mobile App]]"; | ||
|
||
public static final String FEEDBACK_EMAIL = "[email protected]"; | ||
|
@@ -66,6 +71,10 @@ public class CommonsApplication extends Application { | |
|
||
public static final String NOTIFICATION_CHANNEL_ID_ALL = "CommonsNotificationAll"; | ||
|
||
/** | ||
* Constants End | ||
*/ | ||
|
||
private RefWatcher refWatcher; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
app/src/main/java/fr/free/nrw/commons/utils/PermissionUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.free.nrw.commons.utils; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.net.Uri; | ||
import android.provider.Settings; | ||
import fr.free.nrw.commons.CommonsApplication; | ||
|
||
public class PermissionUtils { | ||
|
||
/** | ||
* This method can be used by any activity which requires a permission which has been blocked(marked never ask again by the user) | ||
It open the app settings from where the user can manually give us the required permission. | ||
* @param activity | ||
*/ | ||
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,CommonsApplication.OPEN_APPLICATION_DETAIL_SETTINGS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters