From b15eb7522a1febf480e6dcaf8f6b2542f43620b4 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 16 Sep 2020 13:35:39 -0300 Subject: [PATCH] Always show Nextcloud as an option, offer to install or set up account Outside of SetupWizard restore, we don't offer to set up an account, because we don't know if one already exists and the app was locked with a passcode. --- .../ui/storage/StorageRootFetcher.kt | 20 +++++++++++++++---- .../res/layout/list_item_storage_root.xml | 4 ++++ app/src/main/res/values/strings.xml | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) 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 d8fb40bb..6fd3641d 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.