From 76f1e588f7668e7ed613caac8d0a8cd053d2032b Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Tue, 31 Oct 2023 16:35:56 -0400 Subject: [PATCH] Utilize BundleCompat and IntentCompat methods --- app/src/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 +++- 4 files changed, 9 insertions(+), 4 deletions(-) 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 6b34c8e90..831a8cc4b 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.annotation.Nullable; 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 @@ public class ErrorActivity extends AppCompatActivity { 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 d56d16f3c..54809068a 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.content.Intent; 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 class SubscriptionsExportService extends BaseImportExportService { 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 d624e1038..442c7fddb 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 @@ -30,6 +30,7 @@ import android.util.Pair; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.content.IntentCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import org.reactivestreams.Subscriber; @@ -108,7 +109,7 @@ public class SubscriptionsImportService extends BaseImportExportService { 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 91dc5f35b..61fdb602f 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 android.util.Log; 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 final class StateSaver { 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; }