1.3.2 preparations
This commit is contained in:
parent
14a18fd770
commit
3e50846135
17 changed files with 1929 additions and 1906 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:versionCode="8"
|
||||
android:versionName="1.3.1" package="btools.routingapp">
|
||||
android:versionCode="9"
|
||||
android:versionName="1.3.2" package="btools.routingapp">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<activity android:name=".BRouterActivity"
|
||||
android:label="@string/app_name"
|
||||
|
|
|
|||
|
|
@ -21,473 +21,494 @@ import android.speech.tts.TextToSpeech.OnInitListener;
|
|||
import android.widget.EditText;
|
||||
import btools.router.OsmNodeNamed;
|
||||
|
||||
public class BRouterActivity extends Activity implements OnInitListener {
|
||||
public class BRouterActivity extends Activity implements OnInitListener
|
||||
{
|
||||
private static final int DIALOG_SELECTPROFILE_ID = 1;
|
||||
private static final int DIALOG_EXCEPTION_ID = 2;
|
||||
private static final int DIALOG_SHOW_DM_INFO_ID = 3;
|
||||
private static final int DIALOG_TEXTENTRY_ID = 4;
|
||||
private static final int DIALOG_VIASELECT_ID = 5;
|
||||
private static final int DIALOG_NOGOSELECT_ID = 6;
|
||||
private static final int DIALOG_SHOWRESULT_ID = 7;
|
||||
private static final int DIALOG_ROUTINGMODES_ID = 8;
|
||||
private static final int DIALOG_MODECONFIGOVERVIEW_ID = 9;
|
||||
private static final int DIALOG_PICKWAYPOINT_ID = 10;
|
||||
private static final int DIALOG_SELECTBASEDIR_ID = 11;
|
||||
private static final int DIALOG_MAINACTION_ID = 12;
|
||||
private static final int DIALOG_OLDDATAHINT_ID = 13;
|
||||
|
||||
private static final int DIALOG_SELECTPROFILE_ID = 1;
|
||||
private static final int DIALOG_EXCEPTION_ID = 2;
|
||||
private static final int DIALOG_SHOW_DM_INFO_ID = 3;
|
||||
private static final int DIALOG_TEXTENTRY_ID = 4;
|
||||
private static final int DIALOG_VIASELECT_ID = 5;
|
||||
private static final int DIALOG_NOGOSELECT_ID = 6;
|
||||
private static final int DIALOG_SHOWRESULT_ID = 7;
|
||||
private static final int DIALOG_ROUTINGMODES_ID = 8;
|
||||
private static final int DIALOG_MODECONFIGOVERVIEW_ID = 9;
|
||||
private static final int DIALOG_PICKWAYPOINT_ID = 10;
|
||||
private static final int DIALOG_SELECTBASEDIR_ID = 11;
|
||||
private static final int DIALOG_MAINACTION_ID = 12;
|
||||
private static final int DIALOG_OLDDATAHINT_ID = 13;
|
||||
private BRouterView mBRouterView;
|
||||
private PowerManager mPowerManager;
|
||||
private WakeLock mWakeLock;
|
||||
|
||||
private BRouterView mBRouterView;
|
||||
private PowerManager mPowerManager;
|
||||
private WakeLock mWakeLock;
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onCreate( Bundle savedInstanceState )
|
||||
{
|
||||
super.onCreate( savedInstanceState );
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Get an instance of the PowerManager
|
||||
mPowerManager = (PowerManager) getSystemService( POWER_SERVICE );
|
||||
|
||||
// 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() );
|
||||
|
||||
// Create a bright wake lock
|
||||
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, getClass()
|
||||
.getName());
|
||||
// instantiate our simulation view and set it as the activity's content
|
||||
mBRouterView = new BRouterView( this );
|
||||
mBRouterView.init();
|
||||
setContentView( mBRouterView );
|
||||
}
|
||||
|
||||
// instantiate our simulation view and set it as the activity's content
|
||||
mBRouterView = new BRouterView(this);
|
||||
mBRouterView.init();
|
||||
setContentView(mBRouterView);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Dialog onCreateDialog(int id)
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Dialog onCreateDialog( int id )
|
||||
{
|
||||
AlertDialog.Builder builder;
|
||||
switch ( id )
|
||||
{
|
||||
AlertDialog.Builder builder;
|
||||
switch(id)
|
||||
case DIALOG_SELECTPROFILE_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Select a routing profile" );
|
||||
builder.setItems( availableProfiles, new DialogInterface.OnClickListener()
|
||||
{
|
||||
case DIALOG_SELECTPROFILE_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Select a routing profile");
|
||||
builder.setItems(availableProfiles, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
selectedProfile = availableProfiles[item];
|
||||
mBRouterView.startProcessing(selectedProfile);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_MAINACTION_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Select Main Action");
|
||||
builder.setItems( new String[] { "Download Manager", "BRouter App" }, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
if ( item == 0 ) startDownloadManager();
|
||||
else showDialog( DIALOG_SELECTPROFILE_ID );
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_SHOW_DM_INFO_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( "BRouter Download Manager" )
|
||||
.setMessage( "*** Attention: ***\n\n"
|
||||
+ "The Download Manager is used to download routing-data "
|
||||
+ "files which can be up to 100MB each. Do not start the Download Manager "
|
||||
+ "on a cellular data connection without a data plan! "
|
||||
+ "Download speed is restricted to 2 MBit/s." )
|
||||
.setPositiveButton( "I know", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
Intent intent = new Intent(BRouterActivity.this, BInstallerActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
})
|
||||
.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_OLDDATAHINT_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( "Local setup needs reset" )
|
||||
.setMessage( "You are currently using an old version of the lookup-table "
|
||||
+ "together with routing data made for this old table. "
|
||||
+ "Before downloading new datafiles made for the new table, "
|
||||
+ "you have to reset your local setup by 'moving away' (or deleting) "
|
||||
+ "your <basedir>/brouter directory and start a new setup by calling the "
|
||||
+ "BRouter App again." )
|
||||
.setPositiveButton( "OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_ROUTINGMODES_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( message );
|
||||
builder.setMultiChoiceItems(routingModes, routingModesChecked, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which,
|
||||
boolean isChecked) {
|
||||
routingModesChecked[which] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mBRouterView.configureService(routingModes,routingModesChecked);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_EXCEPTION_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( "An Error occured" )
|
||||
.setMessage( errorMessage )
|
||||
.setPositiveButton( "OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
mBRouterView.continueProcessing();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_TEXTENTRY_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Enter SDCARD base dir:");
|
||||
builder.setMessage(message);
|
||||
final EditText input = new EditText(this);
|
||||
input.setText( defaultbasedir );
|
||||
builder.setView(input);
|
||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
String basedir = input.getText().toString();
|
||||
mBRouterView.startSetup(basedir, true );
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_SELECTBASEDIR_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Select an SDCARD base dir:");
|
||||
builder.setSingleChoiceItems(basedirOptions, 0, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int item )
|
||||
{
|
||||
selectedBasedir = item;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton)
|
||||
{
|
||||
if ( selectedBasedir < availableBasedirs.size() )
|
||||
{
|
||||
mBRouterView.startSetup(availableBasedirs.get(selectedBasedir), true );
|
||||
}
|
||||
else
|
||||
{
|
||||
showDialog( DIALOG_TEXTENTRY_ID );
|
||||
}
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_VIASELECT_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Check VIA Selection:");
|
||||
builder.setMultiChoiceItems(availableVias, getCheckedBooleanArray( availableVias.length ),
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which,
|
||||
boolean isChecked) {
|
||||
if (isChecked)
|
||||
{
|
||||
selectedVias.add(availableVias[which]);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedVias.remove(availableVias[which]);
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mBRouterView.updateViaList( selectedVias );
|
||||
mBRouterView.startProcessing(selectedProfile);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_NOGOSELECT_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle("Check NoGo Selection:");
|
||||
String[] nogoNames = new String[nogoList.size()];
|
||||
for( int i=0; i<nogoList.size(); i++ ) nogoNames[i] = nogoList.get(i).name;
|
||||
final boolean[] nogoEnabled = getCheckedBooleanArray(nogoList.size());
|
||||
builder.setMultiChoiceItems(nogoNames, getCheckedBooleanArray( nogoNames.length ),
|
||||
new DialogInterface.OnMultiChoiceClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
nogoEnabled[which] = isChecked;
|
||||
}
|
||||
});
|
||||
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int whichButton) {
|
||||
mBRouterView.updateNogoList( nogoEnabled );
|
||||
mBRouterView.startProcessing(selectedProfile);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_SHOWRESULT_ID:
|
||||
String leftLabel = wpCount < 0 ? "Exit" : ( wpCount == 0 ? "Select from" : "Select to/via" );
|
||||
String rightLabel = wpCount < 2 ? "Server-Mode" : "Calc Route";
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( title )
|
||||
.setMessage( errorMessage )
|
||||
.setPositiveButton( leftLabel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
if ( wpCount < 0 ) finish();
|
||||
else mBRouterView.pickWaypoints();
|
||||
}
|
||||
})
|
||||
.setNegativeButton( rightLabel, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
if ( wpCount < 2 ) mBRouterView.startConfigureService();
|
||||
else
|
||||
{
|
||||
mBRouterView.finishWaypointSelection();
|
||||
mBRouterView.startProcessing(selectedProfile);
|
||||
}
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_MODECONFIGOVERVIEW_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( "Success" )
|
||||
.setMessage( message )
|
||||
.setPositiveButton( "Exit", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
case DIALOG_PICKWAYPOINT_ID:
|
||||
builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle( wpCount > 0 ? "Select to/via" : "Select from" );
|
||||
builder.setItems(availableWaypoints, new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int item) {
|
||||
mBRouterView.updateWaypointList( availableWaypoints[item] );
|
||||
mBRouterView.startProcessing(selectedProfile);
|
||||
}
|
||||
});
|
||||
return builder.create();
|
||||
|
||||
default:
|
||||
return null;
|
||||
public void onClick( DialogInterface dialog, int item )
|
||||
{
|
||||
selectedProfile = availableProfiles[item];
|
||||
mBRouterView.startProcessing( selectedProfile );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_MAINACTION_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Select Main Action" );
|
||||
builder.setItems( new String[]
|
||||
{ "Download Manager", "BRouter App" }, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int item )
|
||||
{
|
||||
if ( item == 0 )
|
||||
startDownloadManager();
|
||||
else
|
||||
showDialog( DIALOG_SELECTPROFILE_ID );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_SHOW_DM_INFO_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder
|
||||
.setTitle( "BRouter Download Manager" )
|
||||
.setMessage(
|
||||
"*** Attention: ***\n\n" + "The Download Manager is used to download routing-data "
|
||||
+ "files which can be up to 100MB each. Do not start the Download Manager " + "on a cellular data connection without a data plan! "
|
||||
+ "Download speed is restricted to 2 MBit/s." ).setPositiveButton( "I know", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
Intent intent = new Intent( BRouterActivity.this, BInstallerActivity.class );
|
||||
startActivity( intent );
|
||||
finish();
|
||||
}
|
||||
} ).setNegativeButton( "Cancel", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
finish();
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_OLDDATAHINT_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder
|
||||
.setTitle( "Local setup needs reset" )
|
||||
.setMessage(
|
||||
"You are currently using an old version of the lookup-table " + "together with routing data made for this old table. "
|
||||
+ "Before downloading new datafiles made for the new table, "
|
||||
+ "you have to reset your local setup by 'moving away' (or deleting) "
|
||||
+ "your <basedir>/brouter directory and start a new setup by calling the " + "BRouter App again." )
|
||||
.setPositiveButton( "OK", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
finish();
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_ROUTINGMODES_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( message );
|
||||
builder.setMultiChoiceItems( routingModes, routingModesChecked, new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int which, boolean isChecked )
|
||||
{
|
||||
routingModesChecked[which] = isChecked;
|
||||
}
|
||||
} );
|
||||
builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int whichButton )
|
||||
{
|
||||
mBRouterView.configureService( routingModes, routingModesChecked );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_EXCEPTION_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "An Error occured" ).setMessage( errorMessage ).setPositiveButton( "OK", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
mBRouterView.continueProcessing();
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_TEXTENTRY_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Enter SDCARD base dir:" );
|
||||
builder.setMessage( message );
|
||||
final EditText input = new EditText( this );
|
||||
input.setText( defaultbasedir );
|
||||
builder.setView( input );
|
||||
builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int whichButton )
|
||||
{
|
||||
String basedir = input.getText().toString();
|
||||
mBRouterView.startSetup( basedir, true );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_SELECTBASEDIR_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Select an SDCARD base dir:" );
|
||||
builder.setSingleChoiceItems( basedirOptions, 0, new DialogInterface.OnClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int item )
|
||||
{
|
||||
selectedBasedir = item;
|
||||
}
|
||||
} );
|
||||
builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int whichButton )
|
||||
{
|
||||
if ( selectedBasedir < availableBasedirs.size() )
|
||||
{
|
||||
mBRouterView.startSetup( availableBasedirs.get( selectedBasedir ), true );
|
||||
}
|
||||
else
|
||||
{
|
||||
showDialog( DIALOG_TEXTENTRY_ID );
|
||||
}
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_VIASELECT_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Check VIA Selection:" );
|
||||
builder.setMultiChoiceItems( availableVias, getCheckedBooleanArray( availableVias.length ), new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int which, boolean isChecked )
|
||||
{
|
||||
if ( isChecked )
|
||||
{
|
||||
selectedVias.add( availableVias[which] );
|
||||
}
|
||||
else
|
||||
{
|
||||
selectedVias.remove( availableVias[which] );
|
||||
}
|
||||
}
|
||||
} );
|
||||
builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int whichButton )
|
||||
{
|
||||
mBRouterView.updateViaList( selectedVias );
|
||||
mBRouterView.startProcessing( selectedProfile );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_NOGOSELECT_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Check NoGo Selection:" );
|
||||
String[] nogoNames = new String[nogoList.size()];
|
||||
for ( int i = 0; i < nogoList.size(); i++ )
|
||||
nogoNames[i] = nogoList.get( i ).name;
|
||||
final boolean[] nogoEnabled = getCheckedBooleanArray( nogoList.size() );
|
||||
builder.setMultiChoiceItems( nogoNames, getCheckedBooleanArray( nogoNames.length ), new DialogInterface.OnMultiChoiceClickListener()
|
||||
{
|
||||
@Override
|
||||
public void onClick( DialogInterface dialog, int which, boolean isChecked )
|
||||
{
|
||||
nogoEnabled[which] = isChecked;
|
||||
}
|
||||
} );
|
||||
builder.setPositiveButton( "Ok", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int whichButton )
|
||||
{
|
||||
mBRouterView.updateNogoList( nogoEnabled );
|
||||
mBRouterView.startProcessing( selectedProfile );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_SHOWRESULT_ID:
|
||||
String leftLabel = wpCount < 0 ? "Exit" : ( wpCount == 0 ? "Select from" : "Select to/via" );
|
||||
String rightLabel = wpCount < 2 ? "Server-Mode" : "Calc Route";
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( title ).setMessage( errorMessage ).setPositiveButton( leftLabel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
if ( wpCount < 0 )
|
||||
finish();
|
||||
else
|
||||
mBRouterView.pickWaypoints();
|
||||
}
|
||||
} ).setNegativeButton( rightLabel, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
if ( wpCount < 2 )
|
||||
mBRouterView.startConfigureService();
|
||||
else
|
||||
{
|
||||
mBRouterView.finishWaypointSelection();
|
||||
mBRouterView.startProcessing( selectedProfile );
|
||||
}
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_MODECONFIGOVERVIEW_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( "Success" ).setMessage( message ).setPositiveButton( "Exit", new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int id )
|
||||
{
|
||||
finish();
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
case DIALOG_PICKWAYPOINT_ID:
|
||||
builder = new AlertDialog.Builder( this );
|
||||
builder.setTitle( wpCount > 0 ? "Select to/via" : "Select from" );
|
||||
builder.setItems( availableWaypoints, new DialogInterface.OnClickListener()
|
||||
{
|
||||
public void onClick( DialogInterface dialog, int item )
|
||||
{
|
||||
mBRouterView.updateWaypointList( availableWaypoints[item] );
|
||||
mBRouterView.startProcessing( selectedProfile );
|
||||
}
|
||||
} );
|
||||
return builder.create();
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean[] getCheckedBooleanArray( int size )
|
||||
private boolean[] getCheckedBooleanArray( int size )
|
||||
{
|
||||
boolean[] checked = new boolean[size];
|
||||
for ( int i = 0; i < checked.length; i++ ) checked[i] = true;
|
||||
return checked;
|
||||
}
|
||||
|
||||
private String[] availableProfiles;
|
||||
private String selectedProfile = null;
|
||||
|
||||
private List<String> availableBasedirs;
|
||||
private String[] basedirOptions;
|
||||
private int selectedBasedir;
|
||||
|
||||
private String[] availableWaypoints;
|
||||
|
||||
private String[] routingModes;
|
||||
private boolean[] routingModesChecked;
|
||||
|
||||
private String defaultbasedir = null;
|
||||
private String message = null;
|
||||
|
||||
private String[] availableVias;
|
||||
private Set<String> selectedVias;
|
||||
|
||||
private List<OsmNodeNamed> nogoList;
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE );
|
||||
|
||||
return cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectProfile( String[] items )
|
||||
{
|
||||
availableProfiles = items;
|
||||
|
||||
// if we have internet access, first show the main action dialog
|
||||
if ( isOnline() )
|
||||
{
|
||||
boolean[] checked = new boolean[size];
|
||||
for( int i=0; i<checked.length; i++ ) checked[i] = true;
|
||||
return checked;
|
||||
showDialog( DIALOG_MAINACTION_ID );
|
||||
}
|
||||
|
||||
private String[] availableProfiles;
|
||||
private String selectedProfile = null;
|
||||
|
||||
private List<String> availableBasedirs;
|
||||
private String[] basedirOptions;
|
||||
private int selectedBasedir;
|
||||
|
||||
private String[] availableWaypoints;
|
||||
|
||||
private String[] routingModes;
|
||||
private boolean[] routingModesChecked;
|
||||
|
||||
private String defaultbasedir = null;
|
||||
private String message = null;
|
||||
|
||||
private String[] availableVias;
|
||||
private Set<String> selectedVias;
|
||||
|
||||
private List<OsmNodeNamed> nogoList;
|
||||
|
||||
public boolean isOnline() {
|
||||
ConnectivityManager cm =
|
||||
(ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
|
||||
return cm.getActiveNetworkInfo() != null &&
|
||||
cm.getActiveNetworkInfo().isConnectedOrConnecting();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectProfile( String[] items )
|
||||
else
|
||||
{
|
||||
availableProfiles = items;
|
||||
|
||||
// if we have internet access, first show the main action dialog
|
||||
if ( isOnline() )
|
||||
{
|
||||
showDialog( DIALOG_MAINACTION_ID );
|
||||
}
|
||||
else
|
||||
{
|
||||
showDialog( DIALOG_SELECTPROFILE_ID );
|
||||
}
|
||||
showDialog( DIALOG_SELECTPROFILE_ID );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void startDownloadManager()
|
||||
@SuppressWarnings("deprecation")
|
||||
public void startDownloadManager()
|
||||
{
|
||||
if ( !mBRouterView.hasUpToDateLookups() )
|
||||
{
|
||||
if ( !mBRouterView.hasUpToDateLookups() )
|
||||
{
|
||||
showDialog( DIALOG_OLDDATAHINT_ID );
|
||||
}
|
||||
else
|
||||
{
|
||||
showDialog( DIALOG_SHOW_DM_INFO_ID );
|
||||
}
|
||||
showDialog( DIALOG_OLDDATAHINT_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectBasedir( List<String> items, String defaultBasedir, String message )
|
||||
else
|
||||
{
|
||||
this.defaultbasedir = defaultBasedir;
|
||||
this.message = message;
|
||||
availableBasedirs = new ArrayList<String>();
|
||||
ArrayList<Long> dirFreeSizes = new ArrayList<Long>();
|
||||
for( String d : items )
|
||||
showDialog( DIALOG_SHOW_DM_INFO_ID );
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectBasedir( List<String> items, String defaultBasedir, String message )
|
||||
{
|
||||
this.defaultbasedir = defaultBasedir;
|
||||
this.message = message;
|
||||
availableBasedirs = new ArrayList<String>();
|
||||
ArrayList<Long> dirFreeSizes = new ArrayList<Long>();
|
||||
for ( String d : items )
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
StatFs stat = new StatFs(d);
|
||||
long size = (long)stat.getAvailableBlocks()*stat.getBlockSize();
|
||||
StatFs stat = new StatFs( d );
|
||||
long size = (long) stat.getAvailableBlocks() * stat.getBlockSize();
|
||||
int idx = 0;
|
||||
while ( idx < availableBasedirs.size() && dirFreeSizes.get(idx).longValue() > size ) idx++;
|
||||
while (idx < availableBasedirs.size() && dirFreeSizes.get( idx ).longValue() > size)
|
||||
idx++;
|
||||
availableBasedirs.add( idx, d );
|
||||
dirFreeSizes.add( idx, Long.valueOf( size ) );
|
||||
}
|
||||
catch( Exception e ) { /* ignore */ }
|
||||
}
|
||||
|
||||
basedirOptions= new String[items.size() + 1];
|
||||
int bdidx = 0;
|
||||
DecimalFormat df = new DecimalFormat( "###0.00" );
|
||||
for( int idx=0; idx<availableBasedirs.size(); idx++ )
|
||||
{
|
||||
basedirOptions[bdidx++] = availableBasedirs.get(idx)
|
||||
+ " (" + df.format( dirFreeSizes.get(idx)/1024./1024./1024. ) + " GB free)";
|
||||
}
|
||||
basedirOptions[bdidx] = "Other";
|
||||
|
||||
showDialog( DIALOG_SELECTBASEDIR_ID );
|
||||
catch (Exception e) { /* ignore */ }
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectRoutingModes( String[] modes, boolean[] modesChecked, String message )
|
||||
basedirOptions = new String[items.size() + 1];
|
||||
int bdidx = 0;
|
||||
DecimalFormat df = new DecimalFormat( "###0.00" );
|
||||
for ( int idx = 0; idx < availableBasedirs.size(); idx++ )
|
||||
{
|
||||
routingModes = modes;
|
||||
routingModesChecked = modesChecked;
|
||||
this.message = message;
|
||||
showDialog( DIALOG_ROUTINGMODES_ID );
|
||||
basedirOptions[bdidx++] = availableBasedirs.get( idx ) + " (" + df.format( dirFreeSizes.get( idx ) / 1024. / 1024. / 1024. ) + " GB free)";
|
||||
}
|
||||
basedirOptions[bdidx] = "Other";
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showModeConfigOverview( String message )
|
||||
showDialog( DIALOG_SELECTBASEDIR_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectRoutingModes( String[] modes, boolean[] modesChecked, String message )
|
||||
{
|
||||
routingModes = modes;
|
||||
routingModesChecked = modesChecked;
|
||||
this.message = message;
|
||||
showDialog( DIALOG_ROUTINGMODES_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showModeConfigOverview( String message )
|
||||
{
|
||||
this.message = message;
|
||||
showDialog( DIALOG_MODECONFIGOVERVIEW_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectVias( String[] items )
|
||||
{
|
||||
availableVias = items;
|
||||
selectedVias = new HashSet<String>( availableVias.length );
|
||||
for ( String via : items )
|
||||
selectedVias.add( via );
|
||||
showDialog( DIALOG_VIASELECT_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectWaypoint( String[] items )
|
||||
{
|
||||
availableWaypoints = items;
|
||||
showNewDialog( DIALOG_PICKWAYPOINT_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectNogos( List<OsmNodeNamed> nogoList )
|
||||
{
|
||||
this.nogoList = nogoList;
|
||||
showDialog( DIALOG_NOGOSELECT_ID );
|
||||
}
|
||||
|
||||
private Set<Integer> dialogIds = new HashSet<Integer>();
|
||||
|
||||
private void showNewDialog( int id )
|
||||
{
|
||||
if ( dialogIds.contains( Integer.valueOf( id ) ) )
|
||||
{
|
||||
this.message = message;
|
||||
showDialog( DIALOG_MODECONFIGOVERVIEW_ID );
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectVias( String[] items )
|
||||
{
|
||||
availableVias = items;
|
||||
selectedVias = new HashSet<String>(availableVias.length);
|
||||
for( String via : items ) selectedVias.add( via );
|
||||
showDialog( DIALOG_VIASELECT_ID );
|
||||
removeDialog( id );
|
||||
}
|
||||
dialogIds.add( Integer.valueOf( id ) );
|
||||
showDialog( id );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectWaypoint( String[] items )
|
||||
{
|
||||
availableWaypoints = items;
|
||||
showNewDialog( DIALOG_PICKWAYPOINT_ID );
|
||||
}
|
||||
private String errorMessage;
|
||||
private String title;
|
||||
private int wpCount;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void selectNogos( List<OsmNodeNamed> nogoList )
|
||||
{
|
||||
this.nogoList = nogoList;
|
||||
showDialog( DIALOG_NOGOSELECT_ID );
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showErrorMessage( String msg )
|
||||
{
|
||||
errorMessage = msg;
|
||||
showNewDialog( DIALOG_EXCEPTION_ID );
|
||||
}
|
||||
|
||||
private Set<Integer> dialogIds = new HashSet<Integer>();
|
||||
|
||||
private void showNewDialog( int id )
|
||||
{
|
||||
if ( dialogIds.contains( Integer.valueOf( id ) ) )
|
||||
{
|
||||
removeDialog( id );
|
||||
}
|
||||
dialogIds.add( Integer.valueOf( id ) );
|
||||
showDialog( id );
|
||||
}
|
||||
|
||||
private String errorMessage;
|
||||
private String title;
|
||||
private int wpCount;
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showResultMessage( String title, String msg, int wpCount )
|
||||
{
|
||||
errorMessage = msg;
|
||||
this.title = title;
|
||||
this.wpCount = wpCount;
|
||||
showNewDialog( DIALOG_SHOWRESULT_ID );
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showErrorMessage( String msg )
|
||||
{
|
||||
errorMessage = msg;
|
||||
showNewDialog( DIALOG_EXCEPTION_ID );
|
||||
}
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
/*
|
||||
* when the activity is resumed, we acquire a wake-lock so that the screen
|
||||
* stays on, since the user will likely not be fiddling with the screen or
|
||||
* buttons.
|
||||
*/
|
||||
mWakeLock.acquire();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void showResultMessage( String title, String msg, int wpCount )
|
||||
{
|
||||
errorMessage = msg;
|
||||
this.title = title;
|
||||
this.wpCount = wpCount;
|
||||
showNewDialog( DIALOG_SHOWRESULT_ID );
|
||||
}
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
/*
|
||||
* When the activity is paused, we make sure to stop the router
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
/*
|
||||
* when the activity is resumed, we acquire a wake-lock so that the
|
||||
* screen stays on, since the user will likely not be fiddling with the
|
||||
* screen or buttons.
|
||||
*/
|
||||
mWakeLock.acquire();
|
||||
// Stop the simulation
|
||||
mBRouterView.stopRouting();
|
||||
|
||||
// Start the simulation
|
||||
mBRouterView.startSimulation();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
/*
|
||||
* When the activity is paused, we make sure to stop the simulation,
|
||||
* release our sensor resources and wake locks
|
||||
*/
|
||||
|
||||
// Stop the simulation
|
||||
mBRouterView.stopSimulation();
|
||||
|
||||
// and release our wake-lock
|
||||
mWakeLock.release();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit(int i)
|
||||
{
|
||||
}
|
||||
// and release our wake-lock
|
||||
mWakeLock.release();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInit( int i )
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -9,43 +9,56 @@ import java.io.OutputStreamWriter;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
|
||||
/**
|
||||
* Decsription of a service config
|
||||
*/
|
||||
public class ConfigHelper
|
||||
{
|
||||
public static String getBaseDir( Context ctx )
|
||||
{
|
||||
// get base dir from private file
|
||||
InputStream configInput = null;
|
||||
try
|
||||
{
|
||||
configInput = ctx.openFileInput( "config.dat" );
|
||||
BufferedReader br = new BufferedReader( new InputStreamReader (configInput ) );
|
||||
return br.readLine();
|
||||
}
|
||||
catch( Exception e ) { return null; }
|
||||
finally
|
||||
{
|
||||
if ( configInput != null ) try { configInput.close(); } catch( Exception ee ) {}
|
||||
}
|
||||
}
|
||||
public static String getBaseDir( Context ctx )
|
||||
{
|
||||
// get base dir from private file
|
||||
InputStream configInput = null;
|
||||
try
|
||||
{
|
||||
configInput = ctx.openFileInput( "config.dat" );
|
||||
BufferedReader br = new BufferedReader( new InputStreamReader( configInput ) );
|
||||
return br.readLine();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( configInput != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
configInput.close();
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeBaseDir( Context ctx, String baseDir )
|
||||
{
|
||||
BufferedWriter bw = null;
|
||||
try
|
||||
{
|
||||
OutputStream configOutput = ctx.openFileOutput( "config.dat", Context.MODE_PRIVATE );
|
||||
bw = new BufferedWriter( new OutputStreamWriter (configOutput ) );
|
||||
bw.write( baseDir );
|
||||
bw.write( '\n' );
|
||||
}
|
||||
catch( Exception e ) {}
|
||||
finally
|
||||
{
|
||||
if ( bw != null ) try { bw.close(); } catch( Exception ee ) {}
|
||||
}
|
||||
}
|
||||
public static void writeBaseDir( Context ctx, String baseDir )
|
||||
{
|
||||
BufferedWriter bw = null;
|
||||
try
|
||||
{
|
||||
OutputStream configOutput = ctx.openFileOutput( "config.dat", Context.MODE_PRIVATE );
|
||||
bw = new BufferedWriter( new OutputStreamWriter( configOutput ) );
|
||||
bw.write( baseDir );
|
||||
bw.write( '\n' );
|
||||
}
|
||||
catch (Exception e){ /* ignore */ }
|
||||
finally
|
||||
{
|
||||
if ( bw != null )
|
||||
try
|
||||
{
|
||||
bw.close();
|
||||
}
|
||||
catch (Exception ee) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,89 @@
|
|||
package btools.routingapp;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigMigration
|
||||
{
|
||||
public static void tryMigrateStorageConfig( File srcFile, File dstFile )
|
||||
{
|
||||
if ( !srcFile.exists() ) return;
|
||||
|
||||
String ssd = null;
|
||||
String amd = null;
|
||||
|
||||
BufferedReader br = null;
|
||||
BufferedWriter bw = null;
|
||||
try
|
||||
{
|
||||
br = new BufferedReader( new FileReader( srcFile ) );
|
||||
for ( ;; )
|
||||
{
|
||||
String line = br.readLine();
|
||||
if ( line == null ) break;
|
||||
if ( line.trim().startsWith( "secondary_segment_dir=" ) )
|
||||
{
|
||||
if ( !"secondary_segment_dir=../segments2".equals( line ) )
|
||||
{
|
||||
ssd = line;
|
||||
}
|
||||
}
|
||||
if ( line.trim().startsWith( "additional_maptool_dir=" ) )
|
||||
{
|
||||
amd = line;
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
|
||||
List<String> lines = new ArrayList<String>();
|
||||
br = new BufferedReader( new FileReader( dstFile ) );
|
||||
for ( ;; )
|
||||
{
|
||||
String line = br.readLine();
|
||||
if ( line == null ) break;
|
||||
if ( ssd != null && line.trim().startsWith( "secondary_segment_dir=" ) )
|
||||
{
|
||||
line = ssd;
|
||||
}
|
||||
if ( amd != null && line.trim().startsWith( "#additional_maptool_dir=" ) )
|
||||
{
|
||||
line = amd;
|
||||
}
|
||||
lines.add( line );
|
||||
}
|
||||
br.close();
|
||||
br = null;
|
||||
|
||||
bw = new BufferedWriter( new FileWriter( dstFile ) );
|
||||
for( String line: lines )
|
||||
{
|
||||
bw.write( line + "\n" );
|
||||
}
|
||||
}
|
||||
catch (Exception e) { /* ignore */ }
|
||||
finally
|
||||
{
|
||||
if ( br != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
catch (Exception ee) { /* ignore */ }
|
||||
}
|
||||
if ( bw != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
bw.close();
|
||||
}
|
||||
catch (Exception ee) { /* ignore */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,11 @@ import java.io.File;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import android.os.Environment;
|
||||
import btools.router.OsmNodeNamed;
|
||||
|
|
@ -22,7 +25,9 @@ public abstract class CoordinateReader
|
|||
public String rootdir;
|
||||
public String tracksdir;
|
||||
|
||||
public Map<String,OsmNodeNamed> allpoints;
|
||||
private Map<String,Map<String, OsmNodeNamed>> allpointsMap;
|
||||
public List<OsmNodeNamed> allpoints;
|
||||
|
||||
private HashMap<String,OsmNodeNamed> pointmap;
|
||||
|
||||
protected static String[] posnames
|
||||
|
|
@ -35,6 +40,34 @@ public abstract class CoordinateReader
|
|||
|
||||
public abstract long getTimeStamp() throws Exception;
|
||||
|
||||
public void readAllPoints() throws Exception
|
||||
{
|
||||
allpointsMap = new TreeMap<String, Map<String,OsmNodeNamed>>();
|
||||
readFromTo();
|
||||
allpoints = new ArrayList<OsmNodeNamed>();
|
||||
Set<String> names = new HashSet<String>();
|
||||
for( String category : allpointsMap.keySet() )
|
||||
{
|
||||
Map<String, OsmNodeNamed> cat = allpointsMap.get( category );
|
||||
if ( cat.size() < 101 )
|
||||
{
|
||||
for ( OsmNodeNamed wp : cat.values() )
|
||||
{
|
||||
if ( names.add( wp.name ) )
|
||||
{
|
||||
allpoints.add( wp );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OsmNodeNamed nocatHint = new OsmNodeNamed();
|
||||
nocatHint.name = "<big category " + category + " supressed>";
|
||||
allpoints.add( nocatHint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* read the from, to and via-positions from a gpx-file
|
||||
*/
|
||||
|
|
@ -62,13 +95,23 @@ public abstract class CoordinateReader
|
|||
if ( fromToMissing ) waypoints.clear();
|
||||
}
|
||||
|
||||
protected void checkAddPoint( OsmNodeNamed n )
|
||||
protected void checkAddPoint( String category, OsmNodeNamed n )
|
||||
{
|
||||
if ( allpoints != null )
|
||||
{
|
||||
allpoints.put( n.name, n );
|
||||
return;
|
||||
}
|
||||
if ( allpointsMap != null )
|
||||
{
|
||||
if ( category == null ) category = "";
|
||||
Map<String, OsmNodeNamed> cat = allpointsMap.get( category );
|
||||
if ( cat == null )
|
||||
{
|
||||
cat = new TreeMap<String, OsmNodeNamed>();
|
||||
allpointsMap.put( category, cat );
|
||||
}
|
||||
if ( cat.size() < 101 )
|
||||
{
|
||||
cat.put( n.name, n );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean isKnown = false;
|
||||
for( int i=0; i<posnames.length; i++ )
|
||||
|
|
@ -100,70 +143,71 @@ public abstract class CoordinateReader
|
|||
|
||||
public static CoordinateReader obtainValidReader( String basedir, String segmentDir ) throws Exception
|
||||
{
|
||||
CoordinateReader cor = null;
|
||||
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>();
|
||||
CoordinateReader cor = null;
|
||||
ArrayList<CoordinateReader> rl = new ArrayList<CoordinateReader>();
|
||||
|
||||
AppLogger.log( "adding standard maptool-base: " + basedir );
|
||||
rl.add( new CoordinateReaderOsmAnd(basedir) );
|
||||
rl.add( new CoordinateReaderLocus(basedir) );
|
||||
rl.add( new CoordinateReaderOrux(basedir) );
|
||||
AppLogger.log( "adding standard maptool-base: " + basedir );
|
||||
rl.add( new CoordinateReaderOsmAnd( basedir ) );
|
||||
rl.add( new CoordinateReaderLocus( basedir ) );
|
||||
rl.add( new CoordinateReaderOrux( basedir ) );
|
||||
|
||||
// eventually add standard-sd
|
||||
File standardbase = Environment.getExternalStorageDirectory();
|
||||
if ( standardbase != null )
|
||||
{
|
||||
String base2 = standardbase.getAbsolutePath();
|
||||
if ( !base2.equals( basedir ) )
|
||||
{
|
||||
AppLogger.log( "adding internal sd maptool-base: " + base2 );
|
||||
rl.add( new CoordinateReaderOsmAnd(base2) );
|
||||
rl.add( new CoordinateReaderLocus(base2) );
|
||||
rl.add( new CoordinateReaderOrux(base2) );
|
||||
}
|
||||
}
|
||||
// eventually add standard-sd
|
||||
File standardbase = Environment.getExternalStorageDirectory();
|
||||
if ( standardbase != null )
|
||||
{
|
||||
String base2 = standardbase.getAbsolutePath();
|
||||
if ( !base2.equals( basedir ) )
|
||||
{
|
||||
AppLogger.log( "adding internal sd maptool-base: " + base2 );
|
||||
rl.add( new CoordinateReaderOsmAnd( base2 ) );
|
||||
rl.add( new CoordinateReaderLocus( base2 ) );
|
||||
rl.add( new CoordinateReaderOrux( base2 ) );
|
||||
}
|
||||
}
|
||||
|
||||
// eventually add explicit directory
|
||||
File additional = RoutingHelper.getAdditionalMaptoolDir(segmentDir);
|
||||
if ( additional != null )
|
||||
{
|
||||
String base3 = additional.getAbsolutePath();
|
||||
|
||||
AppLogger.log( "adding maptool-base from storage-config: " + base3 );
|
||||
|
||||
rl.add( new CoordinateReaderOsmAnd(base3) );
|
||||
rl.add( new CoordinateReaderLocus(base3) );
|
||||
rl.add( new CoordinateReaderOrux(base3) );
|
||||
}
|
||||
// eventually add explicit directory
|
||||
File additional = RoutingHelper.getAdditionalMaptoolDir( segmentDir );
|
||||
if ( additional != null )
|
||||
{
|
||||
String base3 = additional.getAbsolutePath();
|
||||
|
||||
long tmax = 0;
|
||||
for( CoordinateReader r : rl )
|
||||
{
|
||||
if ( AppLogger.isLogging() )
|
||||
{
|
||||
AppLogger.log( "reading timestamp at systime " + new Date() );
|
||||
}
|
||||
AppLogger.log( "adding maptool-base from storage-config: " + base3 );
|
||||
|
||||
long t = r.getTimeStamp();
|
||||
|
||||
if ( t != 0 )
|
||||
{
|
||||
if ( AppLogger.isLogging() )
|
||||
{
|
||||
AppLogger.log( "found coordinate source at " + r.basedir + r.rootdir + " with timestamp " + new Date( t ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( t > tmax )
|
||||
{
|
||||
tmax = t;
|
||||
cor = r;
|
||||
}
|
||||
}
|
||||
if ( cor == null )
|
||||
{
|
||||
cor = new CoordinateReaderNone();
|
||||
}
|
||||
cor.readFromTo();
|
||||
return cor;
|
||||
rl.add( new CoordinateReaderOsmAnd( base3 ) );
|
||||
rl.add( new CoordinateReaderOsmAnd( base3, true ) );
|
||||
rl.add( new CoordinateReaderLocus( base3 ) );
|
||||
rl.add( new CoordinateReaderOrux( base3 ) );
|
||||
}
|
||||
|
||||
long tmax = 0;
|
||||
for ( CoordinateReader r : rl )
|
||||
{
|
||||
if ( AppLogger.isLogging() )
|
||||
{
|
||||
AppLogger.log( "reading timestamp at systime " + new Date() );
|
||||
}
|
||||
|
||||
long t = r.getTimeStamp();
|
||||
|
||||
if ( t != 0 )
|
||||
{
|
||||
if ( AppLogger.isLogging() )
|
||||
{
|
||||
AppLogger.log( "found coordinate source at " + r.basedir + r.rootdir + " with timestamp " + new Date( t ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( t > tmax )
|
||||
{
|
||||
tmax = t;
|
||||
cor = r;
|
||||
}
|
||||
}
|
||||
if ( cor == null )
|
||||
{
|
||||
cor = new CoordinateReaderNone();
|
||||
}
|
||||
cor.readFromTo();
|
||||
return cor;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,16 @@ public class CoordinateReaderLocus extends CoordinateReader
|
|||
private void _readPointmap( String filename ) throws Exception
|
||||
{
|
||||
SQLiteDatabase myDataBase = SQLiteDatabase.openDatabase( filename, null, SQLiteDatabase.OPEN_READONLY);
|
||||
Cursor c = myDataBase.rawQuery("SELECT name, longitude, latitude FROM waypoints", null);
|
||||
|
||||
Cursor c = myDataBase.rawQuery("SELECT c.name, w.name, w.longitude, w.latitude FROM waypoints w, categories c where w.parent_id = c._id", null);
|
||||
while (c.moveToNext())
|
||||
{
|
||||
OsmNodeNamed n = new OsmNodeNamed();
|
||||
n.name = c.getString(0);
|
||||
n.ilon = (int)( ( Double.parseDouble( c.getString(1) ) + 180. )*1000000. + 0.5);
|
||||
n.ilat = (int)( ( Double.parseDouble( c.getString(2) ) + 90. )*1000000. + 0.5);
|
||||
checkAddPoint( n );
|
||||
String category = c.getString(0);
|
||||
n.name = c.getString(1);
|
||||
n.ilon = (int)( ( Double.parseDouble( c.getString(2) ) + 180. )*1000000. + 0.5);
|
||||
n.ilat = (int)( ( Double.parseDouble( c.getString(3) ) + 90. )*1000000. + 0.5);
|
||||
checkAddPoint( category, n );
|
||||
}
|
||||
myDataBase.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,14 +38,15 @@ public class CoordinateReaderOrux extends CoordinateReader
|
|||
private void _readPointmap( String filename ) throws Exception
|
||||
{
|
||||
SQLiteDatabase myDataBase = SQLiteDatabase.openDatabase( filename, null, SQLiteDatabase.OPEN_READONLY);
|
||||
Cursor c = myDataBase.rawQuery("SELECT poiname, poilon, poilat FROM pois", null);
|
||||
Cursor c = myDataBase.rawQuery("SELECT poiname, poilon, poilat, poifolder FROM pois", null);
|
||||
while (c.moveToNext())
|
||||
{
|
||||
OsmNodeNamed n = new OsmNodeNamed();
|
||||
n.name = c.getString(0);
|
||||
n.ilon = (int)( ( Double.parseDouble( c.getString(1) ) + 180. )*1000000. + 0.5);
|
||||
n.ilat = (int)( ( Double.parseDouble( c.getString(2) ) + 90. )*1000000. + 0.5);
|
||||
checkAddPoint( n );
|
||||
String category = c.getString(3);
|
||||
checkAddPoint( category, n );
|
||||
}
|
||||
myDataBase.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,35 @@ import btools.router.OsmNodeNamed;
|
|||
*/
|
||||
public class CoordinateReaderOsmAnd extends CoordinateReader
|
||||
{
|
||||
private String osmandDir;
|
||||
|
||||
public CoordinateReaderOsmAnd( String basedir )
|
||||
{
|
||||
this( basedir, false );
|
||||
}
|
||||
|
||||
public CoordinateReaderOsmAnd( String basedir, boolean shortPath )
|
||||
{
|
||||
super( basedir );
|
||||
tracksdir = "/osmand/tracks";
|
||||
rootdir = "/osmand";
|
||||
if ( shortPath )
|
||||
{
|
||||
osmandDir = basedir;
|
||||
tracksdir = "/tracks";
|
||||
rootdir = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
osmandDir = basedir + "/osmand";
|
||||
tracksdir = "/osmand/tracks";
|
||||
rootdir = "/osmand";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimeStamp() throws Exception
|
||||
{
|
||||
long t1 = new File( basedir + "/osmand/favourites_bak.gpx" ).lastModified();
|
||||
long t2 = new File( basedir + "/osmand/favourites.gpx" ).lastModified();
|
||||
long t1 = new File( osmandDir + "/favourites_bak.gpx" ).lastModified();
|
||||
long t2 = new File( osmandDir + "/favourites.gpx" ).lastModified();
|
||||
return t1 > t2 ? t1 : t2;
|
||||
}
|
||||
|
||||
|
|
@ -36,11 +53,11 @@ public class CoordinateReaderOsmAnd extends CoordinateReader
|
|||
{
|
||||
try
|
||||
{
|
||||
_readPointmap( basedir + "/osmand/favourites_bak.gpx" );
|
||||
_readPointmap( osmandDir + "/favourites_bak.gpx" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
_readPointmap( basedir + "/osmand/favourites.gpx" );
|
||||
_readPointmap( osmandDir + "/favourites.gpx" );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,7 +95,7 @@ public class CoordinateReaderOsmAnd extends CoordinateReader
|
|||
if ( idx11 >= 0 )
|
||||
{
|
||||
n.name = line.substring( idx10, idx11 ).trim();
|
||||
checkAddPoint( n );
|
||||
checkAddPoint( "(one-for-all)", n );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue