Add some changes
This commit is contained in:
parent
fbb6f78379
commit
e95f4bd282
2 changed files with 29 additions and 20 deletions
|
@ -90,13 +90,13 @@
|
||||||
android:background="@color/ctx_menu_info_view_bg_dark"
|
android:background="@color/ctx_menu_info_view_bg_dark"
|
||||||
android:visibility="gone">
|
android:visibility="gone">
|
||||||
|
|
||||||
<include layout="@layout/card_bottom_divider"/>
|
|
||||||
|
|
||||||
<android.support.v7.widget.RecyclerView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/measure_points_recycler_view"
|
android:id="@+id/measure_points_recycler_view"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_height="match_parent"/>
|
||||||
|
|
||||||
|
<include layout="@layout/card_bottom_divider"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="5dp"
|
android:layout_height="5dp"
|
||||||
|
|
|
@ -74,6 +74,12 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
private TextView distanceTv;
|
private TextView distanceTv;
|
||||||
private TextView pointsTv;
|
private TextView pointsTv;
|
||||||
private String pointsSt;
|
private String pointsSt;
|
||||||
|
private Drawable upIcon;
|
||||||
|
private Drawable downIcon;
|
||||||
|
private View pointsListContainer;
|
||||||
|
private ImageView upDownBtn;
|
||||||
|
private ImageButton undoBtn;
|
||||||
|
private ImageButton redoBtn;
|
||||||
|
|
||||||
private boolean wasCollapseButtonVisible;
|
private boolean wasCollapseButtonVisible;
|
||||||
private boolean pointsListOpened;
|
private boolean pointsListOpened;
|
||||||
|
@ -95,6 +101,8 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
||||||
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
|
||||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||||
|
upIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up);
|
||||||
|
downIcon = iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down);
|
||||||
|
|
||||||
pointsSt = getString(R.string.points).toLowerCase();
|
pointsSt = getString(R.string.points).toLowerCase();
|
||||||
|
|
||||||
|
@ -102,7 +110,8 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
|
|
||||||
final View mainView = view.findViewById(R.id.main_view);
|
final View mainView = view.findViewById(R.id.main_view);
|
||||||
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
AndroidUtils.setBackground(mapActivity, mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||||
view.findViewById(R.id.points_list_container).setBackgroundColor(backgroundColor);
|
pointsListContainer = view.findViewById(R.id.points_list_container);
|
||||||
|
pointsListContainer.setBackgroundColor(backgroundColor);
|
||||||
|
|
||||||
distanceTv = (TextView) mainView.findViewById(R.id.measurement_distance_text_view);
|
distanceTv = (TextView) mainView.findViewById(R.id.measurement_distance_text_view);
|
||||||
pointsTv = (TextView) mainView.findViewById(R.id.measurement_points_text_view);
|
pointsTv = (TextView) mainView.findViewById(R.id.measurement_points_text_view);
|
||||||
|
@ -110,22 +119,22 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
((ImageView) mainView.findViewById(R.id.ruler_icon))
|
((ImageView) mainView.findViewById(R.id.ruler_icon))
|
||||||
.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_ruler, R.color.color_myloc_distance));
|
.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_ruler, R.color.color_myloc_distance));
|
||||||
|
|
||||||
final ImageView upDownBtn = ((ImageView) mainView.findViewById(R.id.up_down_button));
|
upDownBtn = ((ImageView) mainView.findViewById(R.id.up_down_button));
|
||||||
upDownBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
upDownBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||||
|
|
||||||
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.up_down_row).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
if (!pointsListOpened && measurementLayer.getPointsCount() > 0) {
|
if (!pointsListOpened && measurementLayer.getPointsCount() > 0) {
|
||||||
showPointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_down));
|
showPointsList();
|
||||||
} else {
|
} else {
|
||||||
hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
hidePointsList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
final ImageButton undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button));
|
undoBtn = ((ImageButton) mainView.findViewById(R.id.undo_point_button));
|
||||||
final ImageButton redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button));
|
redoBtn = ((ImageButton) mainView.findViewById(R.id.redo_point_button));
|
||||||
|
|
||||||
undoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
|
undoBtn.setImageDrawable(iconsCache.getThemedIcon(R.drawable.ic_action_undo_dark));
|
||||||
undoBtn.setOnClickListener(new View.OnClickListener() {
|
undoBtn.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@ -136,7 +145,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
enable(undoBtn);
|
enable(undoBtn);
|
||||||
} else {
|
} else {
|
||||||
disable(undoBtn, upDownBtn);
|
disable(undoBtn, upDownBtn);
|
||||||
hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
hidePointsList();
|
||||||
}
|
}
|
||||||
adapter.notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
enable(redoBtn);
|
enable(redoBtn);
|
||||||
|
@ -163,14 +172,14 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() {
|
mainView.findViewById(R.id.add_point_button).setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
addPoint(undoBtn, upDownBtn, redoBtn);
|
addPoint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
measurementLayer.setOnSingleTapListener(new MeasurementToolLayer.OnSingleTapListener() {
|
measurementLayer.setOnSingleTapListener(new MeasurementToolLayer.OnSingleTapListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onSingleTap() {
|
public void onSingleTap() {
|
||||||
addPoint(undoBtn, upDownBtn, redoBtn);
|
addPoint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -223,7 +232,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_clear_all:
|
case R.id.action_clear_all:
|
||||||
measurementLayer.clearPoints();
|
measurementLayer.clearPoints();
|
||||||
hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
hidePointsList();
|
||||||
disable(undoBtn, redoBtn, upDownBtn);
|
disable(undoBtn, redoBtn, upDownBtn);
|
||||||
updateText();
|
updateText();
|
||||||
commandManager.clear();
|
commandManager.clear();
|
||||||
|
@ -254,7 +263,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
disable(redoBtn);
|
disable(redoBtn);
|
||||||
updateText();
|
updateText();
|
||||||
if (measurementLayer.getPointsCount() < 1) {
|
if (measurementLayer.getPointsCount() < 1) {
|
||||||
hidePointsList(mainView, iconsCache.getThemedIcon(R.drawable.ic_action_arrow_up));
|
hidePointsList();
|
||||||
disable(upDownBtn);
|
disable(upDownBtn);
|
||||||
if (!commandManager.canUndo()) {
|
if (!commandManager.canUndo()) {
|
||||||
disable(undoBtn);
|
disable(undoBtn);
|
||||||
|
@ -290,7 +299,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPoint(View undoBtn, View upDownBtn, View redoBtn) {
|
private void addPoint() {
|
||||||
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
MeasurementToolLayer measurementLayer = getMeasurementLayer();
|
||||||
if (measurementLayer != null) {
|
if (measurementLayer != null) {
|
||||||
commandManager.execute(new AddPointCommand(measurementLayer));
|
commandManager.execute(new AddPointCommand(measurementLayer));
|
||||||
|
@ -301,10 +310,10 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPointsList(View view, Drawable icon) {
|
private void showPointsList() {
|
||||||
pointsListOpened = true;
|
pointsListOpened = true;
|
||||||
view.findViewById(R.id.points_list_container).setVisibility(View.VISIBLE);
|
pointsListContainer.setVisibility(View.VISIBLE);
|
||||||
((ImageView) view.findViewById(R.id.up_down_button)).setImageDrawable(icon);
|
upDownBtn.setImageDrawable(downIcon);
|
||||||
MapActivity mapActivity = getMapActivity();
|
MapActivity mapActivity = getMapActivity();
|
||||||
if (mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
OsmandMapTileView tileView = mapActivity.getMapView();
|
OsmandMapTileView tileView = mapActivity.getMapView();
|
||||||
|
@ -314,10 +323,10 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hidePointsList(View view, Drawable icon) {
|
private void hidePointsList() {
|
||||||
pointsListOpened = false;
|
pointsListOpened = false;
|
||||||
view.findViewById(R.id.points_list_container).setVisibility(View.GONE);
|
pointsListContainer.setVisibility(View.GONE);
|
||||||
((ImageView) view.findViewById(R.id.up_down_button)).setImageDrawable(icon);
|
upDownBtn.setImageDrawable(upIcon);
|
||||||
setPreviousMapPosition();
|
setPreviousMapPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue