mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-11-16 14:54:57 +00:00
cleanup
This commit is contained in:
parent
fcfdcd1025
commit
716d795970
@ -19,19 +19,19 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
|
|||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
fun exportDatabase(preferences: SharedPreferences, outputPath: String) {
|
fun exportDatabase(preferences: SharedPreferences, outputPath: String) {
|
||||||
ZipOutputStream(BufferedOutputStream(FileOutputStream(outputPath)))
|
ZipOutputStream(BufferedOutputStream(FileOutputStream(outputPath)))
|
||||||
.use { outZip ->
|
.use { outZip ->
|
||||||
ZipHelper.addFileToZip(outZip, fileLocator.db.path, "newpipe.db")
|
ZipHelper.addFileToZip(outZip, fileLocator.db.path, "newpipe.db")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ObjectOutputStream(FileOutputStream(fileLocator.settings)).use { output ->
|
ObjectOutputStream(FileOutputStream(fileLocator.settings)).use { output ->
|
||||||
output.writeObject(preferences.all)
|
output.writeObject(preferences.all)
|
||||||
output.flush()
|
output.flush()
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
}
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
|
||||||
ZipHelper.addFileToZip(outZip, fileLocator.settings.path, "newpipe.settings")
|
ZipHelper.addFileToZip(outZip, fileLocator.settings.path, "newpipe.settings")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
|
|||||||
|
|
||||||
fun extractSettings(filePath: String): Boolean {
|
fun extractSettings(filePath: String): Boolean {
|
||||||
return ZipHelper
|
return ZipHelper
|
||||||
.extractFileFromZip(filePath, fileLocator.settings.path, "newpipe.settings")
|
.extractFileFromZip(filePath, fileLocator.settings.path, "newpipe.settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadSharedPreferences(preferences: SharedPreferences) {
|
fun loadSharedPreferences(preferences: SharedPreferences) {
|
||||||
@ -70,6 +70,7 @@ class ContentSettingsManager(private val fileLocator: NewPipeFileLocator) {
|
|||||||
|
|
||||||
ObjectInputStream(FileInputStream(fileLocator.settings)).use { input ->
|
ObjectInputStream(FileInputStream(fileLocator.settings)).use { input ->
|
||||||
preferenceEditor.clear()
|
preferenceEditor.clear()
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
val entries = input.readObject() as Map<String, *>
|
val entries = input.readObject() as Map<String, *>
|
||||||
for ((key, value) in entries) {
|
for ((key, value) in entries) {
|
||||||
when (value) {
|
when (value) {
|
||||||
|
@ -18,5 +18,4 @@ class NewPipeFileLocator(private val homeDir: File) {
|
|||||||
val dbWal by lazy { File(homeDir, "/databases/newpipe.db-wal") }
|
val dbWal by lazy { File(homeDir, "/databases/newpipe.db-wal") }
|
||||||
|
|
||||||
val settings by lazy { File(homeDir, "/databases/newpipe.settings") }
|
val settings by lazy { File(homeDir, "/databases/newpipe.settings") }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,9 @@ import org.junit.Test
|
|||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.mockito.Mockito
|
import org.mockito.Mockito
|
||||||
import org.mockito.Mockito.`when`
|
import org.mockito.Mockito.`when`
|
||||||
import org.mockito.Mockito.anyString
|
|
||||||
import org.mockito.Mockito.anyBoolean
|
import org.mockito.Mockito.anyBoolean
|
||||||
import org.mockito.Mockito.anyInt
|
import org.mockito.Mockito.anyInt
|
||||||
|
import org.mockito.Mockito.anyString
|
||||||
import org.mockito.Mockito.atLeastOnce
|
import org.mockito.Mockito.atLeastOnce
|
||||||
import org.mockito.Mockito.verify
|
import org.mockito.Mockito.verify
|
||||||
import org.mockito.Mockito.withSettings
|
import org.mockito.Mockito.withSettings
|
||||||
|
Loading…
Reference in New Issue
Block a user