Update buttons, add streets to info about route, update layout

This commit is contained in:
Victor Shcherb 2013-05-17 23:54:44 +02:00
parent 701393f001
commit a47d81ada7
15 changed files with 63 additions and 102 deletions

View file

@ -183,9 +183,6 @@ public class NativeLibrary {
RenderingRuleSearchRequest request, boolean skipDuplicates, int renderRouteDataFile, Object objectWithInterruptedField,
String msgIfNothingFound);
public static native void testRoutingPing();
public static native int testNativeRouting(String obfPath, double sLat, double sLon, double eLat, double eLon);
/**/
// Empty native impl

View file

@ -19,8 +19,6 @@ import org.xmlpull.v1.XmlPullParserException;
*/
public class PlatformUtil {
public static boolean AVIAN_LIBRARY = false;
public static Log getLog(Class<?> cl){
return LogFactory.getLog(cl);
}
@ -30,33 +28,6 @@ public class PlatformUtil {
}
// AVIAN missing dependency
/*public static net.osmand.Collator primaryCollator(){
return new net.osmand.Collator() {
@Override
public int compare(Object o1, Object o2) {
return compare(o1+"", o2+"");
}
@Override
public boolean equals(String source, String target) {
if(source == null) {
return source == target;
}
return source.equals(target);
}
@Override
public int compare(String source, String target) {
if(source == null) {
return source == target ? 0 : -1;
}
return source.compareTo(target);
}
};
}*/
public static net.osmand.Collator primaryCollator() {
// romanian locale encounters diacritics as differnet symbols
final java.text.Collator instance = Locale.getDefault().getLanguage().equals("ro") ? java.text.Collator.getInstance(Locale.US)

View file

@ -216,7 +216,8 @@ public class RouteCalculationResult {
info.setDestinationName(next.getObject().getDestinationName());
}
String description = toString(turn, ctx);
String description = toString(turn, ctx) + " " + RoutingHelper.formatStreetName(info.getStreetName(),
info.getRef(), info.getDestinationName());
info.setDescriptionRoute(description);
info.routePointOffset = prevLocationSize;
if(directions.size() > 0 && prevDirectionTime > 0 && prevDirectionDistance > 0) {

View file

@ -313,18 +313,8 @@ public class RouteProvider {
return new RouteCalculationResult(res, null, params.start, params.end, null, null,
params.ctx, params.leftSide, true);
}
protected RouteCalculationResult findNewVectorMapsRoute(RouteCalculationParams params) throws IOException {
String path = params.ctx.getAppPath("").getAbsolutePath();
NativeLibrary.testNativeRouting(path, params.start.getLatitude(),
params.start.getLongitude(), params.end.getLatitude(),
params.end.getLongitude());
return new RouteCalculationResult("Done ");
}
protected RouteCalculationResult findVectorMapsRoute(RouteCalculationParams params) throws IOException {
if(PlatformUtil.AVIAN_LIBRARY) {
return findNewVectorMapsRoute(params);
}
BinaryMapIndexReader[] files = params.ctx.getTodoAPI().getRoutingMapFiles();
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(!params.preciseRouting);
OsmandSettings settings = params.ctx.getSettings();

View file

@ -601,6 +601,9 @@ public class RoutingHelper {
}
return name;
} else {
if(ref == null) {
return "";
}
return ref;
}
}

View file

@ -9,6 +9,14 @@
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.wifi" android:required="false"/>
<uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.light" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.compass" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="false"/>
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
@ -19,6 +27,8 @@
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
<uses-permission android:name="android.permission.RECORD_AUDIO"></uses-permission>
<supports-screens android:resizeable="true" android:smallScreens="true" android:normalScreens="true" android:largeScreens="true"
android:xlargeScreens="true" android:anyDensity="true" />
<!-- android:theme="@style/OsmandLightDarkActionBarTheme" -->
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true" android:name="net.osmand.plus.OsmandApplication" android:configChanges="locale"

View file

@ -5,10 +5,4 @@
android:layout_height="fill_parent" android:keepScreenOn="true">
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
<LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content" android:layout_gravity="bottom|center" android:layout_marginBottom="12dp">
<Button android:contentDescription="@string/previous_button" android:layout_width="wrap_content" android:id="@+id/PreviousButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_previous"/>
<Button android:contentDescription="@string/info_button" android:layout_width="wrap_content" android:id="@+id/InfoButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_dialog_info" android:layout_marginLeft="12dp"/>
<Button android:contentDescription="@string/next_button" android:layout_width="wrap_content" android:id="@+id/NextButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_next" android:layout_marginLeft="12dp" android:layout_marginRight="15dp"/>
</LinearLayout>
</FrameLayout>

View file

@ -5,15 +5,5 @@
android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false">
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
<LinearLayout android:layout_width="wrap_content" android:id="@+id/RouteLayout" android:orientation="horizontal" android:layout_height="wrap_content"
android:layout_marginBottom="12dp" android:layout_gravity="bottom|center" >
<Button android:layout_width="wrap_content" android:id="@+id/PreviousButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_previous"
android:contentDescription="@string/previous_button"/>
<Button android:layout_width="wrap_content" android:id="@+id/InfoButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_dialog_info"
android:contentDescription="@string/info_button" android:layout_marginLeft="8dp"/>
<Button android:layout_width="wrap_content" android:id="@+id/NextButton" android:layout_height="wrap_content" android:background="@android:drawable/ic_media_next"
android:contentDescription="@string/next_button" android:layout_marginLeft="8dp" android:layout_marginRight="55dp" />
</LinearLayout>
</FrameLayout>

View file

@ -9,7 +9,9 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="cancel_route">Dismiss route</string>
<string name="cancel_navigation">Stop navigation</string>
<string name="clear_destination">Clear destination</string>
<string name="download_using_mobile_internet">Currently WiFi is not connected. Do you want to continue downloading with current internet connection?</string>
<string name="street_name">Street</string>
<string name="hno">House number</string>
@ -1202,7 +1204,6 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="voice_data_not_supported">Unsupported version of voice data</string>
<string name="voice_data_corrupted">Specified voice data is corrupted</string>
<string name="voice_data_unavailable">Selected voice data is not available</string>
<string name="stop_routing">Stop navigtn.</string>
<string name="sd_unmounted">SD card is not accessible.\nYou won\'t be able to see maps or find things.</string>
<string name="sd_mounted_ro">SD card is read-only.\nYou can only see the preloaded map and can\'t download from the Internet.</string>
<string name="unzipping_file">Unzipping file&#8230;</string>
@ -1353,7 +1354,7 @@ Afghanistan, Albania, Algeria, Andorra, Angola, Anguilla, Antigua and Barbuda, A
<string name="ChooseCountry">Choose country</string>
<string name="map_specify_point">Set as destination</string>
<string name="show_view_angle">Display viewing direction</string>
<string name="stop_navigation">Clear destin.</string>
<string name="navigate_to_point">Set as dest.</string>
<string name="map_view_3d_descr">Enable 3D view of the map</string>
<string name="map_view_3d">Map View 3D</string>

View file

@ -306,7 +306,7 @@ public class MainMenuActivity extends Activity {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(MainMenuActivity.this, DownloadIndexActivity.class));
startActivity(new Intent(MainMenuActivity.this, OsmandIntents.getDownloadIndexActivity()));
}
});

