Fix issues

This commit is contained in:
Victor Shcherb 2015-03-25 20:23:25 +01:00
parent c4b91b2333
commit b5b8af3db6
14 changed files with 162 additions and 105 deletions

View file

@ -2,27 +2,51 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical" >
<LinearLayout
android:id="@+id/TopBar"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:gravity="center_horizontal" />
android:gravity="center_horizontal"
android:orientation="horizontal" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="horizontal" >
<ImageView
android:id="@+id/avoid_roads"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/ic_action_road_works_dark" />
<ImageView
android:id="@+id/mute"
android:layout_width="@dimen/dashListItemHeight"
android:layout_height="@dimen/dashListItemHeight"
android:background="@drawable/dashboard_button_light"
android:scaleType="center"
android:src="@drawable/a_10_device_access_volume_muted_dark" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp">
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:text="@string/gpx_navigation"
android:textSize="18sp"></TextView>
android:textSize="18sp" >
</TextView>
<Spinner
android:id="@+id/GPXRouteSpinner"
@ -30,13 +54,15 @@
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:textSize="18sp"></Spinner>
android:textSize="18sp" >
</Spinner>
</LinearLayout>
<ListView
android:id="@android:id/list"
android:layout_marginTop="5dp"
android:layout_width="fill_parent"
android:layout_height="fill_parent"></ListView>
android:layout_height="fill_parent"
android:layout_marginTop="5dp" >
</ListView>
</LinearLayout>

View file

@ -13,6 +13,8 @@
<ImageButton
android:id="@+id/start_navigation"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_width="@dimen/list_item_height"
android:layout_height="@dimen/list_item_height"
android:background="?attr/options_button_background"

View file

@ -64,6 +64,8 @@
android:id="@+id/description"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"
tools:text="@string/lorem_ipsum"
android:text=""/>

View file

@ -34,10 +34,7 @@ import net.osmand.plus.activities.actions.OsmAndDialogs;
import net.osmand.plus.activities.actions.ShareLocation;
import net.osmand.plus.activities.search.SearchActivity;
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.FavoriteDialogs;
import net.osmand.plus.helpers.WaypointDialogHelper;
import net.osmand.plus.osmo.OsMoPositionLayer;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.BaseMapLayer;
@ -56,7 +53,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
@ -547,40 +543,23 @@ public class MapActivityActions implements DialogProvider {
final OsmandMapTileView mapView = mapActivity.getMapView();
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
// 2-4. Navigation related (directions, mute, cancel navigation)
boolean muteVisible = routingHelper.getFinalLocation() != null && routingHelper.isFollowingMode();
// TODO delete
if (muteVisible) {
boolean mute = routingHelper.getVoiceRouter().isMute();
int t = mute ? R.string.menu_mute_on : R.string.menu_mute_off;
int icon;
if(mute) {
icon = R.drawable.a_10_device_access_volume_muted_dark;
} else{
icon = R.drawable.a_10_device_access_volume_on_dark;
}
optionsMenuHelper.item(t).iconColor(icon)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
return true;
}
}).reg();
}
// TODO delete
if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
optionsMenuHelper.item(R.string.get_directions)
.iconColor(R.drawable.ic_action_gdirections_dark)
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
if (!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
enterRoutePlanningMode(null, null, false);
return true;
} else {
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
mapActivity.refreshMap();
}
return true;
}
}).reg();
} else if(routingHelper.isRouteCalculated()) {
// TODO Pause/continue
if(routingHelper.isRouteCalculated()) {
optionsMenuHelper.item(
routingHelper.isRoutePlanningMode() ? R.string.continue_navigation :
R.string.pause_navigation)
@ -602,6 +581,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
}
// TODO stop navigation / delete point
if (mapActivity.getPointToNavigate() != null) {
int nav;
if(routingHelper.isFollowingMode()) {
@ -616,14 +596,12 @@ public class MapActivityActions implements DialogProvider {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
stopNavigationActionConfirm(mapView);
OsMoPositionLayer osMoPositionLayer = mapActivity.getMapView().getLayerByClass(OsMoPositionLayer.class);
if (osMoPositionLayer != null) {
OsMoPositionLayer.setFollowDestination(null);
}
return true;
}
}).reg();
}
optionsMenuHelper.item(R.string.target_points).iconColor(R.drawable.ic_action_flage_dark)
.listen(new OnContextMenuClick() {
@Override
@ -632,19 +610,6 @@ public class MapActivityActions implements DialogProvider {
return false;
}
}).reg();
// TODO delete
if(routingHelper.isRouteCalculated()) {
optionsMenuHelper.item(R.string.impassable_road)
.iconColor(R.drawable.ic_action_road_works_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
app.getAvoidSpecificRoads().showDialog(mapActivity);
return true;
}
}).reg();
}
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.item(R.string.search_button)
.iconColor(R.drawable.ic_action_search_dark)

