Skip to content

Commit 22a709d

Browse files
Merge pull request TeamNewPipe#12388 from mikooomich/sdk35
Target SDK 35
2 parents a4bd82b + 329d76c commit 22a709d

File tree

10 files changed

+62
-25
lines changed

10 files changed

+62
-25
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ jobs:
7272
- api-level: 21
7373
target: default
7474
arch: x86
75-
- api-level: 33
76-
target: google_apis # emulator API 33 only exists with Google APIs
75+
- api-level: 35
76+
target: default
7777
arch: x86_64
7878

7979
permissions:

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ plugins {
1212
}
1313

1414
android {
15-
compileSdk 34
15+
compileSdk 36
1616
namespace 'org.schabi.newpipe'
1717

1818
defaultConfig {
1919
applicationId "org.schabi.newpipe"
2020
resValue "string", "app_name", "NewPipe"
2121
minSdk 21
22-
targetSdk 33
22+
targetSdk 35
2323
if (System.properties.containsKey('versionCodeOverride')) {
2424
versionCode System.getProperty('versionCodeOverride') as Integer
2525
} else {

app/src/main/AndroidManifest.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
1010
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
1111
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
12+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
13+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
1214
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
1315

1416
<!-- We need to be able to open links in the browser on API 30+ -->
@@ -96,7 +98,8 @@
9698

9799
<service android:name=".local.subscription.services.SubscriptionsImportService" />
98100
<service android:name=".local.subscription.services.SubscriptionsExportService" />
99-
<service android:name=".local.feed.service.FeedLoadService" />
101+
<service android:name=".local.feed.service.FeedLoadService"
102+
android:foregroundServiceType="dataSync" />
100103

101104
<activity
102105
android:name=".PanicResponderActivity"
@@ -128,7 +131,8 @@
128131
android:label="@string/app_name"
129132
android:launchMode="singleTask" />
130133

131-
<service android:name="us.shandian.giga.service.DownloadManagerService" />
134+
<service android:name="us.shandian.giga.service.DownloadManagerService"
135+
android:foregroundServiceType="dataSync" />
132136

133137
<activity
134138
android:name=".util.FilePickerActivityHelper"

app/src/main/java/org/schabi/newpipe/MainActivity.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import androidx.appcompat.app.ActionBarDrawerToggle;
4949
import androidx.appcompat.app.AppCompatActivity;
5050
import androidx.core.app.ActivityCompat;
51+
import androidx.core.content.ContextCompat;
5152
import androidx.core.view.GravityCompat;
5253
import androidx.drawerlayout.widget.DrawerLayout;
5354
import androidx.fragment.app.Fragment;
@@ -890,7 +891,8 @@ public void onReceive(final Context context, final Intent intent) {
890891
};
891892
final IntentFilter intentFilter = new IntentFilter();
892893
intentFilter.addAction(VideoDetailFragment.ACTION_PLAYER_STARTED);
893-
registerReceiver(broadcastReceiver, intentFilter);
894+
ContextCompat.registerReceiver(this, broadcastReceiver, intentFilter,
895+
ContextCompat.RECEIVER_EXPORTED);
894896

895897
// If the PlayerHolder is not bound yet, but the service is running, try to bind to it.
896898
// Once the connection is established, the ACTION_PLAYER_STARTED will be sent.

app/src/main/java/org/schabi/newpipe/error/ErrorUtil.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.widget.Toast
1010
import androidx.core.app.NotificationCompat
1111
import androidx.core.app.NotificationManagerCompat
1212
import androidx.core.app.PendingIntentCompat
13+
import androidx.core.content.ContextCompat
1314
import androidx.fragment.app.Fragment
1415
import androidx.preference.PreferenceManager
1516
import com.google.android.material.snackbar.Snackbar
@@ -136,9 +137,11 @@ class ErrorUtil {
136137
NotificationManagerCompat.from(context)
137138
.notify(ERROR_REPORT_NOTIFICATION_ID, notificationBuilder.build())
138139

139-
// since the notification is silent, also show a toast, otherwise the user is confused
140-
Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT)
141-
.show()
140+
ContextCompat.getMainExecutor(context).execute {
141+
// since the notification is silent, also show a toast, otherwise the user is confused
142+
Toast.makeText(context, R.string.error_report_notification_toast, Toast.LENGTH_SHORT)
143+
.show()
144+
}
142145
}
143146

144147
private fun getErrorActivityIntent(context: Context, errorInfo: ErrorInfo): Intent {

app/src/main/java/org/schabi/newpipe/fragments/detail/VideoDetailFragment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,8 @@ public void onReceive(final Context context, final Intent intent) {
14231423
intentFilter.addAction(ACTION_SHOW_MAIN_PLAYER);
14241424
intentFilter.addAction(ACTION_HIDE_MAIN_PLAYER);
14251425
intentFilter.addAction(ACTION_PLAYER_STARTED);
1426-
activity.registerReceiver(broadcastReceiver, intentFilter);
1426+
ContextCompat.registerReceiver(activity, broadcastReceiver, intentFilter,
1427+
ContextCompat.RECEIVER_EXPORTED);
14271428
}
14281429

14291430

app/src/main/java/org/schabi/newpipe/local/feed/service/FeedLoadService.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import androidx.core.app.NotificationCompat
3131
import androidx.core.app.NotificationManagerCompat
3232
import androidx.core.app.PendingIntentCompat
3333
import androidx.core.app.ServiceCompat
34+
import androidx.core.content.ContextCompat
3435
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
3536
import io.reactivex.rxjava3.core.Flowable
3637
import io.reactivex.rxjava3.disposables.Disposable
@@ -200,7 +201,7 @@ class FeedLoadService : Service() {
200201
}
201202
}
202203
}
203-
registerReceiver(broadcastReceiver, IntentFilter(ACTION_CANCEL))
204+
ContextCompat.registerReceiver(this, broadcastReceiver, IntentFilter(ACTION_CANCEL), ContextCompat.RECEIVER_NOT_EXPORTED)
204205
}
205206

