Remove storage permission for Android Q and up.

This commit is contained in:
Alex Ning 2021-07-15 08:33:44 +08:00
parent 054a24fcfc
commit c30dcf415d
7 changed files with 44 additions and 43 deletions

View File

@ -18,7 +18,8 @@
android:maxSdkVersion="22" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

View File

@ -290,7 +290,7 @@ public class ViewImageOrGifActivity extends AppCompatActivity implements SetAsWa
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {

View File

@ -539,7 +539,7 @@ public class ViewVideoActivity extends AppCompatActivity {
}
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(this,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {

View File

@ -167,7 +167,7 @@ public class ViewImgurImageFragment extends Fragment {
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {

View File

@ -149,7 +149,7 @@ public class ViewImgurVideoFragment extends Fragment {
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.action_download_view_imgur_video_fragment) {
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {

View File

@ -225,50 +225,50 @@ public class ViewRedditGalleryImageOrGifFragment extends Fragment {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.action_download_view_reddit_gallery_image_or_gif_fragment:
if (isDownloading) {
return false;
}
int itemId = item.getItemId();
if (itemId == R.id.action_download_view_reddit_gallery_image_or_gif_fragment) {
if (isDownloading) {
return false;
}
isDownloading = true;
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
// Permission is not granted
// No explanation needed; request the permission
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
} else {
// Permission has already been granted
download();
}
// Permission is not granted
// No explanation needed; request the permission
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
PERMISSION_REQUEST_WRITE_EXTERNAL_STORAGE);
} else {
// Permission has already been granted
download();
}
} else {
download();
}
return true;
case R.id.action_share_view_reddit_gallery_image_or_gif_fragment:
if (media.mediaType == Post.Gallery.TYPE_GIF) {
shareGif();
} else {
shareImage();
}
return true;
case R.id.action_set_wallpaper_view_reddit_gallery_image_or_gif_fragment:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putInt(SetAsWallpaperBottomSheetFragment.EXTRA_VIEW_PAGER_POSITION, activity.getCurrentPagePosition());
setAsWallpaperBottomSheetFragment.setArguments(bundle);
setAsWallpaperBottomSheetFragment.show(activity.getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag());
} else {
((SetAsWallpaperCallback) activity).setToBoth(activity.getCurrentPagePosition());
}
return true;
return true;
} else if (itemId == R.id.action_share_view_reddit_gallery_image_or_gif_fragment) {
if (media.mediaType == Post.Gallery.TYPE_GIF) {
shareGif();
} else {
shareImage();
}
return true;
} else if (itemId == R.id.action_set_wallpaper_view_reddit_gallery_image_or_gif_fragment) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
SetAsWallpaperBottomSheetFragment setAsWallpaperBottomSheetFragment = new SetAsWallpaperBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putInt(SetAsWallpaperBottomSheetFragment.EXTRA_VIEW_PAGER_POSITION, activity.getCurrentPagePosition());
setAsWallpaperBottomSheetFragment.setArguments(bundle);
setAsWallpaperBottomSheetFragment.show(activity.getSupportFragmentManager(), setAsWallpaperBottomSheetFragment.getTag());
} else {
((SetAsWallpaperCallback) activity).setToBoth(activity.getCurrentPagePosition());
}
return true;
}
return false;

View File

@ -152,7 +152,7 @@ public class ViewRedditGalleryVideoFragment extends Fragment {
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.action_download_view_reddit_gallery_video_fragment) {
isDownloading = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
if (ContextCompat.checkSelfPermission(activity,
Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {