Rename menu item, move menu divider; add some code for save as gpx
This commit is contained in:
parent
c504866f58
commit
2a34c6a5aa
5 changed files with 106 additions and 22 deletions
61
OsmAnd/res/layout/save_gpx_dialog.xml
Normal file
61
OsmAnd/res/layout/save_gpx_dialog.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/gpx_name_et"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:inputType="text"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/file_exists_text_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginStart="16dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:text="@string/file_with_name_already_exists"
|
||||
android:textColor="@color/marker_red"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp">
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/toggle_show_on_map"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginStart="16dp"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_toLeftOf="@id/toggle_row_toggle"
|
||||
android:layout_toStartOf="@id/toggle_row_toggle"
|
||||
android:text="@string/show_on_map_after_saving"/>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -9,8 +9,10 @@
|
|||
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="enter_gpx_name">Enter name for GPX</string>
|
||||
<string name="show_on_map_after_saving">Show on map after saving</string>
|
||||
<string name="measurement_tool_action_bar">Select a location on the map and click "Add" to add a point to the ruler.</string>
|
||||
<string name="measurement_tool">Measurement tool</string>
|
||||
<string name="measurement_tool">Measure distance</string>
|
||||
<string name="quick_action_resume_pause_navigation">Resume/Pause Navigation</string>
|
||||
<string name="quick_action_resume_pause_navigation_descr">Press this button to pause the navigation, or to resume it if it was already paused.</string>
|
||||
<string name="quick_action_show_navigation_finish_dialog">Show Finish navigation dialog</string>
|
||||
|
|
|
@ -696,21 +696,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, MeasurementToolFragment.TAG)
|
||||
.addToBackStack(MeasurementToolFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
|
@ -774,6 +759,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
*/
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_ruler)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked) {
|
||||
MeasurementToolFragment fragment = new MeasurementToolFragment();
|
||||
mapActivity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.add(R.id.bottomFragmentContainer, fragment, MeasurementToolFragment.TAG)
|
||||
.addToBackStack(MeasurementToolFragment.TAG)
|
||||
.commitAllowingStateLoss();
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
.setIcon(R.drawable.ic_extension_dark)
|
||||
.setListener(new ItemClickListener() {
|
||||
|
@ -843,16 +843,16 @@ public class MapActivityActions implements DialogProvider {
|
|||
//////////// Others
|
||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
||||
int pluginsItemIndex = -1;
|
||||
int measureDistanceItemIndex = -1;
|
||||
for (int i = 0; i < optionsMenuHelper.length(); i++) {
|
||||
if (optionsMenuHelper.getItem(i).getTitleId() == R.string.prefs_plugins) {
|
||||
pluginsItemIndex = i;
|
||||
if (optionsMenuHelper.getItem(i).getTitleId() == R.string.measurement_tool) {
|
||||
measureDistanceItemIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
|
||||
divider.setPosition(pluginsItemIndex >= 0 ? pluginsItemIndex : 7);
|
||||
divider.setPosition(measureDistanceItemIndex >= 0 ? measureDistanceItemIndex : 8);
|
||||
optionsMenuHelper.addItem(divider.createItem());
|
||||
|
||||
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
package net.osmand.plus.measurementtool;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -134,7 +137,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public boolean onMenuItemClick(MenuItem menuItem) {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.action_save_as_gpx:
|
||||
Toast.makeText(mapActivity, "Save as gpx", Toast.LENGTH_SHORT).show();
|
||||
saveAsGpxOnClick(mapActivity);
|
||||
return true;
|
||||
case R.id.action_clear_all:
|
||||
measurementLayer.clearPoints();
|
||||
|
@ -154,6 +157,24 @@ public class MeasurementToolFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
private void saveAsGpxOnClick(MapActivity mapActivity) {
|
||||
LayoutInflater inflater = getLayoutInflater();
|
||||
final View view = inflater.inflate(R.layout.save_gpx_dialog, null);
|
||||
EditText nameEt = view.findViewById(R.id.gpx_name_et);
|
||||
|
||||
new AlertDialog.Builder(mapActivity)
|
||||
.setTitle(R.string.enter_gpx_name)
|
||||
.setView(view)
|
||||
.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.shared_string_cancel, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
|
|
@ -25,7 +25,7 @@ public class MeasurementToolLayer extends OsmandMapLayer {
|
|||
private OsmandMapTileView view;
|
||||
private boolean inMeasurementMode;
|
||||
private LinkedList<WptPt> measurementPoints = new LinkedList<>();
|
||||
private LinkedList<WptPt> cacheMeasurementPoints;
|
||||
private LinkedList<WptPt> cacheMeasurementPoints = new LinkedList<>();
|
||||
private Bitmap centerIconDay;
|
||||
private Bitmap centerIconNight;
|
||||
private Bitmap pointIcon;
|
||||
|
|
Loading…
Reference in a new issue