From 2756ef6d2fd998cf30b689db3a60fdc32ccf3c3b Mon Sep 17 00:00:00 2001 From: Stypox Date: Sat, 30 Mar 2024 18:53:45 +0100 Subject: [PATCH] Show notification when failing to import settings --- .../newpipe/settings/BackupRestoreSettingsFragment.java | 8 +++++++- .../schabi/newpipe/settings/export/ImportExportManager.kt | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java b/app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java index f4080acd3..20af8c150 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java +++ b/app/src/main/java/org/schabi/newpipe/settings/BackupRestoreSettingsFragment.java @@ -217,7 +217,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment { manager.loadSerializedPrefs(file, prefs); } } catch (IOException | ClassNotFoundException | JsonParserException e) { - showErrorSnackbar(e, "Importing preferences"); + createErrorNotification(e, "Importing preferences"); return; } cleanImport(context, prefs); @@ -290,4 +290,10 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment { private void showErrorSnackbar(final Throwable e, final String request) { ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request)); } + private void createErrorNotification(final Throwable e, final String request) { + ErrorUtil.createNotification( + requireContext(), + new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, request) + ); + } } diff --git a/app/src/main/java/org/schabi/newpipe/settings/export/ImportExportManager.kt b/app/src/main/java/org/schabi/newpipe/settings/export/ImportExportManager.kt index 85370449a..843806b80 100644 --- a/app/src/main/java/org/schabi/newpipe/settings/export/ImportExportManager.kt +++ b/app/src/main/java/org/schabi/newpipe/settings/export/ImportExportManager.kt @@ -1,7 +1,6 @@ package org.schabi.newpipe.settings.export import android.content.SharedPreferences -import android.util.Log import com.grack.nanojson.JsonArray import com.grack.nanojson.JsonParser import com.grack.nanojson.JsonParserException