1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-21 18:42:35 +01:00

Improve documentation

This commit is contained in:
TobiGr 2024-04-04 11:38:57 +02:00
parent 2756ef6d2f
commit f0db2aa43c
2 changed files with 12 additions and 4 deletions

View File

@ -187,6 +187,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
throw new IOException("Could not create databases dir");
}
// replace the current database
if (!manager.extractDb(file)) {
Toast.makeText(requireContext(), R.string.could_not_import_all_files,
Toast.LENGTH_LONG)
@ -265,7 +266,7 @@ public class BackupRestoreSettingsFragment extends BasePreferenceFragment {
}
/**
* Save import path and restart system.
* Save import path and restart app.
*
* @param importDataUri The import path to save
*/
@ -290,6 +291,7 @@ 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(),

View File

@ -67,6 +67,12 @@ class ImportExportManager(private val fileLocator: BackupFileLocator) {
return fileLocator.dbDir.exists() || fileLocator.dbDir.mkdir()
}
/**
* Extracts the database from the given file to the app's database directory.
* The current app's database will be overwritten.
* @param file the .zip file to extract the database from
* @return true if the database was successfully extracted, false otherwise
*/
fun extractDb(file: StoredFileHelper): Boolean {
val success = ZipHelper.extractFileFromZip(
file,