206207
// /////////////////////////////////////////////////////////////////////////

app/src/main/java/org/schabi/newpipe/player/Player.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060

6161
import androidx.annotation.NonNull;
6262
import androidx.annotation.Nullable;
63+
import androidx.core.content.ContextCompat;
6364
import androidx.core.math.MathUtils;
6465
import androidx.preference.PreferenceManager;
6566

@@ -764,7 +765,8 @@ private void onBroadcastReceived(final Intent intent) {
764765
private void registerBroadcastReceiver() {
765766
// Try to unregister current first
766767
unregisterBroadcastReceiver();
767-
context.registerReceiver(broadcastReceiver, intentFilter);
768+
ContextCompat.registerReceiver(context, broadcastReceiver, intentFilter,
769+
ContextCompat.RECEIVER_EXPORTED);
768770
}
769771

770772
private void unregisterBroadcastReceiver() {

app/src/main/java/org/schabi/newpipe/player/mediabrowser/PackageValidator.kt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,15 @@ internal class PackageValidator(context: Context) {
147147
private fun buildCallerInfo(callingPackage: String): CallerPackageInfo? {
148148
val packageInfo = getPackageInfo(callingPackage) ?: return null
149149

150-
val appName = packageInfo.applicationInfo.loadLabel(packageManager).toString()
151-
val uid = packageInfo.applicationInfo.uid
150+
val appName = packageInfo.applicationInfo?.loadLabel(packageManager).toString()
151+
val uid = packageInfo.applicationInfo?.uid ?: -1
152152
val signature = getSignature(packageInfo)
153153

154-
val requestedPermissions = packageInfo.requestedPermissions
155-
val permissionFlags = packageInfo.requestedPermissionsFlags
156-
val activePermissions = mutableSetOf<String>()
157-
requestedPermissions?.forEachIndexed { index, permission ->
158-
if (permissionFlags[index] and REQUESTED_PERMISSION_GRANTED != 0) {
159-
activePermissions += permission
160-
}
161-
}
154+
val requestedPermissions = packageInfo.requestedPermissions?.asSequence().orEmpty()
155+
val permissionFlags = packageInfo.requestedPermissionsFlags?.asSequence().orEmpty()
156+
val activePermissions = (requestedPermissions zip permissionFlags)
157+
.filter { (permission, flag) -> flag and REQUESTED_PERMISSION_GRANTED != 0 }
158+
.mapTo(mutableSetOf()) { (permission, flag) -> permission }
162159

163160
return CallerPackageInfo(appName, callingPackage, uid, signature, activePermissions.toSet())
164161
}
@@ -189,12 +186,12 @@ internal class PackageValidator(context: Context) {
189186
*/
190187
@Suppress("deprecation")
191188
private fun getSignature(packageInfo: PackageInfo): String? =
192-
if (packageInfo.signatures == null || packageInfo.signatures.size != 1) {
189+
if (packageInfo.signatures == null || packageInfo.signatures!!.size != 1) {
193190
// Security best practices dictate that an app should be signed with exactly one (1)
194191
// signature. Because of this, if there are multiple signatures, reject it.
195192
null
196193
} else {
197-
val certificate = packageInfo.signatures[0].toByteArray()
194+
val certificate = packageInfo.signatures!![0].toByteArray()
198195
getSignatureSha256(certificate)
199196
}
200197

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<!-- Base Theme -->
5+
<style name="Base.V35" parent="Base.V29">
6+
<item name="android:windowOptOutEdgeToEdgeEnforcement">true</item>
7+
</style>
8+
<style name="Base" parent="Base.V35"/>
9+
10+
<!-- Light Theme -->
11+
<style name="Base.V35.LightTheme" parent="Base.V29.LightTheme">
12+
</style>
13+
<style name="Base.LightTheme" parent="Base.V35.LightTheme" />
14+
15+
<!-- Dark Theme -->
16+
<style name="Base.V35.DarkTheme" parent="Base.V29.DarkTheme">
17+
18+
</style>
19+
<style name="Base.DarkTheme" parent="Base.V35.DarkTheme" />
20+
21+
<!-- Black Theme -->
22+
<style name="Base.V35.BlackTheme" parent="Base.V29.BlackTheme">
23+
24+
</style>
25+
<style name="Base.BlackTheme" parent="Base.V35.BlackTheme" />
26+
27+
</resources>

0 commit comments

Comments
 (0)