aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java16
2 files changed, 32 insertions, 16 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java
index 9ed2fe62..0e08dcb3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewImageActivity.java
@@ -426,22 +426,6 @@ public class ViewImageActivity extends AppCompatActivity {
@Override
protected Void doInBackground(Void... params) {
try {
- String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
- File directory = new File(path + "/Infinity/");
- if(!directory.exists()) {
- if(!directory.mkdir()) {
- saveSuccess = false;
- return null;
- }
- } else {
- if(directory.isFile()) {
- if(!directory.delete() && !directory.mkdir()) {
- saveSuccess = false;
- return null;
- }
- }
- }
-
//Android Q support
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
ContentValues values = new ContentValues();
@@ -478,6 +462,22 @@ public class ViewImageActivity extends AppCompatActivity {
values.put(MediaStore.Images.Media.IS_PENDING, 0);
resolver.update(item, values, null, null);
} else {
+ String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
+ File directory = new File(path + "/Infinity/");
+ if(!directory.exists()) {
+ if(!directory.mkdir()) {
+ saveSuccess = false;
+ return null;
+ }
+ } else {
+ if(directory.isFile()) {
+ if(!directory.delete() && !directory.mkdir()) {
+ saveSuccess = false;
+ return null;
+ }
+ }
+ }
+
File file = new File(path + "/Infinity/", mImageFileName + ".jpg");
int postfix = 1;
while(file.exists()) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java
index bb471562..e96f0cff 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/ViewVideoActivity.java
@@ -51,6 +51,8 @@ import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.util.Util;
+import java.io.File;
+
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -395,6 +397,20 @@ public class ViewVideoActivity extends AppCompatActivity {
if(android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
} else {
+ String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString();
+ File directory = new File(path + "/Infinity/");
+ if(!directory.exists()) {
+ if(!directory.mkdir()) {
+ request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
+ }
+ } else {
+ if(directory.isFile()) {
+ if(!directory.delete() && !directory.mkdir()) {
+ request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, mGifOrVideoFileName);
+ }
+ }
+ }
+
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_PICTURES + "/Infinity/", mGifOrVideoFileName);
}