From a2c5b761054a63aba061647e05d82adad0407e82 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Sat, 13 Nov 2021 06:39:41 +0100 Subject: [PATCH 1/8] Import code from @EssBee59 Fixes #362 --- .../src/main/AndroidManifest.xml | 45 ++++++ .../btools/routingapp/BRouterActivity.java | 148 ++++++++++++++++++ .../src/main/res/layout/import_intent.xml | 45 ++++++ 3 files changed, 238 insertions(+) create mode 100644 brouter-routing-app/src/main/res/layout/import_intent.xml diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index 356c59d..a982626 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -25,6 +25,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dat=content://me.bluemail.mail.attachmentprovider/a2939069-76b5-44e4-8cbd-94485d0fd4ff/cc32b61d-97a6-4871-b67f-945d1d1d43c8/VIEW + String filename = null; + Long filesize = null; + Cursor cursor = null; + try { + cursor = this.getContentResolver().query(intent.getData(), new String[]{ + OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}, null, null, null); + if (cursor != null && cursor.moveToFirst()) { + filename = cursor.getString(0); + filesize = cursor.getLong(1); + } + } finally { + if (cursor != null) + cursor.close(); + } + System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); + scanResults.setText(scanResults.getText() + "File name=" + filename + "\nFile size=" + filesize + " bytes\n"); + // is the file extention ".brf" in the file name + if (filename.indexOf(".brf") != -1 && (filename.indexOf(".brf") == (filename.length() - 4))) { + System.out.println("Brouter OK, file extention is .brf!!!"); + } else { + System.out.println("Brouter ERROR, please provide a file with the valid extention \".brf\"..."); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: File extention must be \".brf\" \n"); + return; + } + // profile size is generally < 30 kb, so set max size to 100 kb + if (filesize > 100000) { + System.out.println("Brouter file size too big!!!"); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: File size too big !!! \n"); + return; + } + + ContentResolver cr = getContentResolver(); + String Profile_code = ""; + try { + // try to read the file + InputStream input = cr.openInputStream(dataUri); + + BufferedReader reader = new BufferedReader( + new InputStreamReader(input)); + Profile_code = reader.lines().collect(Collectors.joining( + System.getProperty("line.separator"))).toString(); + System.out.println("Brouter Profile_CODE=" + Profile_code); + + // consistency check + if (Profile_code.indexOf("highway=") == -1 || (Profile_code.indexOf("costfactor") == -1) || (Profile_code.indexOf("---context:global") == -1)) { + System.out.println("Brouter ERROR, file content is not a valid profile for Brouter!, please provide a valid profile ..."); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: this file is not a valid brouter-profile!!!! \n"); + return; + } + } catch (IOException e) { + System.out.println(e); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: " + e + "/n"); + } + + String baseDir = null; + InputStream configInput = null; + try + { + configInput = openFileInput( "config15.dat" ); + BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) ); + baseDir = br.readLine(); + System.out.println("Brouter baseDir=" + baseDir ); + } + catch (Exception e) + { + System.out.println("Brouter exception by read config15.dat " + e ); + scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); + } + finally + { + if ( configInput != null ) try { configInput.close(); } catch (Exception ee) {} + } + + + // now save profile as file in ./brouter/profiles2/... + try { + File path = getExternalFilesDir(null); + File file = new File(baseDir, "brouter/profiles2/" + filename); + FileOutputStream stream = new FileOutputStream(file); + stream.write(Profile_code.getBytes()); + stream.close(); + System.out.println("Brouter: profile was installed in ./brouter/profiles2 !!!"); + // report success in UI and stop + scanResults.setText(scanResults.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! " ); + return; + } catch (IOException e) { + System.out.println("Exception, File write failed: " + e.toString()); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); + return; + } + } + } } diff --git a/brouter-routing-app/src/main/res/layout/import_intent.xml b/brouter-routing-app/src/main/res/layout/import_intent.xml new file mode 100644 index 0000000..98f6a09 --- /dev/null +++ b/brouter-routing-app/src/main/res/layout/import_intent.xml @@ -0,0 +1,45 @@ + + + + + + + + + + From a528630af94cfc3f06329a8eb70a868aabe34b2e Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Mon, 15 Nov 2021 17:50:12 +0100 Subject: [PATCH 2/8] Move profile import to own activity --- .../src/main/AndroidManifest.xml | 57 ++++--- .../btools/routingapp/BImportActivity.java | 152 ++++++++++++++++++ .../btools/routingapp/BRouterActivity.java | 148 ----------------- 3 files changed, 184 insertions(+), 173 deletions(-) create mode 100644 brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index a982626..2c635b8 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -16,37 +16,48 @@ android:label="@string/app_name" android:allowBackup="false" android:preserveLegacyExternalStorage="true"> - + + + - + - - - - - + - - - + + + + @@ -58,12 +69,14 @@ android:label="@string/app_name" android:priority="50"> + - - - - + + + + + @@ -71,23 +84,17 @@ - - + - + android:enabled="true" /> diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java new file mode 100644 index 0000000..d54c456 --- /dev/null +++ b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java @@ -0,0 +1,152 @@ +package btools.routingapp; + +import android.app.Activity; +import android.content.ContentResolver; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.provider.OpenableColumns; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.stream.Collectors; + +public class BImportActivity extends Activity { + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + Intent intent = getIntent(); + String action = intent.getAction(); + String type = intent.getType(); + System.out.println("Brouter START xxxxxx BrouterActivity"); + if (Intent.ACTION_VIEW.equals(action)) { + System.out.println("Brouter Intent.ACTION_VIEW detected"); + import_profile(intent); + return; + } + } + + private void import_profile(Intent intent) { + TextView scanResults; + // app was activated by an intent with "action_view"... + System.out.println("Brouter Intent.ACTION_VIEW detected"); + + if (intent.getData() == null) { + System.out.println("Brouter intent.get(data) is NULL ERROR"); + } else { + setContentView(R.layout.import_intent); + scanResults = (TextView) findViewById(R.id.Info_brouter); + scanResults.setText("Start importing profile: \n"); + + Uri dataUri = intent.getData(); + System.out.println("Brouter DATA=" + dataUri); + + // by some apps (bluemail) the file name must be "extracted" from the URI, as example with the following code + // see https://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent + // URI example ==> dat=content://me.bluemail.mail.attachmentprovider/a2939069-76b5-44e4-8cbd-94485d0fd4ff/cc32b61d-97a6-4871-b67f-945d1d1d43c8/VIEW + String filename = null; + Long filesize = null; + Cursor cursor = null; + try { + cursor = this.getContentResolver().query(intent.getData(), new String[]{ + OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}, null, null, null); + if (cursor != null && cursor.moveToFirst()) { + filename = cursor.getString(0); + filesize = cursor.getLong(1); + } + } finally { + if (cursor != null) + cursor.close(); + } + System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); + scanResults.setText(scanResults.getText() + "File name=" + filename + "\nFile size=" + filesize + " bytes\n"); + // is the file extention ".brf" in the file name + if (filename.indexOf(".brf") != -1 && (filename.indexOf(".brf") == (filename.length() - 4))) { + System.out.println("Brouter OK, file extention is .brf!!!"); + } else { + System.out.println("Brouter ERROR, please provide a file with the valid extention \".brf\"..."); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: File extention must be \".brf\" \n"); + return; + } + // profile size is generally < 30 kb, so set max size to 100 kb + if (filesize > 100000) { + System.out.println("Brouter file size too big!!!"); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: File size too big !!! \n"); + return; + } + + ContentResolver cr = getContentResolver(); + String Profile_code = ""; + try { + // try to read the file + InputStream input = cr.openInputStream(dataUri); + + BufferedReader reader = new BufferedReader( + new InputStreamReader(input)); + Profile_code = reader.lines().collect(Collectors.joining( + System.getProperty("line.separator"))).toString(); + System.out.println("Brouter Profile_CODE=" + Profile_code); + + // consistency check + if (Profile_code.indexOf("highway=") == -1 || (Profile_code.indexOf("costfactor") == -1) || (Profile_code.indexOf("---context:global") == -1)) { + System.out.println("Brouter ERROR, file content is not a valid profile for Brouter!, please provide a valid profile ..."); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: this file is not a valid brouter-profile!!!! \n"); + return; + } + } catch (IOException e) { + System.out.println(e); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: " + e + "/n"); + } + + String baseDir = null; + InputStream configInput = null; + try + { + configInput = openFileInput( "config15.dat" ); + BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) ); + baseDir = br.readLine(); + System.out.println("Brouter baseDir=" + baseDir ); + } + catch (Exception e) + { + System.out.println("Brouter exception by read config15.dat " + e ); + scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); + } + finally + { + if ( configInput != null ) try { configInput.close(); } catch (Exception ee) {} + } + + // now save profile as file in ./brouter/profiles2/... + try { + File path = getExternalFilesDir(null); + File file = new File(baseDir, "brouter/profiles2/" + filename); + FileOutputStream stream = new FileOutputStream(file); + stream.write(Profile_code.getBytes()); + stream.close(); + System.out.println("Brouter: profile was installed in ./brouter/profiles2 !!!"); + // report success in UI and stop + scanResults.setText(scanResults.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! "); + return; + } catch (IOException e) { + System.out.println("Exception, File write failed: " + e.toString()); + // report error in UI and stop + scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); + return; + } + } + } +} diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java index 320dc28..2424f88 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterActivity.java @@ -1,11 +1,6 @@ package btools.routingapp; -import java.io.BufferedReader; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.lang.reflect.Method; import java.text.DecimalFormat; import java.util.ArrayList; @@ -13,35 +8,29 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; import android.app.Activity; import android.app.ActivityManager; import android.app.AlertDialog; import android.app.Dialog; -import android.content.ContentResolver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.PackageManager; -import android.database.Cursor; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.NetworkInfo; -import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.StatFs; -import android.provider.OpenableColumns; import android.speech.tts.TextToSpeech.OnInitListener; import android.util.Log; import android.view.KeyEvent; import android.widget.EditText; -import android.widget.TextView; import androidx.core.app.ActivityCompat; @@ -87,24 +76,6 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques // Create a bright wake lock mWakeLock = mPowerManager.newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName() ); - // CHANGE: consider start with Intent to import a profile - Intent intent = getIntent(); - String action = intent.getAction(); - String type = intent.getType(); - System.out.println("Brouter START xxxxxx BrouterActivity"); - if (Intent.ACTION_VIEW.equals(action) ) { - System.out.println("Brouter Intent.ACTION_VIEW detected"); - import_profile(intent); - return; - } -// end change - - // Get an instance of the PowerManager - //mPowerManager = (PowerManager) getSystemService( POWER_SERVICE ); - - // Create a bright wake lock - //mWakeLock = mPowerManager.newWakeLock( PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass().getName() ); - ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE); int memoryClass = am.getMemoryClass(); @@ -759,123 +730,4 @@ public class BRouterActivity extends Activity implements ActivityCompat.OnReques } } } - - - private void import_profile(Intent intent) { - TextView scanResults; - // app was activated by an intent with "action_view"... - System.out.println("Brouter Intent.ACTION_VIEW detected"); - - if (intent.getData() == null) { - System.out.println("Brouter intent.get(data) is NULL ERROR"); - } - else - { - setContentView(R.layout.import_intent); - scanResults = (TextView) findViewById(R.id.Info_brouter); - scanResults.setText("Start importing profile: \n"); - - Uri dataUri = intent.getData(); - System.out.println("Brouter DATA=" + dataUri); - -// by some apps (bluemail) the file name must be "extracted" from the URI, as example with the following code -// see https://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent -// URI example ==> dat=content://me.bluemail.mail.attachmentprovider/a2939069-76b5-44e4-8cbd-94485d0fd4ff/cc32b61d-97a6-4871-b67f-945d1d1d43c8/VIEW - String filename = null; - Long filesize = null; - Cursor cursor = null; - try { - cursor = this.getContentResolver().query(intent.getData(), new String[]{ - OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}, null, null, null); - if (cursor != null && cursor.moveToFirst()) { - filename = cursor.getString(0); - filesize = cursor.getLong(1); - } - } finally { - if (cursor != null) - cursor.close(); - } - System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); - scanResults.setText(scanResults.getText() + "File name=" + filename + "\nFile size=" + filesize + " bytes\n"); - // is the file extention ".brf" in the file name - if (filename.indexOf(".brf") != -1 && (filename.indexOf(".brf") == (filename.length() - 4))) { - System.out.println("Brouter OK, file extention is .brf!!!"); - } else { - System.out.println("Brouter ERROR, please provide a file with the valid extention \".brf\"..."); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: File extention must be \".brf\" \n"); - return; - } - // profile size is generally < 30 kb, so set max size to 100 kb - if (filesize > 100000) { - System.out.println("Brouter file size too big!!!"); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: File size too big !!! \n"); - return; - } - - ContentResolver cr = getContentResolver(); - String Profile_code = ""; - try { - // try to read the file - InputStream input = cr.openInputStream(dataUri); - - BufferedReader reader = new BufferedReader( - new InputStreamReader(input)); - Profile_code = reader.lines().collect(Collectors.joining( - System.getProperty("line.separator"))).toString(); - System.out.println("Brouter Profile_CODE=" + Profile_code); - - // consistency check - if (Profile_code.indexOf("highway=") == -1 || (Profile_code.indexOf("costfactor") == -1) || (Profile_code.indexOf("---context:global") == -1)) { - System.out.println("Brouter ERROR, file content is not a valid profile for Brouter!, please provide a valid profile ..."); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: this file is not a valid brouter-profile!!!! \n"); - return; - } - } catch (IOException e) { - System.out.println(e); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: " + e + "/n"); - } - - String baseDir = null; - InputStream configInput = null; - try - { - configInput = openFileInput( "config15.dat" ); - BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) ); - baseDir = br.readLine(); - System.out.println("Brouter baseDir=" + baseDir ); - } - catch (Exception e) - { - System.out.println("Brouter exception by read config15.dat " + e ); - scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); - } - finally - { - if ( configInput != null ) try { configInput.close(); } catch (Exception ee) {} - } - - - // now save profile as file in ./brouter/profiles2/... - try { - File path = getExternalFilesDir(null); - File file = new File(baseDir, "brouter/profiles2/" + filename); - FileOutputStream stream = new FileOutputStream(file); - stream.write(Profile_code.getBytes()); - stream.close(); - System.out.println("Brouter: profile was installed in ./brouter/profiles2 !!!"); - // report success in UI and stop - scanResults.setText(scanResults.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! " ); - return; - } catch (IOException e) { - System.out.println("Exception, File write failed: " + e.toString()); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); - return; - } - } - } } From 18e015a3b5a28719b3e35a833f6334a7e2df6e95 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Tue, 16 Nov 2021 16:04:05 +0100 Subject: [PATCH 3/8] Fix warning --- brouter-routing-app/src/main/AndroidManifest.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index 2c635b8..3bae399 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -43,6 +43,8 @@ + + From 6a8f5036b28f21dcf70e53246c3039ca8f1eab5e Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Mon, 15 Nov 2021 19:52:41 +0100 Subject: [PATCH 4/8] Cleanup --- .../btools/routingapp/BImportActivity.java | 209 ++++++++---------- .../src/main/res/layout/import_intent.xml | 2 +- 2 files changed, 93 insertions(+), 118 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java index d54c456..f899b2d 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java @@ -1,12 +1,12 @@ package btools.routingapp; import android.app.Activity; -import android.content.ContentResolver; import android.content.Intent; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.provider.OpenableColumns; +import android.text.format.Formatter; import android.widget.TextView; import androidx.annotation.Nullable; @@ -17,136 +17,111 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.util.stream.Collectors; public class BImportActivity extends Activity { + // profile size is generally < 30 kb, so set max size to 100 kb + private static final int MAX_PROFILE_SIZE = 100000; + TextView mImportResultView; + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.import_intent); + mImportResultView = findViewById(R.id.Info_brouter); + Intent intent = getIntent(); String action = intent.getAction(); - String type = intent.getType(); - System.out.println("Brouter START xxxxxx BrouterActivity"); if (Intent.ACTION_VIEW.equals(action)) { - System.out.println("Brouter Intent.ACTION_VIEW detected"); - import_profile(intent); + importProfile(intent); + } + } + + private void importProfile(Intent intent) { + StringBuilder resultMessage = new StringBuilder(); + if (intent.getData() == null) { return; } - } + setContentView(R.layout.import_intent); + mImportResultView = findViewById(R.id.Info_brouter); + mImportResultView.setText("Start importing profile: \n"); - private void import_profile(Intent intent) { - TextView scanResults; - // app was activated by an intent with "action_view"... - System.out.println("Brouter Intent.ACTION_VIEW detected"); + Uri dataUri = intent.getData(); + System.out.println("Brouter DATA=" + dataUri); - if (intent.getData() == null) { - System.out.println("Brouter intent.get(data) is NULL ERROR"); - } else { - setContentView(R.layout.import_intent); - scanResults = (TextView) findViewById(R.id.Info_brouter); - scanResults.setText("Start importing profile: \n"); - - Uri dataUri = intent.getData(); - System.out.println("Brouter DATA=" + dataUri); - - // by some apps (bluemail) the file name must be "extracted" from the URI, as example with the following code - // see https://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent - // URI example ==> dat=content://me.bluemail.mail.attachmentprovider/a2939069-76b5-44e4-8cbd-94485d0fd4ff/cc32b61d-97a6-4871-b67f-945d1d1d43c8/VIEW - String filename = null; - Long filesize = null; - Cursor cursor = null; - try { - cursor = this.getContentResolver().query(intent.getData(), new String[]{ - OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}, null, null, null); - if (cursor != null && cursor.moveToFirst()) { - filename = cursor.getString(0); - filesize = cursor.getLong(1); - } - } finally { - if (cursor != null) - cursor.close(); - } - System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); - scanResults.setText(scanResults.getText() + "File name=" + filename + "\nFile size=" + filesize + " bytes\n"); - // is the file extention ".brf" in the file name - if (filename.indexOf(".brf") != -1 && (filename.indexOf(".brf") == (filename.length() - 4))) { - System.out.println("Brouter OK, file extention is .brf!!!"); - } else { - System.out.println("Brouter ERROR, please provide a file with the valid extention \".brf\"..."); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: File extention must be \".brf\" \n"); - return; - } - // profile size is generally < 30 kb, so set max size to 100 kb - if (filesize > 100000) { - System.out.println("Brouter file size too big!!!"); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: File size too big !!! \n"); - return; - } - - ContentResolver cr = getContentResolver(); - String Profile_code = ""; - try { - // try to read the file - InputStream input = cr.openInputStream(dataUri); - - BufferedReader reader = new BufferedReader( - new InputStreamReader(input)); - Profile_code = reader.lines().collect(Collectors.joining( - System.getProperty("line.separator"))).toString(); - System.out.println("Brouter Profile_CODE=" + Profile_code); - - // consistency check - if (Profile_code.indexOf("highway=") == -1 || (Profile_code.indexOf("costfactor") == -1) || (Profile_code.indexOf("---context:global") == -1)) { - System.out.println("Brouter ERROR, file content is not a valid profile for Brouter!, please provide a valid profile ..."); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: this file is not a valid brouter-profile!!!! \n"); - return; - } - } catch (IOException e) { - System.out.println(e); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: " + e + "/n"); - } - - String baseDir = null; - InputStream configInput = null; - try - { - configInput = openFileInput( "config15.dat" ); - BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) ); - baseDir = br.readLine(); - System.out.println("Brouter baseDir=" + baseDir ); - } - catch (Exception e) - { - System.out.println("Brouter exception by read config15.dat " + e ); - scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); - } - finally - { - if ( configInput != null ) try { configInput.close(); } catch (Exception ee) {} - } - - // now save profile as file in ./brouter/profiles2/... - try { - File path = getExternalFilesDir(null); - File file = new File(baseDir, "brouter/profiles2/" + filename); - FileOutputStream stream = new FileOutputStream(file); - stream.write(Profile_code.getBytes()); - stream.close(); - System.out.println("Brouter: profile was installed in ./brouter/profiles2 !!!"); - // report success in UI and stop - scanResults.setText(scanResults.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! "); - return; - } catch (IOException e) { - System.out.println("Exception, File write failed: " + e.toString()); - // report error in UI and stop - scanResults.setText(scanResults.getText() + "ERROR: " + e + " /n"); - return; + // by some apps (bluemail) the file name must be "extracted" from the URI, as example with the following code + // see https://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent + // URI example ==> dat=content://me.bluemail.mail.attachmentprovider/a2939069-76b5-44e4-8cbd-94485d0fd4ff/cc32b61d-97a6-4871-b67f-945d1d1d43c8/VIEW + String filename = null; + long filesize = 0L; + try (Cursor cursor = this.getContentResolver().query(intent.getData(), new String[]{ + OpenableColumns.DISPLAY_NAME, OpenableColumns.SIZE}, null, null, null)) { + if (cursor != null && cursor.moveToFirst()) { + filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME)); + filesize = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); } } + System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); + resultMessage.append("File name=").append(filename).append("\n"); + resultMessage.append("File size=").append(Formatter.formatFileSize(this, filesize)).append(" bytes\n"); + mImportResultView.setText(resultMessage); + // is the file extention ".brf" in the file name + if (filename == null || !filename.endsWith(".brf")) { + resultMessage.append("ERROR: File extention must be \".brf\"\n"); + mImportResultView.setText(resultMessage); + return; + } + + if (filesize > MAX_PROFILE_SIZE) { + resultMessage.append("ERROR: File size exceeds limit (").append(Formatter.formatFileSize(this, MAX_PROFILE_SIZE)).append(")\n"); + mImportResultView.setText(resultMessage); + return; + } + + String profileData = ""; + try ( + InputStream inputStream = getContentResolver().openInputStream(dataUri); + BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append(System.getProperty("line.separator")); + line = br.readLine(); + } + profileData = sb.toString(); + } catch (IOException e) { + System.out.println(e); + resultMessage.append("ERROR: " + e + "\n"); + mImportResultView.setText(resultMessage); + } + + if (!profileData.contains("highway=") || (!profileData.contains("costfactor")) || (!profileData.contains("---context:global"))) { + resultMessage.append("ERROR: this file is not a valid brouter-profile\n"); + mImportResultView.setText(resultMessage); + return; + } + + writeProfile(filename, profileData); } + + void writeProfile(String filename, String profileData) { + File baseDir = ConfigHelper.getBaseDir(this); + + try { + File file = new File(baseDir, "brouter/profiles2/" + filename); + FileOutputStream stream = new FileOutputStream(file); + stream.write(profileData.getBytes()); + stream.close(); + System.out.println("Brouter: profile was installed in ./brouter/profiles2"); + // report success in UI and stop + mImportResultView.setText(mImportResultView.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! "); + } catch (IOException e) { + System.out.println("Exception, File write failed: " + e.toString()); + // report error in UI and stop + mImportResultView.setText(mImportResultView.getText() + "ERROR: " + e + " \n"); + } + } + } diff --git a/brouter-routing-app/src/main/res/layout/import_intent.xml b/brouter-routing-app/src/main/res/layout/import_intent.xml index 98f6a09..c517f9a 100644 --- a/brouter-routing-app/src/main/res/layout/import_intent.xml +++ b/brouter-routing-app/src/main/res/layout/import_intent.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" - tools:context=".MainActivity"> + tools:context=".BImportActivity"> Date: Mon, 15 Nov 2021 20:49:05 +0100 Subject: [PATCH 5/8] Improve UI --- .../src/main/AndroidManifest.xml | 4 +- .../btools/routingapp/BImportActivity.java | 76 +++++++++++-------- .../src/main/res/layout/import_intent.xml | 62 ++++++++------- .../src/main/res/values/strings.xml | 2 + 4 files changed, 79 insertions(+), 65 deletions(-) diff --git a/brouter-routing-app/src/main/AndroidManifest.xml b/brouter-routing-app/src/main/AndroidManifest.xml index 3bae399..c1ffbdf 100644 --- a/brouter-routing-app/src/main/AndroidManifest.xml +++ b/brouter-routing-app/src/main/AndroidManifest.xml @@ -36,9 +36,9 @@ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> + android:theme="@android:style/Theme.NoTitleBar"> diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java index f899b2d..c6b47e7 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java @@ -7,7 +7,9 @@ import android.net.Uri; import android.os.Bundle; import android.provider.OpenableColumns; import android.text.format.Formatter; -import android.widget.TextView; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; import androidx.annotation.Nullable; @@ -21,14 +23,28 @@ import java.io.InputStreamReader; public class BImportActivity extends Activity { // profile size is generally < 30 kb, so set max size to 100 kb private static final int MAX_PROFILE_SIZE = 100000; - TextView mImportResultView; + private EditText mTextFilename; + private Button mButtonImport; + private String mProfileData; + private EditText mTextProfile; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.import_intent); - mImportResultView = findViewById(R.id.Info_brouter); + mTextFilename = findViewById(R.id.editTextFilename); + mButtonImport = findViewById(R.id.buttonImport); + mButtonImport.setEnabled(false); + mButtonImport.setOnClickListener(view -> { + String filename = mTextFilename.getText().toString(); + if (isValidProfileFilename(filename)) { + writeProfile(filename, mProfileData); + } else { + displayMessage("ERROR: File extention must be \".brf\"\n"); + } + }); + mTextProfile = findViewById(R.id.editTextProfile); Intent intent = getIntent(); String action = intent.getAction(); @@ -37,17 +53,17 @@ public class BImportActivity extends Activity { } } + private boolean isValidProfileFilename(String filename) { + return filename.endsWith(".brf"); + } + private void importProfile(Intent intent) { - StringBuilder resultMessage = new StringBuilder(); if (intent.getData() == null) { return; } - setContentView(R.layout.import_intent); - mImportResultView = findViewById(R.id.Info_brouter); - mImportResultView.setText("Start importing profile: \n"); + StringBuilder resultMessage = new StringBuilder(); Uri dataUri = intent.getData(); - System.out.println("Brouter DATA=" + dataUri); // by some apps (bluemail) the file name must be "extracted" from the URI, as example with the following code // see https://stackoverflow.com/questions/14364091/retrieve-file-path-from-caught-downloadmanager-intent @@ -61,24 +77,21 @@ public class BImportActivity extends Activity { filesize = cursor.getLong(cursor.getColumnIndex(OpenableColumns.SIZE)); } } - System.out.println("Brouter filename=" + filename + "\n file size=" + filesize); - resultMessage.append("File name=").append(filename).append("\n"); - resultMessage.append("File size=").append(Formatter.formatFileSize(this, filesize)).append(" bytes\n"); - mImportResultView.setText(resultMessage); - // is the file extention ".brf" in the file name - if (filename == null || !filename.endsWith(".brf")) { + // is the file extention ".brf" in the file name + if (filename == null || !isValidProfileFilename(filename)) { resultMessage.append("ERROR: File extention must be \".brf\"\n"); - mImportResultView.setText(resultMessage); + displayMessage(resultMessage.toString()); return; } if (filesize > MAX_PROFILE_SIZE) { - resultMessage.append("ERROR: File size exceeds limit (").append(Formatter.formatFileSize(this, MAX_PROFILE_SIZE)).append(")\n"); - mImportResultView.setText(resultMessage); + String errorMessage = String.format("ERROR: File size (%s) exceeds limit (%s)\n", + Formatter.formatFileSize(this, filesize), + Formatter.formatFileSize(this, MAX_PROFILE_SIZE)); + displayMessage(errorMessage); return; } - String profileData = ""; try ( InputStream inputStream = getContentResolver().openInputStream(dataUri); BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))) { @@ -90,20 +103,25 @@ public class BImportActivity extends Activity { sb.append(System.getProperty("line.separator")); line = br.readLine(); } - profileData = sb.toString(); + mProfileData = sb.toString(); } catch (IOException e) { - System.out.println(e); - resultMessage.append("ERROR: " + e + "\n"); - mImportResultView.setText(resultMessage); + resultMessage.append(String.format("ERROR: failed to load profile content (%S)", e.getMessage())); + displayMessage(resultMessage.toString()); } - if (!profileData.contains("highway=") || (!profileData.contains("costfactor")) || (!profileData.contains("---context:global"))) { + if (!mProfileData.contains("highway=") || (!mProfileData.contains("costfactor")) || (!mProfileData.contains("---context:global"))) { resultMessage.append("ERROR: this file is not a valid brouter-profile\n"); - mImportResultView.setText(resultMessage); + displayMessage(resultMessage.toString()); return; } - writeProfile(filename, profileData); + mTextFilename.setText(filename); + mTextProfile.setText(mProfileData); + mButtonImport.setEnabled(true); + } + + void displayMessage(String message) { + Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } void writeProfile(String filename, String profileData) { @@ -114,13 +132,9 @@ public class BImportActivity extends Activity { FileOutputStream stream = new FileOutputStream(file); stream.write(profileData.getBytes()); stream.close(); - System.out.println("Brouter: profile was installed in ./brouter/profiles2"); - // report success in UI and stop - mImportResultView.setText(mImportResultView.getText() + "Profile successfully imported into:\n" + baseDir + "brouter/profiles2/" + filename + " \n\nIt can be used now in the same way as a basis profile! "); + displayMessage("Profile successfully imported"); } catch (IOException e) { - System.out.println("Exception, File write failed: " + e.toString()); - // report error in UI and stop - mImportResultView.setText(mImportResultView.getText() + "ERROR: " + e + " \n"); + displayMessage(String.format("Profile import failed: %s", e.getMessage())); } } diff --git a/brouter-routing-app/src/main/res/layout/import_intent.xml b/brouter-routing-app/src/main/res/layout/import_intent.xml index c517f9a..bad6adb 100644 --- a/brouter-routing-app/src/main/res/layout/import_intent.xml +++ b/brouter-routing-app/src/main/res/layout/import_intent.xml @@ -1,45 +1,43 @@ - - - - + android:layout_alignParentBottom="true" + android:text="@string/import_profile" + android:layout_alignParentEnd="true" /> + + + + diff --git a/brouter-routing-app/src/main/res/values/strings.xml b/brouter-routing-app/src/main/res/values/strings.xml index 3f03430..b74d0f0 100644 --- a/brouter-routing-app/src/main/res/values/strings.xml +++ b/brouter-routing-app/src/main/res/values/strings.xml @@ -16,4 +16,6 @@ BRouter + Import Profile + filename.brf From 67bbc3d2ac07907e0c74607f895aae5f433fd1f1 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Wed, 17 Nov 2021 14:19:15 +0100 Subject: [PATCH 6/8] Move serverconfig.txt handling to own class --- .../btools/routingapp/DownloadService.java | 52 ++------------- .../java/btools/routingapp/ServerConfig.java | 66 +++++++++++++++++++ 2 files changed, 73 insertions(+), 45 deletions(-) create mode 100644 brouter-routing-app/src/main/java/btools/routingapp/ServerConfig.java diff --git a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java index 1063fd2..1099501 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/DownloadService.java @@ -11,14 +11,11 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; -import android.os.StatFs; import android.util.Log; import android.widget.Toast; -import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; -import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -35,11 +32,7 @@ public class DownloadService extends Service implements ProgressListener { private static final boolean DEBUG = false; - String segmenturl = "https://brouter.de/brouter/segments4/"; - String lookupurl = "https://brouter.de/brouter/profile2/"; - String profilesurl = "https://brouter.de/brouter/profile2/"; - String checkLookup = "lookups.dat"; - String checkProfiles = ""; + private ServerConfig mServerConfig; private NotificationHelper mNotificationHelper; private List mUrlList; @@ -78,6 +71,7 @@ public class DownloadService extends Service implements ProgressListener { public void onCreate() { if (DEBUG) Log.d("SERVICE", "onCreate"); serviceState = true; + mServerConfig = new ServerConfig(getApplicationContext()); HandlerThread thread = new HandlerThread("ServiceStartArguments", 1); thread.start(); @@ -109,38 +103,6 @@ public class DownloadService extends Service implements ProgressListener { List urlparts = extra.getStringArrayList("urlparts"); mUrlList = urlparts; baseDir = dir; - - File configFile = new File (dir, "segments4/serverconfig.txt"); - if ( configFile.exists() ) { - try { - BufferedReader br = new BufferedReader( new FileReader( configFile ) ); - for ( ;; ) - { - String line = br.readLine(); - if ( line == null ) break; - if ( line.trim().startsWith( "segment_url=" ) ) { - segmenturl = line.substring(12); - } - else if ( line.trim().startsWith( "lookup_url=" ) ) { - lookupurl = line.substring(11); - } - else if ( line.trim().startsWith( "profiles_url=" ) ) { - profilesurl = line.substring(13); - } - else if ( line.trim().startsWith( "check_lookup=" ) ) { - checkLookup = line.substring(13); - } - else if ( line.trim().startsWith( "check_profiles=" ) ) { - checkProfiles = line.substring(15); - } - } - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - - } - } mNotificationHelper.startNotification(this); @@ -185,7 +147,7 @@ public class DownloadService extends Service implements ProgressListener { int count = 1; int size = mUrlList.size(); for (String part: mUrlList) { - String url = segmenturl + part + ".rd5"; + String url = mServerConfig.getSegmentUrl() + part + ".rd5"; if (DEBUG) Log.d("BR", "downlaod " + url); result = download(count, size, url); @@ -386,7 +348,7 @@ public class DownloadService extends Service implements ProgressListener { private String checkScripts() { - String[] sa = checkLookup.split(","); + String[] sa = mServerConfig.getLookups(); for (String f: sa) { if (f.length()>0) { File file = new File(baseDir + "profiles2", f); @@ -394,7 +356,7 @@ public class DownloadService extends Service implements ProgressListener { } } - sa = checkProfiles.split(","); + sa = mServerConfig.getProfiles(); for (String f : sa) { if (f.length()>0) { File file = new File(baseDir + "profiles2", f); @@ -410,12 +372,12 @@ public class DownloadService extends Service implements ProgressListener { } private String checkOrDownloadLookup(String fileName, File f) { - String url = lookupurl + fileName; + String url = mServerConfig.getLookupUrl() + fileName; return downloadScript(url, f); } private String checkOrDownloadScript(String fileName, File f) { - String url = profilesurl + fileName; + String url = mServerConfig.getProfilesUrl() + fileName; return downloadScript(url, f); } diff --git a/brouter-routing-app/src/main/java/btools/routingapp/ServerConfig.java b/brouter-routing-app/src/main/java/btools/routingapp/ServerConfig.java new file mode 100644 index 0000000..6f1c811 --- /dev/null +++ b/brouter-routing-app/src/main/java/btools/routingapp/ServerConfig.java @@ -0,0 +1,66 @@ +package btools.routingapp; + +import android.content.Context; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; + +public class ServerConfig { + private String mSegmentUrl = "https://brouter.de/brouter/segments4/"; + private String mLookupsUrl = "https://brouter.de/brouter/profiles2/"; + private String mProfilesUrl = "https://brouter.de/brouter/profiles2/"; + + private String[] mLookups = new String[]{"lookups.dat"}; + private String[] mProfiles = new String[0]; + + public ServerConfig(Context ctx) { + File configFile = new File(ConfigHelper.getBaseDir(ctx), "/brouter/segments4/serverconfig.txt"); + if (configFile.exists()) { + try { + BufferedReader br = new BufferedReader(new FileReader(configFile)); + for (; ; ) { + String line = br.readLine(); + if (line == null) break; + if (line.trim().startsWith("segment_url=")) { + mSegmentUrl = line.substring(12); + } else if (line.trim().startsWith("lookup_url=")) { + mLookupsUrl = line.substring(11); + } else if (line.trim().startsWith("profiles_url=")) { + mProfilesUrl = line.substring(13); + } else if (line.trim().startsWith("check_lookup=")) { + mLookups = line.substring(13).split(","); + } else if (line.trim().startsWith("check_profiles=")) { + mProfiles = line.substring(15).split(","); + } + } + br.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + } + } + + public String getSegmentUrl() { + return mSegmentUrl; + } + + public String getLookupUrl() { + return mLookupsUrl; + } + + public String getProfilesUrl() { + return mProfilesUrl; + } + + public String[] getLookups() { + return mLookups; + } + + public String[] getProfiles() { + return mProfiles; + } + +} From f29616eefcd0d401209cd39e4fbad8137aa1ae9c Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Wed, 17 Nov 2021 14:34:16 +0100 Subject: [PATCH 7/8] Don't overwrite built-in profiles --- .../btools/routingapp/BImportActivity.java | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java index c6b47e7..bdd18ab 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java @@ -36,28 +36,31 @@ public class BImportActivity extends Activity { mTextFilename = findViewById(R.id.editTextFilename); mButtonImport = findViewById(R.id.buttonImport); mButtonImport.setEnabled(false); - mButtonImport.setOnClickListener(view -> { - String filename = mTextFilename.getText().toString(); - if (isValidProfileFilename(filename)) { - writeProfile(filename, mProfileData); - } else { - displayMessage("ERROR: File extention must be \".brf\"\n"); - } - }); + mButtonImport.setOnClickListener(view -> importProfile()); mTextProfile = findViewById(R.id.editTextProfile); Intent intent = getIntent(); String action = intent.getAction(); if (Intent.ACTION_VIEW.equals(action)) { - importProfile(intent); + parseIntent(intent); } } - private boolean isValidProfileFilename(String filename) { - return filename.endsWith(".brf"); + private boolean isBuiltinProfile(String filename) { + String[] builtinProfiles = new ServerConfig(this).getProfiles(); + for (String builtinProfile : builtinProfiles) { + if (filename.equals(builtinProfile)) { + return true; + } + } + return false; } - private void importProfile(Intent intent) { + private boolean isInvalidProfileFilename(String filename) { + return !filename.endsWith(".brf"); + } + + private void parseIntent(Intent intent) { if (intent.getData() == null) { return; } @@ -78,7 +81,7 @@ public class BImportActivity extends Activity { } } // is the file extention ".brf" in the file name - if (filename == null || !isValidProfileFilename(filename)) { + if (filename == null || isInvalidProfileFilename(filename)) { resultMessage.append("ERROR: File extention must be \".brf\"\n"); displayMessage(resultMessage.toString()); return; @@ -105,7 +108,7 @@ public class BImportActivity extends Activity { } mProfileData = sb.toString(); } catch (IOException e) { - resultMessage.append(String.format("ERROR: failed to load profile content (%S)", e.getMessage())); + resultMessage.append(String.format("ERROR: failed to load profile content (%s)", e.getMessage())); displayMessage(resultMessage.toString()); } @@ -124,6 +127,20 @@ public class BImportActivity extends Activity { Toast.makeText(this, message, Toast.LENGTH_LONG).show(); } + boolean importProfile() { + String filename = mTextFilename.getText().toString(); + if (isInvalidProfileFilename(filename)) { + displayMessage("ERROR: File extention must be \".brf\"\n"); + return false; + } else if (isBuiltinProfile(filename)) { + displayMessage("ERROR: Built-in profile exists\n"); + return false; + } + + writeProfile(filename, mProfileData); + return true; + } + void writeProfile(String filename, String profileData) { File baseDir = ConfigHelper.getBaseDir(this); From c92c289a3f0aae07230839cdd4b7dc00db4a30e9 Mon Sep 17 00:00:00 2001 From: Manuel Fuhr Date: Wed, 17 Nov 2021 14:36:44 +0100 Subject: [PATCH 8/8] Change profile check to also pass on river.brf --- .../src/main/java/btools/routingapp/BImportActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java index bdd18ab..3d5f085 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BImportActivity.java @@ -112,7 +112,7 @@ public class BImportActivity extends Activity { displayMessage(resultMessage.toString()); } - if (!mProfileData.contains("highway=") || (!mProfileData.contains("costfactor")) || (!mProfileData.contains("---context:global"))) { + if (!mProfileData.contains("---context:global") || (!mProfileData.contains("---context:way"))) { resultMessage.append("ERROR: this file is not a valid brouter-profile\n"); displayMessage(resultMessage.toString()); return;