Skip to content

Commit

Permalink
Add support for RoundSync as a storage provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesoltys committed Jan 27, 2024
1 parent 9c4f9d8 commit 64d0c87
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/development/scripts/install_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ $ADB push $ROOT_PROJECT_DIR/app/build/outputs/apk/release/app-release.apk /syste
echo "Installing Seedvault permissions..."
$ADB push $ROOT_PROJECT_DIR/permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml
$ADB push $ROOT_PROJECT_DIR/allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml
$ADB shell am force-stop com.stevesoltys.seedvault
$ADB shell am broadcast -a android.intent.action.BOOT_COMPLETED

echo "Setting Seedvault transport..."
$ADB shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport
1 change: 1 addition & 0 deletions app/src/debug/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<item>org.nextcloud.documents</item>
<item>org.nextcloud.beta.documents</item>
<item>at.bitfire.davdroid.webdav</item>
<item>de.felixnuesse.extract.vcp</item>
</string-array>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import android.content.Intent
import android.content.Intent.ACTION_VIEW
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.net.Uri
import android.provider.DocumentsContract
import android.provider.DocumentsContract.Document.COLUMN_DISPLAY_NAME
import android.provider.DocumentsContract.Document.COLUMN_DOCUMENT_ID
import com.stevesoltys.seedvault.R
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
import com.stevesoltys.seedvault.ui.storage.StorageRootResolver.getIcon
Expand All @@ -30,6 +33,7 @@ internal class SafStorageOptions(
checkOrAddUsbRoot(roots)
checkOrAddDavX5Root(roots)
checkOrAddNextCloudRoot(roots)
checkOrAddRoundSyncRoots(roots)
}

