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"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
|
@ -457,6 +458,26 @@
|
||||||
android:contentDescription="@string/shared_string_close"
|
android:contentDescription="@string/shared_string_close"
|
||||||
android:src="@drawable/ic_action_remove_dark"/>
|
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>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- TOP ROW -->
|
<!-- TOP ROW -->
|
||||||
|
@ -234,6 +235,26 @@
|
||||||
android:contentDescription="@string/shared_string_close"
|
android:contentDescription="@string/shared_string_close"
|
||||||
android:src="@drawable/ic_action_remove_dark"/>
|
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>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|
|
@ -280,7 +280,7 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
enterMeasurementMode();
|
enterMeasurementMode();
|
||||||
|
|
||||||
if (portrait) {
|
if (portrait) {
|
||||||
toolBarController = new MeasurementToolBarController();
|
toolBarController = new MeasurementToolBarController(newGpxLine);
|
||||||
if (newGpxLine != null) {
|
if (newGpxLine != null) {
|
||||||
toolBarController.setTitle(getString(R.string.add_line));
|
toolBarController.setTitle(getString(R.string.add_line));
|
||||||
} else {
|
} else {
|
||||||
|
@ -292,10 +292,14 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
showQuitDialog(false);
|
showQuitDialog(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
toolBarController.setOnCloseButtonClickListener(new View.OnClickListener() {
|
toolBarController.setOnSaveViewClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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);
|
mapActivity.showTopToolbar(toolBarController);
|
||||||
|
@ -810,16 +814,17 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class MeasurementToolBarController extends TopToolbarController {
|
private static class MeasurementToolBarController extends TopToolbarController {
|
||||||
|
private NewGpxLine newGpxLine;
|
||||||
|
|
||||||
MeasurementToolBarController() {
|
MeasurementToolBarController(NewGpxLine newGpxLine) {
|
||||||
super(MapInfoWidgetsFactory.TopToolbarControllerType.MEASUREMENT_TOOL);
|
super(MapInfoWidgetsFactory.TopToolbarControllerType.MEASUREMENT_TOOL);
|
||||||
|
this.newGpxLine = newGpxLine;
|
||||||
setBackBtnIconClrIds(0, 0);
|
setBackBtnIconClrIds(0, 0);
|
||||||
setCloseBtnIconClrIds(0, 0);
|
|
||||||
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
setTitleTextClrIds(R.color.primary_text_dark, R.color.primary_text_dark);
|
||||||
setDescrTextClrIds(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,
|
setBgIds(R.drawable.gradient_toolbar, R.drawable.gradient_toolbar,
|
||||||
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);
|
setBackBtnIconIds(R.drawable.ic_action_remove_dark, R.drawable.ic_action_remove_dark);
|
||||||
setSingleLineTitle(false);
|
setSingleLineTitle(false);
|
||||||
}
|
}
|
||||||
|
@ -828,6 +833,9 @@ public class MeasurementToolFragment extends Fragment {
|
||||||
public void updateToolbar(MapInfoWidgetsFactory.TopToolbarView view) {
|
public void updateToolbar(MapInfoWidgetsFactory.TopToolbarView view) {
|
||||||
super.updateToolbar(view);
|
super.updateToolbar(view);
|
||||||
view.getShadowView().setVisibility(View.GONE);
|
view.getShadowView().setVisibility(View.GONE);
|
||||||
|
if (newGpxLine != null) {
|
||||||
|
view.getSaveView().setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,6 +247,7 @@ public class MapInfoWidgetsFactory {
|
||||||
OnClickListener onTitleClickListener;
|
OnClickListener onTitleClickListener;
|
||||||
OnClickListener onCloseButtonClickListener;
|
OnClickListener onCloseButtonClickListener;
|
||||||
OnClickListener onRefreshButtonClickListener;
|
OnClickListener onRefreshButtonClickListener;
|
||||||
|
OnClickListener onSaveViewClickListener;
|
||||||
|
|
||||||
Runnable onCloseToolbarListener;
|
Runnable onCloseToolbarListener;
|
||||||
|
|
||||||
|
@ -343,6 +344,10 @@ public class MapInfoWidgetsFactory {
|
||||||
this.onCloseButtonClickListener = onCloseButtonClickListener;
|
this.onCloseButtonClickListener = onCloseButtonClickListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnSaveViewClickListener(OnClickListener onSaveViewClickListener) {
|
||||||
|
this.onSaveViewClickListener = onSaveViewClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnRefreshButtonClickListener(OnClickListener onRefreshButtonClickListener) {
|
public void setOnRefreshButtonClickListener(OnClickListener onRefreshButtonClickListener) {
|
||||||
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
this.onRefreshButtonClickListener = onRefreshButtonClickListener;
|
||||||
}
|
}
|
||||||
|
@ -393,6 +398,7 @@ public class MapInfoWidgetsFactory {
|
||||||
private TextView descrView;
|
private TextView descrView;
|
||||||
private ImageButton refreshButton;
|
private ImageButton refreshButton;
|
||||||
private ImageButton closeButton;
|
private ImageButton closeButton;
|
||||||
|
private TextView saveView;
|
||||||
private View shadowView;
|
private View shadowView;
|
||||||
private boolean nightMode;
|
private boolean nightMode;
|
||||||
|
|
||||||
|
@ -407,6 +413,7 @@ public class MapInfoWidgetsFactory {
|
||||||
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
refreshButton = (ImageButton) map.findViewById(R.id.widget_top_bar_refresh_button);
|
||||||
closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
|
closeButton = (ImageButton) map.findViewById(R.id.widget_top_bar_close_button);
|
||||||
titleView = (TextView) map.findViewById(R.id.widget_top_bar_title);
|
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);
|
descrView = (TextView) map.findViewById(R.id.widget_top_bar_description);
|
||||||
shadowView = map.findViewById(R.id.widget_top_bar_shadow);
|
shadowView = map.findViewById(R.id.widget_top_bar_shadow);
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
|
@ -444,6 +451,10 @@ public class MapInfoWidgetsFactory {
|
||||||
return closeButton;
|
return closeButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TextView getSaveView() {
|
||||||
|
return saveView;
|
||||||
|
}
|
||||||
|
|
||||||
public ImageButton getRefreshButton() {
|
public ImageButton getRefreshButton() {
|
||||||
return refreshButton;
|
return refreshButton;
|
||||||
}
|
}
|
||||||
|
@ -515,6 +526,7 @@ public class MapInfoWidgetsFactory {
|
||||||
topBarTitleLayout.setOnClickListener(controller.onTitleClickListener);
|
topBarTitleLayout.setOnClickListener(controller.onTitleClickListener);
|
||||||
closeButton.setOnClickListener(controller.onCloseButtonClickListener);
|
closeButton.setOnClickListener(controller.onCloseButtonClickListener);
|
||||||
refreshButton.setOnClickListener(controller.onRefreshButtonClickListener);
|
refreshButton.setOnClickListener(controller.onRefreshButtonClickListener);
|
||||||
|
saveView.setOnClickListener(controller.onSaveViewClickListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInfo() {
|
public void updateInfo() {
|
||||||
|
@ -553,6 +565,7 @@ public class MapInfoWidgetsFactory {
|
||||||
int descrColor = map.getResources().getColor(controller.descrTextClrDarkId);
|
int descrColor = map.getResources().getColor(controller.descrTextClrDarkId);
|
||||||
titleView.setTextColor(titleColor);
|
titleView.setTextColor(titleColor);
|
||||||
descrView.setTextColor(descrColor);
|
descrView.setTextColor(descrColor);
|
||||||
|
saveView.setTextColor(titleColor);
|
||||||
} else {
|
} else {
|
||||||
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgLightId : controller.bgLightLandId);
|
topBarLayout.setBackgroundResource(AndroidUiHelper.isOrientationPortrait(map) ? controller.bgLightId : controller.bgLightLandId);
|
||||||
if (controller.backBtnIconLightId == 0) {
|
if (controller.backBtnIconLightId == 0) {
|
||||||
|
@ -574,6 +587,7 @@ public class MapInfoWidgetsFactory {
|
||||||
int descrColor = map.getResources().getColor(controller.descrTextClrLightId);
|
int descrColor = map.getResources().getColor(controller.descrTextClrLightId);
|
||||||
titleView.setTextColor(titleColor);
|
titleView.setTextColor(titleColor);
|
||||||
descrView.setTextColor(descrColor);
|
descrView.setTextColor(descrColor);
|
||||||
|
saveView.setTextColor(titleColor);
|
||||||
}
|
}
|
||||||
if (controller.singleLineTitle) {
|
if (controller.singleLineTitle) {
|
||||||
titleView.setSingleLine(true);
|
titleView.setSingleLine(true);
|
||||||
|
|
Loading…
Reference in a new issue