View file

@ -67,6 +67,9 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
View headerView = getLayoutInflater().inflate(R.layout.route_details_header, null);
header = (TextView) headerView.findViewById(R.id.header);
helper = ((OsmandApplication)getApplication()).getRoutingHelper();
((ImageView)
headerView.findViewById(R.id.start_navigation)).setImageDrawable(
getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_start_navigation, R.color.color_myloc_distance));
headerView.findViewById(R.id.start_navigation).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {

View file

@ -160,11 +160,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private void updateListBackgroundHeight() {
if (listBackgroundView == null || listBackgroundView.getHeight() > 0) {
return;
}
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
if(contentView.getHeight() > 0) {
if(listBackgroundView != null) {
listBackgroundView.getLayoutParams().height = contentView.getHeight();
}
if (contentView.getHeight() > 0) {
listBackgroundView.getLayoutParams().height = contentView.getHeight();
} else {
contentView.post(new Runnable() {
@Override
@ -172,9 +173,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
// mListBackgroundView's should fill its parent vertically
// but the height of the content view is 0 on 'onCreate'.
// So we should get it with post().
if (listBackgroundView != null) {
listBackgroundView.getLayoutParams().height = contentView.getHeight();
}
listBackgroundView.getLayoutParams().height = contentView.getHeight();
}
});
}
@ -215,7 +214,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
});
if (waypointsVisible) {
if (waypointsVisible && getMyApplication().getWaypointHelper().getAllPoints().size() > 0) {
edit.setVisibility(View.VISIBLE);
edit.setOnClickListener(new View.OnClickListener() {
@ -224,19 +223,20 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
setDashboardVisibility(true, DashboardType.WAYPOINTS_EDIT);
}
});
// TODO conditional
flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
flat.setImageDrawable(iconsCache.getActionBarIcon(flatNow ?
R.drawable.ic_tree_list_dark : R.drawable.ic_flat_list_dark));
flat.setOnClickListener(new View.OnClickListener() {
if (getMyApplication().getWaypointHelper().isRouteCalculated()) {
flat.setVisibility(View.VISIBLE);
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
flat.setImageDrawable(iconsCache.getActionBarIcon(flatNow ? R.drawable.ic_tree_list_dark
: R.drawable.ic_flat_list_dark));
flat.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS :
DashboardType.WAYPOINTS_FLAT);
}
});
@Override
public void onClick(View v) {
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS : DashboardType.WAYPOINTS_FLAT,
previousVisibleType);
}
});
}
}
if(waypointsEdit) {
ok.setVisibility(View.VISIBLE);
@ -282,9 +282,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
@Override
public void onClick(View v) {
if (visibleType == DashboardType.DASHBOARD) {
setDashboardVisibility(true, DashboardType.LIST_MENU);
setDashboardVisibility(true, DashboardType.LIST_MENU, null);
} else {
setDashboardVisibility(true, DashboardType.DASHBOARD);
setDashboardVisibility(true, DashboardType.DASHBOARD, null);
}
}
});
@ -360,10 +360,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
public void setDashboardVisibility(boolean visible, DashboardType type) {
setDashboardVisibility(visible, type, this.visible ? visibleType : null);
}
public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem) {
if(visible == this.visible && type == visibleType) {
return;
}
this.previousVisibleType = this.visible ? visibleType : null;
this.previousVisibleType = prevItem;
this.visible = visible;
boolean refresh = this.visibleType == type;
this.visibleType = type;

View file

@ -36,13 +36,20 @@ public class AvoidSpecificRoads {
this.app = app;
}
public List<RouteDataObject> getMissingRoads() {
if(missingRoads == null) {
missingRoads = app.getDefaultRoutingConfig().getImpassableRoads();
}
return missingRoads;
}
protected net.osmand.router.RoutingConfiguration.Builder getBuilder() {
return RoutingConfiguration.getDefault();
}
public ArrayAdapter<RouteDataObject> createAdapter(final MapActivity ctx) {
final ArrayList<RouteDataObject> points = new ArrayList<RouteDataObject>();
points.addAll(missingRoads);
points.addAll(getMissingRoads());
final LatLon mapLocation = ctx.getMapLocation();
return new ArrayAdapter<RouteDataObject>(ctx,
R.layout.waypoint_reached, R.id.title, points) {
@ -95,7 +102,7 @@ public class AvoidSpecificRoads {
public void showDialog(final MapActivity mapActivity) {
Builder bld = new AlertDialog.Builder(mapActivity);
bld.setTitle(R.string.impassable_road);
if (missingRoads.size() == 0){
if (getMissingRoads().size() == 0){
bld.setMessage(R.string.avoid_roads_msg);
} else {
final ArrayAdapter<?> listAdapter = createAdapter(mapActivity);
@ -182,11 +189,4 @@ public class AvoidSpecificRoads {
dialog.dismiss();
}
public List<RouteDataObject> getMissingRoads() {
if(missingRoads == null) {
missingRoads = app.getDefaultRoutingConfig().getImpassableRoads();
}
return missingRoads;
}
}

View file

@ -60,7 +60,6 @@ import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.access.AccessibleToast;
@ -69,6 +68,7 @@ import net.osmand.data.PointDescription;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmAndConstants;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener;
import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
import net.osmand.plus.OsmandApplication;
@ -516,7 +516,10 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
if (item.getItemId() == TRACK_DEV_ID) {
if (device != null) {
if (device != null && device.getLastLocation() != null) {
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
targets.navigateToPoint(new LatLon(device.getLastLocation().getLatitude(), device
.getLastLocation().getLongitude()), true, -1);
OsMoPositionLayer.setFollowDestination(device);
MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this);
}

View file

@ -240,7 +240,9 @@ public class MapControlsLayer extends OsmandMapLayer {
});
TextView routeGoButton = (TextView) mapActivity.findViewById(R.id.map_go_route_button);
routeGoControl = createHudButton(routeGoButton, R.drawable.ic_destination_arrow_white).setBg(
routeGoControl = createHudButton(routeGoButton,
R.drawable.ic_action_start_navigation).setIconColorId(R.color.color_myloc_distance) .setBg(
R.drawable.btn_flat, R.drawable.btn_flat_night);
controls.add(routeGoControl);
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go).toUpperCase());

View file

@ -182,7 +182,7 @@ public class MapInfoLayer extends OsmandMapLayer {
for (MapWidgetRegInfo reg : mapInfoControls.getRight()) {
updateReg(ts, reg);
}
updateStreetName(ts);
updateStreetName(nightMode, ts);
lanesControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
rulerControl.updateTextSize(nightMode, ts.textColor, ts.textShadowColor, ts.textShadowRadius);
this.expand.setBackgroundResource(ts.expand);
@ -191,10 +191,10 @@ public class MapInfoLayer extends OsmandMapLayer {
}
}
private void updateStreetName(TextState ts) {
private void updateStreetName(boolean nightMode, TextState ts) {
streetNameView.setBackgroundResource(ScreenOrientationHelper.isOrientationPortrait(map) ? ts.boxTop
: ts.boxFree);
streetNameView.updateTextColor(ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
streetNameView.updateTextColor(nightMode, ts.textColor, ts.textShadowColor, ts.textBold, ts.textShadowRadius);
}
private void updateReg(TextState ts, MapWidgetRegInfo reg) {

View file

@ -11,6 +11,7 @@ import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference;
@ -24,6 +25,7 @@ import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.GeneralRouter;
import net.osmand.router.GeneralRouter.RoutingParameter;
import net.osmand.router.GeneralRouter.RoutingParameterType;
@ -42,6 +44,7 @@ import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;
import android.widget.Spinner;
@ -258,6 +261,14 @@ public class MapRoutePreferencesControl {
final ListView lv = (ListView) settingsDlg.findViewById(android.R.id.list);
final Set<ApplicationMode> selected = new HashSet<ApplicationMode>();
selected.add(am);
ImageView muteBtn = (ImageView) settingsDlg.findViewById(R.id.mute);
setMuteBtn(muteBtn);
ImageView avoidRoads = (ImageView) settingsDlg.findViewById(R.id.avoid_roads);
setAvoidRoads(avoidRoads);
setupSpinner(settingsDlg);
final float scaleCoefficient = mapActivity.getMapView().getScaleCoefficient();
@ -315,6 +326,41 @@ public class MapRoutePreferencesControl {
return settingsDlg;
}
private void setAvoidRoads(ImageView avoidRoads) {
avoidRoads.setContentDescription(mapActivity.getString(R.string.impassable_road));
avoidRoads.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(R.drawable.ic_action_road_works_dark
, R.color.icon_color_light));
avoidRoads.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mapActivity.getMyApplication().getAvoidSpecificRoads().showDialog(mapActivity);
}
});
}
private void setMuteBtn(final ImageView muteBtn) {
final RoutingHelper routingHelper = mapActivity.getMyApplication().getRoutingHelper();
boolean mute = routingHelper.getVoiceRouter().isMute();
int t = mute ? R.string.menu_mute_on : R.string.menu_mute_off;
int icon;
if(mute) {
icon = R.drawable.a_10_device_access_volume_muted_dark;
} else{
icon = R.drawable.a_10_device_access_volume_on_dark;
}
muteBtn.setContentDescription(mapActivity.getString(t));
muteBtn.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getIcon(icon, R.color.icon_color_light));
muteBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
routingHelper.getVoiceRouter().setMute(!routingHelper.getVoiceRouter().isMute());
setMuteBtn(muteBtn);
}
});
}
private void updateParameters() {
ApplicationMode am = settings.APPLICATION_MODE.get();
listAdapter.setNotifyOnChange(false);

View file

@ -312,10 +312,16 @@ public class MapInfoWidgetsFactory {
return false;
}
public void updateTextColor(int textColor, int textShadowColor, boolean bold, int rad) {
public void updateTextColor(boolean nightMode, int textColor, int textShadowColor, boolean bold, int rad) {
updateTextColor(addressText, textColor, textShadowColor, bold, rad);
updateTextColor((TextView) waypointInfoBar.findViewById(R.id.waypoint_text),
textColor, textShadowColor, bold, rad);
updateTextColor((TextView) waypointInfoBar.findViewById(R.id.waypoint_text), textColor, textShadowColor,
bold, rad);
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
all.setImageDrawable(map.getMyApplication().getIconsCache()
.getActionBarIcon(R.drawable.ic_overflow_menu_dark, !nightMode));
remove.setImageDrawable(map.getMyApplication().getIconsCache()
.getActionBarIcon(R.drawable.ic_action_remove_dark, !nightMode));
}
private void updateTextColor(TextView tv, int textColor, int textShadowColor, boolean textBold, int rad) {
@ -402,16 +408,14 @@ public class MapInfoWidgetsFactory {
lastPoint, null);
if (updated) {
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
View btnN = waypointInfoBar.findViewById(R.id.waypoint_close);
all.setImageDrawable(map.getMyApplication().getIconsCache().
getContentIcon(R.drawable.ic_overflow_menu_light));
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
all.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
}
});
btnN.setOnClickListener(new View.OnClickListener() {
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
waypointHelper.removeVisibleLocationPoint(lastPoint);

View file

@ -55,7 +55,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
if(horisontalMini) {
setImageDrawable(turnDrawable, false);
} else {
setTopImageDrawable(turnDrawable, turnType.getExitOut() == 0 ? "" :
setTopImageDrawable(turnDrawable, turnType == null || turnType.getExitOut() == 0 ? "" :
turnType.getExitOut() + "");
}
}

View file

@ -65,6 +65,7 @@ public class TextInfoWidget {
if(imageDrawable != null) {
topImageView.setImageDrawable(imageDrawable);
topImageView.setVisibility(View.VISIBLE);
topTextView.setVisibility(View.VISIBLE);
topTextView.setText(topText == null ? "" : topText);
} else {
topImageView.setVisibility(View.GONE );