diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootFetcher.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootFetcher.kt index ef6431b2..44e11997 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootFetcher.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootFetcher.kt @@ -173,9 +173,17 @@ internal class StorageRootFetcher(private val context: Context, private val isRe roots.add(root) } + /** + * This adds a fake Nextcloud entry if no real one was found. + * + * If Nextcloud 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. + * If this isn't restore, the entry will be disabled, + * because we don't know if there's no account or an activated passcode. + */ private fun checkOrAddNextCloudRoot(roots: ArrayList) { - if (!isRestore) return - for (root in roots) { // return if we already have a NextCloud storage root if (root.authority == AUTHORITY_NEXTCLOUD) return @@ -188,16 +196,20 @@ internal class StorageRootFetcher(private val context: Context, private val isRe putExtra("onlyAdd", true) } val isInstalled = packageManager.resolveActivity(intent, 0) != null + val summaryRes = if (isInstalled) { + if (isRestore) R.string.storage_fake_nextcloud_summary_installed + else R.string.storage_fake_nextcloud_summary_unavailable + } else R.string.storage_fake_nextcloud_summary val root = StorageRoot( authority = AUTHORITY_NEXTCLOUD, rootId = "fake", documentId = "fake", icon = getIcon(context, AUTHORITY_NEXTCLOUD, "fake", 0), title = context.getString(R.string.storage_fake_nextcloud_title), - summary = context.getString(if (isInstalled) R.string.storage_fake_nextcloud_summary_installed else R.string.storage_fake_nextcloud_summary), + summary = context.getString(summaryRes), availableBytes = null, isUsb = false, - enabled = true, + enabled = !isInstalled || isRestore, overrideClickListener = { if (isInstalled) context.startActivity(intent) else { diff --git a/app/src/main/res/layout/list_item_storage_root.xml b/app/src/main/res/layout/list_item_storage_root.xml index e9839533..24f2a776 100644 --- a/app/src/main/res/layout/list_item_storage_root.xml +++ b/app/src/main/res/layout/list_item_storage_root.xml @@ -25,7 +25,9 @@ android:layout_height="wrap_content" android:layout_marginStart="16dp" android:layout_marginTop="16dp" + android:layout_marginEnd="16dp" android:textColor="?android:attr/textColorPrimary" + app:layout_constrainedWidth="true" app:layout_constraintBottom_toTopOf="@+id/summaryView" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" @@ -39,9 +41,11 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" + android:layout_marginEnd="16dp" android:layout_marginBottom="16dp" android:textColor="?android:attr/textColorTertiary" android:textSize="12sp" + app:layout_constrainedWidth="true" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ba1a093e..6cc9dc50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -40,6 +40,7 @@ Nextcloud Click to install Click to set up account + Account not available. Set one up (or disable passcode). Initializing backup location… Looking for backups… An error occurred while accessing the backup location.