Make add after or before multitask

This commit is contained in:
PavelRatushny 2017-08-17 17:49:35 +03:00
parent fc7d91e494
commit e2a21323ec
4 changed files with 211 additions and 17 deletions

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true">
<shape android:shape="rectangle">
<solid android:color="?attr/bg_color" />
<stroke android:color="@color/map_widget_blue_pressed" android:width="3dp"/>
<corners android:radius="@dimen/map_button_rect_rad" />
</shape>
</item>
<item android:state_enabled="false">
<shape android:shape="rectangle">
<solid android:color="?attr/bg_color" />
<stroke android:color="@color/searchbar_tab_inactive_light" android:width="3dp"/>
<corners android:radius="@dimen/map_button_rect_rad" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="?attr/bg_color" />
<stroke android:color="@color/map_widget_blue" android:width="3dp"/>
<corners android:radius="@dimen/map_button_rect_rad" />
</shape>
</item>
</selector>

View file

@ -235,14 +235,14 @@
</LinearLayout>
<RelativeLayout
android:id="@+id/selected_point_controls"
android:id="@+id/move_point_controls"
android:layout_width="0dp"
android:layout_height="52dp"
android:layout_weight="0.6"
android:visibility="gone">
<Button
android:id="@+id/apply_point_button"
android:id="@+id/apply_move_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
@ -260,7 +260,7 @@
android:textColor="@color/color_white"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/cancel_point_button"
android:id="@+id/cancel_move_point_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
@ -275,6 +275,67 @@
osmand:typeface="@string/font_roboto_medium"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/add_point_before_after_controls"
android:layout_width="0dp"
android:layout_weight="0.6"
android:layout_height="52dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/cancel_point_before_after_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:paddingEnd="12dp"
android:paddingLeft="16dp"
android:paddingRight="12dp"
android:paddingStart="16dp"
android:text="@string/shared_string_cancel"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:id="@+id/apply_point_before_after_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/btn_round_white_border"
android:minHeight="36dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons"/>
<Button
android:id="@+id/add_point_before_after_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/btn_round_blue"
android:drawableLeft="@drawable/ic_action_plus"
android:minHeight="36dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/shared_string_add"
android:textColor="@color/color_white"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

View file

@ -254,13 +254,13 @@
</LinearLayout>
<RelativeLayout
android:id="@+id/selected_point_controls"
android:id="@+id/move_point_controls"
android:layout_width="match_parent"
android:layout_height="52dp"
android:visibility="gone">
<Button
android:id="@+id/apply_point_button"
android:id="@+id/apply_move_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
@ -278,7 +278,7 @@
android:textColor="@color/color_white"/>
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/cancel_point_button"
android:id="@+id/cancel_move_point_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
@ -293,6 +293,66 @@
osmand:typeface="@string/font_roboto_medium"/>
</RelativeLayout>
<LinearLayout
android:id="@+id/add_point_before_after_controls"
android:layout_width="match_parent"
android:layout_height="52dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="gone">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/cancel_point_before_after_button"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="?attr/selectableItemBackground"
android:gravity="center_vertical"
android:paddingEnd="12dp"
android:paddingLeft="16dp"
android:paddingRight="12dp"
android:paddingStart="16dp"
android:text="@string/shared_string_cancel"
android:textColor="?attr/color_dialog_buttons"
osmand:textAllCapsCompat="true"
osmand:typeface="@string/font_roboto_medium"/>
<View
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:id="@+id/apply_point_before_after_point_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/btn_round_white_border"
android:minHeight="36dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/shared_string_apply"
android:textColor="?attr/color_dialog_buttons"/>
<Button
android:id="@+id/add_point_before_after_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:background="@drawable/btn_round_blue"
android:drawableLeft="@drawable/ic_action_plus"
android:minHeight="36dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="@string/shared_string_add"
android:textColor="@color/color_white"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>

View file

