diff --git a/app/src/main/java/com/stevesoltys/backup/restore/RestoreProgressFragment.kt b/app/src/main/java/com/stevesoltys/backup/restore/RestoreProgressFragment.kt index 171cd88f..679c953a 100644 --- a/app/src/main/java/com/stevesoltys/backup/restore/RestoreProgressFragment.kt +++ b/app/src/main/java/com/stevesoltys/backup/restore/RestoreProgressFragment.kt @@ -13,6 +13,7 @@ import androidx.lifecycle.ViewModelProviders import com.stevesoltys.backup.R import com.stevesoltys.backup.getAppName import com.stevesoltys.backup.isDebugBuild +import com.stevesoltys.backup.settings.getStorage import kotlinx.android.synthetic.main.fragment_restore_progress.* class RestoreProgressFragment : Fragment() { @@ -32,29 +33,27 @@ class RestoreProgressFragment : Fragment() { viewModel = ViewModelProviders.of(requireActivity()).get(RestoreViewModel::class.java) - viewModel.numPackages.observe(this, Observer { numPackages -> - progressBar.min = 0 - progressBar.max = numPackages - }) - viewModel.chosenRestoreSet.observe(this, Observer { set -> backupNameView.text = set.device }) - viewModel.restoreProgress.observe(this, Observer { progress -> - progressBar.progress = progress.nowBeingRestored - val appName = getAppName(requireActivity().packageManager, progress.currentPackage) - val displayName = if (isDebugBuild()) "$appName (${progress.currentPackage})" else appName + viewModel.restoreProgress.observe(this, Observer { currentPackage -> + val appName = getAppName(requireActivity().packageManager, currentPackage) + val displayName = if (isDebugBuild()) "$appName (${currentPackage})" else appName currentPackageView.text = getString(R.string.restore_current_package, displayName) }) viewModel.restoreFinished.observe(this, Observer { finished -> - progressBarIndefinite.visibility = INVISIBLE - progressBar.progress = viewModel.numPackages.value ?: progressBar.max + progressBar.visibility = INVISIBLE button.visibility = VISIBLE if (finished == 0) { // success currentPackageView.text = getString(R.string.restore_finished_success) + warningView.text = if (getStorage(requireContext())?.ejectable == true) { + getString(R.string.restore_finished_warning_only_installed, getString(R.string.restore_finished_warning_ejectable)) + } else { + getString(R.string.restore_finished_warning_only_installed, null) + } warningView.visibility = VISIBLE } else { // error diff --git a/app/src/main/java/com/stevesoltys/backup/restore/RestoreViewModel.kt b/app/src/main/java/com/stevesoltys/backup/restore/RestoreViewModel.kt index 20db414c..eae78b24 100644 --- a/app/src/main/java/com/stevesoltys/backup/restore/RestoreViewModel.kt +++ b/app/src/main/java/com/stevesoltys/backup/restore/RestoreViewModel.kt @@ -32,11 +32,8 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re private val mChosenRestoreSet = MutableLiveData() internal val chosenRestoreSet: LiveData get() = mChosenRestoreSet - private var mNumPackages = MutableLiveData() - internal val numPackages: LiveData get() = mNumPackages - - private val mRestoreProgress = MutableLiveData() - internal val restoreProgress: LiveData get() = mRestoreProgress + private val mRestoreProgress = MutableLiveData() + internal val restoreProgress: LiveData get() = mRestoreProgress private val mRestoreFinished = MutableLiveData() // Zero on success; a nonzero error code if the restore operation as a whole failed. @@ -84,8 +81,6 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re @WorkerThread private inner class RestoreObserver : IRestoreObserver.Stub() { - private var correctedNow: Int = -1 - /** * Supply a list of the restore datasets available from the current transport. * This method is invoked as a callback following the application's use of the @@ -109,7 +104,7 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re * @param numPackages The total number of packages being processed in this restore operation. */ override fun restoreStarting(numPackages: Int) { - mNumPackages.postValue(numPackages) + // noop } /** @@ -122,12 +117,8 @@ class RestoreViewModel(app: Application) : RequireProvisioningViewModel(app), Re * @param currentPackage The name of the package now being restored. */ override fun onUpdate(nowBeingRestored: Int, currentPackage: String) { - if (nowBeingRestored <= correctedNow) { - correctedNow += 1 - } else { - correctedNow = nowBeingRestored - } - mRestoreProgress.postValue(RestoreProgress(correctedNow, currentPackage)) + // nowBeingRestored reporting is buggy, so don't use it + mRestoreProgress.postValue(currentPackage) } /** @@ -155,7 +146,3 @@ internal class RestoreSetResult( internal fun hasError(): Boolean = errorMsg != null } - -internal class RestoreProgress( - internal val nowBeingRestored: Int, - internal val currentPackage: String) diff --git a/app/src/main/java/com/stevesoltys/backup/transport/backup/KVBackup.kt b/app/src/main/java/com/stevesoltys/backup/transport/backup/KVBackup.kt index ac7e43e2..05138e0a 100644 --- a/app/src/main/java/com/stevesoltys/backup/transport/backup/KVBackup.kt +++ b/app/src/main/java/com/stevesoltys/backup/transport/backup/KVBackup.kt @@ -141,7 +141,7 @@ class KVBackup( val base64Key = key.encodeBase64() val dataSize = changeSet.dataSize - // read and encrypt value + // read value val value = if (dataSize >= 0) { Log.v(TAG, " Delta operation key $key size $dataSize key64 $base64Key") val bytes = ByteArray(dataSize) diff --git a/app/src/main/res/layout/fragment_restore_progress.xml b/app/src/main/res/layout/fragment_restore_progress.xml index 44856401..49983f4d 100644 --- a/app/src/main/res/layout/fragment_restore_progress.xml +++ b/app/src/main/res/layout/fragment_restore_progress.xml @@ -56,7 +56,7 @@ tools:text="@string/restore_current_package" /> - - Restoring %s… Restore complete. An error occurred while restoring the backup. - Note that we could only restore data for apps that are already installed.\n\nWhen you install more apps, we will try to restore their data and settings from this backup. So please do not delete it as long as it might still be needed. + Note that we could only restore data for apps that are already installed.\n\nWhen you install more apps, we will try to restore their data and settings from this backup. So please do not delete it as long as it might still be needed.%s + \n\nPlease also ensure that the storage medium is plugged in when re-installing your apps. Finish Warning You have chosen internal storage for your backup. This will not be available when your phone is lost or broken.