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"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:descendantFocusability="blocksDescendants"
|
||||||
|
android:orientation="horizontal"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:paddingRight="@dimen/list_content_padding"
|
android:paddingRight="@dimen/list_content_padding" >
|
||||||
android:orientation="horizontal" >
|
|
||||||
|
<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
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/title"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
android:gravity="center_vertical"
|
||||||
android:text="@string/layer_poi"
|
android:text="@string/layer_poi"
|
||||||
android:textSize="@dimen/default_list_text_size" />
|
android:textSize="@dimen/default_list_text_size" />
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
android:paddingLeft="@dimen/list_content_padding"
|
android:paddingLeft="@dimen/list_content_padding"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -18,7 +19,6 @@
|
||||||
android:text="@string/gpx_navigation"
|
android:text="@string/gpx_navigation"
|
||||||
android:textSize="@dimen/default_sub_text_size" >
|
android:textSize="@dimen/default_sub_text_size" >
|
||||||
</TextView>
|
</TextView>
|
||||||
|
|
||||||
<Spinner
|
<Spinner
|
||||||
android:id="@+id/GPXRouteSpinner"
|
android:id="@+id/GPXRouteSpinner"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
@ -28,12 +28,4 @@
|
||||||
</Spinner>
|
</Spinner>
|
||||||
</LinearLayout>
|
</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>
|
</LinearLayout>
|
|
@ -171,6 +171,7 @@
|
||||||
android:id="@+id/Info"
|
android:id="@+id/Info"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="@dimen/list_item_height"
|
android:layout_height="@dimen/list_item_height"
|
||||||
|
android:background="?attr/dashboard_button"
|
||||||
android:orientation="horizontal" >
|
android:orientation="horizontal" >
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|
|
@ -298,14 +298,14 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
protected void clickRouteParams() {
|
protected void clickRouteParams() {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
optionsRouteControlDialog.showAndHideDialog();
|
|
||||||
mapRouteInfoControlDialog.hideDialog();
|
mapRouteInfoControlDialog.hideDialog();
|
||||||
|
optionsRouteControlDialog.showAndHideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clickRouteWaypoints() {
|
protected void clickRouteWaypoints() {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
mapRouteInfoControlDialog.showHideDialog();
|
|
||||||
optionsRouteControlDialog.hideDialog();
|
optionsRouteControlDialog.hideDialog();
|
||||||
|
mapRouteInfoControlDialog.showHideDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void clickRouteCancel() {
|
protected void clickRouteCancel() {
|
||||||
|
|
|
@ -95,6 +95,10 @@ public class MapRoutePreferencesControl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class OtherSettingsRoutingParameter extends LocalRoutingParameter {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static class OtherLocalRoutingParameter extends LocalRoutingParameter {
|
private static class OtherLocalRoutingParameter extends LocalRoutingParameter {
|
||||||
public String text;
|
public String text;
|
||||||
public boolean selected;
|
public boolean selected;
|
||||||
|
@ -268,6 +272,7 @@ public class MapRoutePreferencesControl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
list.add(new GpxLocalRoutingParameter());
|
list.add(new GpxLocalRoutingParameter());
|
||||||
|
list.add(new OtherSettingsRoutingParameter());
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -299,11 +304,17 @@ public class MapRoutePreferencesControl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
|
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);
|
CheckBox ch = (CheckBox) view.findViewById(R.id.check_item);
|
||||||
if(ch != null) {
|
if (ch != null) {
|
||||||
ch.setChecked(!ch.isChecked());
|
ch.setChecked(!ch.isChecked());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
listAdapter = new ArrayAdapter<LocalRoutingParameter>(ctx, R.layout.layers_list_activity_item, R.id.title,
|
listAdapter = new ArrayAdapter<LocalRoutingParameter>(ctx, R.layout.layers_list_activity_item, R.id.title,
|
||||||
getRoutingParameters(settings.APPLICATION_MODE.get())) {
|
getRoutingParameters(settings.APPLICATION_MODE.get())) {
|
||||||
|
@ -315,6 +326,15 @@ public class MapRoutePreferencesControl {
|
||||||
setupGPXSpinner(v);
|
setupGPXSpinner(v);
|
||||||
return 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);
|
return inflateRoutingParameter(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -420,6 +440,42 @@ public class MapRoutePreferencesControl {
|
||||||
private void setupGPXSpinner(View settingsDlg) {
|
private void setupGPXSpinner(View settingsDlg) {
|
||||||
final Spinner gpxSpinner = (Spinner) settingsDlg.findViewById(R.id.GPXRouteSpinner);
|
final Spinner gpxSpinner = (Spinner) settingsDlg.findViewById(R.id.GPXRouteSpinner);
|
||||||
updateSpinnerItems(gpxSpinner);
|
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() {
|
gpxSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -443,52 +499,6 @@ public class MapRoutePreferencesControl {
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
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() {
|
public boolean isDialogVisible() {
|
||||||
|
@ -498,6 +508,7 @@ public class MapRoutePreferencesControl {
|
||||||
public void hideDialog() {
|
public void hideDialog() {
|
||||||
if(dialog != null) {
|
if(dialog != null) {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
|
dialog = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue