Configure profile as service when changing profile settings
When trying to change settings for a profile that was not yet configured as a service in the android app, the app exits instead of configuring the profile. This behavior is not very intuitive for users. This change instead adds a dialog to configure the profile as a new service in case `Profile Settings` is selected and the selected profile is not yet configured as a service.
This commit is contained in:
parent
e63cc9888f
commit
e18e2a16f4
@ -78,6 +78,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
private String title;
|
||||
private int wpCount;
|
||||
private boolean startSilent;
|
||||
private String configuredParams = null;
|
||||
|
||||
ActivityResultLauncher<Intent> someActivityResultLauncher;
|
||||
|
||||
@ -108,8 +109,13 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
if (data != null && data.hasExtra("PROFILE_HASH")) {
|
||||
profile_hash = data.getExtras().getString("PROFILE_HASH", "");
|
||||
}
|
||||
|
||||
if (mBRouterView.getConfigureServiceParams(profile) == null) {
|
||||
mBRouterView.startConfigureService(sparams);
|
||||
} else {
|
||||
mBRouterView.configureServiceParams(profile, sparams);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@ -203,6 +209,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
return builder.create();
|
||||
*/
|
||||
case DIALOG_ROUTINGMODES_ID:
|
||||
String configuredParams = this.configuredParams;
|
||||
builder.setTitle(message);
|
||||
builder.setMultiChoiceItems(routingModes, routingModesChecked,
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@ -213,7 +220,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
});
|
||||
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mBRouterView.configureService(routingModes, routingModesChecked);
|
||||
mBRouterView.configureService(routingModes, routingModesChecked, configuredParams);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
@ -345,7 +352,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
if (slist.size() > 1 && item == 0) {
|
||||
if (wpCount == 0) {
|
||||
mBRouterView.startConfigureService();
|
||||
mBRouterView.startConfigureService(null);
|
||||
} else if (wpCount == -3) {
|
||||
showRepeatTimeoutHelp();
|
||||
} else if (wpCount >= 2) {
|
||||
@ -456,7 +463,10 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
}
|
||||
|
||||
String sparams = mBRouterView.getConfigureServiceParams(selectedProfile);
|
||||
if (sparams != null) {
|
||||
if (sparams == null) {
|
||||
// profile is not used yet
|
||||
sparams = "";
|
||||
}
|
||||
if (listParams.size() > 0) {
|
||||
Intent i = new Intent(BRouterActivity.this, RoutingParameterDialog.class);
|
||||
i.putExtra("PROFILE", selectedProfile);
|
||||
@ -469,10 +479,6 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
Toast.makeText(this, R.string.msg_no_profile, Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, selectedProfile + getString(R.string.msg_no_used_profile), Toast.LENGTH_LONG).show();
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean[] getCheckedBooleanArray(int size) {
|
||||
@ -539,10 +545,11 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
}
|
||||
}
|
||||
|
||||
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message) {
|
||||
public void selectRoutingModes(String[] modes, boolean[] modesChecked, String message, String sparams) {
|
||||
routingModes = modes;
|
||||
routingModesChecked = modesChecked;
|
||||
this.message = message;
|
||||
this.configuredParams = sparams;
|
||||
showADialog(DIALOG_ROUTINGMODES_ID);
|
||||
}
|
||||
|
||||
@ -666,7 +673,7 @@ public class BRouterActivity extends AppCompatActivity implements ActivityCompat
|
||||
private void onItemClick(AdapterView<?> adapterView, View view, int which, long l) {
|
||||
if (which == 0) {
|
||||
if (wpCount == 0) {
|
||||
mBRouterView.startConfigureService();
|
||||
mBRouterView.startConfigureService(null);
|
||||
} else if (wpCount == -3) {
|
||||
showRepeatTimeoutHelp();
|
||||
} else if (wpCount >= 2) {
|
||||
|
||||
@ -817,17 +817,17 @@ public class BRouterView extends View {
|
||||
}
|
||||
}
|
||||
|
||||
public void startConfigureService() {
|
||||
public void startConfigureService(String sparams) {
|
||||
String[] modes = new String[]
|
||||
{"foot_short", "foot_fast", "bicycle_short", "bicycle_fast", "motorcar_short", "motorcar_fast"};
|
||||
boolean[] modesChecked = new boolean[6];
|
||||
|
||||
String msg = "Choose service-modes to configure (" + profileName + " [" + nogoVetoList.size() + "])";
|
||||
|
||||
((BRouterActivity) getContext()).selectRoutingModes(modes, modesChecked, msg);
|
||||
((BRouterActivity) getContext()).selectRoutingModes(modes, modesChecked, msg, sparams);
|
||||
}
|
||||
|
||||
public void configureService(String[] routingModes, boolean[] checkedModes) {
|
||||
public void configureService(String[] routingModes, boolean[] checkedModes, String sparams) {
|
||||
// read in current config
|
||||
TreeMap<String, ServiceModeConfig> map = new TreeMap<>();
|
||||
BufferedReader br = null;
|
||||
@ -861,7 +861,8 @@ public class BRouterView extends View {
|
||||
s = sm.params;
|
||||
p = sm.profile;
|
||||
}
|
||||
if (s == null || !p.equals(profileName)) s = "noparams";
|
||||
if (!p.equals(profileName)) s = sparams;
|
||||
if (s == null || s.equals("")) s = "noparams";
|
||||
ServiceModeConfig smc = new ServiceModeConfig(routingModes[i], profileName, s);
|
||||
for (OsmNodeNamed nogo : nogoVetoList) {
|
||||
smc.nogoVetos.add(nogo.ilon + "," + nogo.ilat);
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">اختر إلى/عبر</string>
|
||||
|
||||
<string name="msg_no_profile">لا توجد بيانات ملف التعريف</string>
|
||||
<string name="msg_no_used_profile">، لا يوجد ملف تعريف مستخدم</string>
|
||||
<string name="msg_too_much_data">هناك الكثير من البيانات للتنزيل، من فضلك قم بتقليلها.</string>
|
||||
<string name="msg_download_start">تمت جدولة التنزيل، وتحقق من اتصالك بالإنترنت إذا لم يبدأ التنزيل.</string>
|
||||
<string name="msg_wpt_selection">نقاط الطريق الحالية المحددة:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Seleccionar a/via</string>
|
||||
|
||||
<string name="msg_no_profile">no hi ha dades al perfil</string>
|
||||
<string name="msg_no_used_profile">, cap perfil utilitzat</string>
|
||||
<string name="msg_too_much_data">Massa dades per baixar. Si us plau, redueix-les.</string>
|
||||
<string name="msg_download_start">Baixada programada. Comprovar la connexió a internet si no comença.</string>
|
||||
<string name="msg_wpt_selection">selecció actual de fita:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">"Nach"/Via wählen</string>
|
||||
|
||||
<string name="msg_no_profile">Keine Profildaten</string>
|
||||
<string name="msg_no_used_profile">, kein verwendetes Profil</string>
|
||||
<string name="msg_too_much_data">Zu viele Daten für den Download. Bitte reduzieren.</string>
|
||||
<string name="msg_download_start">Download geplant. Überprüfen Sie die Internetverbindung, wenn der Download nicht startet.</string>
|
||||
<string name="msg_wpt_selection">aktuelle Wegpunktauswahl:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Επιλέξτε προς/μέσω</string>
|
||||
|
||||
<string name="msg_no_profile">μη δεδομένα προφίλ</string>
|
||||
<string name="msg_no_used_profile">, μη χρησιμοποιημένο προφίλ</string>
|
||||
<string name="msg_too_much_data">Πάρα πολλά δεδομένα για λήψη. Παρακαλώ μειώστε.</string>
|
||||
<string name="msg_download_start">Προγραμματισμένη λήψη. Ελέγξτε τη σύνδεση στο διαδίκτυο εάν δεν ξεκινά.</string>
|
||||
<string name="msg_wpt_selection">τρέχουσα επιλογή σημείου:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Seleccionar a/vía</string>
|
||||
|
||||
<string name="msg_no_profile">no hay datos en el perfil</string>
|
||||
<string name="msg_no_used_profile">, ningún perfil utilizado</string>
|
||||
<string name="msg_too_much_data">Demasiados datos a descargar. Por favor, reducidlos.</string>
|
||||
<string name="msg_download_start">Descarga programada. Comprueba la conexión a internet si no se inicia.</string>
|
||||
<string name="msg_wpt_selection">selección actual de waypoint:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Sélectionner vers/via</string>
|
||||
|
||||
<string name="msg_no_profile">aucune donnée de profil</string>
|
||||
<string name="msg_no_used_profile">, aucun profil utilisé</string>
|
||||
<string name="msg_too_much_data">Trop de données à télécharger. Veuillez réduire.</string>
|
||||
<string name="msg_download_start">Téléchargement planifié. Vérifiez la connexion Internet si elle ne démarre pas.</string>
|
||||
<string name="msg_wpt_selection">sélection actuelle du waypoint:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Seleziona a/via</string>
|
||||
|
||||
<string name="msg_no_profile">nessun dato del profilo</string>
|
||||
<string name="msg_no_used_profile">, nessun profilo utilizzato</string>
|
||||
<string name="msg_too_much_data">Troppi dati per il download. Per favore riduci.</string>
|
||||
<string name="msg_download_start">Download programmato. Controlla la connessione Internet se non si avvia.</string>
|
||||
<string name="msg_wpt_selection">selezione del waypoint corrente:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">선택 ~로/경유하여</string>
|
||||
|
||||
<string name="msg_no_profile">프로필 데이터 없음</string>
|
||||
<string name="msg_no_used_profile">, 사용된 프로필 없음</string>
|
||||
<string name="msg_too_much_data">다운로드 하기에 너무 많은 데이터. 줄이도록 하세요.</string>
|
||||
<string name="msg_download_start">다운로드 계획되어 있음. 인터넷 연결 체크 그렇지 않다면 시작.</string>
|
||||
<string name="msg_wpt_selection">현재 장소 선택:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Selecteer naar/via</string>
|
||||
|
||||
<string name="msg_no_profile">geen profiel data</string>
|
||||
<string name="msg_no_used_profile">, geen gebruikt profiel</string>
|
||||
<string name="msg_too_much_data">Te veel gegevens om te downloaden. Verminder a.u.b.</string>
|
||||
<string name="msg_download_start">Download is gepland. Controleer de internetverbinding als deze niet start.</string>
|
||||
<string name="msg_wpt_selection">huidige waypointselectie:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Wybierz do/przez</string>
|
||||
|
||||
<string name="msg_no_profile">brak danych profilu</string>
|
||||
<string name="msg_no_used_profile">, brak używanego profilu</string>
|
||||
<string name="msg_too_much_data">Za dużo danych do pobrania. Proszę ogranicz.</string>
|
||||
<string name="msg_download_start">Pobieranie zaplanowane. Jeśli się nie rozpocznie, sprawdź połączenie internetowe.</string>
|
||||
<string name="msg_wpt_selection">bieżący wybór punktu trasy:\n</string>
|
||||
|
||||
@ -53,7 +53,6 @@
|
||||
<string name="action_select_to">Select to/via</string>
|
||||
|
||||
<string name="msg_no_profile">no profile data</string>
|
||||
<string name="msg_no_used_profile">, no used profile</string>
|
||||
<string name="msg_too_much_data">Too much data for download. Please reduce.</string>
|
||||
<string name="msg_download_start">Download scheduled. Check internet connection if it doesn\'t start.</string>
|
||||
<string name="msg_wpt_selection">current waypoint selection:\n</string>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user