diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreProgressAdapter.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreProgressAdapter.kt index ea5740ce..1df649c7 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreProgressAdapter.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreProgressAdapter.kt @@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView.Adapter import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.restore.RestoreProgressAdapter.PackageViewHolder +import com.stevesoltys.seedvault.ui.AppBackupState import com.stevesoltys.seedvault.ui.AppViewHolder import java.util.LinkedList @@ -64,26 +65,14 @@ internal class RestoreProgressAdapter : Adapter() { appIcon.setImageResource(R.drawable.ic_launcher_default) } } - setStatus(item.status) + setState(item.state, true) } } } -enum class AppRestoreStatus { - IN_PROGRESS, - SUCCEEDED, - NOT_YET_BACKED_UP, - FAILED, - FAILED_NO_DATA, - FAILED_WAS_STOPPED, - FAILED_NOT_ALLOWED, - FAILED_QUOTA_EXCEEDED, - FAILED_NOT_INSTALLED, -} - internal data class AppRestoreResult( val packageName: String, val name: CharSequence, - val status: AppRestoreStatus + val state: AppBackupState ) diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt index b97b48c1..7dace749 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreViewModel.kt @@ -15,6 +15,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.Transformations.switchMap import androidx.lifecycle.asLiveData import androidx.lifecycle.viewModelScope +import com.stevesoltys.seedvault.ui.AppBackupState import com.stevesoltys.seedvault.BackupMonitor import com.stevesoltys.seedvault.MAGIC_PACKAGE_MANAGER import com.stevesoltys.seedvault.R @@ -26,14 +27,14 @@ import com.stevesoltys.seedvault.metadata.PackageState.NO_DATA import com.stevesoltys.seedvault.metadata.PackageState.QUOTA_EXCEEDED import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NOT_ALLOWED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NOT_INSTALLED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NO_DATA -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_QUOTA_EXCEEDED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.IN_PROGRESS -import com.stevesoltys.seedvault.restore.AppRestoreStatus.NOT_YET_BACKED_UP -import com.stevesoltys.seedvault.restore.AppRestoreStatus.SUCCEEDED +import com.stevesoltys.seedvault.ui.AppBackupState.FAILED +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_QUOTA_EXCEEDED +import com.stevesoltys.seedvault.ui.AppBackupState.IN_PROGRESS +import com.stevesoltys.seedvault.ui.AppBackupState.NOT_YET_BACKED_UP +import com.stevesoltys.seedvault.ui.AppBackupState.SUCCEEDED import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_APPS import com.stevesoltys.seedvault.restore.DisplayFragment.RESTORE_BACKUP import com.stevesoltys.seedvault.settings.SettingsManager @@ -99,7 +100,7 @@ internal class RestoreViewModel( AppRestoreResult( packageName = MAGIC_PACKAGE_MANAGER, name = getAppName(app, MAGIC_PACKAGE_MANAGER), - status = IN_PROGRESS + state = IN_PROGRESS ) ) } @@ -222,9 +223,9 @@ internal class RestoreViewModel( private fun updateLatestPackage(list: LinkedList) { val latestResult = list[0] if (restoreCoordinator.isFailedPackage(latestResult.packageName)) { - list[0] = latestResult.copy(status = getFailedStatus(latestResult.packageName)) + list[0] = latestResult.copy(state = getFailedStatus(latestResult.packageName)) } else { - list[0] = latestResult.copy(status = SUCCEEDED) + list[0] = latestResult.copy(state = SUCCEEDED) } } @@ -232,7 +233,7 @@ internal class RestoreViewModel( private fun getFailedStatus( packageName: String, restorableBackup: RestorableBackup = chosenRestorableBackup.value!! - ): AppRestoreStatus { + ): AppBackupState { val metadata = restorableBackup.packageMetadataMap[packageName] ?: return FAILED return when (metadata.state) { NO_DATA -> FAILED_NO_DATA diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt index 3fba9c44..a6e80fbc 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt @@ -16,9 +16,9 @@ import androidx.recyclerview.widget.DiffUtil.DiffResult import androidx.recyclerview.widget.RecyclerView.Adapter import androidx.recyclerview.widget.RecyclerView.NO_POSITION import com.stevesoltys.seedvault.R -import com.stevesoltys.seedvault.restore.AppRestoreStatus -import com.stevesoltys.seedvault.restore.AppRestoreStatus.SUCCEEDED import com.stevesoltys.seedvault.settings.AppStatusAdapter.AppStatusViewHolder +import com.stevesoltys.seedvault.ui.AppBackupState +import com.stevesoltys.seedvault.ui.AppBackupState.SUCCEEDED import com.stevesoltys.seedvault.ui.AppViewHolder import com.stevesoltys.seedvault.ui.toRelativeTime @@ -81,7 +81,7 @@ internal class AppStatusAdapter(private val toggleListener: AppStatusToggleListe startActivity(context, intent, null) true } - setStatus(item.status) + setState(item.status, false) if (item.status == SUCCEEDED) { appInfo.text = item.time.toRelativeTime(context) appInfo.visibility = VISIBLE @@ -110,7 +110,7 @@ data class AppStatus( val icon: Drawable, val name: String, val time: Long, - val status: AppRestoreStatus + val status: AppBackupState ) internal class AppStatusDiff( diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index e538b208..5d5f0882 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -25,15 +25,15 @@ import com.stevesoltys.seedvault.metadata.PackageState.QUOTA_EXCEEDED import com.stevesoltys.seedvault.metadata.PackageState.UNKNOWN_ERROR import com.stevesoltys.seedvault.metadata.PackageState.WAS_STOPPED import com.stevesoltys.seedvault.permitDiskReads -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NOT_ALLOWED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NO_DATA -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_QUOTA_EXCEEDED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_WAS_STOPPED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.NOT_YET_BACKED_UP -import com.stevesoltys.seedvault.restore.AppRestoreStatus.SUCCEEDED import com.stevesoltys.seedvault.transport.backup.PackageService import com.stevesoltys.seedvault.transport.requestBackup +import com.stevesoltys.seedvault.ui.AppBackupState.FAILED +import com.stevesoltys.seedvault.ui.AppBackupState.FAILED_NOT_ALLOWED +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_WAS_STOPPED +import com.stevesoltys.seedvault.ui.AppBackupState.NOT_YET_BACKED_UP +import com.stevesoltys.seedvault.ui.AppBackupState.SUCCEEDED import com.stevesoltys.seedvault.ui.RequireProvisioningViewModel import com.stevesoltys.seedvault.ui.notification.BackupNotificationManager import com.stevesoltys.seedvault.ui.notification.getAppName diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/AppBackupState.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/AppBackupState.kt new file mode 100644 index 00000000..fc40595c --- /dev/null +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/AppBackupState.kt @@ -0,0 +1,43 @@ +package com.stevesoltys.seedvault.ui + +import android.content.Context +import com.stevesoltys.seedvault.R + +enum class AppBackupState { + IN_PROGRESS, + SUCCEEDED, + NOT_YET_BACKED_UP, + FAILED, + FAILED_NO_DATA, + FAILED_WAS_STOPPED, + FAILED_NOT_ALLOWED, + FAILED_QUOTA_EXCEEDED, + FAILED_NOT_INSTALLED; + + private val notShownString = "Please report a bug after you read this." + + fun getBackupText(context: Context): String = when (this) { + IN_PROGRESS -> notShownString + SUCCEEDED -> notShownString + NOT_YET_BACKED_UP -> context.getString(R.string.backup_app_not_yet_backed_up) + FAILED -> notShownString + FAILED_NO_DATA -> context.getString(R.string.backup_app_no_data) + FAILED_WAS_STOPPED -> context.getString(R.string.backup_app_was_stopped) + FAILED_NOT_ALLOWED -> context.getString(R.string.backup_app_not_allowed) + FAILED_NOT_INSTALLED -> notShownString + FAILED_QUOTA_EXCEEDED -> context.getString(R.string.backup_app_quota_exceeded) + } + + fun getRestoreText(context: Context): String = when (this) { + IN_PROGRESS -> notShownString + SUCCEEDED -> notShownString + NOT_YET_BACKED_UP -> context.getString(R.string.restore_app_not_yet_backed_up) + FAILED -> notShownString + FAILED_NO_DATA -> context.getString(R.string.backup_app_no_data) + FAILED_WAS_STOPPED -> context.getString(R.string.restore_app_was_stopped) + FAILED_NOT_ALLOWED -> context.getString(R.string.restore_app_not_allowed) + FAILED_NOT_INSTALLED -> context.getString(R.string.restore_app_not_installed) + FAILED_QUOTA_EXCEEDED -> context.getString(R.string.restore_app_quota_exceeded) + } + +} diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/AppViewHolder.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/AppViewHolder.kt index 33f3479e..b3165204 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/AppViewHolder.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/AppViewHolder.kt @@ -12,16 +12,9 @@ import android.widget.Switch import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import com.stevesoltys.seedvault.R -import com.stevesoltys.seedvault.restore.AppRestoreStatus -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NOT_ALLOWED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NOT_INSTALLED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_NO_DATA -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_QUOTA_EXCEEDED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.FAILED_WAS_STOPPED -import com.stevesoltys.seedvault.restore.AppRestoreStatus.IN_PROGRESS -import com.stevesoltys.seedvault.restore.AppRestoreStatus.NOT_YET_BACKED_UP -import com.stevesoltys.seedvault.restore.AppRestoreStatus.SUCCEEDED +import com.stevesoltys.seedvault.ui.AppBackupState.FAILED +import com.stevesoltys.seedvault.ui.AppBackupState.IN_PROGRESS +import com.stevesoltys.seedvault.ui.AppBackupState.SUCCEEDED internal abstract class AppViewHolder(protected val v: View) : RecyclerView.ViewHolder(v) { @@ -41,8 +34,8 @@ internal abstract class AppViewHolder(protected val v: View) : RecyclerView.View v.background = null } - protected fun setStatus(status: AppRestoreStatus) { - if (status == IN_PROGRESS) { + protected fun setState(state: AppBackupState, isRestore: Boolean) { + if (state == IN_PROGRESS) { appInfo.visibility = GONE appStatus.visibility = INVISIBLE progressBar.visibility = VISIBLE @@ -50,26 +43,18 @@ internal abstract class AppViewHolder(protected val v: View) : RecyclerView.View appStatus.visibility = VISIBLE progressBar.visibility = INVISIBLE appInfo.visibility = GONE - when (status) { + when (state) { SUCCEEDED -> appStatus.setImageResource(R.drawable.ic_check_green) FAILED -> appStatus.setImageResource(R.drawable.ic_error_red) else -> { appStatus.setImageResource(R.drawable.ic_warning_yellow) - appInfo.text = status.getInfo() + appInfo.text = + if (isRestore) state.getRestoreText(context) + else state.getBackupText(context) appInfo.visibility = VISIBLE } } } } - private fun AppRestoreStatus.getInfo(): String = when (this) { - NOT_YET_BACKED_UP -> context.getString(R.string.restore_app_not_yet_backed_up) - FAILED_NO_DATA -> context.getString(R.string.restore_app_no_data) - FAILED_WAS_STOPPED -> context.getString(R.string.restore_app_was_stopped) - FAILED_NOT_ALLOWED -> context.getString(R.string.restore_app_not_allowed) - FAILED_NOT_INSTALLED -> context.getString(R.string.restore_app_not_installed) - FAILED_QUOTA_EXCEEDED -> context.getString(R.string.restore_app_quota_exceeded) - else -> "Please report a bug after you read this." - } - } diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index d284dc5d..b8aa6d16 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -49,7 +49,7 @@ Έγινε υπέρβαση του ορίου αντιγράφων ασφαλείας Η εφαρμογή δεν έχει εγκατασταθεί Η εφαρμογή δεν επιτρέπει τη δημιουργία αντιγράφων ασφαλείας - Η εφαρμογή δεν ανέφερε δεδομένα για δημιουργία αντιγράφων ασφαλείας + Η εφαρμογή δεν ανέφερε δεδομένα για δημιουργία αντιγράφων ασφαλείας Διαχειριστής πακέτων συστήματος Επαναφορά αντιγράφου ασφαλείας Επόμενο diff --git a/app/src/main/res/values-es-rUS/strings.xml b/app/src/main/res/values-es-rUS/strings.xml index 25ac9972..75bedab1 100644 --- a/app/src/main/res/values-es-rUS/strings.xml +++ b/app/src/main/res/values-es-rUS/strings.xml @@ -17,7 +17,7 @@ Cuota de respaldo excedida Aplicación no instalada La aplicación no permite respaldo - La aplicación no reportó datos para respaldo + La aplicación no reportó datos para respaldo Administrador de Paquetes del Sistema Restaurando Respaldo Próximo diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 71cd52b9..301693ea 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -48,7 +48,7 @@ Se ha superado la cuota de la copia de seguridad La aplicación no está instalada La aplicación no permite copias de seguridad - La aplicación no reportó datos para la copia de seguridad + La aplicación no reportó datos para la copia de seguridad Administrador de paquetes del sistema Restaurando copia de seguridad Re-Instalando aplicaciones diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 498fcf16..5ca549e3 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -72,7 +72,7 @@ Quota de sauvegarde dépassé Application non installée L\'application n\'autorise pas la sauvegarde - L\'application n\'a signalé aucune donnée à sauvegarder + L\'application n\'a signalé aucune donnée à sauvegarder Gestionnaire de paquets système Restauration de la sauvegarde Réinstallation des applications diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 07de85da..3e5bc2d1 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -19,7 +19,7 @@ Kvota za sigurnosne kopije premašena Aplikacija nije instalirana Aplikacija ne dozvoljava sigurnosne kopije - Aplikacija nema podataka za sigurnosnu kopiju + Aplikacija nema podataka za sigurnosnu kopiju Upravljanje paketima sustava Vraćanje sigurnosne kopije Sljedeća diff --git a/app/src/main/res/values-is/strings.xml b/app/src/main/res/values-is/strings.xml index 6e55b3a9..abe95ed0 100644 --- a/app/src/main/res/values-is/strings.xml +++ b/app/src/main/res/values-is/strings.xml @@ -16,7 +16,7 @@ Endurvakningu lokið Afritunarrými búið Appið er ekki uppsett - Appið tilkynnti að engin gögn væru til öryggisafritunar + Appið tilkynnti að engin gögn væru til öryggisafritunar Appið leyfir ekki öryggisafritun Pakkastjóri kerfis Endurvek öryggisafrit diff --git a/app/src/main/res/values-nb-rNO/strings.xml b/app/src/main/res/values-nb-rNO/strings.xml index cf982502..c03840a1 100644 --- a/app/src/main/res/values-nb-rNO/strings.xml +++ b/app/src/main/res/values-nb-rNO/strings.xml @@ -11,7 +11,7 @@ Plugg i din %1$s før du installerer programmet for å gjenopprette dataen fra sikkerhetskopi. Velg \"Annet\" Programmet tillater ikke sikkerhetskopiering - Programmet sier ingen data skal sikkerhetskopieres + Programmet sier ingen data skal sikkerhetskopieres System-pakkebehandler Minnepinnefeil ved automatisk gjenoppretting Lisens: Apache2 diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index c17e85b4..b4341063 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -97,7 +97,7 @@ Cota de backup excedida Aplicativo não instalado O aplicativo não permite backup - O aplicativo não relatou nenhum dado para backup + O aplicativo não relatou nenhum dado para backup Gerenciador de pacote do sistema Restaurando backup Próximo diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index d0e257f8..8a6de7c8 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -19,7 +19,7 @@ Cota de backup excedida App não instalado A app não permite backup - A app não relatou nenhuns dados para backup + A app não relatou nenhuns dados para backup Gestor de pacote do sistema Restaurando backup Próximo diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 3cb7bb0d..7e451230 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -23,7 +23,7 @@ Превышена квота резервного копирования Приложение не установлено Приложение не разрешает резервное копирование - Приложение не сообщило об отсутствии данных для резервного копирования + Приложение не сообщило об отсутствии данных для резервного копирования Системный менеджер пакетов Восстановление резервной копии Следующий diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cbf30be9..20de32db 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,6 +89,20 @@ Plug in your %1$s before installing the app to restore its data from backup. Uninstall app + + + + Waiting to back up… + Was not yet backed up + Not backed up as it wasn\'t used recently + Was not backed up as it hadn\'t been used recently + App reported no data for backup + App doesn\'t allow backup + App didn\'t allow backup + Backup quota exceeded + Backup quota was exceeded + App not installed + Restore from backup Choose a backup to restore @@ -102,13 +116,6 @@ Next Restoring backup System package manager - - Not yet backed up - Not backed up as it wasn\'t used recently - App reported no data for backup - App doesn\'t allow backup - App not installed - Backup quota exceeded Restore complete An error occurred while restoring the backup. Finish