Skip to content

Commit

Permalink
Removal of the "show on map"-feature using KML/GPX.
Browse files Browse the repository at this point in the history
Dashboard API is nicer and easier.

Fixes #2012.
  • Loading branch information
dennisguse committed Nov 24, 2024
1 parent d9de56b commit 2cc4218
Show file tree
Hide file tree
Showing 29 changed files with 1 addition and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import de.dennisguse.opentracks.ui.customRecordingLayout.CsvLayoutUtils;
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayout;
import de.dennisguse.opentracks.ui.customRecordingLayout.RecordingLayoutIO;
import de.dennisguse.opentracks.util.IntentDashboardUtils;

/**
* Utilities to access preferences stored in {@link SharedPreferences}.
Expand Down Expand Up @@ -860,14 +859,6 @@ public static void clear() {
sharedPreferences.edit().clear().commit();
}

public static void setShowOnMapFormat(final String showOnMapFormat) {
setString(R.string.show_on_map_format_key, showOnMapFormat);
}

public static String getShowOnMapFormat() {
return getString(R.string.show_on_map_format_key, IntentDashboardUtils.PREFERENCE_ID_ASK);
}

public static int getTotalRowsDeleted() {
return getInt(R.string.total_rows_deleted_key, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,10 @@
import android.widget.Toast;

import androidx.fragment.app.DialogFragment;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import java.util.Map;

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.util.IntentDashboardUtils;

public class UserInterfaceSettingsFragment extends PreferenceFragmentCompat {

Expand All @@ -41,8 +36,6 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {

Preference dynamicColors = findPreference(getString(R.string.settings_ui_dynamic_colors_key));
dynamicColors.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU);

setShowOnMapFormatOptions();
}

@Override
Expand Down Expand Up @@ -79,14 +72,4 @@ public void onDisplayPreferenceDialog(Preference preference) {

super.onDisplayPreferenceDialog(preference);
}

private void setShowOnMapFormatOptions() {
Map<String, String> options = TrackFileFormat.toPreferenceIdLabelMap(getResources(), IntentDashboardUtils.SHOW_ON_MAP_TRACK_FILE_FORMATS);
options.put(IntentDashboardUtils.PREFERENCE_ID_DASHBOARD, getString(R.string.show_on_dashboard));
options.put(IntentDashboardUtils.PREFERENCE_ID_ASK, getString(R.string.show_on_map_format_ask));
ListPreference listPreference = findPreference(getString(R.string.show_on_map_format_key));
listPreference.setEntries(options.values().toArray(new String[0]));
listPreference.setEntryValues(options.keySet().toArray(new String[0]));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,18 @@
import android.content.Intent;
import android.net.Uri;
import android.util.Log;
import android.util.Pair;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;

import de.dennisguse.opentracks.R;
import de.dennisguse.opentracks.data.ContentProviderUtils;
import de.dennisguse.opentracks.data.ShareContentProvider;
import de.dennisguse.opentracks.data.models.Track;
import de.dennisguse.opentracks.data.tables.MarkerColumns;
import de.dennisguse.opentracks.data.tables.TrackPointsColumns;
import de.dennisguse.opentracks.data.tables.TracksColumns;
import de.dennisguse.opentracks.io.file.TrackFileFormat;
import de.dennisguse.opentracks.settings.PreferencesUtils;

/**
Expand All @@ -39,14 +32,6 @@ public class IntentDashboardUtils {

private static final String ACTION_DASHBOARD_PAYLOAD = ACTION_DASHBOARD + ".Payload";

public static final TrackFileFormat[] SHOW_ON_MAP_TRACK_FILE_FORMATS = new TrackFileFormat[] {
TrackFileFormat.KMZ_WITH_TRACKDETAIL_AND_SENSORDATA_AND_PICTURES,
TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA,
TrackFileFormat.GPX};

public static final String PREFERENCE_ID_DASHBOARD = ACTION_DASHBOARD;
public static final String PREFERENCE_ID_ASK = "ASK";

/**
* Assume "v1" if not present.
*/
Expand All @@ -73,59 +58,13 @@ private IntentDashboardUtils() {

/**
* Send intent to show tracks on a map (needs an another app) as resource URIs.
* Shows an AlertDialog with different format option if none is defined as preference.
*
* @param context the context
* @param isRecording are we currently recording?
* @param trackIds the track ids
*/
public static void showTrackOnMap(Context context, boolean isRecording, Track.Id... trackIds) {
Map<String, String> options = TrackFileFormat.toPreferenceIdLabelMap(context.getResources(), IntentDashboardUtils.SHOW_ON_MAP_TRACK_FILE_FORMATS);
options.put(IntentDashboardUtils.PREFERENCE_ID_DASHBOARD, context.getString(R.string.show_on_dashboard));
final String[] optionLabels = options.values().toArray(new String[0]);
final String[] optionValues = options.keySet().toArray(new String[0]);
final AtomicInteger checkedItem = new AtomicInteger(NONE_SELECTED);
String preferenceValue = PreferencesUtils.getShowOnMapFormat();
for (int i = 0; i < optionValues.length; i++) {
if (optionValues[i].equals(preferenceValue)) {
checkedItem.set(i);
}
}
if (checkedItem.get() == NONE_SELECTED) {
checkedItem.set(0); // set first option as default
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.select_show_on_map_behavior);
builder.setSingleChoiceItems(optionLabels, checkedItem.get(), (dialog, which) -> checkedItem.set(which));
builder.setPositiveButton(android.R.string.ok, (dialog, which) -> onFormatSelected(context, isRecording, optionValues[checkedItem.get()], trackIds, false));
builder.setNeutralButton(R.string.always, ((dialog, which) -> onFormatSelected(context, isRecording, optionValues[checkedItem.get()], trackIds, true)));
builder.setNegativeButton(android.R.string.cancel, null);

AlertDialog dialog = builder.create();
dialog.show();
} else {
onFormatSelected(context, isRecording, preferenceValue, trackIds, true);
}
}

