Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Kotlin to 1.8.20 and AndroidX Core to 1.10 and switch to AndroidX's PendingIntentCompat #10021

Merged
merged 3 commits into from
Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.core:core-ktx:1.10.0'
implementation 'androidx.documentfile:documentfile:1.0.1'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/schabi/newpipe/NewVersionWorker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.util.Log
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.content.ContextCompat
import androidx.core.content.edit
import androidx.core.net.toUri
Expand All @@ -19,7 +20,6 @@ import com.grack.nanojson.JsonParser
import com.grack.nanojson.JsonParserException
import org.schabi.newpipe.extractor.downloader.Response
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException
import org.schabi.newpipe.util.PendingIntentCompat
import org.schabi.newpipe.util.ReleaseVersionUtil.coerceUpdateCheckExpiry
import org.schabi.newpipe.util.ReleaseVersionUtil.isLastUpdateCheckExpired
import org.schabi.newpipe.util.ReleaseVersionUtil.isReleaseApk
Expand Down Expand Up @@ -60,7 +60,7 @@ class NewVersionWorker(
val intent = Intent(Intent.ACTION_VIEW, apkLocationUrl?.toUri())
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
val pendingIntent = PendingIntentCompat.getActivity(
applicationContext, 0, intent, 0
applicationContext, 0, intent, 0, false
)
val channelId = applicationContext.getString(R.string.app_update_notification_channel_id)
val notificationBuilder = NotificationCompat.Builder(applicationContext, channelId)
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import android.view.View
import android.widget.Toast
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.fragment.app.Fragment
import com.google.android.material.snackbar.Snackbar
import org.schabi.newpipe.R
import org.schabi.newpipe.util.PendingIntentCompat

/**
* This class contains all of the methods that should be used to let the user know that an error has
Expand Down Expand Up @@ -118,7 +118,8 @@ class ErrorUtil {
context,
0,
getErrorActivityIntent(context, errorInfo),
PendingIntent.FLAG_UPDATE_CURRENT
PendingIntent.FLAG_UPDATE_CURRENT,
false
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.Build
import android.provider.Settings
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.content.ContextCompat
import androidx.preference.PreferenceManager
import com.squareup.picasso.Picasso
Expand All @@ -19,7 +20,6 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipe.local.feed.service.FeedUpdateInfo
import org.schabi.newpipe.util.Localization
import org.schabi.newpipe.util.NavigationHelper
import org.schabi.newpipe.util.PendingIntentCompat
import org.schabi.newpipe.util.PicassoHelper

/**
Expand Down Expand Up @@ -76,7 +76,8 @@ class NotificationHelper(val context: Context) {
NavigationHelper
.getChannelIntent(context, data.listInfo.serviceId, data.listInfo.url)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK),
0
0,
false
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import android.os.IBinder
import android.util.Log
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.app.PendingIntentCompat
import androidx.core.app.ServiceCompat
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.core.Flowable
Expand All @@ -42,7 +43,6 @@ import org.schabi.newpipe.extractor.ListInfo
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipe.local.feed.service.FeedEventManager.Event.ErrorResultEvent
import org.schabi.newpipe.local.feed.service.FeedEventManager.postEvent
import org.schabi.newpipe.util.PendingIntentCompat
import java.util.concurrent.TimeUnit

class FeedLoadService : Service() {
Expand Down Expand Up @@ -152,8 +152,8 @@ class FeedLoadService : Service() {
private lateinit var notificationBuilder: NotificationCompat.Builder

private fun createNotification(): NotificationCompat.Builder {
val cancelActionIntent =
PendingIntentCompat.getBroadcast(this, NOTIFICATION_ID, Intent(ACTION_CANCEL), 0)
val cancelActionIntent = PendingIntentCompat
.getBroadcast(this, NOTIFICATION_ID, Intent(ACTION_CANCEL), 0, false)

return NotificationCompat.Builder(this, getString(R.string.notification_channel_id))
.setOngoing(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.app.PendingIntentCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;

Expand All @@ -21,7 +22,6 @@
import org.schabi.newpipe.player.Player;
import org.schabi.newpipe.player.mediasession.MediaSessionPlayerUi;
import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PendingIntentCompat;

import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -134,7 +134,7 @@ private synchronized NotificationCompat.Builder createNotification() {
.setColorized(player.getPrefs().getBoolean(
player.getContext().getString(R.string.notification_colorize_key), true))
.setDeleteIntent(PendingIntentCompat.getBroadcast(player.getContext(),
NOTIFICATION_ID, new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT));
NOTIFICATION_ID, new Intent(ACTION_CLOSE), FLAG_UPDATE_CURRENT, false));

// set the initial value for the video thumbnail, updatable with updateNotificationThumbnail
setLargeIcon(builder);
Expand All @@ -152,7 +152,7 @@ private synchronized void updateNotification() {

// also update content intent, in case the user switched players
notificationBuilder.setContentIntent(PendingIntentCompat.getActivity(player.getContext(),
NOTIFICATION_ID, getIntentForNotification(), FLAG_UPDATE_CURRENT));
NOTIFICATION_ID, getIntentForNotification(), FLAG_UPDATE_CURRENT, false));
notificationBuilder.setContentTitle(player.getVideoTitle());
notificationBuilder.setContentText(player.getUploaderName());
notificationBuilder.setTicker(player.getVideoTitle());
Expand Down Expand Up @@ -335,7 +335,7 @@ private NotificationCompat.Action getAction(@DrawableRes final int drawable,
final String intentAction) {
return new NotificationCompat.Action(drawable, player.getContext().getString(title),
PendingIntentCompat.getBroadcast(player.getContext(), NOTIFICATION_ID,
new Intent(intentAction), FLAG_UPDATE_CURRENT));
new Intent(intentAction), FLAG_UPDATE_CURRENT, false));
}

private Intent getIntentForNotification() {
Expand Down
69 changes: 0 additions & 69 deletions app/src/main/java/org/schabi/newpipe/util/PendingIntentCompat.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import androidx.collection.SparseArrayCompat;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationCompat.Builder;
import androidx.core.app.PendingIntentCompat;
import androidx.core.app.ServiceCompat;
import androidx.core.content.ContextCompat;
import androidx.preference.PreferenceManager;
Expand All @@ -43,7 +44,6 @@
import org.schabi.newpipe.streams.io.StoredDirectoryHelper;
import org.schabi.newpipe.streams.io.StoredFileHelper;
import org.schabi.newpipe.util.Localization;
import org.schabi.newpipe.util.PendingIntentCompat;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -146,7 +146,7 @@ public void onCreate() {

mOpenDownloadList = PendingIntentCompat.getActivity(this, 0,
openDownloadListIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_UPDATE_CURRENT, false);

icLauncher = BitmapFactory.decodeResource(this.getResources(), R.mipmap.ic_launcher);

Expand Down Expand Up @@ -487,7 +487,7 @@ public void notifyFailedDownload(DownloadMission mission) {
private PendingIntent makePendingIntent(String action) {
Intent intent = new Intent(this, DownloadManagerService.class).setAction(action);
return PendingIntentCompat.getService(this, intent.hashCode(), intent,
PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.FLAG_UPDATE_CURRENT, false);
}

private void manageLock(boolean acquire) {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.8.20'
repositories {
google()
mavenCentral()
Expand Down