Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always show Nextcloud as an option, offer to install or set up account #132

Merged
merged 2 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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