mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
Use dexter for requesting storage permissions (#2258)
* Use dexter for requesting storage permissions * minor changes * Fix minor issue
This commit is contained in:
parent
2ea6bd7f65
commit
a48a09a785
13 changed files with 149 additions and 408 deletions
|
|
@ -143,19 +143,23 @@ public class DialogUtil {
|
|||
builder.setTitle(title);
|
||||
builder.setMessage(message);
|
||||
|
||||
builder.setPositiveButton(positiveButtonText, (dialogInterface, i) -> {
|
||||
dialogInterface.dismiss();
|
||||
if (onPositiveBtnClick != null) {
|
||||
onPositiveBtnClick.run();
|
||||
}
|
||||
});
|
||||
if (!StringUtils.isNullOrWhiteSpace(positiveButtonText)) {
|
||||
builder.setPositiveButton(positiveButtonText, (dialogInterface, i) -> {
|
||||
dialogInterface.dismiss();
|
||||
if (onPositiveBtnClick != null) {
|
||||
onPositiveBtnClick.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
builder.setNegativeButton(negativeButtonText, (DialogInterface dialogInterface, int i) -> {
|
||||
dialogInterface.dismiss();
|
||||
if (onNegativeBtnClick != null) {
|
||||
onNegativeBtnClick.run();
|
||||
}
|
||||
});
|
||||
if (!StringUtils.isNullOrWhiteSpace(negativeButtonText)) {
|
||||
builder.setNegativeButton(negativeButtonText, (DialogInterface dialogInterface, int i) -> {
|
||||
dialogInterface.dismiss();
|
||||
if (onNegativeBtnClick != null) {
|
||||
onNegativeBtnClick.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
showSafely(activity, dialog);
|
||||
|
|
@ -179,13 +183,13 @@ public class DialogUtil {
|
|||
onPositiveBtnClick,
|
||||
onNegativeBtnClick,
|
||||
customView,
|
||||
false);
|
||||
cancelable);
|
||||
}
|
||||
|
||||
/*
|
||||
Shows alert dialog with custom view
|
||||
*/
|
||||
private static void showAlertDialog(Activity activity,
|
||||
public static void showAlertDialog(Activity activity,
|
||||
String title,
|
||||
String message,
|
||||
String positiveButtonText,
|
||||
|
|
|
|||
|
|
@ -12,11 +12,6 @@ import fr.free.nrw.commons.CommonsApplication;
|
|||
|
||||
public class PermissionUtils {
|
||||
|
||||
public static final int CAMERA_PERMISSION_FROM_CONTRIBUTION_LIST = 100;
|
||||
public static final int GALLERY_PERMISSION_FROM_CONTRIBUTION_LIST = 101;
|
||||
public static final int CAMERA_PERMISSION_FROM_NEARBY_MAP = 102;
|
||||
public static final int GALLERY_PERMISSION_FROM_NEARBY_MAP = 103;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
|
|||
|
|
@ -6,9 +6,7 @@ import android.support.annotation.StringRes;
|
|||
import android.support.design.widget.Snackbar;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class ViewUtil {
|
||||
|
|
@ -85,14 +83,16 @@ public class ViewUtil {
|
|||
* A snack bar which has an action button which on click dismisses the snackbar and invokes the
|
||||
* listener passed
|
||||
*/
|
||||
public static void showDismissibleSnackBar(View view, int messageResourceId,
|
||||
int actionButtonResourceId, View.OnClickListener onClickListener) {
|
||||
public static void showDismissibleSnackBar(View view,
|
||||
int messageResourceId,
|
||||
int actionButtonResourceId,
|
||||
View.OnClickListener onClickListener) {
|
||||
if (view.getContext() == null) {
|
||||
return;
|
||||
}
|
||||
ExecutorUtils.uiExecutor().execute(() -> {
|
||||
Snackbar snackbar = Snackbar.make(view, view.getContext().getString(messageResourceId),
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
Snackbar.LENGTH_INDEFINITE);
|
||||
snackbar.setAction(view.getContext().getString(actionButtonResourceId), v -> {
|
||||
snackbar.dismiss();
|
||||
onClickListener.onClick(v);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue