fix permission request handling for permanently denied permissions
This commit is contained in:
parent
c844c4f896
commit
a859682954
2 changed files with 21 additions and 14 deletions
|
@ -2915,11 +2915,17 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener
|
||||||
|
|
||||||
public static void requestPermission(String permission, int requestCode, String rationale, Context context, boolean forceRequest) {
|
public static void requestPermission(String permission, int requestCode, String rationale, Context context, boolean forceRequest) {
|
||||||
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
|
if (ContextCompat.checkSelfPermission(context, permission) != PackageManager.PERMISSION_GRANTED) {
|
||||||
if (!forceRequest && ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permission)) {
|
if (ActivityCompat.shouldShowRequestPermissionRationale((Activity) context, permission)) {
|
||||||
Toast.makeText(context, rationale, Toast.LENGTH_LONG).show();
|
if (context instanceof MainActivity) {
|
||||||
} else {
|
((MainActivity) context).showMessage(rationale);
|
||||||
|
}
|
||||||
|
} else if (forceRequest) {
|
||||||
startingPermissionRequest = true;
|
startingPermissionRequest = true;
|
||||||
ActivityCompat.requestPermissions((Activity) context, new String[] { permission }, requestCode);
|
ActivityCompat.requestPermissions((Activity) context, new String[] { permission }, requestCode);
|
||||||
|
} else {
|
||||||
|
if (context instanceof MainActivity) {
|
||||||
|
((MainActivity) context).showError(rationale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,9 @@ public class PublishFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
checkStoragePermissionAndLoadVideos();
|
if (!storageRefusedOnce) {
|
||||||
|
checkStoragePermissionAndLoadVideos();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
|
@ -394,22 +396,21 @@ public class PublishFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
if (launchFilePickerPending) {
|
if (launchFilePickerPending) {
|
||||||
launchFilePickerPending = false;
|
launchFilePickerPending = false;
|
||||||
launchFilePicker();
|
launchFilePicker();e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStoragePermissionRefused() {
|
public void onStoragePermissionRefused() {
|
||||||
if (!storageRefusedOnce) {
|
storageRefusedOnce = true;
|
||||||
View root = getView();
|
View root = getView();
|
||||||
if (root != null) {
|
if (root != null) {
|
||||||
Snackbar.make(root, R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
|
Snackbar.make(root, R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
|
||||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||||
Helper.setViewText(noVideosLoaded, R.string.storage_permission_rationale_videos);
|
Helper.setViewText(noVideosLoaded, R.string.storage_permission_rationale_videos);
|
||||||
checkNoVideosLoaded();
|
|
||||||
}
|
|
||||||
storageRefusedOnce = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkNoVideosLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSuggestedPublishUrl() {
|
public String getSuggestedPublishUrl() {
|
||||||
|
|
Loading…
Reference in a new issue