View file

@ -1063,8 +1063,14 @@ public class MapActivityActions implements DialogProvider {
}
});
if (mapActivity.getPointToNavigate() != null) {
int nav = (routingHelper.isRouteCalculated() || routingHelper.isFollowingMode() || routingHelper.isRouteBeingCalculated()) ?
R.string.stop_routing : R.string.stop_navigation;
int nav;
if(routingHelper.isFollowingMode()) {
nav = R.string.cancel_navigation;
} else if(routingHelper.isRouteCalculated() || routingHelper.isRouteBeingCalculated()) {
nav = R.string.cancel_route;
} else {
nav = R.string.clear_destination;
}
optionsMenuHelper.registerItem(nav,
light ? R.drawable.a_1_navigation_cancel_light : R.drawable.a_1_navigation_cancel_dark,
new OnContextMenuClick() {

View file

@ -6,7 +6,6 @@ import java.io.File;
import net.osmand.IndexConstants;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
@ -27,12 +26,6 @@ public class SettingsActivity extends SettingsBaseActivity {
private Preference general;
private Preference routing;
// FIXME
public ProgressDialog progressDlg;
public static CharSequence SCREEN_ID_GENERAL_SETTINGS;
public static CharSequence SCREEN_ID_NAVIGATION_SETTINGS;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -53,7 +46,6 @@ public class SettingsActivity extends SettingsBaseActivity {
Intent intent = getIntent();
if(intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0){
int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
String pref = null;
if(s == SCREEN_GENERAL_SETTINGS){
startActivity(new Intent(this, SettingsGeneralActivity.class));
} else if(s == SCREEN_NAVIGATION_SETTINGS){

View file

@ -16,12 +16,7 @@ import net.osmand.plus.R;
import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.TurnPathHelper;
import android.graphics.Color;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
@ -51,25 +46,8 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
ListView lv = new ListView(this);
lv.setId(android.R.id.list);
header = new TextView(this);
TextView linkSaveAs = new TextView(this);
helper = ((OsmandApplication)getApplication()).getRoutingHelper();
lv.addHeaderView(header);
final CharSequence link = getText(R.string.save_route_as_gpx);
SpannableString content = new SpannableString(link);
content.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
}
@Override
public void updateDrawState(TextPaint ds) {
super.updateDrawState(ds);
ds.setColor(Color.GREEN);
}
}, 0, link.length(), 0);
linkSaveAs.setText(content);
linkSaveAs.setMovementMethod(LinkMovementMethod.getInstance());
setContentView(lv);
dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
@ -144,7 +122,8 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
ImageView icon = (ImageView) row.findViewById(R.id.direction);
if(!(icon.getDrawable() instanceof TurnPathHelper.RouteDrawable)){
icon.setImageDrawable(new TurnPathHelper.RouteDrawable(getResources()));
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources());
icon.setImageDrawable(drawable);
}
((TurnPathHelper.RouteDrawable) icon.getDrawable()).setRouteType(model.getTurnType());
distanceLabel.setText(OsmAndFormatter.getFormattedDistance(model.distance, getMyApplication()));

View file

@ -14,9 +14,13 @@ import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.RectF;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;
@ -35,12 +39,9 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
public RouteInfoLayer(RoutingHelper routingHelper, MapActivity activity, ContextMenuLayer contextMenu){
final LinearLayout layout = (LinearLayout) activity.findViewById(R.id.RouteLayout);
createLayout(activity);
this.routingHelper = routingHelper;
this.contextMenu = contextMenu;
prev = (Button) layout.findViewById(R.id.PreviousButton);
next = (Button) layout.findViewById(R.id.NextButton);
info = (Button) layout.findViewById(R.id.InfoButton);
routingHelper.addListener(this);
attachListeners();
updateVisibility();
@ -50,6 +51,30 @@ public class RouteInfoLayer extends OsmandMapLayer implements IRouteInformationL
activity.accessibleContent.add(info);
}
private void createLayout(MapActivity activity) {
FrameLayout fl = (FrameLayout) activity.getMapView().getParent();
LinearLayout ll = new LinearLayout(activity);
ll.setOrientation(LinearLayout.HORIZONTAL);
DisplayMetrics dm = activity.getResources().getDisplayMetrics();
ll.setPadding(0, 0, (int) (dm.density * 15), (int) (dm.density * 50));
fl.addView(ll, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER));
prev = new Button(activity);
prev.setContentDescription(activity.getString(R.string.previous_button));
prev.setCompoundDrawables(activity.getResources().getDrawable(R.drawable.a_1_navigation_previous_item_light), null, null, null);
ll.addView(prev);
info = new Button(activity);
info.setContentDescription(activity.getString(R.string.info_button));
info.setPadding((int) (dm.density * 8), 0, 0, 0);
info.setCompoundDrawables(activity.getResources().getDrawable(R.drawable.a_2_action_about_light), null, null, null);
ll.addView(info);
next = new Button(activity);
next.setContentDescription(activity.getString(R.string.next_button));
next.setPadding((int) (dm.density * 8), 0, 0, 0);
next.setBackground(activity.getResources().getDrawable(R.drawable.a_1_navigation_next_item_light));
next.setCompoundDrawables(activity.getResources().getDrawable(R.drawable.a_1_navigation_next_item_light), null, null, null);
ll.addView(next);
}
@Override
public void initLayer(OsmandMapTileView view) {
this.view = view;

View file

@ -238,19 +238,21 @@ public class TurnPathHelper {
public RouteDrawable(Resources resources){
paintRouteDirection = new Paint();
paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow));
paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant));
paintRouteDirection.setAntiAlias(true);
TurnPathHelper.calcTurnPath(dp, TurnType.valueOf(TurnType.KL, false), null);
}
@Override
protected void onBoundsChange(Rect bounds) {
Matrix m = new Matrix();
m.setScale(bounds.width()/72f, bounds.height()/72f);
m.setScale(bounds.width() / 72f, bounds.height() / 72f);
p.transform(m, dp);
}
public void setRouteType(TurnType t){
TurnPathHelper.calcTurnPath(p, t, null);
System.out.println("Draw " + getBounds().toShortString() + " " );
onBoundsChange(getBounds());
}