mirror of https://github.com/readrops/Readrops.git
Fix OPML export not working with API 29+
This commit is contained in:
parent
440e6ea810
commit
d51c7ed90a
|
@ -65,11 +65,7 @@ dependencies {
|
|||
exclude group: 'moshi', module: 'moshi' // moshi converter uses moshi 1.8.0 which breaks codegen 1.9.2
|
||||
}
|
||||
|
||||
implementation ('com.squareup.retrofit2:converter-simplexml:2.9.0') {
|
||||
exclude module: 'stax'
|
||||
exclude module: 'stax-api'
|
||||
exclude module: 'xpp3'
|
||||
}
|
||||
implementation ('com.squareup.retrofit2:converter-simplexml:2.9.0')
|
||||
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.readrops.api.opml.OPMLHelper;
|
|||
import com.readrops.api.opml.OPMLParser;
|
||||
import com.readrops.app.R;
|
||||
import com.readrops.app.ReadropsApp;
|
||||
import com.readrops.app.account.AccountViewModel;
|
||||
import com.readrops.app.account.AddAccountActivity;
|
||||
import com.readrops.app.feedsfolders.ManageFeedsFoldersActivity;
|
||||
import com.readrops.app.notifications.NotificationPermissionActivity;
|
||||
|
@ -31,12 +32,16 @@ import com.readrops.app.utils.FileUtils;
|
|||
import com.readrops.app.utils.PermissionManager;
|
||||
import com.readrops.app.utils.SharedPreferencesManager;
|
||||
import com.readrops.app.utils.Utils;
|
||||
import com.readrops.app.account.AccountViewModel;
|
||||
import com.readrops.db.entities.Feed;
|
||||
import com.readrops.db.entities.Folder;
|
||||
import com.readrops.db.entities.account.Account;
|
||||
import com.readrops.db.entities.account.AccountType;
|
||||
|
||||
import org.koin.androidx.viewmodel.compat.ViewModelCompat;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.observers.DisposableCompletableObserver;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
@ -239,13 +244,14 @@ public class AccountSettingsFragment extends PreferenceFragmentCompat {
|
|||
String fileName = "subscriptions.opml";
|
||||
|
||||
try {
|
||||
String path = FileUtils.writeDownloadFile(getContext(), fileName, "text/xml", outputStream -> {
|
||||
viewModel.getFoldersWithFeeds()
|
||||
.flatMapCompletable(folderListMap -> OPMLParser.write(folderListMap, outputStream))
|
||||
String path = FileUtils.writeDownloadFile(getContext(), fileName, "text/x-opml", outputStream -> {
|
||||
Map<Folder, List<Feed>> folderListMap = viewModel.getFoldersWithFeeds()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnError(e -> Utils.showSnackbar(getView(), e.getMessage()))
|
||||
.subscribe();
|
||||
.blockingGet();
|
||||
|
||||
|
||||
OPMLParser.write(folderListMap, outputStream)
|
||||
.blockingAwait();
|
||||
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
|
|
|
@ -34,20 +34,20 @@ object FileUtils {
|
|||
|
||||
val contentUri = resolver.insert(downloadsUri, fileDetails)
|
||||
|
||||
resolver.openFileDescriptor(contentUri!!, "w", null).use { pfd ->
|
||||
val outputStream = FileOutputStream(pfd?.fileDescriptor!!)
|
||||
|
||||
resolver.openOutputStream(contentUri!!)!!.use { stream ->
|
||||
try {
|
||||
listener(outputStream)
|
||||
listener(stream)
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
} finally {
|
||||
outputStream.flush()
|
||||
outputStream.close()
|
||||
stream.flush()
|
||||
stream.close()
|
||||
}
|
||||
|
||||
fileDetails.put(MediaStore.Downloads.IS_PENDING, 0)
|
||||
resolver.update(contentUri, fileDetails, null, null)
|
||||
}
|
||||
|
||||
fileDetails.clear()
|
||||
fileDetails.put(MediaStore.Downloads.IS_PENDING, 0)
|
||||
resolver.update(contentUri, fileDetails, null, null)
|
||||
|
||||
|
|
Loading…
Reference in New Issue