Skip to content

Commit

Permalink
Always show Nextcloud as an option, offer to install or set up account
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
grote authored and chirayudesai committed Sep 25, 2020
1 parent c5aca6d commit e340661
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<StorageRoot>) {
if (!isRestore) return

for (root in roots) {
// return if we already have a NextCloud storage root
if (root.authority == AUTHORITY_NEXTCLOUD) return
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/layout/list_item_storage_root.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
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 @@ -40,6 +40,7 @@
<string name="storage_fake_nextcloud_title" translatable="false">Nextcloud</string>
<string name="storage_fake_nextcloud_summary">Click to install</string>
<string name="storage_fake_nextcloud_summary_installed">Click 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_check_fragment_backup_title">Initializing backup location…</string>
<string name="storage_check_fragment_restore_title">Looking for backups…</string>
<string name="storage_check_fragment_backup_error">An error occurred while accessing the backup location.</string>
Expand Down

0 comments on commit e340661

Please sign in to comment.