Add save button
This commit is contained in:
parent
6714afb316
commit
707a918d05
4 changed files with 70 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
|
@ -457,6 +458,26 @@
|
|||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/widget_top_bar_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAllCaps="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:contentDescription="@string/shared_string_save"
|
||||
android:text="@string/shared_string_save"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- TOP ROW -->
|
||||
|
@ -234,6 +235,26 @@
|
|||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/widget_top_bar_save"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="56dp"
|
||||
android:background="@null"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:textAllCaps="true"
|
||||
android:singleLine="true"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
android:contentDescription="@string/shared_string_save"
|
||||
android:text="@string/shared_string_save"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
@ -280,7 +280,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
enterMeasurementMode();
|
||||
|
||||
if (portrait) {
|
||||
toolBarController = new MeasurementToolBarController();
|
||||
toolBarController = new MeasurementToolBarController(newGpxLine);
|
||||
if (newGpxLine != null) {
|
||||
toolBarController.setTitle(getString(R.string.add_line));
|
||||
} else {
|
||||
|
@ -292,10 +292,14 @@ public class MeasurementToolFragment extends Fragment {
|
|||
showQuitDialog(false);
|
||||
}
|
||||
});
|
||||
toolBarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
||||
toolBarController.setOnSaveViewClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
// Pasha, do your stuff here :)
|
||||
if (measurementLayer.getPointsCount() > 0) {
|
||||
saveAsNewSegment(mapActivity);
|
||||
} else {
|
||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
mapActivity.showTopToolbar(toolBarController);
|
||||
|
@ -810,16 +814,17 @@ public class MeasurementToolFragment extends Fragment {
|
|||
}
|
||||
|
||||
private static class MeasurementToolBarController extends TopToolbarController {
|
||||
private NewGpxLine newGpxLine;
|
||||
|
||||
MeasurementToolBarController() {
|
||||
MeasurementToolBarController(NewGpxLine newGpxLine) {
|
||||
super(MapInfoWidgetsFactory.TopToolbarControllerType.MEASUREMENT_TOOL);
|
||||
this.newGpxLine = newGpxLine;
|
||||
setBackBtnIconClrIds(0, 0);
|
||||
setCloseBtnIconClrIds(0, 0);
|
||||
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
||||
setDescrTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
||||
setBgIds(R.drawable.gradient_toolbar, R.drawable.gradient_toolbar,
|
||||
R.drawable.gradient_toolbar, R.drawable.gradient_toolbar);
|
||||
setCloseBtnIconIds(R.drawable.ic_overflow_menu_white, R.drawable.ic_overflow_menu_white); // Pasha, change this icon :)
|
||||
setCloseBtnVisible(false);
|
||||
setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||
setSingleLineTitle(false);
|
||||
}
|
||||
|
@ -828,6 +833,9 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public void updateToolbar(MapInfoWidgetsFactory.TopToolbarView view) {
|
||||
super.updateToolbar(view);
|
||||
view.getShadowView().setVisibility(View.GONE);
|
||||
if (newGpxLine != null) {
|
||||
view.getSaveView().setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@ public class MapInfoWidgetsFactory {
|
|||
OnClickListener onTitleClickListener;
|
||||
OnClickListener onCloseButtonClickListener;
|
||||
OnClickListener onRefreshButtonClickListener;
|
||||
OnClickListener onSaveViewClickListener;
|
||||
|
||||
Runnable onCloseToolbarListener;
|
||||
|
||||
|
@ -343,6 +344,10 @@ public class MapInfoWidgetsFactory {
|
|||
this.onCloseButtonClickListener = onCloseButtonClickListener;
|
||||
}
|
||||
|
||||
public void setOnSaveViewClickListener(OnClickListener onSaveViewClickListener) {
|
||||
this.onSaveViewClickListener = onSaveViewClickListener;
|
||||
}
|
||||
|
||||
public void setOnRefreshButtonClickListener(OnClickListener onRefreshButtonClickListener) {
|
||||
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
||||
}
|
||||
|
@ -393,6 +398,7 @@ public class MapInfoWidgetsFactory {
|
|||
private TextView descrView;
|
||||
private ImageButton refreshButton;
|
||||
private ImageButton closeButton;
|
||||
private TextView saveView;
|
||||
private View shadowView;
|
||||
private boolean nightMode;
|
||||
|
||||
|
@ -407,6 +413,7 @@ public class MapInfoWidgetsFactory {
|
|||
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
||||
closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
|
||||
titleView = (TextView) map.findViewById(R.id.widget_top_bar_title);
|
||||
saveView = (TextView) map.findViewById(R.id.widget_top_bar_save);
|
||||
descrView = (TextView) map.findViewById(R.id.widget_top_bar_description);
|
||||
shadowView = map.findViewById(R.id.widget_top_bar_shadow);
|
||||
updateVisibility(false);
|
||||
|
@ -444,6 +451,10 @@ public class MapInfoWidgetsFactory {
|
|||
return closeButton;
|
||||
}
|
||||
|
||||
public TextView getSaveView() {
|
||||
return saveView;
|
||||
}
|
||||
|
||||
public ImageButton getRefreshButton() {
|
||||
return refreshButton;
|
||||
}
|
||||
|
@ -515,6 +526,7 @@ public class MapInfoWidgetsFactory {
|
|||
topBarTitleLayout.setOnClickListener(controller.onTitleClickListener);
|
||||
closeButton.setOnClickListener(controller.onCloseButtonClickListener);
|
||||
refreshButton.setOnClickListener(controller.onRefreshButtonClickListener);
|
||||
saveView.setOnClickListener(controller.onSaveViewClickListener);
|
||||
}
|
||||
|
||||
public void updateInfo() {
|
||||
|
@ -553,6 +565,7 @@ public class MapInfoWidgetsFactory {
|
|||
int descrColor = map.getResources().getColor(controller.descrTextClrDarkId);
|
||||
titleView.setTextColor(titleColor);
|
||||
descrView.setTextColor(descrColor);
|
||||
saveView.setTextColor(titleColor);
|
||||
} else {
|
||||
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgLightId : controller.bgLightLandId);
|
||||
if (controller.backBtnIconLightId == 0) {
|
||||
|
@ -574,6 +587,7 @@ public class MapInfoWidgetsFactory {
|
|||
int descrColor = map.getResources().getColor(controller.descrTextClrLightId);
|
||||
titleView.setTextColor(titleColor);
|
||||
descrView.setTextColor(descrColor);
|
||||
saveView.setTextColor(titleColor);
|
||||
}
|
||||
if (controller.singleLineTitle) {
|
||||
titleView.setSingleLine(true);
|
||||
|
|
Loading…
Reference in a new issue