Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
aa90d9a727
3 changed files with 85 additions and 14 deletions
|
@ -22,7 +22,7 @@
|
|||
android:paddingBottom="12dp"
|
||||
android:paddingTop="12dp">
|
||||
|
||||
<ImageButton
|
||||
<ImageView
|
||||
android:id="@+id/ruler_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -37,7 +37,7 @@
|
|||
tools:src="@drawable/ic_action_ruler"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/up_down_icon"
|
||||
android:id="@+id/up_down_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
|
@ -70,9 +70,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toEndOf="@id/measurement_distance_text_view"
|
||||
android:layout_toLeftOf="@id/up_down_icon"
|
||||
android:layout_toLeftOf="@id/up_down_button"
|
||||
android:layout_toRightOf="@id/measurement_distance_text_view"
|
||||
android:layout_toStartOf="@id/up_down_icon"
|
||||
android:layout_toStartOf="@id/up_down_button"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="points: 3"/>
|
||||
|
@ -88,7 +88,7 @@
|
|||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/previous_dot_icon"
|
||||
android:id="@+id/undo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
|
@ -102,14 +102,14 @@
|
|||
tools:src="@drawable/ic_action_undo_dark"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/next_dot_icon"
|
||||
android:id="@+id/redo_point_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_toEndOf="@id/previous_dot_icon"
|
||||
android:layout_toRightOf="@id/previous_dot_icon"
|
||||
android:layout_toEndOf="@id/undo_point_button"
|
||||
android:layout_toRightOf="@id/undo_point_button"
|
||||
android:background="@null"
|
||||
tools:src="@drawable/ic_action_redo_dark"/>
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
@ -55,21 +56,59 @@ public class MeasurementToolFragment extends Fragment {
|
|||
|
||||
((ImageView) mainView.findViewById(R.id.ruler_icon))
|
||||
.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_ruler, R.color.color_myloc_distance));
|
||||
((ImageView) mainView.findViewById(R.id.up_down_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
((ImageView) mainView.findViewById(R.id.previous_dot_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
|
||||
((ImageView) mainView.findViewById(R.id.next_dot_icon))
|
||||
.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_redo_dark));
|
||||
|
||||
final ImageButton upDownBtn = ((ImageButton) mainView.findViewById(R.id.up_down_button));
|
||||
upDownBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
upDownBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Toast.makeText(getActivity(), "Up / Down", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
final ImageButton undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button));
|
||||
final ImageButton redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button));
|
||||
|
||||
undoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
|
||||
undoBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (measurementLayer.undoPointOnClick()) {
|
||||
enable(undoBtn);
|
||||
} else {
|
||||
disable(undoBtn);
|
||||
}
|
||||
enable(redoBtn);
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
|
||||
redoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_redo_dark));
|
||||
redoBtn.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (measurementLayer.redoPointOnClick()) {
|
||||
enable(redoBtn);
|
||||
} else {
|
||||
disable(redoBtn);
|
||||
}
|
||||
enable(undoBtn);
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
|
||||
mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
measurementLayer.addPointOnClick();
|
||||
enable(undoBtn);
|
||||
disable(redoBtn);
|
||||
updateText();
|
||||
}
|
||||
});
|
||||
|
||||
disable(undoBtn, redoBtn);
|
||||
|
||||
enterMeasurementMode();
|
||||
|
||||
if (portrait) {
|
||||
|
@ -99,6 +138,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
return true;
|
||||
case R.id.action_clear_all:
|
||||
measurementLayer.clearPoints();
|
||||
disable(undoBtn, redoBtn);
|
||||
updateText();
|
||||
return true;
|
||||
}
|
||||
|
@ -132,6 +172,20 @@ public class MeasurementToolFragment extends Fragment {
|
|||
return null;
|
||||
}
|
||||
|
||||
private void enable(View... views) {
|
||||
for (View view : views) {
|
||||
view.setEnabled(true);
|
||||
view.setAlpha(1);
|
||||
}
|
||||
}
|
||||
|
||||
private void disable(View... views) {
|
||||
for (View view : views) {
|
||||
view.setEnabled(false);
|
||||
view.setAlpha(.5f);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateText() {
|
||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||
if (measurementLayer != null) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
private OsmandMapTileView view;
|
||||
private boolean inMeasurementMode;
|
||||
private LinkedList<WptPt> measurementPoints = new LinkedList<>();
|
||||
private LinkedList<WptPt> cacheMeasurementPoints;
|
||||
private Bitmap centerIconDay;
|
||||
private Bitmap centerIconNight;
|
||||
private Bitmap pointIcon;
|
||||
|
@ -78,6 +79,7 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
|
||||
void clearPoints() {
|
||||
measurementPoints.clear();
|
||||
cacheMeasurementPoints.clear();
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
|
@ -141,9 +143,24 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
} else {
|
||||
measurementPoints.add(pt);
|
||||
}
|
||||
cacheMeasurementPoints = new LinkedList<>(measurementPoints);
|
||||
view.refreshMap();
|
||||
}
|
||||
|
||||
boolean undoPointOnClick() {
|
||||
measurementPoints.remove(measurementPoints.size() - 1);
|
||||
WptPt pt = measurementPoints.get(measurementPoints.size() - 1);
|
||||
view.getAnimatedDraggingThread().startMoving(pt.getLatitude(), pt.getLongitude(), view.getZoom(), true);
|
||||
return measurementPoints.size() > 0;
|
||||
}
|
||||
|
||||
boolean redoPointOnClick() {
|
||||
WptPt pt = cacheMeasurementPoints.get(measurementPoints.size());
|
||||
measurementPoints.add(pt);
|
||||
view.getAnimatedDraggingThread().startMoving(pt.getLatitude(), pt.getLongitude(), view.getZoom(), true);
|
||||
return cacheMeasurementPoints.size() > measurementPoints.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyLayer() {
|
||||
|
||||
|
|
Loading…
Reference in a new issue