@ -205,12 +205,19 @@ public class MeasurementToolFragment extends Fragment {
upDownBtn = (ImageView) mainView.findViewById(R.id.up_down_button);
upDownBtn.setImageDrawable(upIcon);
mainView.findViewById(R.id.cancel_point_button).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.cancel_move_point_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (inMovePointMode) {
cancelMovePointMode();
} else if (inAddPointAfterMode) {
}
}
});
mainView.findViewById(R.id.cancel_point_before_after_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (inAddPointAfterMode) {
cancelAddPointAfterMode();
} else if (inAddPointBeforeMode) {
cancelAddPointBeforeMode();
@ -234,12 +241,19 @@ public class MeasurementToolFragment extends Fragment {
}
});
mainView.findViewById(R.id.apply_point_button).setOnClickListener(new View.OnClickListener() {
mainView.findViewById(R.id.apply_move_point_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (inMovePointMode) {
applyMovePointMode();
} else if (inAddPointAfterMode) {
}
}
});
mainView.findViewById(R.id.apply_point_before_after_point_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (inAddPointAfterMode) {
applyAddPointAfterMode();
} else if (inAddPointBeforeMode) {
applyAddPointBeforeMode();
@ -247,6 +261,17 @@ public class MeasurementToolFragment extends Fragment {
}
});
mainView.findViewById(R.id.add_point_before_after_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (inAddPointAfterMode) {
addPointAfter();
} else if (inAddPointBeforeMode) {
addPointBefore();
}
}
});
mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -837,14 +862,26 @@ public class MeasurementToolFragment extends Fragment {
}
}
private void addPointAfter() {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null && positionToAddPoint != -1) {
addPointToPosition(positionToAddPoint);
selectedPointPos += 1;
selectedCachedPoint = new WptPt(measurementLayer.getMeasurementPoints().get(selectedPointPos));
measurementLayer.setSelectedPointPos(selectedPointPos);
measurementLayer.setSelectedCachedPoint(selectedCachedPoint);
measurementLayer.refreshMap();
positionToAddPoint += 1;
}
}
private void applyAddPointAfterMode() {
if (inAddPointAfterMode) {
switchAddPointAfterMode(false);
}
clearSelection();
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null && positionToAddPoint != -1) {
addPointToPosition(positionToAddPoint);
if (measurementLayer != null) {
measurementLayer.exitAddPointAfterMode();
measurementLayer.clearSelection();
measurementLayer.refreshMap();
@ -866,14 +903,24 @@ public class MeasurementToolFragment extends Fragment {
positionToAddPoint = -1;
}
private void addPointBefore() {
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null && positionToAddPoint != -1) {
addPointToPosition(positionToAddPoint);
selectedCachedPoint = new WptPt(measurementLayer.getMeasurementPoints().get(selectedPointPos));
measurementLayer.setSelectedPointPos(selectedPointPos);
measurementLayer.setSelectedCachedPoint(selectedCachedPoint);
measurementLayer.refreshMap();
}
}
private void applyAddPointBeforeMode() {
if (inAddPointBeforeMode) {
switchAddPointBeforeMode(false);
}
clearSelection();
MeasurementToolLayer measurementLayer = getMeasurementLayer();
if (measurementLayer != null && positionToAddPoint != -1) {
addPointToPosition(positionToAddPoint);
if (measurementLayer != null) {
measurementLayer.exitAddPointBeforeMode();
measurementLayer.clearSelection();
measurementLayer.refreshMap();
@ -905,7 +952,7 @@ public class MeasurementToolFragment extends Fragment {
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
mark(enable ? View.VISIBLE : View.GONE,
R.id.move_point_text,
R.id.selected_point_controls);
R.id.move_point_controls);
mainIcon.setImageDrawable(getActiveIcon(enable
? R.drawable.ic_action_move_point
: R.drawable.ic_action_ruler));
@ -916,7 +963,7 @@ public class MeasurementToolFragment extends Fragment {
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
mark(enable ? View.VISIBLE : View.GONE,
R.id.add_point_after_text,
R.id.selected_point_controls);
R.id.add_point_before_after_controls);
mainIcon.setImageDrawable(getActiveIcon(enable
? R.drawable.ic_action_addpoint_above
: R.drawable.ic_action_ruler));
@ -927,7 +974,7 @@ public class MeasurementToolFragment extends Fragment {
markGeneralComponents(enable ? View.GONE : View.VISIBLE);
mark(enable ? View.VISIBLE : View.GONE,
R.id.add_point_before_text,
R.id.selected_point_controls);
R.id.add_point_before_after_controls);
mainIcon.setImageDrawable(getActiveIcon(enable
? R.drawable.ic_action_addpoint_below
: R.drawable.ic_action_ruler));