From ff4544f7f3c6ed8326b095c3ad0d514aae36429a Mon Sep 17 00:00:00 2001 From: Chumva Date: Tue, 13 Feb 2018 11:46:34 +0200 Subject: [PATCH] Made improvements in Measure Distance --- OsmAnd/res/values/strings.xml | 1 + .../MeasurementToolFragment.java | 64 ++++++++++++------- .../mapwidgets/MapInfoWidgetsFactory.java | 11 ++++ 3 files changed, 52 insertions(+), 24 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index ad57d5f7b0..c0828c3c7b 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -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 --> + Enter the file name. Make as Start Point Current Adds the last stop along the route diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index 5e3dd47ac4..98aa068107 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -1111,8 +1111,33 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { } nameEt.setText(displayedName); nameEt.setSelection(displayedName.length()); - final boolean[] textChanged = new boolean[1]; + + AlertDialog.Builder builder=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) { + + final String name = nameEt.getText().toString(); + String fileName = name + GPX_SUFFIX; + if (textChanged[0]) { + File fout = new File(dir, fileName); + int ind = 1; + while (fout.exists()) { + fileName = name + "_" + (++ind) + GPX_SUFFIX; + fout = new File(dir, fileName); + } + } + saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), saveType, false); + + } + }) + .setNegativeButton(R.string.shared_string_cancel, null); + final AlertDialog dialog=builder.create(); + dialog.show(); + nameEt.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { @@ -1128,34 +1153,25 @@ public class MeasurementToolFragment extends BaseOsmAndFragment { public void afterTextChanged(Editable editable) { if (new File(dir, editable.toString() + GPX_SUFFIX).exists()) { fileExistsTv.setVisibility(View.VISIBLE); + fileExistsTv.setText(R.string.file_with_name_already_exists); + dialog.getButton(AlertDialog.BUTTON_POSITIVE) + .setEnabled(true); + + } else if (editable.toString().trim().isEmpty()) { + fileExistsTv.setVisibility(View.VISIBLE); + fileExistsTv.setText(R.string.enter_the_file_name); + dialog.getButton(AlertDialog.BUTTON_POSITIVE) + .setEnabled(false); + } else { fileExistsTv.setVisibility(View.INVISIBLE); + dialog.getButton(AlertDialog.BUTTON_POSITIVE) + .setEnabled(true); } - textChanged[0] = true; + textChanged[0] = true; + } }); - - 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) { - final String name = nameEt.getText().toString(); - String fileName = name + GPX_SUFFIX; - if (textChanged[0]) { - File fout = new File(dir, fileName); - int ind = 1; - while (fout.exists()) { - fileName = name + "_" + (++ind) + GPX_SUFFIX; - fout = new File(dir, fileName); - } - } - saveNewGpx(dir, fileName, showOnMapToggle.isChecked(), saveType, false); - } - }) - .setNegativeButton(R.string.shared_string_cancel, null) - .show(); } } diff --git a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java index 1a9343cbcb..7599b0a3f6 100644 --- a/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java +++ b/OsmAnd/src/net/osmand/plus/views/mapwidgets/MapInfoWidgetsFactory.java @@ -1,6 +1,9 @@ package net.osmand.plus.views.mapwidgets; +import android.content.res.ColorStateList; +import android.graphics.Color; import android.graphics.drawable.Drawable; +import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v7.widget.SwitchCompat; import android.view.View; import android.view.View.OnClickListener; @@ -417,6 +420,8 @@ public class MapInfoWidgetsFactory { view.updateVisibility(switchCompat, topBarSwitchVisible); if (topBarSwitchVisible) { switchCompat.setChecked(topBarSwitchChecked); + view.setTopBarBackgroundColor(switchCompat,topBarSwitchChecked); + } if (view.getShadowView() != null) { view.getShadowView().setVisibility(View.VISIBLE); @@ -565,7 +570,13 @@ public class MapInfoWidgetsFactory { } return false; } + public void setTopBarBackgroundColor(View v,boolean active ) { + SwitchCompat switchCompat=(SwitchCompat)v; + if(active){ + DrawableCompat.setTint(switchCompat.getTrackDrawable(),Color.parseColor("#c5d2e6")); + } + } private void initToolbar(TopToolbarController controller) { backButton.setOnClickListener(controller.onBackButtonClickListener); topBarTitleLayout.setOnClickListener(controller.onTitleClickListener);