Show notification when failing to import settings

This commit is contained in:
Stypox 2024-03-30 18:53:45 +01:00
parent 7da1d30010
commit 2756ef6d2f
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23
2 changed files with 7 additions and 2 deletions

View file

@ -217,7 +217,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
manager.loadSerializedPrefs(file, prefs); manager.loadSerializedPrefs(file, prefs);
} }
} catch (IOException | ClassNotFoundException | JsonParserException e) { } catch (IOException | ClassNotFoundException | JsonParserException e) {
showErrorSnackbar(e, "Importing preferences"); createErrorNotification(e, "Importing preferences");
return; return;
} }
cleanImport(context, prefs); cleanImport(context, prefs);
@ -290,4 +290,10 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
private void showErrorSnackbar(final Throwable e, final String request) { private void showErrorSnackbar(final Throwable e, final String request) {
ErrorUtil.showSnackbar(this, new ErrorInfo(e, UserAction.DATABASE_IMPORT_EXPORT, 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)
);
}
} }

View file

@ -1,7 +1,6 @@
package org.schabi.newpipe.settings.export package org.schabi.newpipe.settings.export
import android.content.SharedPreferences import android.content.SharedPreferences
import android.util.Log
import com.grack.nanojson.JsonArray import com.grack.nanojson.JsonArray
import com.grack.nanojson.JsonParser import com.grack.nanojson.JsonParser
import com.grack.nanojson.JsonParserException import com.grack.nanojson.JsonParserException