Skip to content

Commit

Permalink
Use map commands
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jan 21, 2023
1 parent c76a913 commit e5aeff6
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import com.kylecorry.andromeda.alerts.Alerts
import com.kylecorry.andromeda.fragments.BoundFragment
import com.kylecorry.andromeda.pickers.Pickers
import com.kylecorry.trail_sense.R
import com.kylecorry.trail_sense.databinding.FragmentMapsBinding
import com.kylecorry.trail_sense.shared.FormatService
import com.kylecorry.trail_sense.shared.extensions.inBackground
import com.kylecorry.trail_sense.shared.extensions.onIO
import com.kylecorry.trail_sense.tools.guide.infrastructure.UserGuideUtils
import com.kylecorry.trail_sense.tools.maps.domain.Map
import com.kylecorry.trail_sense.tools.maps.domain.MapProjectionType
import com.kylecorry.trail_sense.tools.maps.infrastructure.MapRepo
import com.kylecorry.trail_sense.tools.maps.infrastructure.MapService
import com.kylecorry.trail_sense.tools.maps.ui.commands.DeleteMapCommand
import com.kylecorry.trail_sense.tools.maps.ui.commands.RenameMapCommand
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

Expand Down Expand Up @@ -89,23 +89,12 @@ class MapsFragment : BoundFragment<FragmentMapsBinding>() {
UserGuideUtils.openGuide(this, R.raw.importing_maps)
}
2 -> { // Rename
Pickers.text(
requireContext(),
getString(R.string.create_map),
getString(R.string.create_map_description),
map?.name,
hint = getString(R.string.name)
) { name ->
if (name != null) {
binding.mapName.text = name
inBackground {
onIO {
map?.let {
val updated = mapRepo.getMap(it.id)!!.copy(name = name)
mapRepo.addMap(updated)
map = updated
}
}
inBackground {
map?.let {
mapRepo.getMap(it.id)?.let { updated ->
RenameMapCommand(requireContext(), mapService).execute(updated)
map = mapRepo.getMap(updated.id)
binding.mapName.text = map?.name
}
}
}
Expand Down Expand Up @@ -144,22 +133,10 @@ class MapsFragment : BoundFragment<FragmentMapsBinding>() {
}
}
5 -> { // Delete
Alerts.dialog(
requireContext(),
getString(R.string.delete_map),
map?.name,
) { cancelled ->
if (!cancelled) {
inBackground {
withContext(Dispatchers.IO) {
map?.let {
mapRepo.deleteMap(it)
}
}
withContext(Dispatchers.Main) {
findNavController().popBackStack()
}
}
inBackground {
map?.let {
DeleteMapCommand(requireContext(), mapService).execute(it)
findNavController().popBackStack()
}
}
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-bs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@
<string name="coordinates_tab">Koordinati</string>
<string name="distance">Razdaljina</string>
<string name="convert">Pretvori</string>
<string name="delete_map">Izbriši kartu\?</string>
<string name="pref_barometer_info_summary">Pritisak se može razlikovati od pritiska u obližnjim stanicama</string>
<string name="battery_history">Istorija baterije - posljednja %s</string>
<string name="dusk_type">Sumrak (%s)</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,6 @@
<string name="pref_nmea_elevation_title">Kompenzace nadmořské výšky NMEA</string>
<string name="pref_nmea_elevation_summary">Používá kompenzace NMEA pro převod nadmořské výšky</string>
<string name="pref_barometer_pressure_smoothing_title">Vyhlazení tlaku</string>
<string name="delete_map">Smazat mapu\?</string>
<string name="convert">Převést</string>
<string name="distance">Vzdálenost</string>
<string name="move">Přesunout</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,6 @@
<string name="pref_barometer_info_summary">Der Druck könnte von dem von benachbarten Stationen abweichen</string>
<string name="battery_history">Batterienutzung - letzte %s</string>
<string name="no_data">Keine Daten</string>
<string name="delete_map">Karte löschen\?</string>
<string name="pref_barometer_pressure_smoothing_title">Druckglättung</string>
<string name="battery_capacity_format">%s mAh</string>
<string name="moved_to">Nach %s verschoben</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@
<string name="points">Puntos</string>
<string name="pref_barometer_pressure_smoothing_title">Suavizado de presión</string>
<string name="gallon_format">%s gal</string>
<string name="delete_map">¿Eliminar mapa\?</string>
<string name="import_map">Importar mapa</string>
<string name="quart_format">%s qt</string>
<string name="sort">Clasificar</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@
<string name="precise_percent_format">%s%%</string>
<string name="degree">%s°</string>
<string name="moved_to">Déplacé vers %s</string>
<string name="delete_map">Supprimer la carte \?</string>
<string name="no_groups">Aucun groupe</string>
<string name="coordinates_tab">Coordonnées</string>
<string name="distance">Distance</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
<string name="battery_warning">Akkumerülési figyelmeztetés</string>
<string name="activity_recognition_permission_denied">Testmozgáshoz való hozzáférés megtagadva, a lépésszámláló funkciókat nem lehet bekapcsolni. A beállításokban engedélyezheted.</string>
<string name="pref_nmea_elevation_summary">NMEA eltéréseket használ a magasság átalakításához</string>
<string name="delete_map">Térkép törlése\?</string>
<string name="no_groups">Nincsenek csoportok</string>
<string name="move">Áthelyezés</string>
<string name="map_perspective_instructions">Rajzold körbe a térképet</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-in/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,6 @@
<string name="dotted">Bertitik-titik</string>
<string name="battery_warning">Peringatan pengurasan baterai</string>
<string name="whistle_signal_acknowledged">Diakui</string>
<string name="delete_map">Hapus peta\?</string>
<string name="convert">Konversi</string>
<string name="no_groups">Tidak ada grup</string>
<string name="coordinates_tab">Koordinat</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-iw/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@
<string name="pref_show_nautical_times_title">זמנים ימיים</string>
<string name="pref_show_astronomical_times_title">זמנים אסטרונומיים</string>
<string name="pref_barometer_pressure_smoothing_title">החלקת לחץ</string>
<string name="delete_map">האם למחוק מפה\?</string>
<string name="backtrack_battery_warning">מרווחים קטנים (מתחת ל-15 דקות) עלולים לגרום לריקון יתר של הסוללה</string>
<string name="camera_permission_denied">הרשאת המצלמה נדחתה, לא ניתן להפעיל תכונות מצלמה. באפשרותך להפוך אותו לזמין בהגדרות.</string>
<string name="last_signal_beacon_name">אות אחרון - %s (%s)</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-nb-rNO/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,6 @@
<string name="on">På</string>
<string name="map_perspective_instructions">Omriss av kartet</string>
<string name="preview">Forhåndsvis</string>
<string name="delete_map">Slett kart\?</string>
<string name="error_importing_map">Feil ved importering av kart</string>
<string name="importing_map">Importering av kart</string>
<string name="next">Neste</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-nl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,6 @@
<string name="coordinates_tab">Coördinaten</string>
<string name="distance">Distantie</string>
<string name="convert">Omrekenen</string>
<string name="delete_map">Kaart verwijderen\?</string>
<string name="pref_barometer_pressure_smoothing_title">Drukvereffening</string>
<string name="pref_nmea_elevation_summary">Gebruikt NMEA-offsets voor hoogteconversie</string>
<string name="pref_nmea_elevation_title">NMEA hoogte offsets</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@
<string name="weather_monitor">Monitorowanie pogody</string>
<string name="no_data">Brak danych</string>
<string name="backtrack">Ślad powrotny</string>
<string name="delete_map">Usunąć mapę\?</string>
<string name="pref_nmea_elevation_title">Przesunięcia wysokości NMEA</string>
<string name="water_boil_guide_title">Spraw, aby woda była bezpieczna do picia</string>
<string name="solid">Stały</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@
<string name="coordinates_tab">Coordenadas</string>
<string name="distance">Distância</string>
<string name="convert">Converter</string>
<string name="delete_map">Excluir o mapa\?</string>
<string name="pref_barometer_pressure_smoothing_title">Regularização da pressão</string>
<string name="pref_nmea_elevation_summary">Utiliza compensações NMEA para conversão de altitude</string>
<string name="pref_nmea_elevation_title">Compensação de altitude NMEA</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-pt/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@
<string name="coordinates_tab">Coordenadas</string>
<string name="distance">Distância</string>
<string name="convert">Converter</string>
<string name="delete_map">Eliminar o mapa\?</string>
<string name="pref_barometer_pressure_smoothing_title">Regularização da pressão</string>
<string name="pref_nmea_elevation_summary">Utiliza compensações NMEA para conversão de altitude</string>
<string name="pref_nmea_elevation_title">Compensação de altitude NMEA</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@
<string name="coordinates_tab">Координаты</string>
<string name="distance">Расстояние</string>
<string name="convert">Конвертировать</string>
<string name="delete_map">Удалить карту\?</string>
<string name="pref_barometer_pressure_smoothing_title">Сглаживание давления</string>
<string name="pref_nmea_elevation_summary">Использует смещения NMEA для преобразования высоты</string>
<string name="pref_nmea_elevation_title">Смещение высоты по NMEA</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-tr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@
<string name="network_no_signal">Sinyal yok</string>
<string name="pref_nmea_elevation_summary">İrtifa dönüşümü için NMEA ofsetlerini kullanır</string>
<string name="pref_nmea_elevation_title">NMEA irtifa ofsetleri</string>
<string name="delete_map">Harita silinsin mi\?</string>
<string name="pref_barometer_pressure_smoothing_title">Basınç düzenleme</string>
<string name="pref_barometer_info_summary">Basınç, yakındaki istasyonlardan farklı olabilir</string>
<string name="battery_history">Pil geçmişi - son %s</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-uk/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@
<string name="weather_monitor">Відстеження погоди</string>
<string name="dusk_type">Захід сонця (%s)</string>
<string name="dawn_type">Схід сонця (%s)</string>
<string name="delete_map">Видалити мапу\?</string>
<string name="pref_barometer_pressure_smoothing_title">Згладжування тиску</string>
<string name="pref_nmea_elevation_summary">Використовує зсуви NMEA для перетворення висоти</string>
<string name="pref_nmea_elevation_title">Зсуви висоти NMEA</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,6 @@
<string name="battery_history">历史电量 - 过去 %s</string>
<string name="no_data">无数据</string>
<string name="pref_nmea_elevation_title">NMEA高度偏移</string>
<string name="delete_map">删除地图?</string>
<string name="pref_barometer_pressure_smoothing_title">大气压数据平滑</string>
<string name="pref_nmea_elevation_summary">使用NMEA偏移量进行高度转换</string>
<string name="moved_to">已移动到 %s</string>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,6 @@
<string name="pref_nmea_elevation_summary">Uses NMEA offsets for elevation conversion</string>
<string name="pref_barometer_pressure_smoothing" translatable="false">pref_barometer_pressure_smoothing</string>
<string name="pref_barometer_pressure_smoothing_title">Pressure smoothing</string>
<string name="delete_map">Delete map?</string>
<string name="convert">Convert</string>
<string name="distance">Distance</string>
<string name="coordinates_tab">Coordinates</string>
Expand Down

0 comments on commit e5aeff6

Please sign in to comment.