better handling of permanent storage permission denial on file view page
This commit is contained in:
parent
7cf9de8c2a
commit
6c63eb7d66
2 changed files with 27 additions and 6 deletions
|
@ -175,6 +175,7 @@ public class FileViewFragment extends BaseFragment implements
|
|||
private long startTimeMillis;
|
||||
private GetFileTask getFileTask;
|
||||
|
||||
private boolean storagePermissionRefusedOnce;
|
||||
private View buttonPublishSomething;
|
||||
private View layoutLoadingState;
|
||||
private View layoutNothingAtLocation;
|
||||
|
@ -1022,6 +1023,12 @@ public class FileViewFragment extends BaseFragment implements
|
|||
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||
startDownload();
|
||||
} else {
|
||||
if (storagePermissionRefusedOnce) {
|
||||
showStoragePermissionRefusedError();
|
||||
restoreMainActionButton();
|
||||
return;
|
||||
}
|
||||
|
||||
startDownloadPending = true;
|
||||
MainActivity.requestPermission(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
|
@ -1035,6 +1042,12 @@ public class FileViewFragment extends BaseFragment implements
|
|||
private void checkStoragePermissionAndFileGet() {
|
||||
Context context = getContext();
|
||||
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||
if (storagePermissionRefusedOnce) {
|
||||
showStoragePermissionRefusedError();
|
||||
restoreMainActionButton();
|
||||
return;
|
||||
}
|
||||
|
||||
fileGetPending = true;
|
||||
MainActivity.requestPermission(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
|
@ -1082,11 +1095,12 @@ public class FileViewFragment extends BaseFragment implements
|
|||
}
|
||||
}
|
||||
public void onStoragePermissionRefused() {
|
||||
storagePermissionRefusedOnce = true;
|
||||
fileGetPending = false;
|
||||
startDownloadPending = false;
|
||||
onDownloadAborted();
|
||||
Snackbar.make(getView(), R.string.storage_permission_rationale_download, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
|
||||
showStoragePermissionRefusedError();
|
||||
}
|
||||
|
||||
public void startDownload() {
|
||||
|
@ -2370,4 +2384,12 @@ public class FileViewFragment extends BaseFragment implements
|
|||
playerView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
private void showStoragePermissionRefusedError() {
|
||||
View root = getView();
|
||||
if (root != null) {
|
||||
Snackbar.make(root, R.string.storage_permission_rationale_download, Snackbar.LENGTH_LONG).
|
||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import android.view.LayoutInflater;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.camera.core.Camera;
|
||||
|
@ -53,7 +52,7 @@ public class PublishFragment extends BaseFragment implements
|
|||
CameraPermissionListener, FilePickerListener, StoragePermissionListener {
|
||||
|
||||
private boolean cameraPreviewInitialized;
|
||||
private boolean storageRefusedOnce;
|
||||
private boolean storagePermissionRefusedOnce;
|
||||
private PreviewView cameraPreview;
|
||||
private RecyclerView galleryGrid;
|
||||
private GalleryGridAdapter adapter;
|
||||
|
@ -255,7 +254,7 @@ public class PublishFragment extends BaseFragment implements
|
|||
}
|
||||
}
|
||||
|
||||
if (!storageRefusedOnce) {
|
||||
if (!storagePermissionRefusedOnce) {
|
||||
checkStoragePermissionAndLoadVideos();
|
||||
}
|
||||
}
|
||||
|
@ -402,7 +401,7 @@ public class PublishFragment extends BaseFragment implements
|
|||
|
||||
@Override
|
||||
public void onStoragePermissionRefused() {
|
||||
storageRefusedOnce = true;
|
||||
storagePermissionRefusedOnce = true;
|
||||
View root = getView();
|
||||
if (root != null) {
|
||||
Snackbar.make(root, R.string.storage_permission_rationale_videos, Snackbar.LENGTH_LONG).
|
||||
|
|
Loading…
Reference in a new issue