Skip to content

Commit

Permalink
Merged down vector maps dev branch. As well as bringing in the mapsfo…
Browse files Browse the repository at this point in the history
…rge vector rendering, also closes #58, closes #51.
  • Loading branch information
jezhiggins committed Jun 3, 2012
2 parents a37bf7d + 1c715ec commit 484f2d4
Show file tree
Hide file tree
Showing 30 changed files with 572 additions and 260 deletions.
6 changes: 4 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="lib" path="libs/slf4j-android-1.5.8.jar"/>
<classpathentry kind="lib" path="libs/apache-mime4j-0.6.jar"/>
<classpathentry kind="lib" path="libs/httpmime-4.0.1.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-map-0.3.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.3.0-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="libs/osmdroid-android-3.0.8.jar"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="libs/osmdroid-android-3.0.6.jar"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.cyclestreets"
android:versionCode="9"
android:versionName="1.3"
android:versionCode="10"
android:versionName="1.4"
android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
13 changes: 12 additions & 1 deletion assets/whatsnew.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
</style>
</head>
<body>
<h3>Release 1.3</h3>
<h3>Release 1.4</h3>
<ul>
<li>On-device Map Rendering!<br/>
<ul>
<li>Download <a href='http://download.mapsforge.org/maps/snapshot/europe/great_britain-0.3.0-SNAPSHOT.map'>this mapfile</a></li>
<li>Go to Settings</li>
<li>Configure <i>Vector Mapfile Location</i> to point to the downloaded file</li>
<li>Set <i>Map style</i> to <i>Offline Vector Maps</i></li>
<li>Enjoy vector mapping goodness</li>
</ul>
</ul>
<h3>Release 1.3</h3>
<ul>
<li>Photomap photos can be shared via Email, Twitter, etc</li>
<li>Various small bug fixes.</li>
</ul>
Expand Down
Binary file added libs/mapsforge-map-0.3.0-SNAPSHOT.jar
Binary file not shown.
Binary file added libs/mapsforge-map-reader-0.3.0-SNAPSHOT.jar
Binary file not shown.
Binary file not shown.
2 changes: 2 additions & 0 deletions res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@
<item>OpenCycleMap (shows hills)</item>
<item>OpenStreetMap default style</item>
<item>Ordnance Survey OpenData</item>
<item>Offline Vector Maps</item>
</string-array>
<string-array name="mapstyle_values">
<item>CycleStreets</item>
<item>CycleStreets-OSM</item>
<item>CycleStreets-OS</item>
<item>CycleStreets-Mapsforge</item>
</string-array>
<string-array name="uploadsize">
<item>Always resize to 640 pixels wide</item>
Expand Down
7 changes: 5 additions & 2 deletions res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@
android:defaultValue="CycleStreets-OSM"
android:entries="@array/mapstyle"
android:entryValues="@array/mapstyle_values" />
<ListPreference
<EditTextPreference
android:key="mapfile"
android:title="Vector Mapfile Location"/>
<ListPreference
android:key="iconsize"
android:title="Icon size"
android:summary="Icon Size"
Expand Down Expand Up @@ -64,7 +67,7 @@
android:key="uploadsize"
android:title="Photo Upload"
android:summary="medium"
android:defaultValue="bigIfWifi"
android:defaultValue="big"
android:entries="@array/uploadsize"
android:entryValues="@array/uploadsize_values"/>
</PreferenceCategory>
Expand Down
27 changes: 26 additions & 1 deletion src/net/cyclestreets/AccountDetailsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.Spanned;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -58,11 +60,16 @@ public void onCreate(final Bundle saved)

final LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);

final InputFilter[] usernameFilters = new InputFilter[]{ new WhitespaceInputFilter() };

registerView_ = inflater.inflate(R.layout.accountdetails, null);
registerDetails_ = inflater.inflate(R.layout.accountregister, null);
textView(registerDetails_, R.id.username).setFilters(usernameFilters);
signinDetails_ = inflater.inflate(R.layout.accountsignin, null);
signinButton_ = (Button)signinDetails_.findViewById(R.id.signin_button);
textView(signinDetails_, R.id.username).addTextChangedListener(this);
TextView usernameTV = textView(signinDetails_, R.id.username);
usernameTV.addTextChangedListener(this);
usernameTV.setFilters(usernameFilters);
textView(signinDetails_, R.id.password).addTextChangedListener(this);
signinButton_.setEnabled(false);

