-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Readds the importer/exporter logic for local accounts
- Loading branch information
Showing
28 changed files
with
751 additions
and
45 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,12 @@ jobs: | |
- name: Set up Java | ||
uses: actions/[email protected] | ||
with: | ||
distribution: 'zulu' | ||
java-version: '17' | ||
distribution: "zulu" | ||
java-version: "17" | ||
- name: Setup build dependencies | ||
env: | ||
BUNDLE_______DEPLOYMENT: "frozen true" | ||
BUNDLE_DEPLOYMENT: "true" | ||
run: make deps | ||
- name: Configure Git user | ||
run: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
source "https://rubygems.org" | ||
|
||
gem "fastlane" | ||
gem "fastlane", "~> 2.221" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
app/src/main/java/com/jocmp/capyreader/transfers/OPMLExporter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.jocmp.capyreader.transfers | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.jocmp.capy.Account | ||
import com.jocmp.capyreader.R | ||
import com.jocmp.capyreader.common.fileURI | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import java.io.File | ||
import java.nio.file.Files | ||
import java.nio.file.StandardCopyOption | ||
|
||
class OPMLExporter( | ||
private val context: Context, | ||
) { | ||
suspend fun export(account: Account) = withContext(Dispatchers.IO) { | ||
val exports = File(context.filesDir, "transfers") | ||
exports.mkdirs() | ||
val source = File(exports, "source.xml").apply { | ||
writeText(account.opmlDocument()) | ||
} | ||
val export = File(exports, "subscriptions.xml") | ||
val target = export.toPath() | ||
|
||
if (!source.exists()) { | ||
return@withContext | ||
} | ||
|
||
val result = Files.copy(source.toPath(), target, StandardCopyOption.REPLACE_EXISTING) | ||
|
||
source.delete() | ||
|
||
withContext(Dispatchers.Main) { | ||
try { | ||
val uri = context.fileURI(result.toFile()) | ||
val shareIntent = Intent(Intent.ACTION_SEND).apply { | ||
type = "text/xml" | ||
putExtra(Intent.EXTRA_STREAM, uri) | ||
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) | ||
} | ||
|
||
context.startActivity( | ||
Intent.createChooser( | ||
shareIntent, | ||
context.getString(R.string.transfers_export_subscriptions) | ||
) | ||
) | ||
} catch (e: IllegalArgumentException) { | ||
// no-op | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.jocmp.capy | ||
|
||
class OPMLFile( | ||
val account: Account | ||
) { | ||
suspend fun opmlDocument(): String { | ||
val openingText = """ | ||
|<?xml version="1.0" encoding="UTF-8"?> | ||
|<!-- OPML generated by Capy Reader --> | ||
|<opml version="1.1"> | ||
| <head> | ||
| <title>Capy Reader Export</title> | ||
| </head> | ||
| <body> | ||
| | ||
""".trimMargin() | ||
|
||
val closingText = """ | ||
| </body> | ||
|</opml> | ||
""".trimMargin() | ||
|
||
return openingText + account.asOPML() + closingText | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.