@ -15,6 +15,7 @@ import androidx.preference.ListPreference
import androidx.preference.Preference
import io.legado.app.R
import io.legado.app.base.BasePreferenceFragment
import io.legado.app.constant.AppLog
import io.legado.app.constant.PreferKey
import io.legado.app.help.AppConfig
import io.legado.app.help.LocalConfig
@ -47,8 +48,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
}
}
}
private val backupDir = registerForActivityResult ( HandleFileContract ( ) ) {
i t. uri ?. let { uri ->
private val backupDir = registerForActivityResult ( HandleFileContract ( ) ) { result ->
resul t. uri ?. let { uri ->
if ( uri . isContentScheme ( ) ) {
AppConfig . backupPath = uri . toString ( )
Coroutine . async {
@ -56,7 +57,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
} . onSuccess {
appCtx . toastOnUi ( R . string . backup _success )
} . onError {
appCtx . toastOnUi ( R . string . backup _fail )
AppLog . put ( " 备份出错 \n ${it.localizedMessage} " , it )
appCtx . toastOnUi ( getString ( R . string . backup _fail , it . localizedMessage ) )
}
} else {
uri . path ?. let { path ->
@ -66,7 +68,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
} . onSuccess {
appCtx . toastOnUi ( R . string . backup _success )
} . onError {
appCtx . toastOnUi ( R . string . backup _fail )
AppLog . put ( " 备份出错 \n ${it.localizedMessage} " , it )
appCtx . toastOnUi ( getString ( R . string . backup _fail , it . localizedMessage ) )
}
}
}
@ -242,7 +245,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
} . onSuccess {
appCtx . toastOnUi ( R . string . backup _success )
} . onError {
appCtx . toastOnUi ( R . string . backup _fail )
AppLog . put ( " 备份出错 \n ${it.localizedMessage} " , it )
appCtx . toastOnUi ( getString ( R . string . backup _fail , it . localizedMessage ) )
}
} else {
backupDir . launch ( null )
@ -264,7 +268,8 @@ class BackupConfigFragment : BasePreferenceFragment(),
} . onSuccess {
appCtx . toastOnUi ( R . string . backup _success )
} . onError {
appCtx . toastOnUi ( R . string . backup _fail )
AppLog . put ( " 备份出错 \n ${it.localizedMessage} " , it )
appCtx . toastOnUi ( getString ( R . string . backup _fail , it . localizedMessage ) )
}
}
. request ( )