Add images to save as menu
This commit is contained in:
parent
5e397592f3
commit
a8cb9d4743
3 changed files with 118 additions and 15 deletions
|
@ -32,10 +32,79 @@
|
|||
android:layout_height="44dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingStart="16dp"
|
||||
android:text="@string/measurement_tool_snap_to_road_descr"
|
||||
android:text="@string/measurement_tool_save_as_new_track_descr"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_desc_text_size"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/route_point_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
tools:src="@drawable/img_help_trip_route_points_night"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/route_point_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/route_point_image"
|
||||
android:layout_alignStart="@id/route_point_image"
|
||||
android:layout_margin="8dp"
|
||||
android:text="@string/route_point"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_split_segments_sub"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/line_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:foreground="?attr/selectableItemBackground"
|
||||
tools:src="@drawable/img_help_trip_track_night"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/line_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@id/line_image"
|
||||
android:layout_alignStart="@id/line_image"
|
||||
android:layout_margin="8dp"
|
||||
android:text="@string/line"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_split_segments_sub"/>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/save_as_route_point_row"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
|
||||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
<string name="line">Line</string>
|
||||
<string name="save_as_route_point">Save as Route Point</string>
|
||||
<string name="save_as_line">Save as line</string>
|
||||
<string name="route_point">Route point</string>
|
||||
|
@ -17,6 +18,7 @@
|
|||
<string name="add_point_after">Add point after</string>
|
||||
<string name="shared_string_options">Options</string>
|
||||
<string name="measurement_tool_snap_to_road_descr">OsmAnd will add additional points, depending on the navigation type.</string>
|
||||
<string name="measurement_tool_save_as_new_track_descr">You can save points either as route points or as a line.</string>
|
||||
<string name="choose_navigation_type">Choose navigation type</string>
|
||||
<string name="none_point_error">Please add at least one point.</string>
|
||||
<string name="enter_gpx_name">GPX file name:</string>
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver;
|
||||
|
@ -14,7 +17,6 @@ import android.widget.ImageView;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.base.BottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
|
@ -36,7 +38,6 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
|
||||
final OsmandSettings settings = getMyApplication().getSettings();
|
||||
final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
|
||||
final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_save_as_new_track_bottom_sheet_dialog, container);
|
||||
|
@ -44,32 +45,38 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
|
|||
AndroidUtils.setBackground(getActivity(), mainView, nightMode, R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
|
||||
}
|
||||
|
||||
final ImageView routePointImage = (ImageView) mainView.findViewById(R.id.route_point_image);
|
||||
ImageView lineImage = (ImageView) mainView.findViewById(R.id.line_image);
|
||||
if (nightMode) {
|
||||
((TextView) mainView.findViewById(R.id.save_as_new_track_title)).setTextColor(getResources().getColor(R.color.ctx_menu_info_text_dark));
|
||||
|
||||
routePointImage.setImageResource(R.drawable.img_help_trip_route_points_night);
|
||||
lineImage.setImageResource(R.drawable.img_help_trip_track_night);
|
||||
} else {
|
||||
routePointImage.setImageResource(R.drawable.img_help_trip_route_points_day);
|
||||
lineImage.setImageResource(R.drawable.img_help_trip_track_day);
|
||||
}
|
||||
|
||||
((ImageView) mainView.findViewById(R.id.route_point_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_route_points));
|
||||
((ImageView) mainView.findViewById(R.id.line_icon)).setImageDrawable(getContentIcon(R.drawable.ic_action_split_interval));
|
||||
|
||||
mainView.findViewById(R.id.save_as_line_row).setOnClickListener(new View.OnClickListener() {
|
||||
mainView.findViewById(R.id.line_text).setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsLineOnClick();
|
||||
}
|
||||
dismiss();
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
lineImage.setOnClickListener(saveAsLineOnClickListener);
|
||||
mainView.findViewById(R.id.save_as_line_row).setOnClickListener(saveAsLineOnClickListener);
|
||||
|
||||
mainView.findViewById(R.id.save_as_route_point_row).setOnClickListener(new View.OnClickListener() {
|
||||
mainView.findViewById(R.id.route_point_text).setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsRoutePointOnClick();
|
||||
}
|
||||
dismiss();
|
||||
public boolean onTouch(View view, MotionEvent motionEvent) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
routePointImage.setOnClickListener(saveAsLineOnClickListener);
|
||||
mainView.findViewById(R.id.save_as_route_point_row).setOnClickListener(saveAsRoutePointOnClickListener);
|
||||
|
||||
mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -129,6 +136,31 @@ public class SaveAsNewTrackBottomSheetDialogFragment extends BottomSheetDialogFr
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Drawable getContentIcon(@DrawableRes int id) {
|
||||
return getIcon(id, nightMode ? R.color.ctx_menu_info_text_dark : R.color.on_map_icon_color);
|
||||
}
|
||||
|
||||
private View.OnClickListener saveAsLineOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsLineOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
private View.OnClickListener saveAsRoutePointOnClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (listener != null) {
|
||||
listener.saveAsRoutePointOnClick();
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
};
|
||||
|
||||
interface SaveAsNewTrackFragmentListener {
|
||||
|
||||
void saveAsRoutePointOnClick();
|
||||
|
|
Loading…
Reference in a new issue