Expand Down Expand Up @@ -355,4 +362,22 @@ protected void onPostExecute(final Registration.Result result)
MessageBox(result.message(), result.ok());
} // onPostExecute
} // class RegisterTask

private class WhitespaceInputFilter implements InputFilter
{
public CharSequence filter(CharSequence source,
int start, int end,
Spanned dest,
int dstart, int dend)
{
StringBuilder sb = new StringBuilder();
for (int i = start; i < end; i++) {
char c = source.charAt(i);
if (!Character.isWhitespace(c)) {
sb.append(c);
}
}
return sb.toString();
} // filter
} // class WhitespaceInputFilter
} // class AccountDetailsActivity
194 changes: 97 additions & 97 deletions src/net/cyclestreets/CycleMapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,124 +21,124 @@

public class CycleMapActivity extends Activity
{
private CycleMapView map_;
private CycleMapView map_;

@Override
public void onCreate(final Bundle saved)
{
super.onCreate(saved);
map_ = new CycleMapView(this, this.getClass().getName());
@Override
public void onCreate(final Bundle saved)
{
super.onCreate(saved);
map_ = new CycleMapView(this, this.getClass().getName());

final RelativeLayout rl = new RelativeLayout(this);
rl.addView(map_, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView(rl);
final RelativeLayout rl = new RelativeLayout(this);
rl.addView(map_, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
setContentView(rl);
} // onCreate
protected CycleMapView mapView() { return map_; }
protected Overlay overlayPushBottom(final Overlay overlay) { return map_.overlayPushBottom(overlay); }
protected Overlay overlayPushTop(final Overlay overlay) { return map_.overlayPushTop(overlay); }

protected CycleMapView mapView() { return map_; }
protected Overlay overlayPushBottom(final Overlay overlay) { return map_.overlayPushBottom(overlay); }
protected Overlay overlayPushTop(final Overlay overlay) { return map_.overlayPushTop(overlay); }

protected void findPlace() { launchFindDialog(); }
protected void findPlace() { launchFindDialog(); }

@Override
protected void onPause()
{
map_.onPause();
super.onPause();
} // onPause
@Override
protected void onPause()
{
map_.onPause();
super.onPause();
} // onPause

@Override
protected void onResume()
{
super.onResume();
map_.onResume();
} // onResume
@Override
protected void onResume()
{
super.onResume();
map_.onResume();
} // onResume

@Override
public boolean onCreateOptionsMenu(final Menu menu)
{
map_.onCreateOptionsMenu(menu);
menu.add(0, R.string.ic_menu_findplace, Menu.NONE, R.string.ic_menu_findplace).setIcon(R.drawable.ic_menu_search);
menu.add(0, R.string.ic_menu_settings, 99, R.string.ic_menu_settings).setIcon(R.drawable.ic_menu_settings);
return true;
} // onCreateOptionsMenu
@Override
public boolean onCreateOptionsMenu(final Menu menu)
{
map_.onCreateOptionsMenu(menu);
menu.add(0, R.string.ic_menu_findplace, Menu.NONE, R.string.ic_menu_findplace).setIcon(R.drawable.ic_menu_search);
menu.add(0, R.string.ic_menu_settings, 99, R.string.ic_menu_settings).setIcon(R.drawable.ic_menu_settings);
return true;
} // onCreateOptionsMenu

@Override
public boolean onPrepareOptionsMenu(final Menu menu)
{
map_.onPrepareOptionsMenu(menu);
return true;
@Override
public boolean onPrepareOptionsMenu(final Menu menu)
{
map_.onPrepareOptionsMenu(menu);
return true;
} // onPrepareOptionsMenu

@Override
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
@Override
public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
} // onCreateContextMenu

@Override
public boolean onMenuItemSelected(final int featureId, final MenuItem item)
{
if(map_.onMenuItemSelected(featureId, item))
return true;
@Override
public boolean onMenuItemSelected(final int featureId, final MenuItem item)
{
if(map_.onMenuItemSelected(featureId, item))
return true;

if(item.getItemId() == R.string.ic_menu_findplace)
{
launchFindDialog();
return true;
} // if ...
if(item.getItemId() == R.string.ic_menu_findplace)
{
launchFindDialog();
return true;
} // if ...

if(item.getItemId() == R.string.ic_menu_settings)
{
startActivity(new Intent(this, SettingsActivity.class));
return true;
} // if ...

return false;
} // onMenuItemSelected

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

if(resultCode != RESULT_OK)
return;

if(requestCode != R.string.ic_menu_findplace)
return;

final GeoPoint place = GeoIntent.getGeoPoint(data);
// we're in the wrong thread, so pop this away for later and force a refresh
map_.centreOn(place);
} // onActivityResult
if(item.getItemId() == R.string.ic_menu_settings)
{
startActivity(new Intent(this, SettingsActivity.class));
return true;
} // if ...

return false;
} // onMenuItemSelected

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);

if(resultCode != RESULT_OK)
return;

private void launchFindDialog()
{
final Intent intent = new Intent(this, FindPlaceActivity.class);
GeoIntent.setBoundingBox(intent, map_.getBoundingBox());
startActivityForResult(intent, R.string.ic_menu_findplace);
} // launchFindDialog
if(requestCode != R.string.ic_menu_findplace)
return;

final GeoPoint place = GeoIntent.getGeoPoint(data);
// we're in the wrong thread, so pop this away for later and force a refresh
map_.centreOn(place);
} // onActivityResult

private void launchFindDialog()
{
final Intent intent = new Intent(this, FindPlaceActivity.class);
GeoIntent.setBoundingBox(intent, map_.getBoundingBox());
startActivityForResult(intent, R.string.ic_menu_findplace);
} // launchFindDialog

@Override
public boolean onTrackballEvent(MotionEvent event)
{
return map_.onTrackballEvent(event);
} // onTrackballEvent
@Override
public boolean onTrackballEvent(MotionEvent event)
{
return map_.onTrackballEvent(event);
} // onTrackballEvent

@Override
public boolean onTouchEvent(MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_MOVE)
map_.disableFollowLocation();
return super.onTouchEvent(event);
} // onTouchEvent
@Override
public boolean onTouchEvent(MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_MOVE)
map_.disableFollowLocation();
return super.onTouchEvent(event);
} // onTouchEvent

