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.
This commit is contained in:
parent
4b72cf87ec
commit
b974c31515
3 changed files with 21 additions and 4 deletions
|
@ -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
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in a new issue