mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-01-30 19:34:45 +01:00
Fix missing pendingintent mutability flag.
This commit is contained in:
parent
3df7b761a2
commit
8e8dc6f93b
@ -5,6 +5,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.app.NotificationCompat;
|
import androidx.core.app.NotificationCompat;
|
||||||
@ -26,10 +27,10 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
|
||||||
import ml.docilealligator.infinityforreddit.account.Account;
|
import ml.docilealligator.infinityforreddit.account.Account;
|
||||||
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
|
import ml.docilealligator.infinityforreddit.activities.InboxActivity;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.apis.RedditAPI;
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.message.FetchMessage;
|
import ml.docilealligator.infinityforreddit.message.FetchMessage;
|
||||||
import ml.docilealligator.infinityforreddit.message.Message;
|
import ml.docilealligator.infinityforreddit.message.Message;
|
||||||
@ -105,6 +106,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
long currentTime = Calendar.getInstance().getTimeInMillis();
|
long currentTime = Calendar.getInstance().getTimeInMillis();
|
||||||
mSharedPreferences.edit().putLong(SharedPreferencesUtils.PULL_NOTIFICATION_TIME, currentTime).apply();
|
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--) {
|
for (int messageIndex = messageSize - 1; messageIndex >= 0; messageIndex--) {
|
||||||
Message message = messages.get(messageIndex);
|
Message message = messages.get(messageIndex);
|
||||||
if (message.getTimeUTC() <= lastNotificationTime) {
|
if (message.getTimeUTC() <= lastNotificationTime) {
|
||||||
@ -146,12 +148,12 @@ public class PullNotificationWorker extends Worker {
|
|||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
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);
|
builder.setContentIntent(pendingIntent);
|
||||||
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
|
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
Intent intent = new Intent(context, InboxActivity.class);
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
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);
|
builder.setContentIntent(summaryPendingIntent);
|
||||||
} else if (kind.equals(Message.TYPE_LINK)) {
|
} else if (kind.equals(Message.TYPE_LINK)) {
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||||
@ -159,23 +161,23 @@ public class PullNotificationWorker extends Worker {
|
|||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
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);
|
builder.setContentIntent(pendingIntent);
|
||||||
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
} else if (kind.equals(Message.TYPE_MESSAGE)) {
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
Intent intent = new Intent(context, InboxActivity.class);
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(InboxActivity.EXTRA_VIEW_MESSAGE, true);
|
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);
|
builder.setContentIntent(summaryPendingIntent);
|
||||||
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
Intent intent = new Intent(context, InboxActivity.class);
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
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);
|
builder.setContentIntent(summaryPendingIntent);
|
||||||
} else {
|
} else {
|
||||||
Intent intent = new Intent(context, InboxActivity.class);
|
Intent intent = new Intent(context, InboxActivity.class);
|
||||||
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
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);
|
builder.setContentIntent(summaryPendingIntent);
|
||||||
}
|
}
|
||||||
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
|
notificationManager.notify(NotificationUtils.getNotificationIdUnreadMessage(accountIndex, messageIndex), builder.build());
|
||||||
@ -189,7 +191,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
Intent summaryIntent = new Intent(context, InboxActivity.class);
|
Intent summaryIntent = new Intent(context, InboxActivity.class);
|
||||||
summaryIntent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
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);
|
summaryBuilder.setContentIntent(summaryPendingIntent);
|
||||||
|
|
||||||
notificationManager.notify(NotificationUtils.getSummaryIdUnreadMessage(accountIndex), summaryBuilder.build());
|
notificationManager.notify(NotificationUtils.getSummaryIdUnreadMessage(accountIndex), summaryBuilder.build());
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package ml.docilealligator.infinityforreddit.services;
|
package ml.docilealligator.infinityforreddit.services;
|
||||||
|
|
||||||
|
import static android.os.Environment.getExternalStoragePublicDirectory;
|
||||||
|
|
||||||
import android.app.Notification;
|
import android.app.Notification;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
@ -50,8 +52,6 @@ import okhttp3.ResponseBody;
|
|||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
import retrofit2.Retrofit;
|
import retrofit2.Retrofit;
|
||||||
|
|
||||||
import static android.os.Environment.getExternalStoragePublicDirectory;
|
|
||||||
|
|
||||||
public class DownloadMediaService extends Service {
|
public class DownloadMediaService extends Service {
|
||||||
public static final String EXTRA_URL = "EU";
|
public static final String EXTRA_URL = "EU";
|
||||||
public static final String EXTRA_FILE_NAME = "EFN";
|
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.setAction(android.content.Intent.ACTION_VIEW);
|
||||||
intent.setDataAndType(destinationFileUri, mimeType);
|
intent.setDataAndType(destinationFileUri, mimeType);
|
||||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
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,
|
updateNotification(mediaType, R.string.downloading_media_finished, -1,
|
||||||
randomNotificationIdOffset, pendingIntent);
|
randomNotificationIdOffset, pendingIntent);
|
||||||
EventBus.getDefault().post(new DownloadMediaEvent(true));
|
EventBus.getDefault().post(new DownloadMediaEvent(true));
|
||||||
|
@ -571,7 +571,7 @@ public class DownloadRedditVideoService extends Service {
|
|||||||
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);
|
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);
|
updateNotification(R.string.downloading_reddit_video_finished, -1, randomNotificationIdOffset, pendingIntent);
|
||||||
EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
|
EventBus.getDefault().post(new DownloadRedditVideoEvent(true));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user