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 long startTimeMillis;
|
||||||
private GetFileTask getFileTask;
|
private GetFileTask getFileTask;
|
||||||
|
|
||||||
|
private boolean storagePermissionRefusedOnce;
|
||||||
private View buttonPublishSomething;
|
private View buttonPublishSomething;
|
||||||
private View layoutLoadingState;
|
private View layoutLoadingState;
|
||||||
private View layoutNothingAtLocation;
|
private View layoutNothingAtLocation;
|
||||||
|
@ -1022,6 +1023,12 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
if (MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||||
startDownload();
|
startDownload();
|
||||||
} else {
|
} else {
|
||||||
|
if (storagePermissionRefusedOnce) {
|
||||||
|
showStoragePermissionRefusedError();
|
||||||
|
restoreMainActionButton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
startDownloadPending = true;
|
startDownloadPending = true;
|
||||||
MainActivity.requestPermission(
|
MainActivity.requestPermission(
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||||
|
@ -1035,6 +1042,12 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
private void checkStoragePermissionAndFileGet() {
|
private void checkStoragePermissionAndFileGet() {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
if (!MainActivity.hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, context)) {
|
||||||
|
if (storagePermissionRefusedOnce) {
|
||||||
|
showStoragePermissionRefusedError();
|
||||||
|
restoreMainActionButton();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fileGetPending = true;
|
fileGetPending = true;
|
||||||
MainActivity.requestPermission(
|
MainActivity.requestPermission(
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||||
|
@ -1082,11 +1095,12 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void onStoragePermissionRefused() {
|
public void onStoragePermissionRefused() {
|
||||||
|
storagePermissionRefusedOnce = true;
|
||||||
fileGetPending = false;
|
fileGetPending = false;
|
||||||
startDownloadPending = false;
|
startDownloadPending = false;
|
||||||
onDownloadAborted();
|
onDownloadAborted();
|
||||||
Snackbar.make(getView(), R.string.storage_permission_rationale_download, Snackbar.LENGTH_LONG).
|
|
||||||
setBackgroundTint(Color.RED).setTextColor(Color.WHITE).show();
|
showStoragePermissionRefusedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startDownload() {
|
public void startDownload() {
|
||||||
|
@ -2370,4 +2384,12 @@ public class FileViewFragment extends BaseFragment implements
|
||||||
playerView.setVisibility(View.VISIBLE);
|
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.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.camera.core.Camera;
|
import androidx.camera.core.Camera;
|
||||||
|
@ -53,7 +52,7 @@ public class PublishFragment extends BaseFragment implements
|
||||||
CameraPermissionListener, FilePickerListener, StoragePermissionListener {
|
CameraPermissionListener, FilePickerListener, StoragePermissionListener {
|
||||||
|
|
||||||
private boolean cameraPreviewInitialized;
|
private boolean cameraPreviewInitialized;
|
||||||
private boolean storageRefusedOnce;
|
private boolean storagePermissionRefusedOnce;
|
||||||
private PreviewView cameraPreview;
|
private PreviewView cameraPreview;
|
||||||
private RecyclerView galleryGrid;
|
private RecyclerView galleryGrid;
|
||||||
private GalleryGridAdapter adapter;
|
private GalleryGridAdapter adapter;
|
||||||
|
@ -255,7 +254,7 @@ public class PublishFragment extends BaseFragment implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storageRefusedOnce) {
|
if (!storagePermissionRefusedOnce) {
|
||||||
checkStoragePermissionAndLoadVideos();
|
checkStoragePermissionAndLoadVideos();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +401,7 @@ public class PublishFragment extends BaseFragment implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStoragePermissionRefused() {
|
public void onStoragePermissionRefused() {
|
||||||
storageRefusedOnce = true;
|
storagePermissionRefusedOnce = 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).
|
||||||
|
|
Loading…
Reference in a new issue