Handle local contacts backup specially in app list

as it might not be installed
This commit is contained in:
Torsten Grote 2020-11-18 17:21:10 -03:00
parent 14f6e5ad93
commit 4ea563f8a3
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 8 additions and 2 deletions

View file

@ -14,6 +14,7 @@ import com.stevesoltys.seedvault.transport.backup.PackageService
import com.stevesoltys.seedvault.ui.AppBackupState import com.stevesoltys.seedvault.ui.AppBackupState
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED import com.stevesoltys.seedvault.ui.AppBackupState.FAILED
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_ALLOWED import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_ALLOWED
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_INSTALLED
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NO_DATA import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NO_DATA
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_QUOTA_EXCEEDED import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_QUOTA_EXCEEDED
import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_WAS_STOPPED import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_WAS_STOPPED
@ -68,13 +69,18 @@ internal class AppListRetriever(
) )
return specialPackages.map { (packageName, stringId) -> return specialPackages.map { (packageName, stringId) ->
val metadata = metadataManager.getPackageMetadata(packageName) val metadata = metadataManager.getPackageMetadata(packageName)
val status = if (packageName == PACKAGE_NAME_CONTACTS && metadata?.state == null) {
// handle local contacts backup specially as it might not be installed
if (packageService.getVersionName(packageName) == null) FAILED_NOT_INSTALLED
else NOT_YET_BACKED_UP
} else metadata?.state.toAppBackupState()
AppStatus( AppStatus(
packageName = packageName, packageName = packageName,
enabled = settingsManager.isBackupEnabled(packageName), enabled = settingsManager.isBackupEnabled(packageName),
icon = getIcon(packageName), icon = getIcon(packageName),
name = context.getString(stringId), name = context.getString(stringId),
time = metadata?.time ?: 0, time = metadata?.time ?: 0,
status = metadata?.state.toAppBackupState(), status = status,
isSpecial = true isSpecial = true
) )
} }

View file

@ -24,7 +24,7 @@ enum class AppBackupState {
FAILED_NO_DATA -> context.getString(R.string.backup_app_no_data) FAILED_NO_DATA -> context.getString(R.string.backup_app_no_data)
FAILED_WAS_STOPPED -> context.getString(R.string.backup_app_was_stopped) FAILED_WAS_STOPPED -> context.getString(R.string.backup_app_was_stopped)
FAILED_NOT_ALLOWED -> context.getString(R.string.backup_app_not_allowed) FAILED_NOT_ALLOWED -> context.getString(R.string.backup_app_not_allowed)
FAILED_NOT_INSTALLED -> notShownString FAILED_NOT_INSTALLED -> context.getString(R.string.restore_app_not_installed)
FAILED_QUOTA_EXCEEDED -> context.getString(R.string.backup_app_quota_exceeded) FAILED_QUOTA_EXCEEDED -> context.getString(R.string.backup_app_quota_exceeded)
} }