Fix straight line
This commit is contained in:
parent
a38921a095
commit
794d611f60
2 changed files with 27 additions and 17 deletions
|
@ -571,6 +571,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment {
|
||||||
mapActivity.refreshMap();
|
mapActivity.refreshMap();
|
||||||
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
|
SnapToRoadBottomSheetDialogFragment fragment = new SnapToRoadBottomSheetDialogFragment();
|
||||||
fragment.setListener(createSnapToRoadFragmentListener());
|
fragment.setListener(createSnapToRoadFragmentListener());
|
||||||
|
fragment.setShowStraightLine(true);
|
||||||
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
fragment.show(mapActivity.getSupportFragmentManager(), SnapToRoadBottomSheetDialogFragment.TAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.measurementtool;
|
||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
import android.graphics.drawable.Drawable;
|
||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
|
@ -18,6 +19,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||||
|
@ -35,6 +37,7 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
||||||
private boolean portrait;
|
private boolean portrait;
|
||||||
private boolean snapToRoadEnabled;
|
private boolean snapToRoadEnabled;
|
||||||
private boolean removeDefaultMode = true;
|
private boolean removeDefaultMode = true;
|
||||||
|
private boolean showStraightLine = false;
|
||||||
|
|
||||||
public void setListener(SnapToRoadFragmentListener listener) {
|
public void setListener(SnapToRoadFragmentListener listener) {
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
|
@ -44,6 +47,10 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
||||||
this.removeDefaultMode = removeDefaultMode;
|
this.removeDefaultMode = removeDefaultMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowStraightLine(boolean showStraightLine) {
|
||||||
|
this.showStraightLine = showStraightLine;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupDialog(Dialog dialog, int style) {
|
public void setupDialog(Dialog dialog, int style) {
|
||||||
super.setupDialog(dialog, style);
|
super.setupDialog(dialog, style);
|
||||||
|
@ -78,7 +85,7 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
||||||
View.OnClickListener onClickListener = new View.OnClickListener() {
|
View.OnClickListener onClickListener = new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
snapToRoadEnabled = true;
|
snapToRoadEnabled = false;
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
ApplicationMode mode = null;
|
ApplicationMode mode = null;
|
||||||
if ((int) view.getTag() != STRAIGHT_LINE_TAG) {
|
if ((int) view.getTag() != STRAIGHT_LINE_TAG) {
|
||||||
|
@ -91,23 +98,16 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
|
if (showStraightLine) {
|
||||||
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
|
Drawable icon = app.getUIUtilities().getIcon(R.drawable.ic_action_split_interval, nightMode);
|
||||||
app.getUIUtilities().getIcon(R.drawable.ic_action_split_interval, nightMode));
|
addProfileView(container, onClickListener, STRAIGHT_LINE_TAG, icon,
|
||||||
((TextView) row.findViewById(R.id.title)).setText(app.getText(R.string.routing_profile_straightline));
|
app.getText(R.string.routing_profile_straightline));
|
||||||
row.setOnClickListener(onClickListener);
|
}
|
||||||
row.setTag(STRAIGHT_LINE_TAG);
|
|
||||||
container.addView(row);
|
|
||||||
|
|
||||||
for (int i = 0; i < modes.size(); i++) {
|
for (int i = 0; i < modes.size(); i++) {
|
||||||
ApplicationMode mode = modes.get(i);
|
ApplicationMode mode = modes.get(i);
|
||||||
row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
|
Drawable icon = app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode));
|
||||||
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(
|
addProfileView(container, onClickListener, i, icon, mode.toHumanString());
|
||||||
app.getUIUtilities().getIcon(mode.getIconRes(), mode.getIconColorInfo().getColor(nightMode)));
|
|
||||||
((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString());
|
|
||||||
row.setOnClickListener(onClickListener);
|
|
||||||
row.setTag(i);
|
|
||||||
container.addView(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!portrait) {
|
if (!portrait) {
|
||||||
|
@ -125,6 +125,15 @@ public class SnapToRoadBottomSheetDialogFragment extends BottomSheetDialogFragme
|
||||||
((View) mainView.getParent()).setBackgroundResource(0);
|
((View) mainView.getParent()).setBackgroundResource(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addProfileView(LinearLayout container, View.OnClickListener onClickListener, Object tag, Drawable icon, CharSequence title) {
|
||||||
|
View row = UiUtilities.getInflater(getContext(), nightMode).inflate(R.layout.list_item_icon_and_title, null);
|
||||||
|
((ImageView) row.findViewById(R.id.icon)).setImageDrawable(icon);
|
||||||
|
((TextView) row.findViewById(R.id.title)).setText(title);
|
||||||
|
row.setOnClickListener(onClickListener);
|
||||||
|
row.setTag(tag);
|
||||||
|
container.addView(row);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
|
Loading…
Reference in a new issue