diff --git a/app/build.gradle b/app/build.gradle index 4d180548..ff4a5b3f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,7 +41,7 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:3.14.2' + implementation 'com.simplemobiletools:commons:3.14.4' implementation 'com.android.support.constraint:constraint-layout:1.0.2' } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditTimeZoneDialog.kt b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditTimeZoneDialog.kt index 5febc726..bc57acbd 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditTimeZoneDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/dialogs/EditTimeZoneDialog.kt @@ -4,6 +4,7 @@ import android.support.v7.app.AlertDialog import com.simplemobiletools.clock.R import com.simplemobiletools.clock.activities.SimpleActivity import com.simplemobiletools.clock.extensions.config +import com.simplemobiletools.clock.helpers.EDITED_TIME_ZONE_SEPARATOR import com.simplemobiletools.clock.helpers.getDefaultTimeZoneTitle import com.simplemobiletools.clock.models.MyTimeZone import com.simplemobiletools.commons.extensions.setupDialogStuff @@ -33,8 +34,22 @@ class EditTimeZoneDialog(val activity: SimpleActivity, val myTimeZone: MyTimeZon val editedTimeZoneTitles = activity.config.editedTimeZoneTitles val editedTitlesMap = HashMap() editedTimeZoneTitles.forEach { - val parts = it.split(":".toRegex(), 2) + val parts = it.split(EDITED_TIME_ZONE_SEPARATOR.toRegex(), 2) + editedTitlesMap[parts[0].toInt()] = parts[1] } + + if (newTitle.isEmpty()) { + editedTitlesMap.remove(myTimeZone.id) + } else { + editedTitlesMap[myTimeZone.id] = newTitle + } + + val newTitlesSet = HashSet() + for ((key, value) in editedTitlesMap) { + newTitlesSet.add("$key$EDITED_TIME_ZONE_SEPARATOR$value") + } + + activity.config.editedTimeZoneTitles = newTitlesSet callback() } } diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt index 2b78305e..c062345d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/helpers/Constants.kt @@ -9,6 +9,7 @@ const val SELECTED_TIME_ZONES = "selected_time_zones" const val EDITED_TIME_ZONE_TITLES = "edited_time_zone_titles" const val TABS_COUNT = 3 +const val EDITED_TIME_ZONE_SEPARATOR = ":" fun getDefaultTimeZoneTitle(id: Int) = getAllTimeZones().firstOrNull { it.id == id }?.title ?: ""