From 640d24974fa25cb9fdce265d399c43de2fad4afc Mon Sep 17 00:00:00 2001 From: Sparky93 Date: Fri, 14 Feb 2020 12:10:36 +0200 Subject: [PATCH] Fix for #8426 - Migration steps displayed in a different order than UI specifications Changed the order of the whitelisted migrations in order to respect the UI specifications. Now using linked hash map instead of hash map for the whitelisted migrations so we can preserve the order of the steps upon status changing in the migration process. --- .../migration/MigrationProgressActivity.kt | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt index 11e670a03..aa092634c 100644 --- a/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/migration/MigrationProgressActivity.kt @@ -91,29 +91,23 @@ class MigrationProgressActivity : AbstractMigrationProgressActivity() { } // These are the only items we want to show migrating in the UI. -internal val whiteList = mapOf( - Bookmarks to R.string.preferences_sync_bookmarks, +internal val whiteList = linkedMapOf( + Settings to R.string.settings_title, History to R.string.preferences_sync_history, - Logins to R.string.migration_text_passwords, - Settings to R.string.settings_title + Bookmarks to R.string.preferences_sync_bookmarks, + Logins to R.string.migration_text_passwords ) -internal fun MigrationResults.toItemList() = filterKeys { - whiteList.keys.contains(it) -}.map { (type, status) -> - MigrationItem( - type, - status.success - ) -}.toMutableList() - .plus( - whiteList - .filterKeys { !this.containsKey(it) } - .keys - .map { MigrationItem(it, false) } - ).sortedBy { it.migration.javaClass.simpleName } +internal fun MigrationResults.toItemList() = whiteList.keys + .map { + if (containsKey(it)) { + MigrationItem(it, getValue(it).success) + } else { + MigrationItem(it) + } + } -internal data class MigrationItem(val migration: Migration, val status: Boolean) +internal data class MigrationItem(val migration: Migration, val status: Boolean = false) internal class MigrationStatusAdapter : ListAdapter(DiffCallback) {