/**
* A format was selected, remember if <code>always</code> is true and start the necessary action
*
* @param context the context
* @param isRecording are we currently recording?
* @param selectedValue the chosen format
* @param trackIds the track ids
* @param always set the selectedValue as default preference
*/
private static void onFormatSelected(final Context context, final boolean isRecording, final String selectedValue, final Track.Id[] trackIds, final boolean always) {
if (always) {
PreferencesUtils.setShowOnMapFormat(selectedValue);
}
TrackFileFormat trackFileFormat = TrackFileFormat.valueOfPreferenceId(selectedValue);
if (trackFileFormat != null) {
showTrackOnMapWithFileFormat(context, trackFileFormat, Set.of(trackIds));
} else {
startDashboard(context, isRecording, null, null, trackIds);
}
startDashboard(context, isRecording, null, null, trackIds);
}

/**
Expand Down Expand Up @@ -183,28 +122,4 @@ public static void startDashboard(Context context, boolean isRecording, @Nullabl
Toast.makeText(context, R.string.show_on_dashboard_not_installed, Toast.LENGTH_SHORT).show();
}
}

/**
* Send intent to show tracks on a map (needs an another app) to support specific trackFileFormat.
*
* @param context the context
* @param trackFileFormat the track file format
* @param trackIds the track ids
*/
private static void showTrackOnMapWithFileFormat(Context context, TrackFileFormat trackFileFormat, Set<Track.Id> trackIds) {
if (trackIds.isEmpty()) {
return;
}

Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

Pair<Uri, String> uriAndMime = ShareContentProvider.createURI(trackIds, "SharingTrack", trackFileFormat);
intent.setDataAndType(uriAndMime.first, uriAndMime.second);

intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

context.startActivity(Intent.createChooser(intent, context.getString(R.string.open_track_as_trackfileformat, trackFileFormat.getExtension())));
}

}
2 changes: 0 additions & 2 deletions src/main/res/values-co/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,6 @@
<string name="no_compatible_camera_installed">Nisuna appiecazione cumpatibile per l’apparechju-fotò ùn hè installata</string>
<string name="error_crash_title">%1$s s‘hè lampatu</string>
<string name="report_bug">Signalà un prublema</string>
<string name="select_show_on_map_behavior">Selezziunà u cumpurtamentu « Affissà nant’à a carta »</string>
<string name="show_on_map_format_ask">Dumandà</string>
<string name="show_on_dashboard">API di tavula di cundutta d’OpenTracks</string>
<string name="show_on_dashboard_not_installed">Nisuna appiecazione accettendu l’API di tavula di cundutta d’OpenTracks ùn hè installata.</string>
<string name="power">Putenza</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -543,12 +543,10 @@ limitations under the License.
<string name="value_float_knots">%1$.1f uzlů</string>
<string name="track_delete_number_of_tracks">%1$d stop</string>
<string name="image_discard">Vyřadit</string>
<string name="show_on_map_format_ask">Zeptat se</string>
<string name="settings_stats_units_nautical">Námořní (NM, ft)</string>
<string name="report_bug">Nahlásit chybu</string>
<string name="settings_announcements_lap_heart_rate">Srdeční tep kola</string>
<string name="introduction_osm_dashboard">OpenTracks sám o sobě mapu neposkytuje. Pro zobrazení záznamů na mapě si nainstalujte OSMDashboard.</string>
<string name="select_show_on_map_behavior">Zvolte chování \"zobrazit na mapě\"</string>
<string name="always">Vždy</string>
<string name="help_data_google_play_services_content">Ne</string>
<string name="description_speed_nautical">Rychlost (uzly)</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ Meldet das GPS-Gerät ungenaue Daten (z.B. Standort, Geschwindigkeit, Höhe), ka
<string name="error_crash_title">%1$s ist abgestürzt</string>
<string name="share_crash_report">Absturzbericht teilen</string>
<string name="always">Immer</string>
<string name="select_show_on_map_behavior">Wähle \"Zeige auf Karte\"-Verhalten</string>
<string name="settings_open_tracks_summary">Alles über das OpenTracks-Projekt</string>
<string name="settings_layout_reset_confirm_message">Alle Layout-Einstellungen werden auf die Standardwerte zurückgesetzt. Aufzeichnungen werden nicht vom Gerät gelöscht.</string>
<string name="report_bug">Fehler melden</string>
Expand All @@ -587,7 +586,6 @@ Meldet das GPS-Gerät ungenaue Daten (z.B. Standort, Geschwindigkeit, Höhe), ka
<string name="no_compatible_gallery_installed">Keine kompatible Bildergalerie Anwendung installiert</string>
<string name="show_on_dashboard_not_installed">Es ist keine Anwendung installiert, die die OpenTracks Dashboard API unterstützt.</string>
<string name="location_latitude_longitude">%1$s, %2$s</string>
<string name="show_on_map_format_ask">Nachfragen</string>
<string name="settings_stats_units_nautical">Nautisches Maß (NM, ft)</string>
<string name="unit_minute_per_nautical_mile">min/NM</string>
<string name="voice_on_device_speaker_title">Verwende den Lautsprecher des Gerätes</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,6 @@ limitations under the License.
<string name="voice_per_nautical_mile">por milla náutica</string>
<string name="error_crash_title">%1$s falló</string>
<string name="report_bug">Reportar error</string>
<string name="show_on_map_format_ask">Preguntar</string>
<string name="show_on_dashboard">Panel de control del API de OpenTracks</string>
<string name="show_on_dashboard_not_installed">No se ha instalado ninguna aplicación compatible con el panel de control del API de OpenTracks.</string>
<string name="always">Siempre</string>
Expand All @@ -622,7 +621,6 @@ limitations under the License.
other {{n,number,#.0} millas náuticas}
}
</string>
<string name="select_show_on_map_behavior">Seleccionar el comportamiento de \"mostrar en el mapa\"</string>
<string name="introduction_osm_dashboard">OpenTracks en sí no proporciona un mapa. Por favor, instale OSMDashboard para ver sus grabaciones en un mapa.</string>
<string name="share_crash_report">Compartir informe de fallo</string>
<string name="settings_stats_units_imperial_meter">Imperial (millas, metros)</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-fi/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,13 @@ limitations under the License.
<string name="lap_speed">Kierrosnopeus</string>
<string name="total_distance">Kokonaismatka</string>
<string name="always">Aina</string>
<string name="show_on_map_format_ask">Kysyä</string>
<string name="error_crash_title">%1$s kaatui</string>
<string name="share_crash_report">Jaa kaatumisraportti</string>
<string name="report_bug">Ilmoita virheestä</string>
<string name="generic_dismiss">Vapauta</string>
<string name="gps_recording_without_signal">OpenTracks tallentaa ilman GPS-tietoja.</string>
<string name="settings_defaults_title">Oletusyksiköt ja toiminta</string>
<string name="settings_defaults_summary">Suositeltavat yksiköt, Oletusaktiviteetti, Seurannan oletusnimi</string>
<string name="select_show_on_map_behavior">Valitse\" Näytä kartalla\"käyttäytyminen</string>
<string name="settings_sensors_summary">Pyöräilyanturit, Pyörän ympärysmitta, Juoksuanturit</string>
<string name="settings_announcements_statistics_title">Ääni-ilmoitukset</string>
<string name="settings_announcements_summary">Aika, etäisyys, äänennopeus</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-fr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,13 @@ Si le dispositif GPS signale des données inexactes (par exemple, la localisatio
<string name="voice_per_mile">par mile</string>
<string name="pace">Rythme</string>
<string name="lap_speed">Vitesse par tour</string>
<string name="show_on_map_format_ask">Demander</string>
<string name="show_on_dashboard">Tableau de bord de l\'API OpenTracks</string>
<string name="always">Toujours</string>
<string name="share_crash_report">Partager le rapport de crash</string>
<string name="report_bug">Signaler un problème</string>
<string name="error_crash_title">%1$s a crashé</string>
<string name="gps_recording_without_signal">OpenTracks enregistre actuellement sans les données GPS.</string>
<string name="settings_export_filename_title">Format du nom de fichier</string>
<string name="select_show_on_map_behavior">Sélectionner le comportement \"Montrer sur la carte\"</string>
<string name="settings_public_api_dashboard_enabled_title">Transfert automatique des données</string>
<string name="settings_public_api_dashboard_enabled_summary_on">Une application qui a commencé un enregistrement peut aussi accéder aux données enregistrées.</string>
<string name="settings_announcements_average_speed_pace">Allure/vitesse moyenne</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-ga/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@
<string name="hold_to_stop">Coinnigh chun stop a chur</string>
<string name="share_image_subject">Ba mhaith liom íomhá a roinnt leat</string>
<string name="show_on_dashboard">API Painéal OpenTracks</string>
<string name="show_on_map_format_ask">Iarr</string>
<string name="select_show_on_map_behavior">Roghnaigh iompar \"taispeáin ar léarscáil\"</string>
<string name="report_bug">Tuairiscigh fabht</string>
<string name="share_crash_report">Comhroinn tuairisc tuairteála</string>
<string name="no_compatible_file_manager_installed">Níl aon bhainisteoir comhad comhoiriúnach suiteáilte</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-gl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,6 @@ Se o GPS informa sobre datos pouco precisos (ex.: localización, velocidade, ele
<string name="value_float_knots_recommended">%1$.1f nós (recomendado)</string>
<string name="voice_per_nautical_mile">por milla náutica</string>
<string name="show_on_dashboard_not_installed">Non hai ningunha aplicación instalada con soporte para a API de OpenTracks.</string>
<string name="select_show_on_map_behavior">Elixe \"ver no mapa\"</string>
<string name="show_on_map_format_ask">Preguntar</string>
<string name="always">Sempre</string>
<string name="error_crash_title">%1$s fallou</string>
<string name="report_bug">Informar do problema</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-hr/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ limitations under the License.
<string name="settings_public_api_enabled_summary_on">Druge instalirane aplikacije mogu pokrenuti ili prekinuti snimanja.</string>
<string name="help_track_export_title">Kako mogu izvesti/dijeliti snimljene rute\?</string>
<string name="voice_on_device_speaker_title">Koristi zvučnik uređaja</string>
<string name="show_on_map_format_ask">Pitaj</string>
<string name="generic_today">Danas</string>
<string name="marker_add_photo_canceled">Prekinuto, nije dodana nijedna oznaka za slike</string>
<string name="value_float_kilometer_hour">%1$.1f km/h</string>
Expand Down Expand Up @@ -561,7 +560,6 @@ limitations under the License.
<string name="export_dir_not_writable">" (zabranjeno pisanje!)"</string>
<string name="export_progress_summary_overwrite_msg">Datoteke su prepisane</string>
<string name="settings_public_api_dashboard_enabled_summary_off">Snimljeni podaci se neće automatski dijeliti s drugim aplikacijama.</string>
<string name="select_show_on_map_behavior">Odaberi „Prikaži na karti”</string>
<string name="export_progress_summary_skip_msg">Datoteke su preskočene</string>
<string name="activity_type_kickscooter">skuter</string>
<string name="help_gps_troubleshooting_content"> \u0020Što možeš učiniti:
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@ limitations under the License.
<string name="voiceMinutesPlural">{n,number} perc</string>
<string name="voiceSpeedMKnotsPlural">{n,number,#.0} csomó</string>
<string name="voice_per_mile">mérföldenként</string>
<string name="show_on_map_format_ask">Rákérdezés</string>
<string name="show_on_dashboard">OpenTracks Dashboard API</string>
<string name="show_on_dashboard_not_installed">Nincs OpenTracks Dashboard API-t támogató alkalmazás telepítve.</string>
<string name="value_float_mile_hour">%1$.1f mérföld/óra</string>
Expand Down Expand Up @@ -556,7 +555,6 @@ limitations under the License.
<string name="no_compatible_camera_installed">Nincs kompatibilis kamera alkalmazás telepítve</string>
<string name="share_crash_report">Hibajelentés megosztása</string>
<string name="report_bug">Hibajelentés</string>
<string name="select_show_on_map_behavior">A „megjelenítés a térképen” viselkedés választása</string>
<string name="image_discard">Eldobás</string>
<string name="settings_import_export_title">Importálás és exportálás</string>
<string name="generic_undo">Visszavonás</string>
Expand Down
2 changes: 0 additions & 2 deletions src/main/res/values-kn/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,6 @@
<string name="error_crash_title">%1$s ಕ್ರ್ಯಾಶ್ ಆಗಿದೆ</string>
<string name="share_crash_report">ಕ್ರ್ಯಾಶ್ ವರದಿಯನ್ನು ಹಂಚಿಕೊಳ್ಳಿ</string>
<string name="report_bug">ದೋಷವನ್ನು ವರದಿ ಮಾಡಿ</string>
<string name="select_show_on_map_behavior">\"ನಕ್ಷೆಯಲ್ಲಿ ತೋರಿಸು\" ನಡವಳಿಕೆಯನ್ನು ಆಯ್ಕೆಮಾಡಿ</string>
<string name="show_on_map_format_ask">ಕೇಳು</string>
<string name="show_on_dashboard">OpenTracks ಡ್ಯಾಶ್‌ಬೋರ್ಡ್ API</string>
<string name="show_on_dashboard_not_installed">OpenTracks ಡ್ಯಾಶ್‌ಬೋರ್ಡ್ API ಅನ್ನು ಬೆಂಬಲಿಸುವ ಯಾವುದೇ ಅಪ್ಲಿಕೇಶನ್ ಸ್ಥಾಪಿಸಲಾಗಿಲ್ಲ.</string>
<string name="always">ಯಾವಾಗಲೂ</string>
Expand Down
Loading

0 comments on commit 2cc4218

Please sign in to comment.