Update gpx
This commit is contained in:
parent
ac2f61ff22
commit
b138522e4e
5 changed files with 78 additions and 64 deletions
|
@ -2,17 +2,27 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:descendantFocusability="blocksDescendants"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:orientation="horizontal" >
|
||||
android:paddingRight="@dimen/list_content_padding" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:scaleType="center"
|
||||
android:visibility="gone"
|
||||
android:src="@drawable/ic_action_settings" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:text="@string/layer_poi"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:orientation="horizontal" >
|
||||
android:orientation="horizontal"
|
||||
>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -18,7 +19,6 @@
|
|||
android:text="@string/gpx_navigation"
|
||||
android:textSize="@dimen/default_sub_text_size" >
|
||||
</TextView>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/GPXRouteSpinner"
|
||||
android:layout_width="fill_parent"
|
||||
|
@ -28,12 +28,4 @@
|
|||
</Spinner>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/settings"
|
||||
android:layout_width="@dimen/list_item_height"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:scaleType="center"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:src="@drawable/ic_action_settings" />
|
||||
|
||||
</LinearLayout>
|
|
@ -171,6 +171,7 @@
|
|||
android:id="@+id/Info"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="@dimen/list_item_height"
|
||||
android:background="?attr/dashboard_button"
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ImageView
|
||||
|
|
|
@ -298,14 +298,14 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
|
||||
protected void clickRouteParams() {
|
||||
notifyClicked();
|
||||
optionsRouteControlDialog.showAndHideDialog();
|
||||
mapRouteInfoControlDialog.hideDialog();
|
||||
optionsRouteControlDialog.showAndHideDialog();
|
||||
}
|
||||
|
||||
protected void clickRouteWaypoints() {
|
||||
notifyClicked();
|
||||
mapRouteInfoControlDialog.showHideDialog();
|
||||
optionsRouteControlDialog.hideDialog();
|
||||
mapRouteInfoControlDialog.showHideDialog();
|
||||
}
|
||||
|
||||
protected void clickRouteCancel() {
|
||||
|
|
|
@ -93,6 +93,10 @@ public class MapRoutePreferencesControl {
|
|||
|
||||
private static class GpxLocalRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
}
|
||||
|
||||
private static class OtherSettingsRoutingParameter extends LocalRoutingParameter {
|
||||
|
||||
}
|
||||
|
||||
private static class OtherLocalRoutingParameter extends LocalRoutingParameter {
|
||||
|
@ -268,6 +272,7 @@ public class MapRoutePreferencesControl {
|
|||
}
|
||||
}
|
||||
list.add(new GpxLocalRoutingParameter());
|
||||
list.add(new OtherSettingsRoutingParameter());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
@ -299,9 +304,15 @@ public class MapRoutePreferencesControl {
|
|||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
CheckBox ch = (CheckBox) view.findViewById(R.id.check_item);
|
||||
if(ch != null) {
|
||||
ch.setChecked(!ch.isChecked());
|
||||
if(listAdapter.getItem(position) instanceof OtherSettingsRoutingParameter) {
|
||||
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
|
||||
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
|
||||
mapActivity.startActivity(settings);
|
||||
} else {
|
||||
CheckBox ch = (CheckBox) view.findViewById(R.id.check_item);
|
||||
if (ch != null) {
|
||||
ch.setChecked(!ch.isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -315,6 +326,15 @@ public class MapRoutePreferencesControl {
|
|||
setupGPXSpinner(v);
|
||||
return v;
|
||||
}
|
||||
if(parameter instanceof OtherSettingsRoutingParameter) {
|
||||
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
|
||||
final ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
icon.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_gsettings_dark));
|
||||
icon.setVisibility(View.VISIBLE);
|
||||
((TextView)v.findViewById(R.id.title)).setText(R.string.routing_settings_2);
|
||||
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
||||
return v;
|
||||
}
|
||||
return inflateRoutingParameter(position);
|
||||
}
|
||||
|
||||
|
@ -420,6 +440,42 @@ public class MapRoutePreferencesControl {
|
|||
private void setupGPXSpinner(View settingsDlg) {
|
||||
final Spinner gpxSpinner = (Spinner) settingsDlg.findViewById(R.id.GPXRouteSpinner);
|
||||
updateSpinnerItems(gpxSpinner);
|
||||
|
||||
}
|
||||
|
||||
protected void openGPXFileSelection(final Spinner gpxSpinner) {
|
||||
GpxUiHelper.selectGPXFile(mapActivity, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||
|
||||
@Override
|
||||
public boolean processResult(GPXFile[] result) {
|
||||
mapActivity.getMapActions().setGPXRouteParams(result[0]);
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().updateRouteAndReferesh(true);
|
||||
updateSpinnerItems(gpxSpinner);
|
||||
updateParameters();
|
||||
mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateSpinnerItems(final Spinner gpxSpinner) {
|
||||
ArrayList<String> gpxActions = new ArrayList<String>();
|
||||
gpxActions.add(mapActivity.getString(R.string.shared_string_none));
|
||||
gpxActions.add(mapActivity.getString(R.string.select_gpx));
|
||||
GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
|
||||
if (rp != null) {
|
||||
gpxActions.add(new File(rp.getFile().path).getName());
|
||||
}
|
||||
|
||||
ArrayAdapter<String> gpxAdapter = new ArrayAdapter<String>(mapActivity, android.R.layout.simple_spinner_item,
|
||||
gpxActions);
|
||||
gpxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
gpxSpinner.setAdapter(gpxAdapter);
|
||||
if (rp != null) {
|
||||
gpxSpinner.setSelection(2);
|
||||
} else {
|
||||
gpxSpinner.setSelection(0);
|
||||
}
|
||||
gpxSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
|
||||
@Override
|
||||
|
@ -443,52 +499,6 @@ public class MapRoutePreferencesControl {
|
|||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
}
|
||||
});
|
||||
final ImageView settings = (ImageView) settingsDlg.findViewById(R.id.settings);
|
||||
settings.setImageDrawable(mapActivity.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_gsettings_dark));
|
||||
settings.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final Intent settings = new Intent(mapActivity, SettingsNavigationActivity.class);
|
||||
settings.putExtra(SettingsNavigationActivity.INTENT_SKIP_DIALOG, true);
|
||||
mapActivity.startActivity(settings);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void openGPXFileSelection(final Spinner gpxSpinner) {
|
||||
GpxUiHelper.selectGPXFile(mapActivity, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
|
||||
|
||||
@Override
|
||||
public boolean processResult(GPXFile[] result) {
|
||||
mapActivity.getMapActions().setGPXRouteParams(result[0]);
|
||||
mapActivity.getMyApplication().getTargetPointsHelper().updateRouteAndReferesh(true);
|
||||
updateSpinnerItems(gpxSpinner);
|
||||
updateParameters();
|
||||
mapActivity.getRoutingHelper().recalculateRouteDueToSettingsChange();
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateSpinnerItems(Spinner gpxSpinner) {
|
||||
ArrayList<String> gpxActions = new ArrayList<String>();
|
||||
gpxActions.add(mapActivity.getString(R.string.shared_string_none));
|
||||
gpxActions.add(mapActivity.getString(R.string.select_gpx));
|
||||
GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute();
|
||||
if (rp != null) {
|
||||
gpxActions.add(new File(rp.getFile().path).getName());
|
||||
}
|
||||
|
||||
ArrayAdapter<String> gpxAdapter = new ArrayAdapter<String>(mapActivity, android.R.layout.simple_spinner_item,
|
||||
gpxActions);
|
||||
gpxAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
gpxSpinner.setAdapter(gpxAdapter);
|
||||
if (rp != null) {
|
||||
gpxSpinner.setSelection(2);
|
||||
} else {
|
||||
gpxSpinner.setSelection(0);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDialogVisible() {
|
||||
|
@ -498,6 +508,7 @@ public class MapRoutePreferencesControl {
|
|||
public void hideDialog() {
|
||||
if(dialog != null) {
|
||||
dialog.hide();
|
||||
dialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue