Made improvements in Measure Distance

This commit is contained in:
Chumva 2018-02-13 11:46:34 +02:00
parent eab4d5a9fc
commit ff4544f7f3
3 changed files with 52 additions and 24 deletions

View file

@ -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="enter_the_file_name">Enter the file name.</string>
<string name="make_as_start_point">Make as Start Point</string>
<string name="shared_string_current">Current</string>
<string name="last_intermediate_dest_description">Adds the last stop along the route</string>

View file

@ -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;
}
});
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();
}
}

View file

@ -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);