Always add a storage option placeholder for DavX5
This commit is contained in:
parent
4ee7605b50
commit
17a83eaab3
8 changed files with 102 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
<words>
|
||||
<w>apk</w>
|
||||
<w>chunker</w>
|
||||
<w>davx</w>
|
||||
<w>ejectable</w>
|
||||
<w>hasher</w>
|
||||
<w>hkdf</w>
|
||||
|
|
|
@ -9,6 +9,8 @@ import com.stevesoltys.seedvault.R
|
|||
import com.stevesoltys.seedvault.ui.storage.StorageOption.SafOption
|
||||
import com.stevesoltys.seedvault.ui.storage.StorageRootResolver.getIcon
|
||||
|
||||
private const val DAVX5_PACKAGE = "at.bitfire.davdroid"
|
||||
private const val DAVX5_ACTIVITY = "at.bitfire.davdroid.ui.webdav.WebdavMountsActivity"
|
||||
private const val NEXTCLOUD_PACKAGE = "com.nextcloud.client"
|
||||
private const val NEXTCLOUD_ACTIVITY = "com.owncloud.android.authentication.AuthenticatorActivity"
|
||||
|
||||
|
@ -26,6 +28,7 @@ internal class SafStorageOptions(
|
|||
|
||||
internal fun checkOrAddExtraRoots(roots: ArrayList<SafOption>) {
|
||||
checkOrAddUsbRoot(roots)
|
||||
checkOrAddDavX5Root(roots)
|
||||
checkOrAddNextCloudRoot(roots)
|
||||
}
|
||||
|
||||
|
@ -47,6 +50,53 @@ internal class SafStorageOptions(
|
|||
roots.add(root)
|
||||
}
|
||||
|
||||
/**
|
||||
* This adds a fake Dav X5 entry if no real one was found.
|
||||
*
|
||||
* If Dav X5 is *not* installed,
|
||||
* the user will always have the option to install it by clicking the entry.
|
||||
*
|
||||
* If it *is* installed and this is restore, the user can set up a new account by clicking.
|
||||
*/
|
||||
private fun checkOrAddDavX5Root(roots: ArrayList<SafOption>) {
|
||||
if (doNotInclude(AUTHORITY_DAVX5, roots)) return
|
||||
|
||||
val intent = Intent().apply {
|
||||
addFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||
setClassName(DAVX5_PACKAGE, DAVX5_ACTIVITY)
|
||||
}
|
||||
val marketIntent =
|
||||
Intent(ACTION_VIEW, Uri.parse("market://details?id=$DAVX5_PACKAGE")).apply {
|
||||
addFlags(FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
val isInstalled = packageManager.resolveActivity(intent, 0) != null
|
||||
val canInstall = packageManager.resolveActivity(marketIntent, 0) != null
|
||||
val summaryRes = if (isInstalled) {
|
||||
if (isRestore) R.string.storage_fake_davx5_summary_installed
|
||||
else R.string.storage_fake_davx5_summary_unavailable
|
||||
} else {
|
||||
if (canInstall) R.string.storage_fake_davx5_summary
|
||||
else R.string.storage_fake_davx5_summary_unavailable_market
|
||||
}
|
||||
val root = SafOption(
|
||||
authority = AUTHORITY_DAVX5,
|
||||
rootId = "fake",
|
||||
documentId = "fake",
|
||||
icon = getIcon(context, AUTHORITY_DAVX5, "fake", 0),
|
||||
title = context.getString(R.string.storage_fake_davx5_title),
|
||||
summary = context.getString(summaryRes),
|
||||
availableBytes = null,
|
||||
isUsb = false,
|
||||
requiresNetwork = true,
|
||||
enabled = isInstalled || canInstall,
|
||||
nonDefaultAction = {
|
||||
if (isInstalled) context.startActivity(intent)
|
||||
else if (canInstall) context.startActivity(marketIntent)
|
||||
}
|
||||
)
|
||||
roots.add(root)
|
||||
}
|
||||
|
||||
/**
|
||||
* This adds a fake Nextcloud entry if no real one was found.
|
||||
*
|
||||
|
|
|
@ -23,6 +23,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"
|
||||
|
||||
internal interface RemovableStorageListener {
|
||||
fun onStorageChanged()
|
||||
|
|
|
@ -96,6 +96,9 @@ internal object StorageRootResolver {
|
|||
authority == AUTHORITY_NEXTCLOUD -> {
|
||||
context.getDrawable(R.drawable.nextcloud)
|
||||
}
|
||||
authority == AUTHORITY_DAVX5 -> {
|
||||
context.getDrawable(R.drawable.davx5)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
5
app/src/main/res/drawable/davx5.xml
Normal file
5
app/src/main/res/drawable/davx5.xml
Normal file
|
@ -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/davx5_background" />
|
||||
<foreground android:drawable="@drawable/davx5_foreground" />
|
||||
</adaptive-icon>
|
36
app/src/main/res/drawable/davx5_foreground.xml
Normal file
36
app/src/main/res/drawable/davx5_foreground.xml
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--suppress AndroidUnknownAttribute -->
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108"
|
||||
android:width="108dp"
|
||||
android:height="108dp">
|
||||
<group
|
||||
android:translateX="-213.3939"
|
||||
android:translateY="-709.5244">
|
||||
<group
|
||||
android:scaleX="0.0662553"
|
||||
android:scaleY="0.0662553"
|
||||
android:translateX="233.5464"
|
||||
android:translateY="729.8276">
|
||||
<path
|
||||
android:pathData="M282.78183 280.50711l-85.53115 -85.53116 -0.00001 228.08306 228.08306 0 -85.53115 -85.53114c94.36922 -94.36921 247.75506 -94.36951 342.12458 0.00001 28.79533 28.79533 49.03756 48.10677 59.87183 84.60006l83.25028 0c-12.82982 -57.30603 -41.34018 -96.85969 -86.10134 -141.62083 -126.01589 -126.0159 -330.15022 -126.0159 -456.1661 0zm399.14533 399.14532c-94.36952 94.36952 -247.75535 94.36921 -342.12458 0 -28.79562 -28.79564 -49.03816 -48.10677 -59.8718 -84.60006l-83.25029 0c12.82949 57.30571 41.33988 96.85938 86.10134 141.62083 126.01588 126.0159 330.15021 126.0159 456.1661 0l85.53115 85.53115 0.00001 -228.08305 -228.08307 0z"
|
||||
android:fillColor="#ffffff" />
|
||||
<path
|
||||
android:pathData="M201.33878 550.34595l27.70423 0c25.78414 0 44.43649 -13.44067 44.43649 -44.98509 0 -31.54442 -18.65235 -44.16219 -45.80799 -44.16219l-26.33273 0zm23.58974 -18.92666l0 -51.29397 1.3715 0c12.89207 0 23.04114 4.38879 23.04114 25.23554 0 20.84675 -10.14907 26.05843 -23.04114 26.05843z"
|
||||
android:fillColor="#ffffff" />
|
||||
<path
|
||||
android:pathData="M311.13854 507.00666c2.1944 -8.50328 4.38879 -19.20096 6.30889 -28.25283l0.5486 0c2.19439 8.91472 4.38879 19.74955 6.58318 28.25283l1.50865 6.17173 -16.45796 0zm-34.28741 43.33929l24.13834 0 4.38879 -18.92666 24.96124 0 4.38878 18.92666 24.96124 0 -27.15563 -89.14728 -28.52713 0z"
|
||||
android:fillColor="#ffffff" />
|
||||
<path
|
||||
android:pathData="M380.56703 550.34595l28.52713 0 26.33273 -89.14728 -24.13834 0 -9.05188 38.9505c-2.33154 9.46333 -4.11449 18.65236 -6.58318 28.25283l-0.5486 0c-2.46869 -9.60047 -4.11449 -18.7895 -6.58318 -28.25283l-9.32618 -38.9505 -24.96124 0z"
|
||||
android:fillColor="#ffffff" />
|
||||
<path
|
||||
android:pathData="M449.1301 596.08783l39.35586 0 6.19081 -15.47702c2.4321 -6.41191 5.0853 -12.82382 7.51741 -19.01463l0.8844 0c3.3165 6.19081 6.41191 12.82382 9.72841 19.01463l8.84401 15.47702 40.68246 0 -33.16504 -53.06408 31.39624 -57.48608 -39.35586 0 -5.3064 15.47703c-1.98991 6.1908 -4.64311 12.82381 -6.63301 19.01462l-0.8844 0c-2.87431 -6.19081 -5.96971 -12.82382 -8.84402 -19.01462l-7.95961 -15.47703 -40.68245 0 31.39624 53.06408z"
|
||||
android:fillColor="#ffffff" />
|
||||
<path
|
||||
android:pathData="M601.43782 509.37229c18.53926 0 34.49164 -11.78465 34.49164 -32.19221 0 -19.25783 -13.50922 -28.16817 -29.3179 -28.16817 -3.01801 0 -5.46117 0.28743 -8.62291 1.43715l1.14972 -13.2218 32.76707 0 0 -20.69499 -54.03691 0 -2.29945 46.85116 10.63493 6.89832c5.46117 -3.44916 7.76062 -4.31145 12.64693 -4.31145 7.18576 0 12.35951 4.02402 12.35951 11.78464 0 8.04806 -4.88632 11.78465 -13.50923 11.78465 -6.6109 0 -12.93437 -3.73659 -18.39554 -8.62291l-10.92236 15.52124c7.47319 7.47319 18.10812 12.93437 33.0545 12.93437z"
|
||||
android:fillColor="#ffffff" />
|
||||
</group>
|
||||
</group>
|
||||
</vector>
|
|
@ -11,4 +11,5 @@
|
|||
<color name="divider">#20ffffff</color>
|
||||
<color name="green">#558B2F</color>
|
||||
<color name="yellow">#F9A825</color>
|
||||
<color name="davx5_background">#7cb342</color>
|
||||
</resources>
|
||||
|
|
|
@ -60,6 +60,11 @@
|
|||
<string name="storage_fake_nextcloud_summary_installed">Tap to set up account</string>
|
||||
<string name="storage_fake_nextcloud_summary_unavailable">Account not available. Set one up (or disable passcode).</string>
|
||||
<string name="storage_fake_nextcloud_summary_unavailable_market">Not installed</string>
|
||||
<string name="storage_fake_davx5_title" translatable="false">DAVx⁵</string>
|
||||
<string name="storage_fake_davx5_summary" translatable="false">@string/storage_fake_nextcloud_summary</string>
|
||||
<string name="storage_fake_davx5_summary_installed">Tap to set up a WebDAV mount</string>
|
||||
<string name="storage_fake_davx5_summary_unavailable">WebDAV mount not available. Set one up.</string>
|
||||
<string name="storage_fake_davx5_summary_unavailable_market" translatable="false">@string/storage_fake_nextcloud_summary_unavailable_market</string>
|
||||
<string name="storage_check_fragment_backup_title">Initializing backup location…</string>
|
||||
<string name="storage_check_fragment_patience">This may take some time…</string>
|
||||
<string name="storage_check_fragment_restore_title">Looking for backups…</string>
|
||||
|
|
Loading…
Reference in a new issue