Merge pull request #653 from afischerdev/engine-mode

App: some error handling
This commit is contained in:
afischerdev 2024-01-15 18:08:26 +01:00 committed by GitHub
commit 6b659def02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 30 deletions

View file

@ -96,11 +96,13 @@ public class BRouterService extends Service {
if (errMsg != null) {
return errMsg;
}
// profile is already done
params.remove("profile");
boolean canCompress = "true".equals(params.getString("acceptCompressedResult"));
try {
String gpxMessage = worker.getTrackFromParams(params);
if (canCompress) {
if (canCompress && (gpxMessage.startsWith("<") || gpxMessage.startsWith("{"))) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
baos.write("z64".getBytes(Charset.forName("UTF-8"))); // marker prefix

View file

@ -10,6 +10,7 @@ import android.os.Bundle;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import androidx.activity.OnBackPressedCallback;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
@ -168,6 +169,22 @@ public class RoutingParameterDialog extends AppCompatActivity {
new OnBackInvokedCallback() {
@Override
public void onBackInvoked() {
handleBackPressed();
}
}
);
} else {
OnBackPressedCallback callback = new OnBackPressedCallback(true) {
@Override
public void handleOnBackPressed() {
handleBackPressed();
}
};
getOnBackPressedDispatcher().addCallback(this, callback);
}
}
private void handleBackPressed() {
StringBuilder sb = null;
if (sharedValues != null) {
// fill preference with used params
@ -195,12 +212,7 @@ public class RoutingParameterDialog extends AppCompatActivity {
setResult(Activity.RESULT_OK, i);
finish();
}
}
);
}
}
@Override