@Override
public void onBackPressed()
{
if(!map_.onBackPressed())
super.onBackPressed();
} // onBackPressed
} // onBackPressed
} // class MapActivity
6 changes: 6 additions & 0 deletions src/net/cyclestreets/CycleStreetsPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.content.SharedPreferences.Editor;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Environment;
import android.preference.PreferenceManager;
import android.telephony.TelephonyManager;

Expand All @@ -15,6 +16,7 @@ public class CycleStreetsPreferences
public final static String PREF_UNITS_KEY = "units";
public final static String PREF_SPEED_KEY = "speed";
public final static String PREF_MAPSTYLE_KEY = "mapstyle";
public final static String PREF_MAPFILE_KEY = "mapfile";
public final static String PREF_CONFIRM_NEW_ROUTE = "confirm-new-route";
public final static String PREF_USERNAME_KEY = "username";
public final static String PREF_PASSWORD_KEY = "password";
Expand Down Expand Up @@ -55,6 +57,10 @@ static public String mapstyle() {
return getString(PREF_MAPSTYLE_KEY, "CycleMap");
}

static public String mapfile() {
return getString(PREF_MAPFILE_KEY, Environment.getExternalStorageDirectory() + "/download/great_britain-0.3.0.map");
}

static public int iconSize() {
return Integer.parseInt(getString(PREF_ICON_SIZE, "20"));
}
Expand Down
10 changes: 5 additions & 5 deletions src/net/cyclestreets/PhotomapActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

public class PhotomapActivity extends CycleMapActivity
{
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);

overlayPushBottom(new PhotosOverlay(this, mapView()));
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
overlayPushBottom(new PhotosOverlay(this, mapView()));
} // onCreate

} // PhotomapActivity
Loading

0 comments on commit 484f2d4

Please sign in to comment.