aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorDocile-Alligator <chineseperson5@gmail.com>2022-05-20 01:20:17 +0000
committerDocile-Alligator <chineseperson5@gmail.com>2022-05-20 01:20:17 +0000
commit8e8dc6f93b113d991874a24c7f520f12009a007b (patch)
treecb8d33fd166ca5b91a73d7fcc8c60f1dd71277e1 /app/src/main/java
parent3df7b761a29159368b4df32a28b1caed5006783a (diff)
downloadinfinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar.gz
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar.bz2
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar.lz
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar.xz
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.tar.zst
infinity-for-reddit-8e8dc6f93b113d991874a24c7f520f12009a007b.zip
Fix missing pendingintent mutability flag.
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java2
3 files changed, 14 insertions, 12 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
index 6f49519a..67caf295 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/PullNotificationWorker.java
@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
+import android.os.Build;
import androidx.annotation.NonNull;
import androidx.core.app.NotificationCompat;
@@ -26,10 +27,10 @@ import java.util.Map;
import javax.inject.Inject;
import javax.inject.Named;
-import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.account.Account;
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.apis.RedditAPI;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.message.FetchMessage;
import ml.docilealligator.infinityforreddit.message.Message;
@@ -105,6 +106,7 @@ public class PullNotificationWorker extends Worker {
long currentTime = Calendar.getInstance().getTimeInMillis();
mSharedPreferences.edit().putLong(SharedPreferencesUtils.PULL_NOTIFICATION_TIME, currentTime).apply();
+ int pendingIntentFlags = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE : PendingIntent.FLAG_UPDATE_CURRENT;
for (int messageIndex = messageSize - 1; messageIndex >= 0; messageIndex--) {
Message message = messages.get(messageIndex);
if (message.getTimeUTC() <= lastNotificationTime) {
@@ -146,12 +148,12 @@ public class PullNotificationWorker extends Worker {
intent.setData(uri);
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
- PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, pendingIntentFlags);
builder.setContentIntent(pendingIntent);
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
- PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 1, intent, pendingIntentFlags);
builder.setContentIntent(summaryPendingIntent);
} else if (kind.equals(Message.TYPE_LINK)) {
Intent intent = new Intent(context, LinkResolverActivity.class);
@@ -159,23 +161,23 @@ public class PullNotificationWorker extends Worker {
intent.setData(uri);
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
- PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 2, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 2, intent, pendingIntentFlags);
builder.setContentIntent(pendingIntent);
} else if (kind.equals(Message.TYPE_MESSAGE)) {
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
intent.putExtra(InboxActivity.EXTRA_VIEW_MESSAGE, true);
- PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 3, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 3, intent, pendingIntentFlags);
builder.setContentIntent(summaryPendingIntent);
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
- PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 4, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 4, intent, pendingIntentFlags);
builder.setContentIntent(summaryPendingIntent);
} else {
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
- PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 5, intent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 5, intent, pendingIntentFlags);
builder.setContentIntent(summaryPendingIntent);
}
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
@@ -189,7 +191,7 @@ public class PullNotificationWorker extends Worker {
Intent summaryIntent = new Intent(context, InboxActivity.class);
summaryIntent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
- PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 6, summaryIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 6, summaryIntent, pendingIntentFlags);
summaryBuilder.setContentIntent(summaryPendingIntent);
notificationManager.notify(NotificationUtils.getSummaryIdUnreadMessage(accountIndex), summaryBuilder.build());
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
index b27c6f09..a7059db9 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadMediaService.java
@@ -1,5 +1,7 @@
package ml.docilealligator.infinityforreddit.services;
+import static android.os.Environment.getExternalStoragePublicDirectory;
+
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
@@ -50,8 +52,6 @@ import okhttp3.ResponseBody;
import retrofit2.Response;
import retrofit2.Retrofit;
-import static android.os.Environment.getExternalStoragePublicDirectory;
-
public class DownloadMediaService extends Service {
public static final String EXTRA_URL = "EU";
public static final String EXTRA_FILE_NAME = "EFN";
@@ -336,7 +336,7 @@ public class DownloadMediaService extends Service {
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(destinationFileUri, mimeType);
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- PendingIntent pendingIntent = PendingIntent.getActivity(DownloadMediaService.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
+ PendingIntent pendingIntent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.getActivity(DownloadMediaService.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE) : PendingIntent.getActivity(DownloadMediaService.this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
updateNotification(mediaType, R.string.downloading_media_finished, -1,
randomNotificationIdOffset, pendingIntent);
EventBus.getDefault().post(new DownloadMediaEvent(true));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
index eebbf8ea..73f885b7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java
@@ -571,7 +571,7 @@ public class DownloadRedditVideoService extends Service {
intent.setAction(android.content.Intent.ACTION_VIEW);
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 = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ? PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE) : PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
updateNotification(R.string.downloading_reddit_video_finished, -1, randomNotificationIdOffset, pendingIntent);
EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
}