mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-30 19:34:45 +01:00
Fix media cannot be opened by clicking the download finished notification. Fix random post or subreddit still showing after users go back from FetchRandomSubredditOrPostActivity.
This commit is contained in:
parent
2f94ef3f9a
commit
db818d8ca8
@ -36,6 +36,7 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
|
|||||||
SharedPreferences mSharedPreferences;
|
SharedPreferences mSharedPreferences;
|
||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
private boolean isCanceled = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@ -51,6 +52,7 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
|
|||||||
|| option == RandomBottomSheetFragment.RANDOM_NSFW_POST, new FetchPost.FetchRandomPostListener() {
|
|| option == RandomBottomSheetFragment.RANDOM_NSFW_POST, new FetchPost.FetchRandomPostListener() {
|
||||||
@Override
|
@Override
|
||||||
public void fetchRandomPostSuccess(String postId, String subredditName) {
|
public void fetchRandomPostSuccess(String postId, String subredditName) {
|
||||||
|
if (!isCanceled) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case RandomBottomSheetFragment.RANDOM_SUBREDDIT:
|
case RandomBottomSheetFragment.RANDOM_SUBREDDIT:
|
||||||
case RandomBottomSheetFragment.RANDOM_NSFW_SUBREDDIT: {
|
case RandomBottomSheetFragment.RANDOM_NSFW_SUBREDDIT: {
|
||||||
@ -69,6 +71,7 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
|
|||||||
|
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchRandomPostFailed() {
|
public void fetchRandomPostFailed() {
|
||||||
@ -78,6 +81,12 @@ public class FetchRandomSubredditOrPostActivity extends BaseActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBackPressed() {
|
||||||
|
super.onBackPressed();
|
||||||
|
isCanceled = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SharedPreferences getDefaultSharedPreferences() {
|
protected SharedPreferences getDefaultSharedPreferences() {
|
||||||
return mSharedPreferences;
|
return mSharedPreferences;
|
||||||
|
@ -302,6 +302,7 @@ public class DownloadMediaService extends Service {
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(destinationFileUri, mimeType);
|
intent.setDataAndType(destinationFileUri, mimeType);
|
||||||
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
updateNotification(R.string.downloading_media_finished, fileName, pendingIntent);
|
updateNotification(R.string.downloading_media_finished, fileName, pendingIntent);
|
||||||
EventBus.getDefault().post(new DownloadMediaEvent(true));
|
EventBus.getDefault().post(new DownloadMediaEvent(true));
|
||||||
|
@ -306,6 +306,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(android.content.Intent.ACTION_VIEW);
|
intent.setAction(android.content.Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(destinationFileUri, "video/*");
|
intent.setDataAndType(destinationFileUri, "video/*");
|
||||||
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||||
updateNotification(R.string.downloading_reddit_video_finished, fileName, pendingIntent);
|
updateNotification(R.string.downloading_reddit_video_finished, fileName, pendingIntent);
|
||||||
EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
|
EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
|
||||||
|
@ -2,6 +2,8 @@ package ml.docilealligator.infinityforreddit.Subreddit;
|
|||||||
|
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -20,6 +22,7 @@ class ParseSubredditData {
|
|||||||
new ParseSubredditListingDataAsyncTask(response, nsfw, parseSubredditListingDataListener).execute();
|
new ParseSubredditListingDataAsyncTask(response, nsfw, parseSubredditListingDataListener).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static SubredditData parseSubredditData(JSONObject subredditDataJsonObject, boolean nsfw) throws JSONException {
|
private static SubredditData parseSubredditData(JSONObject subredditDataJsonObject, boolean nsfw) throws JSONException {
|
||||||
boolean isNSFW = !subredditDataJsonObject.isNull(JSONUtils.OVER18_KEY) && subredditDataJsonObject.getBoolean(JSONUtils.OVER18_KEY);
|
boolean isNSFW = !subredditDataJsonObject.isNull(JSONUtils.OVER18_KEY) && subredditDataJsonObject.getBoolean(JSONUtils.OVER18_KEY);
|
||||||
if (!nsfw && isNSFW) {
|
if (!nsfw && isNSFW) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user