Skip to content

Commit ee3455e

Browse files
authored
Merge pull request #10086 from TacoTheDank/bumpAndroidX
Update some AndroidX libraries and compileSdk to 34
2 parents 2c1bb27 + f9fc1cd commit ee3455e

16 files changed

Lines changed: 83 additions & 66 deletions

File tree

app/build.gradle

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

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

1818
defaultConfig {
@@ -106,9 +106,9 @@ android {
106106
ext {
107107
checkstyleVersion = '10.12.1'
108108

109-
androidxLifecycleVersion = '2.5.1'
109+
androidxLifecycleVersion = '2.6.2'
110110
androidxRoomVersion = '2.5.2'
111-
androidxWorkVersion = '2.7.1'
111+
androidxWorkVersion = '2.8.1'
112112

113113
icepickVersion = '3.2.0'
114114
exoPlayerVersion = '2.18.7'
@@ -208,25 +208,25 @@ dependencies {
208208
implementation "org.jetbrains.kotlin:kotlin-stdlib:${kotlin_version}"
209209

210210
/** AndroidX **/
211-
implementation 'androidx.appcompat:appcompat:1.5.1'
211+
implementation 'androidx.appcompat:appcompat:1.6.1'
212212
implementation 'androidx.cardview:cardview:1.0.0'
213213
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
214-
implementation 'androidx.core:core-ktx:1.10.0'
214+
implementation 'androidx.core:core-ktx:1.12.0'
215215
implementation 'androidx.documentfile:documentfile:1.0.1'
216-
implementation 'androidx.fragment:fragment-ktx:1.4.1'
216+
implementation 'androidx.fragment:fragment-ktx:1.6.1'
217217
implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}"
218218
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${androidxLifecycleVersion}"
219219
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
220220
implementation 'androidx.media:media:1.6.0'
221-
implementation 'androidx.preference:preference:1.2.0'
222-
implementation 'androidx.recyclerview:recyclerview:1.2.1'
221+
implementation 'androidx.preference:preference:1.2.1'
222+
implementation 'androidx.recyclerview:recyclerview:1.3.2'
223223
implementation "androidx.room:room-runtime:${androidxRoomVersion}"
224224
implementation "androidx.room:room-rxjava3:${androidxRoomVersion}"
225225
kapt "androidx.room:room-compiler:${androidxRoomVersion}"
226226
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
227227
// Newer version specified to prevent accessibility regressions with RecyclerView, see:
228228
// https://developer.android.com/jetpack/androidx/releases/viewpager2#1.1.0-alpha01
229-
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta01'
229+
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
230230
implementation "androidx.work:work-runtime-ktx:${androidxWorkVersion}"
231231
implementation "androidx.work:work-rxjava3:${androidxWorkVersion}"
232232
implementation 'com.google.android.material:material:1.9.0'

app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import androidx.annotation.IntDef;
2626
import androidx.annotation.NonNull;
2727
import androidx.annotation.Nullable;
28+
import androidx.core.os.BundleCompat;
2829
import androidx.lifecycle.Lifecycle;
2930
import androidx.viewpager.widget.PagerAdapter;
3031

@@ -284,7 +285,7 @@ public Parcelable saveState() {
284285
Bundle state = null;
285286
if (!mSavedState.isEmpty()) {
286287
state = new Bundle();
287-
state.putParcelableArray("states", mSavedState.toArray(new Fragment.SavedState[0]));
288+
state.putParcelableArrayList("states", mSavedState);
288289
}
289290
for (int i = 0; i < mFragments.size(); i++) {
290291
final Fragment f = mFragments.get(i);
@@ -311,13 +312,12 @@ public void restoreState(@Nullable final Parcelable state, @Nullable final Class
311312
if (state != null) {
312313
final Bundle bundle = (Bundle) state;
313314
bundle.setClassLoader(loader);
314-
final Parcelable[] fss = bundle.getParcelableArray("states");
315+
final var states = BundleCompat.getParcelableArrayList(bundle, "states",
316+
Fragment.SavedState.class);
315317
mSavedState.clear();
316318
mFragments.clear();
317-
if (fss != null) {
318-
for (final Parcelable parcelable : fss) {
319-
mSavedState.add((Fragment.SavedState) parcelable);
320-
}
319+
if (states != null) {
320+
mSavedState.addAll(states);
321321
}
322322
final Iterable<String> keys = bundle.keySet();
323323
for (final String key : keys) {

app/src/main/java/org/schabi/newpipe/about/AboutActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class AboutActivity : AppCompatActivity() {
116116
/**
117117
* List of all software components.
118118
*/
119-
private val SOFTWARE_COMPONENTS = arrayOf(
119+
private val SOFTWARE_COMPONENTS = arrayListOf(
120120
SoftwareComponent(
121121
"ACRA", "2013", "Kevin Gaudin",
122122
"https://github.com/ACRA/acra", StandardLicenses.APACHE2

app/src/main/java/org/schabi/newpipe/about/LicenseFragment.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ import org.schabi.newpipe.BuildConfig
1818
import org.schabi.newpipe.R
1919
import org.schabi.newpipe.databinding.FragmentLicensesBinding
2020
import org.schabi.newpipe.databinding.ItemSoftwareComponentBinding
21+
import org.schabi.newpipe.ktx.parcelableArrayList
2122
import org.schabi.newpipe.util.Localization
2223
import org.schabi.newpipe.util.external_communication.ShareUtils
2324

2425
/**
2526
* Fragment containing the software licenses.
2627
*/
2728
class LicenseFragment : Fragment() {
28-
private lateinit var softwareComponents: Array<SoftwareComponent>
29+
private lateinit var softwareComponents: List<SoftwareComponent>
2930
private var activeSoftwareComponent: SoftwareComponent? = null
3031
private val compositeDisposable = CompositeDisposable()
3132

3233
override fun onCreate(savedInstanceState: Bundle?) {
3334
super.onCreate(savedInstanceState)
34-
softwareComponents = arguments?.getParcelableArray(ARG_COMPONENTS) as Array<SoftwareComponent>
35+
softwareComponents = arguments?.parcelableArrayList<SoftwareComponent>(ARG_COMPONENTS)!!
36+
.sortedBy { it.name } // Sort components by name
3537
activeSoftwareComponent = savedInstanceState?.getSerializable(SOFTWARE_COMPONENT_KEY) as? SoftwareComponent
36-
// Sort components by name
37-
softwareComponents.sortBy { it.name }
3838
}
3939

4040
override fun onDestroy() {
@@ -130,7 +130,8 @@ class LicenseFragment : Fragment() {
130130
StandardLicenses.GPL3,
131131
BuildConfig.VERSION_NAME
132132
)
133-
fun newInstance(softwareComponents: Array<SoftwareComponent>): LicenseFragment {
133+
134+
fun newInstance(softwareComponents: ArrayList<SoftwareComponent>): LicenseFragment {
134135
val fragment = LicenseFragment()
135136
fragment.arguments = bundleOf(ARG_COMPONENTS to softwareComponents)
136137
return fragment

app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
import java.io.File;
7676
import java.io.IOException;
77+
import java.util.ArrayList;
7778
import java.util.List;
7879
import java.util.Locale;
7980
import java.util.Objects;
@@ -1052,7 +1053,7 @@ private void continueSelectedDownload(@NonNull final StoredFileHelper storage) {
10521053
final char kind;
10531054
int threads = dialogBinding.threads.getProgress() + 1;
10541055
final String[] urls;
1055-
final MissionRecoveryInfo[] recoveryInfo;
1056+
final List<MissionRecoveryInfo> recoveryInfo;
10561057
String psName = null;
10571058
String[] psArgs = null;
10581059
long nearLength = 0;
@@ -1117,9 +1118,7 @@ private void continueSelectedDownload(@NonNull final StoredFileHelper storage) {
11171118
urls = new String[] {
11181119
selectedStream.getContent()
11191120
};
1120-
recoveryInfo = new MissionRecoveryInfo[] {
1121-
new MissionRecoveryInfo(selectedStream)
1122-
};
1121+
recoveryInfo = List.of(new MissionRecoveryInfo(selectedStream));
11231122
} else {
11241123
if (secondaryStream.getDeliveryMethod() != PROGRESSIVE_HTTP) {
11251124
throw new IllegalArgumentException("Unsupported stream delivery format"
@@ -1129,12 +1128,14 @@ private void continueSelectedDownload(@NonNull final StoredFileHelper storage) {
11291128
urls = new String[] {
11301129
selectedStream.getContent(), secondaryStream.getContent()
11311130
};
1132-
recoveryInfo = new MissionRecoveryInfo[] {new MissionRecoveryInfo(selectedStream),
1133-
new MissionRecoveryInfo(secondaryStream)};
1131+
recoveryInfo = List.of(
1132+
new MissionRecoveryInfo(selectedStream),
1133+
new MissionRecoveryInfo(secondaryStream)
1134+
);
11341135
}
11351136

11361137
DownloadManagerService.startMission(context, urls, storage, kind, threads,
1137-
currentInfo.getUrl(), psName, psArgs, nearLength, recoveryInfo);
1138+
currentInfo.getUrl(), psName, psArgs, nearLength, new ArrayList<>(recoveryInfo));
11381139

11391140
Toast.makeText(context, getString(R.string.download_has_started),
11401141
Toast.LENGTH_SHORT).show();

app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import androidx.appcompat.app.ActionBar;
1818
import androidx.appcompat.app.AlertDialog;
1919
import androidx.appcompat.app.AppCompatActivity;
20+
import androidx.core.content.IntentCompat;
2021

2122
import com.grack.nanojson.JsonWriter;
2223

@@ -105,7 +106,7 @@ protected void onCreate(final Bundle savedInstanceState) {
105106
actionBar.setDisplayShowTitleEnabled(true);
106107
}
107108

108-
errorInfo = intent.getParcelableExtra(ERROR_INFO);
109+
errorInfo = IntentCompat.getParcelableExtra(intent, ERROR_INFO, ErrorInfo.class);
109110

110111
// important add guru meditation
111112
addGuruMeditation();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.schabi.newpipe.ktx
2+
3+
import android.os.Bundle
4+
import android.os.Parcelable
5+
import androidx.core.os.BundleCompat
6+
7+
inline fun <reified T : Parcelable> Bundle.parcelableArrayList(key: String?): ArrayList<T>? {
8+
return BundleCompat.getParcelableArrayList(this, key, T::class.java)
9+
}

app/src/main/java/org/schabi/newpipe/local/feed/notifications/NotificationWorker.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class NotificationWorker(
137137
.enqueueUniquePeriodicWork(
138138
WORK_TAG,
139139
if (force) {
140-
ExistingPeriodicWorkPolicy.REPLACE
140+
ExistingPeriodicWorkPolicy.CANCEL_AND_REENQUEUE
141141
} else {
142142
ExistingPeriodicWorkPolicy.KEEP
143143
},

app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsExportService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.net.Uri;
2626
import android.util.Log;
2727

28+
import androidx.core.content.IntentCompat;
2829
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
2930

3031
import org.reactivestreams.Subscriber;
@@ -65,7 +66,7 @@ public int onStartCommand(final Intent intent, final int flags, final int startI
6566
return START_NOT_STICKY;
6667
}
6768

68-
final Uri path = intent.getParcelableExtra(KEY_FILE_PATH);
69+
final Uri path = IntentCompat.getParcelableExtra(intent, KEY_FILE_PATH, Uri.class);
6970
if (path == null) {
7071
stopAndReportError(new IllegalStateException(
7172
"Exporting to a file, but the path is null"),

app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
import androidx.annotation.NonNull;
3232
import androidx.annotation.Nullable;
33+
import androidx.core.content.IntentCompat;
3334
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
3435

3536
import org.reactivestreams.Subscriber;
@@ -108,7 +109,7 @@ public int onStartCommand(final Intent intent, final int flags, final int startI
108109
if (currentMode == CHANNEL_URL_MODE) {
109110
channelUrl = intent.getStringExtra(KEY_VALUE);
110111
} else {
111-
final Uri uri = intent.getParcelableExtra(KEY_VALUE);
112+
final Uri uri = IntentCompat.getParcelableExtra(intent, KEY_VALUE, Uri.class);
112113
if (uri == null) {
113114
stopAndReportError(new IllegalStateException(
114115
"Importing from input stream, but file path is null"),

0 commit comments

Comments
 (0)