From a3255b4e12273fa5ee1a261c3a79b11e5ffb9ae9 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Tue, 30 May 2023 12:31:03 -0400 Subject: [PATCH] Update some AndroidX libraries --- app/build.gradle | 8 ++++---- .../app/FragmentStatePagerAdapterMenuWorkaround.java | 4 +++- .../main/java/org/schabi/newpipe/about/LicenseFragment.kt | 5 ++++- .../main/java/org/schabi/newpipe/error/ErrorActivity.java | 3 ++- .../subscription/services/SubscriptionsExportService.java | 3 ++- .../subscription/services/SubscriptionsImportService.java | 3 ++- app/src/main/java/org/schabi/newpipe/util/StateSaver.java | 4 +++- .../us/shandian/giga/service/DownloadManagerService.java | 8 +++++--- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e0bbca63646..201e1470a2f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -109,7 +109,7 @@ android { ext { checkstyleVersion = '10.3.1' - androidxLifecycleVersion = '2.5.1' + androidxLifecycleVersion = '2.6.1' androidxRoomVersion = '2.4.3' androidxWorkVersion = '2.7.1' @@ -212,10 +212,10 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlin_version}" /** AndroidX **/ - implementation 'androidx.appcompat:appcompat:1.5.1' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'androidx.core:core-ktx:1.10.0' + implementation 'androidx.core:core-ktx:1.10.1' implementation 'androidx.documentfile:documentfile:1.0.1' implementation 'androidx.fragment:fragment-ktx:1.4.1' implementation "androidx.lifecycle:lifecycle-livedata-ktx:${androidxLifecycleVersion}" @@ -223,7 +223,7 @@ dependencies { implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0' implementation 'androidx.media:media:1.6.0' implementation 'androidx.preference:preference:1.2.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'androidx.recyclerview:recyclerview:1.3.0' implementation "androidx.room:room-runtime:${androidxRoomVersion}" implementation "androidx.room:room-rxjava3:${androidxRoomVersion}" kapt "androidx.room:room-compiler:${androidxRoomVersion}" diff --git a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java index 8d87e90bddf..9dea6b48ba7 100644 --- a/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java +++ b/app/src/main/java/androidx/fragment/app/FragmentStatePagerAdapterMenuWorkaround.java @@ -25,6 +25,7 @@ import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.os.BundleCompat; import androidx.lifecycle.Lifecycle; import androidx.viewpager.widget.PagerAdapter; @@ -311,7 +312,8 @@ public void restoreState(@Nullable final Parcelable state, @Nullable final Class if (state != null) { final Bundle bundle = (Bundle) state; bundle.setClassLoader(loader); - final Parcelable[] fss = bundle.getParcelableArray("states"); + final Parcelable[] fss = BundleCompat.getParcelableArray( + bundle, "states", Parcelable.class); mSavedState.clear(); mFragments.clear(); if (fss != null) { diff --git a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.kt b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.kt index f19ecd74a02..bf0d0eac785 100644 --- a/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.kt +++ b/app/src/main/java/org/schabi/newpipe/about/LicenseFragment.kt @@ -4,6 +4,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.os.BundleCompat import androidx.core.os.bundleOf import androidx.fragment.app.Fragment import io.reactivex.rxjava3.disposables.CompositeDisposable @@ -21,7 +22,9 @@ class LicenseFragment : Fragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - softwareComponents = arguments?.getParcelableArray(ARG_COMPONENTS) as Array + softwareComponents = arguments?.let { + BundleCompat.getParcelableArray(it, ARG_COMPONENTS, SoftwareComponent::class.java) + } as Array activeLicense = savedInstanceState?.getSerializable(LICENSE_KEY) as? License // Sort components by name softwareComponents.sortBy { it.name } diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index dd065c3bb40..309315976de 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -17,6 +17,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; +import androidx.core.content.IntentCompat; import com.grack.nanojson.JsonWriter; @@ -105,7 +106,7 @@ protected void onCreate(final Bundle savedInstanceState) { actionBar.setDisplayShowTitleEnabled(true); } - errorInfo = intent.getParcelableExtra(ERROR_INFO); + errorInfo = IntentCompat.getParcelableExtra(intent, ERROR_INFO, ErrorInfo.class); // important add guru meditation addGuruMeditation(); diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsExportService.java b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsExportService.java index d56d16f3cc5..54809068ac8 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsExportService.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsExportService.java @@ -25,6 +25,7 @@ import android.net.Uri; import android.util.Log; +import androidx.core.content.IntentCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.reactivestreams.Subscriber; @@ -65,7 +66,7 @@ public int onStartCommand(final Intent intent, final int flags, final int startI return START_NOT_STICKY; } - final Uri path = intent.getParcelableExtra(KEY_FILE_PATH); + final Uri path = IntentCompat.getParcelableExtra(intent, KEY_FILE_PATH, Uri.class); if (path == null) { stopAndReportError(new IllegalStateException( "Exporting to a file, but the path is null"), diff --git a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java index af598b10601..6459d9190f9 100644 --- a/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java +++ b/app/src/main/java/org/schabi/newpipe/local/subscription/services/SubscriptionsImportService.java @@ -29,6 +29,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.IntentCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.reactivestreams.Subscriber; @@ -105,7 +106,7 @@ public int onStartCommand(final Intent intent, final int flags, final int startI if (currentMode == CHANNEL_URL_MODE) { channelUrl = intent.getStringExtra(KEY_VALUE); } else { - final Uri uri = intent.getParcelableExtra(KEY_VALUE); + final Uri uri = IntentCompat.getParcelableExtra(intent, KEY_VALUE, Uri.class); if (uri == null) { stopAndReportError(new IllegalStateException( "Importing from input stream, but file path is null"), diff --git a/app/src/main/java/org/schabi/newpipe/util/StateSaver.java b/app/src/main/java/org/schabi/newpipe/util/StateSaver.java index 3c901aacb51..8799652a285 100644 --- a/app/src/main/java/org/schabi/newpipe/util/StateSaver.java +++ b/app/src/main/java/org/schabi/newpipe/util/StateSaver.java @@ -27,6 +27,7 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.os.BundleCompat; import org.schabi.newpipe.BuildConfig; import org.schabi.newpipe.MainActivity; @@ -82,7 +83,8 @@ public static SavedState tryToRestore(final Bundle outState, final WriteRead wri return null; } - final SavedState savedState = outState.getParcelable(KEY_SAVED_STATE); + final SavedState savedState = BundleCompat.getParcelable( + outState, KEY_SAVED_STATE, SavedState.class); if (savedState == null) { return null; } diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index 009a4f4be89..52b0de90db5 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -36,6 +36,7 @@ import androidx.core.app.PendingIntentCompat; import androidx.core.app.ServiceCompat; import androidx.core.content.ContextCompat; +import androidx.core.content.IntentCompat; import androidx.preference.PreferenceManager; import org.schabi.newpipe.R; @@ -380,8 +381,8 @@ public static void startMission(Context context, String[] urls, StoredFileHelper private void startMission(Intent intent) { String[] urls = intent.getStringArrayExtra(EXTRA_URLS); - Uri path = intent.getParcelableExtra(EXTRA_PATH); - Uri parentPath = intent.getParcelableExtra(EXTRA_PARENT_PATH); + Uri path = IntentCompat.getParcelableExtra(intent, EXTRA_PATH, Uri.class); + Uri parentPath = IntentCompat.getParcelableExtra(intent, EXTRA_PARENT_PATH, Uri.class); int threads = intent.getIntExtra(EXTRA_THREADS, 1); char kind = intent.getCharExtra(EXTRA_KIND, '?'); String psName = intent.getStringExtra(EXTRA_POSTPROCESSING_NAME); @@ -389,7 +390,8 @@ private void startMission(Intent intent) { String source = intent.getStringExtra(EXTRA_SOURCE); long nearLength = intent.getLongExtra(EXTRA_NEAR_LENGTH, 0); String tag = intent.getStringExtra(EXTRA_STORAGE_TAG); - Parcelable[] parcelRecovery = intent.getParcelableArrayExtra(EXTRA_RECOVERY_INFO); + Parcelable[] parcelRecovery = IntentCompat.getParcelableArrayExtra( + intent, EXTRA_RECOVERY_INFO, Parcelable.class); StoredFileHelper storage; try {