private fun checkOrAddUsbRoot(roots: ArrayList<SafOption>) {
Expand All @@ -50,6 +54,49 @@ internal class SafStorageOptions(
roots.add(root)
}

/**
* Add a storage root for each child directory at the RoundSync root, if it exists.
*/
private fun checkOrAddRoundSyncRoots(roots: ArrayList<SafOption>) {

val roundSyncRoot = roots.firstOrNull {
it.authority == AUTHORITY_ROUND_SYNC
} ?: return

roots.remove(roundSyncRoot)

val childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(
roundSyncRoot.uri, roundSyncRoot.documentId
)
val projection = arrayOf(COLUMN_DISPLAY_NAME, COLUMN_DOCUMENT_ID)
val cursor = context.contentResolver.query(childrenUri, projection, null, null, null)

cursor?.use {
val nameIndex = cursor.getColumnIndex(COLUMN_DISPLAY_NAME)
val documentIdIndex = cursor.getColumnIndex(COLUMN_DOCUMENT_ID)

while (cursor.moveToNext()) {
val name = cursor.getString(nameIndex)
val documentId = cursor.getString(documentIdIndex)

val childRoot = SafOption(
authority = AUTHORITY_ROUND_SYNC,
rootId = name,
documentId = documentId,
icon = getIcon(context, AUTHORITY_ROUND_SYNC, name, 0),
title = name,
summary = context.getString(R.string.storage_round_sync_summary_prefix) + name,
availableBytes = null,
isUsb = false,
requiresNetwork = true,
enabled = true
)

roots.add(childRoot)
}
}
}

/**
* This adds a fake Dav X5 entry if no real one was found.
*
Expand Down Expand Up @@ -136,8 +183,10 @@ internal class SafStorageOptions(
rootId = "fake",
documentId = "fake",
icon = getIcon(context, AUTHORITY_NEXTCLOUD, "fake", 0),
title = context.getString(R.string.storage_not_recommended,
context.getString(R.string.storage_fake_nextcloud_title)),
title = context.getString(
R.string.storage_not_recommended,
context.getString(R.string.storage_fake_nextcloud_title)
),
summary = context.getString(summaryRes),
availableBytes = null,
isUsb = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const val ROOT_ID_HOME = "home"
const val AUTHORITY_DOWNLOADS = "com.android.providers.downloads.documents"
const val AUTHORITY_NEXTCLOUD = "org.nextcloud.documents"
const val AUTHORITY_DAVX5 = "at.bitfire.davdroid.webdav"
const val AUTHORITY_ROUND_SYNC = "de.felixnuesse.extract.vcp"

internal interface RemovableStorageListener {
fun onStorageChanged()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ internal object StorageRootResolver {
context.getDrawable(R.drawable.davx5)
}

authority == AUTHORITY_ROUND_SYNC -> {
context.getDrawable(R.drawable.round_sync)
}

else -> null
}
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/round_sync.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/round_sync_background" />
<foreground android:drawable="@drawable/round_sync_foreground" />
</adaptive-icon>
18 changes: 18 additions & 0 deletions app/src/main/res/drawable/round_sync_foreground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="158"
android:viewportHeight="165.45605">
<group android:scaleX="0.37535927"
android:scaleY="0.39307252"
android:translateX="47.908993"
android:translateY="49.607723">
<group android:translateY="134.20805">
<path android:pathData="M76.171875,-0Q73.4375,-4.890625,70.046875,-10.296875Q66.671875,-15.703125,63,-21.234375Q59.328125,-26.78125,55.359375,-32.171875Q51.40625,-37.578125,47.375,-42.34375Q44.640625,-41.90625,41.828125,-41.75Q39.03125,-41.609375,35.859375,-41.609375L18.859375,-41.609375L18.859375,-0L13.53125,-0L13.53125,-98.203125Q17.28125,-99.21875,23.390625,-99.796875Q29.515625,-100.375,36.4375,-100.375Q76.171875,-100.375,76.171875,-70.265625Q76.171875,-59.046875,70.265625,-52.421875Q64.375,-45.796875,53.140625,-43.34375Q56.734375,-39.171875,60.546875,-33.90625Q64.375,-28.65625,68.1875,-22.96875Q72,-17.28125,75.59375,-11.4375Q79.203125,-5.609375,82.21875,-0L76.171875,-0ZM36.4375,-46.515625Q53.28125,-46.515625,61.984375,-51.90625Q70.703125,-57.3125,70.703125,-70.421875Q70.703125,-83.09375,62.0625,-89.28125Q53.421875,-95.46875,36.4375,-95.46875Q34.125,-95.46875,31.671875,-95.390625Q29.234375,-95.328125,26.859375,-95.109375Q24.484375,-94.890625,22.390625,-94.671875Q20.296875,-94.46875,18.859375,-94.171875L18.859375,-46.515625L36.4375,-46.515625Z"
android:fillColor="#FFFFFF"/>
<path android:pathData="M92.765625,-10.078125Q98.234375,-6.90625,105,-5.171875Q111.78125,-3.453125,118.109375,-3.453125Q146.48438,-3.453125,146.48438,-25.0625Q146.48438,-28.9375,145.25,-32.109375Q144.03125,-35.28125,141.14062,-38.078125Q138.26562,-40.890625,133.57812,-43.40625Q128.90625,-45.9375,122.140625,-48.53125Q114.375,-51.546875,109.109375,-54.5Q103.859375,-57.453125,100.546875,-60.828125Q97.234375,-64.21875,95.796875,-68.109375Q94.359375,-72,94.359375,-76.890625Q94.359375,-88.984375,102.34375,-95.109375Q110.34375,-101.234375,124.875,-101.234375Q127.765625,-101.234375,131.14062,-100.796875Q134.53125,-100.375,137.76562,-99.578125Q141.01562,-98.78125,143.89062,-97.703125Q146.76562,-96.625,148.92188,-95.328125L146.90625,-90.859375Q142.29688,-93.453125,136.32812,-94.890625Q130.35938,-96.34375,124.296875,-96.34375Q112.203125,-96.34375,106.015625,-91.375Q99.828125,-86.40625,99.828125,-76.75Q99.828125,-72.859375,101.046875,-69.6875Q102.265625,-66.53125,105.28125,-63.796875Q108.3125,-61.0625,113.28125,-58.46875Q118.25,-55.875,125.75,-52.84375Q139.85938,-47.375,145.90625,-41.03125Q151.95312,-34.703125,151.95312,-25.34375Q151.95312,-12.234375,143.45312,-5.390625Q134.95312,1.4375,118.546875,1.4375Q110.484375,1.4375,103.421875,-0.359375Q96.375,-2.15625,90.890625,-5.46875L92.765625,-10.078125Z"
android:fillColor="#FFFFFF"/>
</group>
</group>
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
<color name="green">#558B2F</color>
<color name="yellow">#F9A825</color>
<color name="davx5_background">#7cb342</color>
<color name="round_sync_background">#4bae4f</color>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<item>com.android.externalstorage.documents</item>
<item>org.nextcloud.documents</item>
<item>at.bitfire.davdroid.webdav</item>
<item>de.felixnuesse.extract.vcp</item>
</string-array>

<!--
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<string name="storage_fake_drive_summary">Needs to be plugged in</string>
<string name="storage_available_bytes"><xliff:g example="1 GB" id="size">%1$s</xliff:g> free</string>
<string name="storage_not_recommended"><xliff:g example="Skynet">%1$s</xliff:g> (Not recommended)</string>
<string name="storage_round_sync_summary_prefix" translatable="false">RoundSync Remote: </string>
<string name="storage_fake_nextcloud_title" translatable="false">Nextcloud</string>
<string name="storage_fake_nextcloud_summary">Tap to install</string>
<string name="storage_fake_nextcloud_summary_installed">Tap to set up account</string>
Expand Down

0 comments on commit 64d0c87

Please sign in to comment.