1.0 preparations

This commit is contained in:
Arndt 2014-07-13 16:19:44 +02:00
parent e13d1ad468
commit fb4bf8e0cd
9 changed files with 169 additions and 27 deletions

View file

@ -3,7 +3,13 @@ package btools.routingapp;
public class BInstallerSizes {
public static int[] rd5_sizes = {
public static int getRd5Size( int idx )
{
int i = rd5_sizes[idx];
return (3*i)/4;
}
private static int[] rd5_sizes = {
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,73999,0,0,
@ -223,6 +229,12 @@ public class BInstallerSizes {
0,0,0,0,0,0,0,0,0,0,0,0,
};
public static int getCd5Size( int idx )
{
int i = cd5_sizes[idx];
return (3*i)/4;
}
public static int[] cd5_sizes = {
0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,70091,0,0,

View file

@ -39,6 +39,10 @@ public class BInstallerView extends View
9, 8, 9, 8,
12, 12, 12, 12 };
private int imgwOrig;
private int imghOrig;
private float scaleOrig;
private int imgw;
private int imgh;
@ -132,7 +136,7 @@ public class BInstallerView extends View
boolean isCd5 = (mask == 2);
if ( ( s & mask ) != 0 && ( s & (mask*4)) == 0 )
{
int tilesize = isCd5 ? BInstallerSizes.cd5_sizes[tidx] : BInstallerSizes.rd5_sizes[tidx];
int tilesize = isCd5 ? BInstallerSizes.getCd5Size(tidx) : BInstallerSizes.getRd5Size(tidx);
if ( tilesize > 0 && tilesize < min_size )
{
tidx_min = tidx;
@ -229,6 +233,7 @@ public class BInstallerView extends View
}
private Matrix mat;
private Matrix matText;
public void startInstaller() {
@ -249,8 +254,8 @@ public class BInstallerView extends View
tileStatus = new int[72*36];
scanExistingFiles();
float scaleX = imgw / ((float)bmp.getWidth());
float scaley = imgh / ((float)bmp.getHeight());
float scaleX = imgwOrig / ((float)bmp.getWidth());
float scaley = imghOrig / ((float)bmp.getHeight());
viewscale = scaleX < scaley ? scaleX : scaley;
@ -270,8 +275,17 @@ public class BInstallerView extends View
DisplayMetrics metrics = new DisplayMetrics();
((Activity)getContext()).getWindowManager().getDefaultDisplay().getMetrics(metrics);
imgw = metrics.widthPixels;
imgh = metrics.heightPixels;
imgwOrig = metrics.widthPixels;
imghOrig = metrics.heightPixels;
int im = imgwOrig > imghOrig ? imgwOrig : imghOrig;
scaleOrig = im / 480.f;
matText = new Matrix();
matText.preScale( scaleOrig, scaleOrig );
imgw = (int)(imgwOrig / scaleOrig);
imgh = (int)(imghOrig / scaleOrig);
}
@Override
@ -328,7 +342,7 @@ public class BInstallerView extends View
pnt_2.setStrokeWidth(2);
drawSelectedTiles( canvas, pnt_2, fw, fh, MASK_SELECTED_RD5, MASK_SELECTED_CD5, true, drawGrid );
canvas.setMatrix( null );
canvas.setMatrix( matText );
Paint paint = new Paint();
paint.setColor(Color.RED);
@ -388,13 +402,13 @@ float tx, ty;
boolean isCd5 = (tileStatus[tidx] & maskCd5) != 0;
if ( isRd5 || isCd5 )
{
int tilesize = BInstallerSizes.rd5_sizes[tidx];
int tilesize = BInstallerSizes.getRd5Size(tidx);
if ( tilesize > 0 )
{
if ( doCount )
{
if ( isRd5) { rd5Tiles++; totalSize += BInstallerSizes.rd5_sizes[tidx]; };
if ( isCd5) { cd5Tiles++; totalSize += BInstallerSizes.cd5_sizes[tidx]; };
if ( isRd5) { rd5Tiles++; totalSize += BInstallerSizes.getRd5Size(tidx); };
if ( isCd5) { cd5Tiles++; totalSize += BInstallerSizes.getCd5Size(tidx); };
}
if ( !doDraw ) continue;
if ( isRd5 ) canvas.drawLine( fw*ix, fh*iy, fw*(ix+1), fh*(iy+1), pnt);
@ -499,7 +513,7 @@ float tx, ty;
}
// download button?
if ( rd5Tiles + cd5Tiles > 0 && event.getX() > imgh - btnh && event.getY() > imgh-btnh )
if ( rd5Tiles + cd5Tiles > 0 && event.getX() > imgwOrig - btnw*scaleOrig && event.getY() > imghOrig-btnh*scaleOrig )
{
toggleDownload();
invalidate();

View file

@ -35,6 +35,7 @@ public class BRouterActivity extends Activity implements OnInitListener {
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;
@ -106,6 +107,21 @@ public class BRouterActivity extends Activity implements OnInitListener {
}
});
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 );
@ -319,7 +335,14 @@ public class BRouterActivity extends Activity implements OnInitListener {
@SuppressWarnings("deprecation")
public void startDownloadManager()
{
showDialog( DIALOG_SHOW_DM_INFO_ID );
if ( !mBRouterView.hasUpToDateLookups() )
{
showDialog( DIALOG_OLDDATAHINT_ID );
}
else
{
showDialog( DIALOG_SHOW_DM_INFO_ID );
}
}
@SuppressWarnings("deprecation")

View file

@ -191,12 +191,6 @@ public class BRouterView extends View
if ( fileName.endsWith( ".cd5" ) ) segmentFound = true;
}
}
if ( !segmentFound )
{
((BRouterActivity)getContext()).startDownloadManager();
waitingForSelection = true;
return;
}
fileNames = new File( profileDir ).list();
ArrayList<String> profiles = new ArrayList<String>();
@ -222,6 +216,12 @@ public class BRouterView extends View
+ " contains no routing profiles (*.brf)."
+ " see www.dr-brenschede.de/brouter for setup instructions." );
}
if ( !segmentFound )
{
((BRouterActivity)getContext()).startDownloadManager();
waitingForSelection = true;
return;
}
((BRouterActivity)getContext()).selectProfile( profiles.toArray( new String[0]) );
}
catch( Exception e )
@ -234,6 +234,13 @@ public class BRouterView extends View
waitingForSelection = true;
}
public boolean hasUpToDateLookups()
{
BExpressionMetaData meta = new BExpressionMetaData();
meta.readMetaData( new File( profileDir, "lookups.dat" ) );
return meta.lookupVersion == 10;
}
public void continueProcessing()
{
waitingForSelection = false;